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
 next : Version next
1
 next : Version next
2
  * Add --output-tos (-g) option used to set output TOS value.
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
  * 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
 2011-12-23 : Version 5.0
6
 2011-12-23 : Version 5.0
6
  * Add --bench (-b) option that benchmarks libdvbcsa decryption.
7
  * Add --bench (-b) option that benchmarks libdvbcsa decryption.

+ 1
- 0
README View File

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

+ 5
- 0
data.h View File

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

+ 17
- 1
process.c View File

25
 static unsigned long ts_pack;
25
 static unsigned long ts_pack;
26
 static int ts_pack_shown;
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
 	int i;
29
 	int i;
30
 	uint16_t nitpid = 0x0010, pmtpid = 0xffff, pcrpid = 0xffff;
30
 	uint16_t nitpid = 0x0010, pmtpid = 0xffff, pcrpid = 0xffff;
31
 
31
 
266
 		uint8_t *ts_packet = data + i;
266
 		uint8_t *ts_packet = data + i;
267
 		uint16_t pid = ts_packet_get_pid(ts_packet);
267
 		uint16_t pid = ts_packet_get_pid(ts_packet);
268
 
268
 
269
+		if (ts->pid_report)
270
+			ts->pid_stats[pid]++;
271
+
269
 		ts_pack_shown = 0;
272
 		ts_pack_shown = 0;
270
 
273
 
271
 		process_pat(ts, pid, ts_packet);
274
 		process_pat(ts, pid, ts_packet);
313
 		ts_pack++;
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
 void *decode_thread(void *_ts);
21
 void *decode_thread(void *_ts);
22
 void *write_thread(void *_ts);
22
 void *write_thread(void *_ts);
23
 void process_packets(struct ts *ts, uint8_t *data, ssize_t data_len);
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
 #endif
26
 #endif

+ 4
- 0
tsdecrypt.1 View File

47
 dump.
47
 dump.
48
 Setting higher level enables the levels bellow.
48
 Setting higher level enables the levels bellow.
49
 .TP
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
 \fB\-b\fR, \fB\-\-bench\fR
54
 \fB\-b\fR, \fB\-\-bench\fR
51
 Bechmark libdvbcsa decryption. The benchmark is single threaded.
55
 Bechmark libdvbcsa decryption. The benchmark is single threaded.
52
 If you want to fully test your CPU, run couple of tsdecrypts in parallel.
56
 If you want to fully test your CPU, run couple of tsdecrypts in parallel.

+ 9
- 3
tsdecrypt.c View File

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

Loading…
Cancel
Save