Browse Source

Add --input-dump option.

Georgi Chorbadzhiyski 12 years ago
parent
commit
60e69f008b
5 changed files with 33 additions and 3 deletions
  1. 1
    0
      ChangeLog
  2. 1
    0
      README
  3. 3
    0
      data.h
  4. 7
    0
      tsdecrypt.1
  5. 21
    3
      tsdecrypt.c

+ 1
- 0
ChangeLog View File

@@ -1,5 +1,6 @@
1 1
 next : Version next
2 2
  * Add --output-tos (-g) option used to set output TOS value.
3
+ * Add --input-dump (-W) option used save input stream in file.
3 4
 
4 5
 2011-12-23 : Version 5.0
5 6
  * Add --bench (-b) option that benchmarks libdvbcsa decryption.

+ 1
- 0
README View File

@@ -37,6 +37,7 @@ Input options:
37 37
  -R --input-rtp             | Enable RTP input
38 38
  -z --input-ignore-disc     | Do not report discontinuty errors in input.
39 39
  -M --input-service <srvid> | Choose service id when input is MPTS.
40
+ -W --input-dump <filename> | Save input stream in file.
40 41
 
41 42
 Output options:
42 43
  -O --output <dest>         | Where to send output. File or multicast address.

+ 3
- 0
data.h View File

@@ -243,6 +243,9 @@ struct ts {
243 243
 	struct io			input;
244 244
 	struct io			output;
245 245
 
246
+	FILE				*input_dump_file;
247
+	char				*input_dump_filename;
248
+
246 249
 	int					debug_level;
247 250
 	int					ts_discont;
248 251
 

+ 7
- 0
tsdecrypt.1 View File

@@ -79,6 +79,13 @@ in order to select the correct service (program). If the input is MPTS
79 79
 and \fB\-\-input\-service\fR is not used, tsdecrypt chooses the last service
80 80
 listed in PAT.
81 81
 .TP
82
+\fB\-W\fR, \fB\-\-input\-dump\fR <filename>
83
+Save input stream in <filename>. If the input is RTP, the file will contain
84
+the data without RTP headers (pure mpeg transport stream). Easiest way to
85
+save the input is using command line like the following:
86
+
87
+tsdecrypt -I 239.78.78.78:5000 -O /dev/null -s 0.0.0.0 -W file.ts
88
+.TP
82 89
 .SH OUTPUT OPTIONS
83 90
 .PP
84 91
 .TP

+ 21
- 3
tsdecrypt.c View File

@@ -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
 

Loading…
Cancel
Save