Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
linuxdvb_ca: check for CAIDs on the ES level, fixes #2794
  • Loading branch information
dmarion authored and perexg committed Apr 29, 2015
1 parent aaaa7a1 commit 8ae5b7f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
41 changes: 17 additions & 24 deletions src/descrambler/dvbcam.c
Expand Up @@ -102,11 +102,12 @@ dvbcam_unregister_cam(linuxdvb_ca_t * lca, uint8_t slot)
void
dvbcam_pmt_data(mpegts_service_t *s, const uint8_t *ptr, int len)
{
linuxdvb_frontend_t *lfe;
dvbcam_active_caid_t *ac;
dvbcam_active_service_t *as = NULL, *as2;
int i, l;
uint8_t *p;
linuxdvb_frontend_t *lfe;
dvbcam_active_caid_t *ac;
dvbcam_active_service_t *as = NULL, *as2;
elementary_stream_t *st;
caid_t *c;
int i;

lfe = (linuxdvb_frontend_t*) s->s_dvb_active_input;

Expand Down Expand Up @@ -134,34 +135,26 @@ dvbcam_pmt_data(mpegts_service_t *s, const uint8_t *ptr, int len)
as->last_pmt_len = len + 3;
as->ca = NULL;

l = (ptr[7] & 0x03 )| ptr[8];
p = (uint8_t *) ptr + 9;

while (l > 0 ) {
uint8_t desc_tag = p[0];
uint8_t desc_len = p[1];

if (desc_tag == DVB_DESC_CA) {
uint16_t caid = (p[2] << 8) | p[3];

pthread_mutex_lock(&dvbcam_mutex);
pthread_mutex_lock(&dvbcam_mutex);

/* check all ellementary streams for CAIDs, if any send PMT to CAM */
TAILQ_FOREACH(st, &s->s_components, es_link) {
LIST_FOREACH(c, &st->es_caids, link) {
TAILQ_FOREACH(ac, &dvbcam_active_caids, link) {
for(i=0;i<ac->num_caids;i++) {
if(ac->ca && ac->ca->lca_adapter == lfe->lfe_adapter &&
ac->caids[i] == caid)
ac->caids[i] == c->caid)
{
as->ca = ac->ca;
as->slot = ac->slot;
break;
break;
}
}
}
}
pthread_mutex_unlock(&dvbcam_mutex);
}
p += desc_len + 2;
l -= desc_len + 2;
}
}
}

pthread_mutex_unlock(&dvbcam_mutex);

/* this service doesn't have assigned CAM */
if (!as->ca)
Expand Down
8 changes: 4 additions & 4 deletions src/input/mpegts/dvb_psi.c
Expand Up @@ -988,10 +988,6 @@ dvb_pmt_callback
if (s->s_dvb_service_id == sid) break;
if (!s) return -1;

#if ENABLE_LINUXDVB_CA
dvbcam_pmt_data(s, ptr, len);
#endif

/* Process */
tvhdebug("pmt", "sid %04X (%d)", sid, sid);
pthread_mutex_lock(&s->s_stream_mutex);
Expand All @@ -1000,6 +996,10 @@ dvb_pmt_callback
if (r)
service_restart((service_t*)s);

#if ENABLE_LINUXDVB_CA
dvbcam_pmt_data(s, ptr, len);
#endif

/* Finish */
return dvb_table_end((mpegts_psi_table_t *)mt, st, sect);
}
Expand Down

0 comments on commit 8ae5b7f

Please sign in to comment.