|
@@ -66,9 +66,11 @@ static void show_help(struct ts *ts) {
|
66
|
66
|
printf(" -D --create-dirs | Save files in subdirs YYYY/MM/DD/HH/file.\n");
|
67
|
67
|
printf("\n");
|
68
|
68
|
printf("Input options:\n");
|
69
|
|
- printf(" -i --input <source> | Where to read from. Multicast address.\n");
|
|
69
|
+ printf(" -i --input <source> | Where to read from.\n");
|
70
|
70
|
printf(" . -i udp://224.0.0.1:5000 (v4 multicast)\n");
|
71
|
71
|
printf(" . -i udp://[ff01::1111]:5000 (v6 multicast)\n");
|
|
72
|
+ printf(" . -i rtp://224.0.0.1:5000 (v4 RTP input)\n");
|
|
73
|
+ printf(" . -i rtp://[ff01::1111]:5000 (v6 RTP input)\n");
|
72
|
74
|
printf(" -z --input-ignore-disc | Do not report discontinuty errors in input.\n");
|
73
|
75
|
printf(" -4 --ipv4 | Use only IPv4 addresses.\n");
|
74
|
76
|
printf(" -6 --ipv6 | Use only IPv6 addresses.\n");
|
|
@@ -79,13 +81,6 @@ static void show_help(struct ts *ts) {
|
79
|
81
|
printf("\n");
|
80
|
82
|
}
|
81
|
83
|
|
82
|
|
-static int parse_io_param(struct io *io, char *opt) {
|
83
|
|
- int port_set = 0;
|
84
|
|
- io->type = NET_IO;
|
85
|
|
- int host_set = parse_host_and_port(opt, &io->hostname, &io->service, &port_set);
|
86
|
|
- return !(!port_set || !host_set);
|
87
|
|
-}
|
88
|
|
-
|
89
|
84
|
extern char *optarg;
|
90
|
85
|
extern int optind, opterr, optopt;
|
91
|
86
|
|
|
@@ -111,7 +106,7 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
|
111
|
106
|
ts->create_dirs = !ts->create_dirs;
|
112
|
107
|
break;
|
113
|
108
|
case 'i': // --input
|
114
|
|
- input_addr_err = !parse_io_param(&ts->input, optarg);
|
|
109
|
+ input_addr_err = !parse_host_and_port(optarg, &ts->input);
|
115
|
110
|
break;
|
116
|
111
|
case 'z': // --input-ignore-disc
|
117
|
112
|
ts->ts_discont = !ts->ts_discont;
|
|
@@ -140,7 +135,10 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
|
140
|
135
|
}
|
141
|
136
|
|
142
|
137
|
p_info("Prefix : %s\n", ts->prefix);
|
143
|
|
- p_info("Input addr : udp://%s:%s/\n", ts->input.hostname, ts->input.service);
|
|
138
|
+ p_info("Input addr : %s://%s:%s/\n",
|
|
139
|
+ ts->input.type == UDP ? "udp" :
|
|
140
|
+ ts->input.type == RTP ? "rtp" : "???",
|
|
141
|
+ ts->input.hostname, ts->input.service);
|
144
|
142
|
p_info("Seconds : %u\n", ts->rotate_secs);
|
145
|
143
|
p_info("Output dir : %s (create directories: %s)\n", ts->output_dir,
|
146
|
144
|
ts->create_dirs ? "YES" : "no");
|
|
@@ -204,7 +202,6 @@ static uint8_t rtp_hdr[2][RTP_HDR_SZ];
|
204
|
202
|
static struct ts ts;
|
205
|
203
|
|
206
|
204
|
int main(int argc, char **argv) {
|
207
|
|
- ssize_t readen;
|
208
|
205
|
int i;
|
209
|
206
|
int have_data = 1;
|
210
|
207
|
int ntimeouts = 0;
|
|
@@ -244,8 +241,13 @@ int main(int argc, char **argv) {
|
244
|
241
|
|
245
|
242
|
p_info("Start %s\n", program_id);
|
246
|
243
|
|
247
|
|
- if (ts.input.type == NET_IO && udp_connect_input(&ts.input) < 1)
|
248
|
|
- goto EXIT;
|
|
244
|
+ switch (ts.input.type) {
|
|
245
|
+ case UDP:
|
|
246
|
+ case RTP:
|
|
247
|
+ if (udp_connect_input(&ts.input) < 1)
|
|
248
|
+ exit(EXIT_FAILURE);
|
|
249
|
+ break;
|
|
250
|
+ }
|
249
|
251
|
|
250
|
252
|
signal(SIGCHLD, SIG_IGN);
|
251
|
253
|
signal(SIGPIPE, SIG_IGN);
|
|
@@ -257,10 +259,13 @@ int main(int argc, char **argv) {
|
257
|
259
|
|
258
|
260
|
int data_received = 0;
|
259
|
261
|
do {
|
|
262
|
+ ssize_t readen = -1;
|
260
|
263
|
set_log_io_errors(0);
|
261
|
|
- if (!ts.rtp_input) {
|
|
264
|
+ switch (ts.input.type) {
|
|
265
|
+ case UDP:
|
262
|
266
|
readen = fdread_ex(ts.input.fd, (char *)ts_packet, FRAME_SIZE, 250, 4, 1);
|
263
|
|
- } else {
|
|
267
|
+ break;
|
|
268
|
+ case RTP:
|
264
|
269
|
readen = fdread_ex(ts.input.fd, (char *)ts_packet, FRAME_SIZE + RTP_HDR_SZ, 250, 4, 1);
|
265
|
270
|
if (readen > RTP_HDR_SZ) {
|
266
|
271
|
memcpy(rtp_hdr[rtp_hdr_pos], ts_packet, RTP_HDR_SZ);
|
|
@@ -275,6 +280,7 @@ int main(int argc, char **argv) {
|
275
|
280
|
pssrc, ssrc, ((ssrc - pssrc)-1) & 0xffff);
|
276
|
281
|
num_packets++;
|
277
|
282
|
}
|
|
283
|
+ break;
|
278
|
284
|
}
|
279
|
285
|
set_log_io_errors(1);
|
280
|
286
|
if (readen < 0) {
|
|
@@ -297,7 +303,6 @@ int main(int argc, char **argv) {
|
297
|
303
|
if (!keep_running)
|
298
|
304
|
break;
|
299
|
305
|
} while (have_data);
|
300
|
|
-EXIT:
|
301
|
306
|
|
302
|
307
|
queue_add(ts.packet_queue, ts.current_packet);
|
303
|
308
|
queue_add(ts.packet_queue, NULL); // Exit write_thread
|