|
@@ -103,7 +103,7 @@ void run_benchmark(void) {
|
103
|
103
|
puts("* Done *");
|
104
|
104
|
}
|
105
|
105
|
|
106
|
|
-// Unused short options: FQTWYajkmnqruv0123456789
|
|
106
|
+// Unused short options: FQTYajkmnqruv0123456789
|
107
|
107
|
static const struct option long_options[] = {
|
108
|
108
|
{ "ident", required_argument, NULL, 'i' },
|
109
|
109
|
{ "daemon", required_argument, NULL, 'd' },
|
|
@@ -116,6 +116,7 @@ static const struct option long_options[] = {
|
116
|
116
|
{ "input-rtp", no_argument, NULL, 'R' },
|
117
|
117
|
{ "input-ignore-disc", no_argument, NULL, 'z' },
|
118
|
118
|
{ "input-service", required_argument, NULL, 'M' },
|
|
119
|
+ { "input-dump", required_argument, NULL, 'W' },
|
119
|
120
|
|
120
|
121
|
{ "output", required_argument, NULL, 'O' },
|
121
|
122
|
{ "output-intf", required_argument, NULL, 'o' },
|
|
@@ -178,6 +179,7 @@ static void show_help(struct ts *ts) {
|
178
|
179
|
printf(" -R --input-rtp | Enable RTP input\n");
|
179
|
180
|
printf(" -z --input-ignore-disc | Do not report discontinuty errors in input.\n");
|
180
|
181
|
printf(" -M --input-service <srvid> | Choose service id when input is MPTS.\n");
|
|
182
|
+ printf(" -W --input-dump <filename> | Save input stream in file.\n");
|
181
|
183
|
printf("\n");
|
182
|
184
|
printf("Output options:\n");
|
183
|
185
|
printf(" -O --output <dest> | Where to send output. File or multicast address.\n");
|
|
@@ -266,7 +268,7 @@ static int parse_io_param(struct io *io, char *opt, int open_flags, mode_t open_
|
266
|
268
|
|
267
|
269
|
static void parse_options(struct ts *ts, int argc, char **argv) {
|
268
|
270
|
int j, i, ca_err = 0, server_err = 1, input_addr_err = 0, output_addr_err = 0, output_intf_err = 0, ident_err = 0, port_set = 0;
|
269
|
|
- while ( (j = getopt_long(argc, argv, "i:d:N:Sl:L:I:RzM:O:o:t:g:pwxyc:C:A:s:U:P:B:eZ:Ef:X:H:G:KJ:D:bhV", long_options, NULL)) != -1 ) {
|
|
271
|
+ while ( (j = getopt_long(argc, argv, "i:d:N:Sl:L:I:RzM:W:O:o:t:g:pwxyc:C:A:s:U:P:B:eZ:Ef:X:H:G:KJ:D:bhV", long_options, NULL)) != -1 ) {
|
270
|
272
|
char *p = NULL;
|
271
|
273
|
switch (j) {
|
272
|
274
|
case 'i':
|
|
@@ -309,6 +311,9 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
|
309
|
311
|
case 'M':
|
310
|
312
|
ts->forced_service_id = strtoul(optarg, NULL, 0) & 0xffff;
|
311
|
313
|
break;
|
|
314
|
+ case 'W':
|
|
315
|
+ ts->input_dump_filename = optarg;
|
|
316
|
+ break;
|
312
|
317
|
|
313
|
318
|
case 'O':
|
314
|
319
|
output_addr_err = parse_io_param(&ts->output, optarg,
|
|
@@ -512,6 +517,13 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
|
512
|
517
|
} else if (ts->input.type == FILE_IO) {
|
513
|
518
|
ts_LOGf("Input file : %s\n", ts->input.fd == 0 ? "STDIN" : ts->input.fname);
|
514
|
519
|
}
|
|
520
|
+ if (ts->input_dump_filename) {
|
|
521
|
+ ts->input_dump_file = fopen(ts->input_dump_filename, "w");
|
|
522
|
+ if (ts->input_dump_file)
|
|
523
|
+ ts_LOGf("Input dump : %s\n", ts->input_dump_filename);
|
|
524
|
+ else
|
|
525
|
+ ts_LOGf("Input dump : %s | ERROR: %s\n", ts->input_dump_filename, strerror(errno));
|
|
526
|
+ }
|
515
|
527
|
if (ts->forced_service_id)
|
516
|
528
|
ts_LOGf("Service id : 0x%04x (%d)\n",
|
517
|
529
|
ts->forced_service_id, ts->forced_service_id);
|
|
@@ -759,8 +771,11 @@ int main(int argc, char **argv) {
|
759
|
771
|
readen = read(ts.input.fd, ts_packet, FRAME_SIZE);
|
760
|
772
|
have_data = !(readen <= 0);
|
761
|
773
|
}
|
762
|
|
- if (readen > 0)
|
|
774
|
+ if (readen > 0) {
|
|
775
|
+ if (ts.input_dump_file)
|
|
776
|
+ fwrite(ts_packet, readen, 1, ts.input_dump_file);
|
763
|
777
|
process_packets(&ts, ts_packet, readen);
|
|
778
|
+ }
|
764
|
779
|
if (!keep_running)
|
765
|
780
|
break;
|
766
|
781
|
} while (have_data);
|
|
@@ -787,6 +802,9 @@ EXIT:
|
787
|
802
|
closelog();
|
788
|
803
|
}
|
789
|
804
|
|
|
805
|
+ if (ts.input_dump_file)
|
|
806
|
+ fclose(ts.input_dump_file);
|
|
807
|
+
|
790
|
808
|
if (ts.daemonize)
|
791
|
809
|
unlink(ts.pidfile);
|
792
|
810
|
|