|
@@ -46,6 +46,20 @@ struct ts {
|
46
|
46
|
|
47
|
47
|
struct ts *ts_alloc() {
|
48
|
48
|
struct ts *ts = calloc(1, sizeof(struct ts));
|
|
49
|
+ ts->pat = ts_pat_alloc();
|
|
50
|
+ ts->curpat = ts_pat_alloc();
|
|
51
|
+
|
|
52
|
+ ts->cat = ts_cat_alloc();
|
|
53
|
+ ts->curcat = ts_cat_alloc();
|
|
54
|
+
|
|
55
|
+ ts->pmt = ts_pmt_alloc();
|
|
56
|
+ ts->curpmt = ts_pmt_alloc();
|
|
57
|
+
|
|
58
|
+ ts->emm = ts_privsec_alloc();
|
|
59
|
+ ts->last_emm = ts_privsec_alloc();
|
|
60
|
+
|
|
61
|
+ ts->ecm = ts_privsec_alloc();
|
|
62
|
+ ts->last_ecm = ts_privsec_alloc();
|
49
|
63
|
return ts;
|
50
|
64
|
}
|
51
|
65
|
|
|
@@ -284,18 +298,16 @@ static int camd35_send_emm(uint16_t ca_id, uint8_t *data, uint8_t data_len) {
|
284
|
298
|
#define handle_table_changes(TABLE) \
|
285
|
299
|
do { \
|
286
|
300
|
show_ts_pack(pid, #TABLE, NULL, ts_packet); \
|
287
|
|
- if (!ts->cur##TABLE) \
|
288
|
|
- ts->cur##TABLE = ts_##TABLE##_alloc(); \
|
289
|
301
|
ts->cur##TABLE = ts_##TABLE##_push_packet(ts->cur##TABLE, ts_packet); \
|
290
|
302
|
if (!ts->cur##TABLE->initialized) \
|
291
|
303
|
return; \
|
292
|
304
|
if (ts_##TABLE##_is_same(ts->TABLE, ts->cur##TABLE)) { \
|
293
|
|
- ts_##TABLE##_free(&ts->cur##TABLE); \
|
|
305
|
+ ts_##TABLE##_clear(ts->cur##TABLE); \
|
294
|
306
|
return; \
|
295
|
307
|
} \
|
296
|
308
|
ts_##TABLE##_free(&ts->TABLE); \
|
297
|
|
- ts->TABLE = ts->cur##TABLE; \
|
298
|
|
- ts->cur##TABLE = NULL; \
|
|
309
|
+ ts->TABLE = ts_##TABLE##_copy(ts->cur##TABLE); \
|
|
310
|
+ ts_##TABLE##_clear(ts->cur##TABLE); \
|
299
|
311
|
ts_##TABLE##_dump(ts->TABLE); \
|
300
|
312
|
} while(0)
|
301
|
313
|
|
|
@@ -351,8 +363,6 @@ void process_emm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
351
|
363
|
return;
|
352
|
364
|
|
353
|
365
|
show_ts_pack(pid, "emm", NULL, ts_packet);
|
354
|
|
- if (!ts->emm)
|
355
|
|
- ts->emm = ts_privsec_alloc();
|
356
|
366
|
|
357
|
367
|
ts->emm = ts_privsec_push_packet(ts->emm, ts_packet);
|
358
|
368
|
if (!ts->emm->initialized)
|
|
@@ -368,9 +378,8 @@ void process_emm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
368
|
378
|
sec->section_data_len,
|
369
|
379
|
dump);
|
370
|
380
|
camd35_send_emm(ts->emm_caid, sec->section_data, sec->section_data_len);
|
371
|
|
- ts_privsec_free(&ts->last_emm);
|
372
|
|
- ts->last_emm = ts->emm;
|
373
|
|
- ts->emm = ts_privsec_alloc();
|
|
381
|
+ ts_privsec_copy(ts->emm, ts->last_emm);
|
|
382
|
+ ts_privsec_clear(ts->emm);
|
374
|
383
|
}
|
375
|
384
|
|
376
|
385
|
void process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
|
@@ -378,9 +387,6 @@ void process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
378
|
387
|
if (!ts->ecm_pid || ts->ecm_pid != pid)
|
379
|
388
|
return;
|
380
|
389
|
|
381
|
|
- if (!ts->ecm)
|
382
|
|
- ts->ecm = ts_privsec_alloc();
|
383
|
|
-
|
384
|
390
|
ts->ecm = ts_privsec_push_packet(ts->ecm, ts_packet);
|
385
|
391
|
if (!ts->ecm->initialized)
|
386
|
392
|
return;
|
|
@@ -406,9 +412,8 @@ void process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
|
406
|
412
|
sec->section_data_len,
|
407
|
413
|
ts->ecm_counter - 1);
|
408
|
414
|
}
|
409
|
|
- ts_privsec_free(&ts->last_ecm);
|
410
|
|
- ts->last_ecm = ts->ecm;
|
411
|
|
- ts->ecm = ts_privsec_alloc();
|
|
415
|
+ ts_privsec_copy(ts->ecm, ts->last_ecm);
|
|
416
|
+ ts_privsec_clear(ts->ecm);
|
412
|
417
|
|
413
|
418
|
show_ts_pack(pid, !duplicate ? "ecm" : "ec+", NULL, ts_packet);
|
414
|
419
|
}
|