Browse Source

Add --pid-report option.

Georgi Chorbadzhiyski 12 years ago
parent
commit
e560bc39c5
7 changed files with 38 additions and 4 deletions
  1. 1
    0
      ChangeLog
  2. 1
    0
      README
  3. 5
    0
      data.h
  4. 17
    1
      process.c
  5. 1
    0
      process.h
  6. 4
    0
      tsdecrypt.1
  7. 9
    3
      tsdecrypt.c

+ 1
- 0
ChangeLog View File

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

+ 1
- 0
README View File

@@ -95,6 +95,7 @@ Misc options:
95 95
                             .    3 = show duplicate ECMs
96 96
                             .    4 = packet debug
97 97
                             .    5 = packet debug + packet dump
98
+ -j --pid-report            | Report how much packets were received.
98 99
  -b --bench                 | Benchmark decrypton.
99 100
  -h --help                  | Show help screen.
100 101
  -V --version               | Show program version.

+ 5
- 0
data.h View File

@@ -173,6 +173,8 @@ struct io {
173 173
 	struct in_addr		intf;
174 174
 };
175 175
 
176
+#define MAX_PIDS 8192
177
+
176 178
 struct ts {
177 179
 	// Stream handling
178 180
 	struct ts_pat		*pat, *curpat;
@@ -212,6 +214,9 @@ struct ts {
212 214
 	unsigned int		cw_warn_sec;
213 215
 	time_t				cw_last_warn;
214 216
 
217
+	unsigned int		pid_report;
218
+	unsigned int		pid_stats[MAX_PIDS];
219
+
215 220
 	// CAMD handling
216 221
 	struct key			key;
217 222
 	struct camd			camd;

+ 17
- 1
process.c View File

@@ -25,7 +25,7 @@
25 25
 static unsigned long ts_pack;
26 26
 static int ts_pack_shown;
27 27
 
28
-static char *get_pid_desc(struct ts *ts, uint16_t pid) {
28
+char *get_pid_desc(struct ts *ts, uint16_t pid) {
29 29
 	int i;
30 30
 	uint16_t nitpid = 0x0010, pmtpid = 0xffff, pcrpid = 0xffff;
31 31
 
@@ -266,6 +266,9 @@ void process_packets(struct ts *ts, uint8_t *data, ssize_t data_len) {
266 266
 		uint8_t *ts_packet = data + i;
267 267
 		uint16_t pid = ts_packet_get_pid(ts_packet);
268 268
 
269
+		if (ts->pid_report)
270
+			ts->pid_stats[pid]++;
271
+
269 272
 		ts_pack_shown = 0;
270 273
 
271 274
 		process_pat(ts, pid, ts_packet);
@@ -313,3 +316,16 @@ void process_packets(struct ts *ts, uint8_t *data, ssize_t data_len) {
313 316
 		ts_pack++;
314 317
 	}
315 318
 }
319
+
320
+void show_pid_report(struct ts *ts) {
321
+	int i;
322
+	if (!ts->pid_report)
323
+		return;
324
+
325
+	for (i = 0; i < MAX_PIDS; i++) {
326
+		if (ts->pid_stats[i]) {
327
+			ts_LOGf("PID | %8u packets with PID 0x%04x (%4u) %s\n",
328
+					ts->pid_stats[i], i, i, get_pid_desc(ts, i));
329
+		}
330
+	}
331
+}

+ 1
- 0
process.h View File

@@ -21,5 +21,6 @@
21 21
 void *decode_thread(void *_ts);
22 22
 void *write_thread(void *_ts);
23 23
 void process_packets(struct ts *ts, uint8_t *data, ssize_t data_len);
24
+void show_pid_report(struct ts *ts);
24 25
 
25 26
 #endif

+ 4
- 0
tsdecrypt.1 View File

@@ -47,6 +47,10 @@ duplicate ECMs, 4 = packet debug. 5 = packet debug + mpeg ts packet
47 47
 dump.
48 48
 Setting higher level enables the levels bellow.
49 49
 .TP
50
+\fB\-j\fR, \fB\-\-pid\-report\fR
51
+When this option is used, tsdecrypt on exit reports how much packets
52
+were received on each PID.
53
+.TP
50 54
 \fB\-b\fR, \fB\-\-bench\fR
51 55
 Bechmark libdvbcsa decryption. The benchmark is single threaded.
52 56
 If you want to fully test your CPU, run couple of tsdecrypts in parallel.

+ 9
- 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: FQTYajkmnqruv0123456789
106
+// Unused short options: FQTYakmnqruv0123456789
107 107
 static const struct option long_options[] = {
108 108
 	{ "ident",				required_argument, NULL, 'i' },
109 109
 	{ "daemon",				required_argument, NULL, 'd' },
@@ -149,6 +149,7 @@ static const struct option long_options[] = {
149 149
 	{ "cw-warn-time",		required_argument, NULL, 'J' },
150 150
 
151 151
 	{ "debug",				required_argument, NULL, 'D' },
152
+	{ "pid-report",			no_argument,       NULL, 'j' },
152 153
 	{ "bench",				no_argument,       NULL, 'b' },
153 154
 	{ "help",				no_argument,       NULL, 'h' },
154 155
 	{ "version",			no_argument,       NULL, 'V' },
@@ -237,6 +238,7 @@ static void show_help(struct ts *ts) {
237 238
 	printf("                            .    3 = show duplicate ECMs\n");
238 239
 	printf("                            .    4 = packet debug\n");
239 240
 	printf("                            .    5 = packet debug + packet dump\n");
241
+	printf(" -j --pid-report            | Report how much packets were received.\n");
240 242
 	printf(" -b --bench                 | Benchmark decrypton.\n");
241 243
 	printf(" -h --help                  | Show help screen.\n");
242 244
 	printf(" -V --version               | Show program version.\n");
@@ -268,7 +270,7 @@ static int parse_io_param(struct io *io, char *opt, int open_flags, mode_t open_
268 270
 
269 271
 static void parse_options(struct ts *ts, int argc, char **argv) {
270 272
 	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;
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 ) {
273
+	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:jbhV", long_options, NULL)) != -1 ) {
272 274
 		char *p = NULL;
273 275
 		switch (j) {
274 276
 			case 'i':
@@ -444,7 +446,9 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
444 446
 			case 'D':
445 447
 				ts->debug_level = atoi(optarg);
446 448
 				break;
447
-
449
+			case 'j':
450
+				ts->pid_report = 1;
451
+				break;
448 452
 			case 'b':
449 453
 				run_benchmark();
450 454
 				exit(EXIT_SUCCESS);
@@ -792,6 +796,8 @@ EXIT:
792 796
 			pthread_join(ts.write_thread, NULL);
793 797
 	}
794 798
 
799
+	show_pid_report(&ts);
800
+
795 801
 	notify_sync(&ts, "STOP", "Stopping %s", program_id);
796 802
 	ts_LOGf("Stop %s\n", program_id);
797 803
 

Loading…
Cancel
Save