/* * dvbtune -f 722166667 -qam 16 -cr 3_4 && dvbsnoop 0x10 * * NIT: * PID=0x10 * TID=0x40 * tag=0x83 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define TIMEOUT 30 #define MAX_TABLE_LEN 4096 /* Network Information Table PID and TID */ #define PID_NIT 0x0010 #define TID_NIT 0x40 #define TAG_LCN 0x83 bool read_nit(char *, unsigned int, unsigned char *); bool read_table(char *, uint16_t, uint8_t, unsigned int, unsigned char *); void fatal(char *, ...); int main(void) { unsigned char nit[MAX_TABLE_LEN]; unsigned char *data; unsigned int section_len; unsigned int nit_len; unsigned int descriptors_loop_len; unsigned int transport_stream_id; unsigned int ntransport_ids; unsigned int transport_ids[6]; unsigned int i; /* * Malvern transmitter (repeater for Sutton Coldfield) broadcasts 2 NITs * one has the LCNs for 5 MUXs * the other has the LCNs for the other MUX */ ntransport_ids = 0; while(ntransport_ids < 6) { bzero(nit, MAX_TABLE_LEN); if(!read_nit("/dev/dvb/adapter0/demux0", TIMEOUT, nit)) fatal("Unable to read NIT"); /* generic header */ data = nit; section_len = ((data[1] & 0x0f) << 8) | data[2]; data += 8; /* header + CRC */ nit_len = section_len - (5 + 4); /* skip the first descriptors loop */ descriptors_loop_len = ((data[0] & 0x0f) << 8) | data[1]; data += descriptors_loop_len + 4; nit_len -= descriptors_loop_len + 4; while(nit_len > 6) { transport_stream_id = (data[0] << 8) | data[1]; /* have we already seen it */ for(i=0; i 0) { unsigned char desc_tag = data[0]; unsigned char desc_len = data[1] + 2; data += 2; if(desc_tag == TAG_LCN) { for(i=0; i