Browse Source

Add ECM reports and --ecm-report-time parameter.

Georgi Chorbadzhiyski 12 years ago
parent
commit
f2d5a4600f
6 changed files with 46 additions and 2 deletions
  1. 5
    2
      camd.c
  2. 3
    0
      data.c
  3. 6
    0
      data.h
  4. 2
    0
      tables.c
  5. 4
    0
      tsdecrypt.1
  6. 26
    0
      tsdecrypt.c

+ 5
- 2
camd.c View File

@@ -285,8 +285,11 @@ static void camd_do_msg(struct camd_msg *msg) {
285 285
 		if (camd35_send_emm(msg->ts, msg->ca_id, msg->data, msg->data_len) > 0)
286 286
 			msg->ts->emm_processed_count++;
287 287
 	}
288
-	if (msg->type == ECM_MSG)
289
-		camd35_send_ecm(msg->ts, msg->ca_id, msg->service_id, msg->idx, msg->data, msg->data_len);
288
+	if (msg->type == ECM_MSG) {
289
+		msg->ts->ecm_seen_count++;
290
+		if (camd35_send_ecm(msg->ts, msg->ca_id, msg->service_id, msg->idx, msg->data, msg->data_len) > 0)
291
+			msg->ts->ecm_processed_count++;
292
+	}
290 293
 
291 294
 	camd_msg_free(&msg);
292 295
 }

+ 3
- 0
data.c View File

@@ -79,6 +79,9 @@ void data_init(struct ts *ts) {
79 79
 	ts->emm_report_interval = 60;
80 80
 	ts->emm_last_report     = time(NULL);
81 81
 
82
+	ts->ecm_report_interval = 60;
83
+	ts->ecm_last_report     = time(NULL);
84
+
82 85
 	ts->input.fd    = 0; // STDIN
83 86
 	ts->input.type  = FILE_IO;
84 87
 

+ 6
- 0
data.h View File

@@ -110,6 +110,12 @@ struct ts {
110 110
 	unsigned int		emm_report_interval;
111 111
 	time_t				emm_last_report;
112 112
 
113
+	unsigned int		ecm_seen_count;
114
+	unsigned int		ecm_processed_count;
115
+	unsigned int		ecm_duplicate_count;
116
+	unsigned int		ecm_report_interval;
117
+	time_t				ecm_last_report;
118
+
113 119
 	// CAMD handling
114 120
 	struct key			key;
115 121
 	struct camd35		camd35;

+ 2
- 0
tables.c View File

@@ -167,6 +167,8 @@ static void __process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
167 167
 	struct ts_header *th = &ts->ecm->ts_header;
168 168
 	struct ts_section_header *sec = ts->ecm->section_header;
169 169
 	int duplicate = ts_privsec_is_same(ts->ecm, ts->last_ecm);
170
+	if (duplicate && !ts->is_cw_error)
171
+		ts->ecm_duplicate_count++;
170 172
 	if (!duplicate || ts->is_cw_error) {
171 173
 		if (ts->ecm_cw_log) {
172 174
 			ts_hex_dump_buf(dump, dump_buf_sz, sec->section_data, min(dump_sz, sec->section_data_len), 0);

+ 4
- 0
tsdecrypt.1 View File

@@ -128,6 +128,10 @@ always chooses the first stream from the chosen CA system. Run tsdecrypt
128 128
 with --debug 2 and look at CA descriptors in PMT to see what CA streams
129 129
 are available.
130 130
 .TP
131
+\fB\-H\fR, \fB\-\-ecm\-report\-time\fR <seconds>
132
+Set interval for ECM reports. The default is \fB60\fR seconds. Set to \fB0\fR
133
+to disable ECM reports.
134
+.TP
131 135
 \fB\-G\fR, \fB\-\-ecm\-irdeto\-type\fR <type>
132 136
 Set ECM IRDETO type. IRDETO CA send ECMs with different id mixed
133 137
 into one stream. Only one of the IDs are valid in given time. This

+ 26
- 0
tsdecrypt.c View File

@@ -73,6 +73,7 @@ static const struct option long_options[] = {
73 73
 	{ "emm-report-time",	required_argument, NULL, 'f' },
74 74
 
75 75
 	{ "ecm-pid",			required_argument, NULL, 'X' },
76
+	{ "ecm-report-time",	required_argument, NULL, 'H' },
76 77
 	{ "ecm-irdeto-type",	required_argument, NULL, 'G' },
77 78
 	{ "ecm-no-log",			no_argument      , NULL, 'K' },
78 79
 
@@ -133,6 +134,9 @@ static void show_help(struct ts *ts) {
133 134
 	printf("\n");
134 135
 	printf("ECM options:\n");
135 136
 	printf(" -X --ecm-pid <pid>         | Force ECM pid. Default: none\n");
137
+	printf(" -H --ecm-report-time <sec> | Report each <sec> how much ECMs and CWs have been\n");
138
+	printf("                            . processed/skipped. Set <sec> to 0 to disable\n");
139
+	printf("                            . the reports. Default: %d sec\n", ts->ecm_report_interval);
136 140
 	printf(" -G --ecm-irdeto-type <int> | Process IRDETO ECMs with type X /0..3/. Default: %d\n", ts->irdeto_ecm);
137 141
 	printf(" -K --ecm-no-log            | Disable ECM and code words logging.\n");
138 142
 	printf("\n");
@@ -284,6 +288,11 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
284 288
 			case 'X':
285 289
 				ts->forced_ecm_pid = strtoul(optarg, NULL, 0) & 0x1fff;
286 290
 				break;
291
+			case 'H':
292
+				ts->ecm_report_interval = strtoul(optarg, NULL, 10);
293
+				if (ts->ecm_report_interval > 86400)
294
+					ts->ecm_report_interval = 86400;
295
+				break;
287 296
 			case 'G':
288 297
 				ts->irdeto_ecm = atoi(optarg);
289 298
 				break;
@@ -375,6 +384,10 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
375 384
 		ts_LOGf("EMM send   : %s\n", ts->emm_send   ? "enabled" : "disabled");
376 385
 		ts_LOGf("Decoding   : %s\n", ts->threaded ? "threaded" : "single thread");
377 386
 	}
387
+	if (!ts->emm_only && ts->ecm_report_interval)
388
+		ts_LOGf("ECM report : %d sec\n", ts->emm_report_interval);
389
+	if (!ts->emm_only && ts->ecm_report_interval == 0)
390
+		ts_LOGf("ECM report : disabled\n");
378 391
 
379 392
 	if (!ts->ecm_cw_log)
380 393
 		ts_LOGf("ECM/CW log : disabled\n");
@@ -400,6 +413,19 @@ static void do_reports(struct ts *ts) {
400 413
 			ts->emm_processed_count = 0;
401 414
 		}
402 415
 	}
416
+	if (!ts->emm_only && ts->ecm_report_interval) {
417
+		if ((time_t)(ts->ecm_last_report + ts->ecm_report_interval) <= now) {
418
+			ts->ecm_last_report = now;
419
+			ts_LOGf("ECM | Received %u (%u dup) and processed %u in %u seconds.\n",
420
+				ts->ecm_seen_count,
421
+				ts->ecm_duplicate_count,
422
+				ts->ecm_processed_count,
423
+				ts->ecm_report_interval);
424
+			ts->ecm_seen_count = 0;
425
+			ts->ecm_duplicate_count = 0;
426
+			ts->ecm_processed_count = 0;
427
+		}
428
+	}
403 429
 }
404 430
 
405 431
 void signal_quit(int sig) {

Loading…
Cancel
Save