From c8352b40b2653157f7a1bdbd3657f6cf0791fb16 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 17 Nov 2013 18:35:40 -0200 Subject: [PATCH] libdvbv5/dvb-file: use the new descriptors for virtual channel Search for the LCN and TS info descriptors at the NIT table, for the virtual channel information. Signed-off-by: Mauro Carvalho Chehab --- lib/include/descriptors/nit.h | 2 +- lib/include/dvb-file.h | 3 --- lib/include/dvb-scan-table-handler.h | 23 ----------------- lib/libdvbv5/dvb-file.c | 50 +++++++++++++++++++++--------------- 4 files changed, 31 insertions(+), 47 deletions(-) diff --git a/lib/include/descriptors/nit.h b/lib/include/descriptors/nit.h index 204fbf1..87adee0 100644 --- a/lib/include/descriptors/nit.h +++ b/lib/include/descriptors/nit.h @@ -69,7 +69,7 @@ struct dvb_table_nit { #define dvb_nit_transport_foreach( tran, nit ) \ - for( struct dvb_table_nit_transport *tran = nit->transport; tran; tran = tran->next ) \ + for (struct dvb_table_nit_transport *tran = nit->transport; tran; tran = tran->next) \ struct dvb_v5_fe_parms; diff --git a/lib/include/dvb-file.h b/lib/include/dvb-file.h index e38fe85..cdbd18c 100644 --- a/lib/include/dvb-file.h +++ b/lib/include/dvb-file.h @@ -129,9 +129,6 @@ struct dvb_file *read_dvb_file(const char *fname); int write_dvb_file(const char *fname, struct dvb_file *dvb_file); -char *dvb_vchannel(struct dvb_v5_descriptors *dvb_desc, - int service); - int store_dvb_channel(struct dvb_file **dvb_file, struct dvb_v5_fe_parms *parms, struct dvb_v5_descriptors *dvb_desc, diff --git a/lib/include/dvb-scan-table-handler.h b/lib/include/dvb-scan-table-handler.h index cadf03b..265fb6d 100644 --- a/lib/include/dvb-scan-table-handler.h +++ b/lib/include/dvb-scan-table-handler.h @@ -58,11 +58,6 @@ struct transport_table { uint16_t tr_id; }; -struct lcn_table { - uint16_t service_id; - uint16_t lcn; -}; - struct nit_table { uint16_t network_id; unsigned char version; @@ -109,23 +104,6 @@ struct nit_table { unsigned lcn_len; }; -struct service_table { - uint16_t service_id; - char running; - char scrambled; - unsigned char type; - char *service_name, *service_alias; - char *provider_name, *provider_alias; -}; - -struct sdt_table { - unsigned char version; - uint16_t ts_id; - struct service_table *service_table; - unsigned service_table_len; -}; - - struct dvb_v5_descriptors_program { struct dvb_table_pat_program *pat_pgm; struct dvb_table_pmt *pmt; @@ -136,7 +114,6 @@ struct dvb_v5_descriptors { uint32_t delivery_system; struct nit_table nit_table; - struct sdt_table sdt_table; /* New data */ diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c index fe715d5..38334b5 100644 --- a/lib/libdvbv5/dvb-file.c +++ b/lib/libdvbv5/dvb-file.c @@ -28,6 +28,8 @@ #include "dvb-scan.h" #include "dvb-scan-table-handler.h" #include "dvb-log.h" +#include "descriptors/desc_ts_info.h" +#include "descriptors/desc_logical_channel.h" /* * Generic parse function for all formats each channel is contained into @@ -739,34 +741,43 @@ int write_dvb_file(const char *fname, struct dvb_file *dvb_file) return 0; }; -char *dvb_vchannel(struct dvb_v5_descriptors *dvb_scan_handler, - int service) +static char *dvb_vchannel(struct dvb_table_nit *nit, uint16_t service_id) { - struct service_table *service_table = &dvb_scan_handler->sdt_table.service_table[service]; - struct lcn_table *lcn = dvb_scan_handler->nit_table.lcn; int i; char *buf; - if (!lcn) { - if (!dvb_scan_handler->nit_table.virtual_channel) - return NULL; + dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) { + struct dvb_desc_logical_channel *d = (void *)desc; - asprintf(&buf, "%d.%d", dvb_scan_handler->nit_table.virtual_channel, - service); - return buf; + size_t len; + + len = d->length / sizeof(d->lcn); + + for (i = 0; i < len; i++) { + if (service_id == d->lcn[i].service_id) { + asprintf(&buf, "%d.%d", + d->lcn[i].logical_channel_number, i); + return buf; + } + } } - for (i = 0; i < dvb_scan_handler->nit_table.lcn_len; i++) { - if (lcn[i].service_id == service_table->service_id) { - asprintf(&buf, "%d.%d.%d", - dvb_scan_handler->nit_table.virtual_channel, - lcn[i].lcn, service); - return buf; + dvb_desc_find(struct dvb_desc_ts_info, desc, nit, TS_Information_descriptior) { + const struct dvb_desc_ts_info *d = (const void *) desc; + const struct dvb_desc_ts_info_transmission_type *t; + + t = &d->transmission_type; + + for (i = 0; i < t->num_of_service; i++) { + if (d->service_id[i] == service_id) { + asprintf(&buf, "%d.%d", + d->remote_control_key_id, i); + return buf; + } } } - asprintf(&buf, "%d.%d", dvb_scan_handler->nit_table.virtual_channel, - service); - return buf; + + return NULL; } static void handle_std_specific_parms(struct dvb_entry *entry, @@ -1222,4 +1233,3 @@ int write_file_format(const char *fname, return ret; } - -- 2.7.4