Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cwc: improve the preferred PID validation
  • Loading branch information
perexg committed Aug 25, 2015
1 parent cb5f6a1 commit 2218885
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/descrambler/cwc.c
Expand Up @@ -1300,26 +1300,30 @@ cwc_table_input(void *opaque, int pid, const uint8_t *data, int len, int emm)
// Validate prefered ECM PID
tvhlog(LOG_DEBUG, "cwc", "ECM state INIT");

if(t->s_dvb_prefcapid != PREFCAPID_OFF) {
struct elementary_stream *prefca
= service_stream_find((service_t*)t, t->s_dvb_prefcapid);
if (!prefca || prefca->es_type != SCT_CA) {
tvhlog(LOG_DEBUG, "cwc", "Invalid prefered ECM (PID %d) found for service \"%s\"", t->s_dvb_prefcapid, t->s_dvb_svcname);
t->s_dvb_prefcapid = 0;
}
if(t->s_dvb_prefcapid_lock != PREFCAPID_OFF) {
st = service_stream_find((service_t*)t, t->s_dvb_prefcapid);
if (st && st->es_type == SCT_CA)
LIST_FOREACH(c, &st->es_caids, link)
LIST_FOREACH(pcard, &cwc->cwc_cards, cs_card)
if(pcard->cs_ra.caid == c->caid && verify_provider(pcard, c->providerid))
goto prefcapid_ok;
tvhlog(LOG_DEBUG, "cwc", "Invalid prefered ECM (PID %d) found for service \"%s\"", t->s_dvb_prefcapid, t->s_dvb_svcname);
t->s_dvb_prefcapid = 0;
}

if(t->s_dvb_prefcapid == pid || t->s_dvb_prefcapid == 0) {
prefcapid_ok:
if(t->s_dvb_prefcapid == pid || t->s_dvb_prefcapid == 0 ||
t->s_dvb_prefcapid_lock == PREFCAPID_OFF) {
ep = calloc(1, sizeof(ecm_pid_t));
ep->ep_pid = pid;
LIST_INSERT_HEAD(&ct->cs_pids, ep, ep_link);
tvhlog(LOG_DEBUG, "cwc", "Insert %s ECM (PID %d) for service \"%s\"",
t->s_dvb_prefcapid ? "preferred" : "new", pid, t->s_dvb_svcname);
}
}
if(ep == NULL)
goto end;
}
if(ep == NULL)
goto end;

st = service_stream_find((service_t *)t, pid);
if (st) {
Expand Down

0 comments on commit 2218885

Please sign in to comment.