Open malakudi opened 6 years ago
I think I found when the problem happens: it is when original stream is lost for a while (dvblast restart or sat signal loss). Initially when running tsdecrypt we get:
2018-08-04 13:41:43 | NEW | Input PID 0x0010 appeared (NIT) 2018-08-04 13:41:43 | PAT | Using service 0xXXXX (YYYY), PMT pid: 00ZZ (ZZ) 2018-08-04 13:41:43 | NEW | Input PID 0x0000 appeared (PAT) 2018-08-04 13:41:43 | SDT | Service 0xXXXX (YYYY) Type: 0x01 (Tv) Provider: "DUMMY" Service: "DUMMY" 2018-08-04 13:41:43 | NEW | Input PID 0x0011 appeared (SDT) 2018-08-04 13:41:43 | --- | ECM CAID: 0x0500 (VIACCESS) 2018-08-04 13:41:43 | --- | ECM pid : 0x0575 (VIACCESS) 2018-08-04 13:41:43 | --- | ECM pid : 0x0031 (VIACCESS) idx:0 2018-08-04 13:41:43 | --- | ECM pid : 0x0545 (VIACCESS) idx:1 2018-08-04 13:41:43 | --- | ECM pid : 0x0575 (VIACCESS) idx:2 2018-08-04 13:41:43 | NEW | Input PID 0x0025 appeared (PMT) 2018-08-04 13:41:43 | NEW | Input PID 0x0575 appeared (ECM) 2018-08-04 13:41:43 | ERR | [newcamd] Card was not able to decode the channel. 2018-08-04 13:41:43 | ECM | Switching ECM pid to 0x0545 (1349) idx:1 2018-08-04 13:41:43 | NEW | Input PID 0x1255 appeared (H.264/14496-10 video (MPEG-4/AVC)) 2018-08-04 13:41:44 | NEW | Input PID 0x1256 appeared (11172-3 audio (MPEG-1)) 2018-08-04 13:41:44 | NEW | Input PID 0x0545 appeared (ECM) 2018-08-04 13:41:44 | CW | OK: Valid code word was received.
But after stopping dvblast for few seconds then restarting it: 2018-08-04 13:44:45 | --- | Input read timeout. 2018-08-04 13:44:47 | --- | Input read timeout. 2018-08-04 13:44:48 | +++ | Input OK after 50 sec timeout. 2018-08-04 13:44:48 | PAT | Using service 0xXXXX (YYYY), PMT pid: 00ZZ (ZZ) 2018-08-04 13:44:48 | --- | TS discontinuity on PID 0x0000 expected 8 got 6 /14/ (PAT) 2018-08-04 13:44:48 | --- | TS discontinuity on PID 0x0010 expected 1 got 9 /8/ (NIT) 2018-08-04 13:44:48 | ECM | Received 0 (66 dup) and processed 0 in 62 seconds. 2018-08-04 13:44:49 | --- | ECM CAID: 0x0500 (VIACCESS) 2018-08-04 13:44:49 | --- | ECM pid : 0x0575 (VIACCESS) 2018-08-04 13:44:49 | --- | TS discontinuity on PID 0x0025 expected 7 got 8 /1/ (PMT) 2018-08-04 13:44:49 | --- | TS discontinuity on PID 0x1255 expected 5 got 13 /8/ (H.264/14496-10 video (MPEG-4/AVC)) 2018-08-04 13:44:49 | CWC | SID 0x35c3 ------------ EcmTime: 68228 ms CW_time: 68045 ms 2018-08-04 13:44:49 | --- | TS discontinuity on PID 0x1256 expected 6 got 4 /14/ (11172-3 audio (MPEG-1)) 2018-08-04 13:44:49 | --- | TS discontinuity on PID 0x0545 expected 5 got 14 /9/ (Unknown) 2018-08-04 13:44:49 | --- | TS discontinuity on PID 0x0575 expected 5 got 14 /9/ (ECM) 2018-08-04 13:44:49 | ERR | [newcamd] Card was not able to decode the channel. 2018-08-04 13:44:49 | CW | ERR No valid code word was received in 69 seconds. Decryption is disabled. 2018-08-04 13:44:49 | ERR | [newcamd] Card was not able to decode the channel. 2018-08-04 13:44:49 | ERR | [newcamd] Card was not able to decode the channel. 2018-08-04 13:44:49 | ERR | [newcamd] Card was not able to decode the channel. and keeps trying invalid ECM pid.
So it seems after data is back, it doesn't read all ECM pids but only one, which in my case is one that can't be decrypted.
OK, I think I found the issue. The code that detects the ecm pids (int __ts_get_ecm_info) calls find_CA_descriptor. But in order to work correctly, passed values ts->ecm_caid, ts->ecm_pid and ts->ecm_pids[X] should all be set to zero. On first run they are zero but after signal loss, on second run, they have the previously detected values and ecm pid detection fails (detects 0 pids).
Following patch fixes that:
--- tsdecrypt-original/tables.c 2018-08-04 15:58:55.264421539 +0300
+++ tsdecrypt/tables.c 2018-08-04 15:58:08.485290218 +0300
@@ -211,7 +211,14 @@
if (ts->camd.constant_codeword)
return;
+ // initialise used values to 0
+ ts->ecm_caid = 0;
+ ts->ecm_pid = 0;
+ for (int j=0; j<MAX_ECM_PIDS; j++)
+ ts->ecm_pids[j] = 0;
+ // end initialising values
ts->n_ecm_pids = 0;
+
__ts_get_ecm_info(ts->pmt, ts->req_CA_sys, ts->forced_caid, &ts->ecm_caid, &ts->ecm_pid, &ts->ecm_pids[0], &ts->n_ecm_pids);
if (ts->forced_ecm_pid)
Using tsdecrypt on some VIACCESS channels that have different ECM pids for different viaccess providers, for example 0500:050F00, 0500:043800 and 0500:051E00. Newcamd line supports both 43800 and 50F00 but not 51E00. Everything works as expected, tsdecrypted switches between providers if there is an issue (timeout, cw not found etc) but after some time (can be days or hours) it seems it gets in a situation that only keeps retrying 051E00 which is not supported. I tried to debug it but the issue happens after some time so it is difficult. Any thoughts?