From c870eb9df0da93dd62ab24672f15a2186a001f64 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sat, 26 Dec 2015 18:35:12 +0100 Subject: [PATCH] capmt: when the caid is forced for a service, try to use it as PID 8191, fixes #2942 --- src/descrambler/capmt.c | 53 ++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index 8eecff215..332691591 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -1737,6 +1737,24 @@ capmt_table_input(void *opaque, int pid, const uint8_t *data, int len, int emm) pthread_mutex_unlock(&capmt->capmt_mutex); } +static void +capmt_caid_add(capmt_service_t *ct, mpegts_service_t *t, int pid, caid_t *c) +{ + capmt_caid_ecm_t *cce; + + tvhlog(LOG_DEBUG, "capmt", + "%s: New caid 0x%04X:0x%06X (pid 0x%04X) for service \"%s\"", + capmt_name(ct->ct_capmt), c->caid, c->providerid, pid, t->s_dvb_svcname); + + cce = calloc(1, sizeof(capmt_caid_ecm_t)); + cce->cce_caid = c->caid; + cce->cce_ecmpid = pid; + cce->cce_providerid = c->providerid; + cce->cce_service = t; + LIST_INSERT_HEAD(&ct->ct_caid_ecm, cce, cce_link); + ct->ct_constcw |= c->caid == 0x2600 ? 1 : 0; +} + static void capmt_caid_change(th_descrambler_t *td) { @@ -1766,18 +1784,7 @@ capmt_caid_change(th_descrambler_t *td) break; if (cce) continue; - tvhlog(LOG_DEBUG, "capmt", - "%s: New caid 0x%04X:0x%06X for service \"%s\"", - capmt_name(capmt), c->caid, c->providerid, t->s_dvb_svcname); - - /* ecmpid not already seen, add it to list */ - cce = calloc(1, sizeof(capmt_caid_ecm_t)); - cce->cce_caid = c->caid; - cce->cce_ecmpid = st->es_pid; - cce->cce_providerid = c->providerid; - cce->cce_service = t; - LIST_INSERT_HEAD(&ct->ct_caid_ecm, cce, cce_link); - ct->ct_constcw |= c->caid == 0x2600 ? 1 : 0; + capmt_caid_add(ct, t, st->es_pid, c); change = 1; } } @@ -1970,7 +1977,6 @@ capmt_service_start(caclient_t *cac, service_t *s) { capmt_t *capmt = (capmt_t *)cac; capmt_service_t *ct; - capmt_caid_ecm_t *cce; th_descrambler_t *td; mpegts_service_t *t = (mpegts_service_t*)s; elementary_stream_t *st; @@ -2055,22 +2061,19 @@ capmt_service_start(caclient_t *cac, service_t *s) continue; if (t->s_dvb_forcecaid && t->s_dvb_forcecaid != c->caid) continue; - - tvhlog(LOG_DEBUG, "capmt", - "%s: New caid 0x%04X for service \"%s\"", capmt_name(capmt), c->caid, t->s_dvb_svcname); - - /* add it to list */ - cce = calloc(1, sizeof(capmt_caid_ecm_t)); - cce->cce_caid = c->caid; - cce->cce_ecmpid = st->es_pid; - cce->cce_providerid = c->providerid; - cce->cce_service = t; - LIST_INSERT_HEAD(&ct->ct_caid_ecm, cce, cce_link); - ct->ct_constcw |= c->caid == 0x2600 ? 1 : 0; + capmt_caid_add(ct, t, st->es_pid, c); change = 1; } } + if (!change && t->s_dvb_forcecaid) { + caid_t sca; + memset(&sca, 0, sizeof(sca)); + sca.caid = t->s_dvb_forcecaid; + capmt_caid_add(ct, t, 8191, &sca); + change = 1; + } + td = (th_descrambler_t *)ct; snprintf(buf, sizeof(buf), "capmt-%s-%i", capmt->capmt_sockfile, -- 2.47.3