static char *output_charset = "utf-8";
static void parse_descriptor(struct dvb_descriptors *dvb_desc,
- const unsigned char *buf, int len)
+ const unsigned char *buf, int len,
+ void *ptr)
{
int dlen = buf[1] + 1;
/* FIXME: Not all descriptors are valid for all tables */
+ printf("Descriptor 0x%02x, len %d\n", buf[0], dlen);
switch(buf[0]) {
case network_name_descriptor:
parse_string(&dvb_desc->nit_table.network_name,
}
void parse_nit_descriptor(struct dvb_descriptors *dvb_desc,
- const unsigned char *buf, int len)
+ const unsigned char *buf, int len, void *ptr)
{
/* Check if the descriptor is valid on a NIT table */
switch (buf[0]) {
case XAIT_location_descriptor:
case FTA_content_management_descriptor:
case extension_descriptor:
- parse_descriptor(dvb_desc, buf, len);
+ parse_descriptor(dvb_desc, buf, len, ptr);
break;
default:
return;
* Descriptors, as defined on ETSI EN 300 468 V1.11.1 (2010-04)
*/
-enum table_type {
- PAT,
- PMT,
- NIT,
- NUM_TABLE_TYPES
-};
-
enum descriptors {
network_name_descriptor = 0x40,
service_list_descriptor = 0x41,
};
void parse_nit_descriptor(struct dvb_descriptors *dvb_desc,
- const unsigned char *buf, int len);
+ const unsigned char *buf, int len, void *ptr);
int id, int version)
{
struct nit_table *nit_table = &dvb_desc->nit_table;
- int len;
+ int len, n;
nit_table->network_id = id;
nit_table->version = version;
return;
}
- printf("descriptor 0x%02x, len %d\n", buf[2], len);
+ parse_nit_descriptor(dvb_desc, &buf[2], len, NULL);
- parse_nit_descriptor(dvb_desc, &buf[2], len);
+ *section_length -= len + 4;
+ buf += len + 4;
+
+ n = nit_table->tr_table_len;
+ while (*section_length > 6) {
+ nit_table->tr_table = realloc(nit_table->tr_table,
+ sizeof(*nit_table->tr_table) * (n + 1));
+ nit_table->tr_table[n].tr_id = (buf[0] << 8) | buf[1];
+
+ len = ((buf[4] & 0x0f) << 8) | buf[5];
+ if (*section_length < len + 4) {
+ printf("NIT section too short for Network ID 0x%04x, transport stream ID 0x%04x",
+ id, nit_table->tr_table[n].tr_id);
+ continue;
+ } else {
+ printf("Transport stream ID 0x%04x, len %d\n",
+ nit_table->tr_table[n].tr_id);
+
+ parse_nit_descriptor(dvb_desc, &buf[6], len,
+ &nit_table->tr_table[n]);
+ n++;
+ }
+ *section_length -= len + 6;
+ buf += len + 6;
+ }
+ nit_table->tr_table_len = n;
}
uint16_t program_number;
uint16_t pid;
struct pmt_table pmt_table;
- int video_pid_len, audio_pid_len;
+ unsigned video_pid_len, audio_pid_len;
uint16_t *video_pid;
uint16_t *audio_pid;
};
unsigned pid_table_len;
};
+struct transport_table {
+ uint16_t tr_id;
+};
+
struct nit_table {
uint16_t network_id;
unsigned char version;
char *network_name, *network_alias;
+ struct transport_table *tr_table;
+ unsigned tr_table_len;
};
struct dvb_descriptors {