Browse Source

List available Irdeto CHIDs found in ECM stream.

Georgi Chorbadzhiyski 10 years ago
parent
commit
b508fbe282
2 changed files with 31 additions and 2 deletions
  1. 8
    0
      data.h
  2. 23
    2
      tables.c

+ 8
- 0
data.h View File

@@ -217,6 +217,11 @@ struct filter {
217 217
 	char		name[MAX_FILTER_NAME];	// Filter name (default: NO_NAME)
218 218
 };
219 219
 
220
+struct chid {
221
+	int			seen;
222
+	uint16_t	chid;
223
+};
224
+
220 225
 #define MAX_PIDS 8192
221 226
 
222 227
 struct ts {
@@ -298,6 +303,9 @@ struct ts {
298 303
 		IRDETO_FILTER_CHID,
299 304
 	} irdeto_ecm_filter_type;
300 305
 
306
+	struct chid			irdeto_chid[0xff];
307
+	uint8_t				irdeto_max_chids;
308
+
301 309
 	int					ecm_cw_log;
302 310
 
303 311
 	int					rtp_input;

+ 23
- 2
tables.c View File

@@ -12,6 +12,8 @@
12 12
  * GNU General Public License (COPYING file) for more details.
13 13
  *
14 14
  */
15
+#include <string.h>
16
+
15 17
 #include "data.h"
16 18
 #include "tables.h"
17 19
 #include "camd.h"
@@ -173,6 +175,11 @@ void process_pmt(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
173 175
 	} else {
174 176
 		ts_LOGf("*** | ERROR: Can't detect ECM pid.\n");
175 177
 	}
178
+
179
+	if (ts->req_CA_sys == CA_IRDETO) {
180
+		memset(ts->irdeto_chid, 0, sizeof(ts->irdeto_chid));
181
+		ts->irdeto_max_chids = 0;
182
+	}
176 183
 }
177 184
 
178 185
 static int sdt_parse_service_name_desc(
@@ -315,12 +322,26 @@ static void __process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
315 322
 
316 323
 	if (ts->req_CA_sys == CA_IRDETO) {
317 324
 		uint8_t idx     = ts->ecm->section_header->section_data[4];
325
+		uint8_t max_idx = ts->ecm->section_header->section_data[5];
318 326
 		uint16_t chid   = (ts->ecm->section_header->section_data[6] << 8) | ts->ecm->section_header->section_data[7];
319 327
 
328
+		if (max_idx != ts->irdeto_max_chids) {
329
+			memset(ts->irdeto_chid, 0, sizeof(ts->irdeto_chid));
330
+			ts->irdeto_max_chids = max_idx;
331
+		}
332
+
320 333
 		bool ecm_ok = false;
334
+		const char *filter_type;
321 335
 		switch (ts->irdeto_ecm_filter_type) {
322
-		case IRDETO_FILTER_IDX : ecm_ok = (idx == ts->irdeto_ecm_idx); break;
323
-		case IRDETO_FILTER_CHID: ecm_ok = (chid == ts->irdeto_ecm_chid); break;
336
+		case IRDETO_FILTER_IDX : ecm_ok = (idx == ts->irdeto_ecm_idx); filter_type = " BY IDX"; break;
337
+		case IRDETO_FILTER_CHID: ecm_ok = (chid == ts->irdeto_ecm_chid); filter_type = " BY CHID"; break;
338
+		}
339
+
340
+		if (ts->irdeto_chid[idx].seen < 1) {
341
+			ts_LOGf("CAS | Seen Irdeto CHID 0x%04x (idx %u/%u)%s%s\n", chid, idx, max_idx,
342
+				ecm_ok ? " *SELECTED*" : "",
343
+				ecm_ok ? filter_type   : "");
344
+			ts->irdeto_chid[idx].seen++;
324 345
 		}
325 346
 
326 347
 		if (!ecm_ok) {

Loading…
Cancel
Save