csa: add back in CAT/CA processing

This commit is contained in:
Adam Sutton 2013-06-17 13:13:49 +01:00
parent d76c1e19f0
commit 5e03ad3b4e
3 changed files with 63 additions and 0 deletions

View file

@ -33,6 +33,7 @@ struct mpegts_table;
/* PIDs */
#define DVB_PAT_PID 0x00
#define DVB_CAT_PID 0x02
#define DVB_NIT_PID 0x10
#define DVB_SDT_PID 0x11
#define DVB_BAT_PID 0x11
@ -42,6 +43,9 @@ struct mpegts_table;
#define DVB_PAT_BASE 0x00
#define DVB_PAT_MASK 0x00
#define DVB_CAT_BASE 0x01
#define DVB_CAT_MASK 0xFF
#define DVB_PMT_BASE 0x02
#define DVB_PMT_MASK 0xFF
@ -152,6 +156,8 @@ do {\
int dvb_pat_callback
(struct mpegts_table *mt, const uint8_t *ptr, int len, int tableid);
int dvb_cat_callback
(struct mpegts_table *mt, const uint8_t *ptr, int len, int tableid);
int dvb_pmt_callback
(struct mpegts_table *mt, const uint8_t *ptr, int len, int tabelid);
int dvb_nit_callback

View file

@ -489,6 +489,61 @@ dvb_pat_callback
return mt->mt_state[0].complete ? 0 : -1;
}
/*
* CAT processing
*/
// TODO: might be a better way of handling this
#include "descrambler/cwc.h"
static int
dvb_ca_callback
(mpegts_table_t *mt, const uint8_t *ptr, int len, int tableid)
{
#if ENABLE_CWC
cwc_emm((uint8_t*)ptr, len, (uintptr_t)mt->mt_opaque, mt->mt_mux);
#endif
return 0;
}
int
dvb_cat_callback
(mpegts_table_t *mt, const uint8_t *ptr, int len, int tableid)
{
int sect, last, ver;
uint8_t dtag, dlen;
uint16_t pid;
uintptr_t caid;
mpegts_mux_t *mm = mt->mt_mux;
/* Start */
if (dvb_table_begin(mt, ptr, len, tableid, 7, &sect, &last, &ver))
return -1;
ptr += 5;
len -= 5;
while(len > 2) {
dtag = *ptr++;
dlen = *ptr++;
len -= 2;
switch(dtag) {
case DVB_DESC_CA:
caid = ( ptr[0] << 8) | ptr[1];
pid = ((ptr[2] & 0x1f) << 8) | ptr[3];
if(pid != 0)
mpegts_table_add(mm, 0, 0, dvb_ca_callback,
(void*)caid, "ca", MT_FULL, pid);
break;
default:
break;
}
ptr += dlen;
len -= dlen;
}
return 0;
}
/*
* PMT processing
*/

View file

@ -432,6 +432,8 @@ linuxdvb_frontend_default_tables
/* DVB */
} else {
mpegts_table_add(mm, DVB_CAT_BASE, DVB_CAT_MASK, dvb_cat_callback,
NULL, "cat", MT_QUICKREQ | MT_CRC, DVB_CAT_PID);
mpegts_table_add(mm, DVB_NIT_BASE, DVB_NIT_MASK, dvb_nit_callback,
NULL, "nit", MT_QUICKREQ | MT_CRC, DVB_NIT_PID);
mpegts_table_add(mm, DVB_SDT_BASE, DVB_SDT_MASK, dvb_sdt_callback,