From 4b5ee3585ce243dee0aba06691b768e81996ac43 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Mon, 17 Sep 2012 16:13:27 +0100 Subject: [PATCH] Added some new transport/multiplex search routines and used them in epg modules. --- src/dvb/dvb.h | 9 +++++++++ src/dvb/dvb_multiplex.c | 21 +++++++++++++++++++++ src/dvb/dvb_transport.c | 35 +++++++++++++++++++++++++++++++++++ src/epggrab/module/eit.c | 14 ++++---------- src/epggrab/module/opentv.c | 21 ++------------------- 5 files changed, 71 insertions(+), 29 deletions(-) diff --git a/src/dvb/dvb.h b/src/dvb/dvb.h index 25e2ea2a..571431b5 100644 --- a/src/dvb/dvb.h +++ b/src/dvb/dvb.h @@ -399,6 +399,10 @@ int dvb_mux_copy(th_dvb_adapter_t *dst, th_dvb_mux_instance_t *tdmi_src, void dvb_mux_add_to_scan_queue (th_dvb_mux_instance_t *tdmi); +th_dvb_mux_instance_t *dvb_mux_find + (th_dvb_adapter_t *tda, const char *netname, uint16_t onid, uint16_t tsid, + int enabled ); + /** * DVB Transport (aka DVB service) */ @@ -412,6 +416,11 @@ struct service *dvb_transport_find2(th_dvb_mux_instance_t *tdmi, uint16_t sid, int pmt_pid, const char *identifier, int *save); +struct service *dvb_transport_find3 + (th_dvb_adapter_t *tda, th_dvb_mux_instance_t *tdmi, + const char *netname, uint16_t onid, uint16_t tsid, uint16_t sid, + int enabled, int epgprimary); + void dvb_transport_notify(struct service *t); void dvb_transport_notify_by_adapter(th_dvb_adapter_t *tda); diff --git a/src/dvb/dvb_multiplex.c b/src/dvb/dvb_multiplex.c index 0c4c1273..3b13f15e 100644 --- a/src/dvb/dvb_multiplex.c +++ b/src/dvb/dvb_multiplex.c @@ -1262,3 +1262,24 @@ void dvb_mux_add_to_scan_queue ( th_dvb_mux_instance_t *tdmi ) tdmi->tdmi_scan_queue = &tda->tda_scan_queues[ti]; TAILQ_INSERT_TAIL(tdmi->tdmi_scan_queue, tdmi, tdmi_scan_link); } + +th_dvb_mux_instance_t *dvb_mux_find + ( th_dvb_adapter_t *tda, const char *netname, uint16_t onid, uint16_t tsid, + int enabled ) +{ + th_dvb_mux_instance_t *tdmi; + if (tda) { + LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link) { + if (enabled && !tdmi->tdmi_enabled) continue; + if (onid && onid != tdmi->tdmi_network_id) continue; + if (tsid && tsid != tdmi->tdmi_transport_stream_id) continue; + if (netname && strcmp(netname, tdmi->tdmi_network ?: "")) continue; + return tdmi; + } + } else { + TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) + if ((tdmi = dvb_mux_find(tda, netname, onid, tsid, enabled))) + return tdmi; + } + return NULL; +} diff --git a/src/dvb/dvb_transport.c b/src/dvb/dvb_transport.c index 7106d133..8552780d 100644 --- a/src/dvb/dvb_transport.c +++ b/src/dvb/dvb_transport.c @@ -383,6 +383,41 @@ dvb_grace_period(service_t *t) return 10; } +/* + * Find transport based on the DVB identification + */ +service_t * +dvb_transport_find3 + (th_dvb_adapter_t *tda, th_dvb_mux_instance_t *tdmi, + const char *netname, uint16_t onid, uint16_t tsid, uint16_t sid, + int enabled, int epgprimary) +{ + service_t *svc; + if (tdmi) { + LIST_FOREACH(svc, &tdmi->tdmi_transports, s_group_link) { + if (enabled && !svc->s_enabled) continue; + if (epgprimary && !service_is_primary_epg(svc)) continue; + if (sid == svc->s_dvb_service_id) return svc; + } + } else if (tda) { + LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link) { + if (enabled && !tdmi->tdmi_enabled) continue; + if (onid && onid != tdmi->tdmi_network_id) continue; + if (tsid && tsid != tdmi->tdmi_transport_stream_id) continue; + if (netname && strcmp(netname, tdmi->tdmi_network ?: "")) continue; + if ((svc = dvb_transport_find3(tda, tdmi, NULL, 0, 0, sid, + enabled, epgprimary))) + return svc; + } + } else { + TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) + if ((svc = dvb_transport_find3(tda, NULL, netname, onid, tsid, + sid, enabled, epgprimary))) + return svc; + } + return NULL; +} + /** * Find a transport based on 'serviceid' on the given mux diff --git a/src/epggrab/module/eit.c b/src/epggrab/module/eit.c index 54925ccc..3da8da57 100644 --- a/src/epggrab/module/eit.c +++ b/src/epggrab/module/eit.c @@ -713,11 +713,8 @@ static int _eit_callback // Note: tableid=0x4f,0x60-0x6f is other TS // so must find the tdmi if(tableid == 0x4f || tableid >= 0x60) { - tda = tdmi->tdmi_adapter; - LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link) - if(tdmi->tdmi_transport_stream_id == tsid && - tdmi->tdmi_network_id == onid) - break; + tda = tdmi->tdmi_adapter; + tdmi = dvb_mux_find(tda, NULL, onid, tsid, 1); } else { if (tdmi->tdmi_transport_stream_id != tsid || tdmi->tdmi_network_id != onid) { @@ -733,11 +730,8 @@ static int _eit_callback if(!tdmi) goto done; /* Get service */ - svc = dvb_transport_find(tdmi, sid, 0, NULL); - if (!svc || !svc->s_enabled || !svc->s_ch) goto done; - - /* Ignore (not primary EPG service) */ - if (!service_is_primary_epg(svc)) goto done; + svc = dvb_transport_find3(NULL, tdmi, NULL, 0, 0, sid, 1, 1); + if (!svc || !svc->s_ch) goto done; /* Register as interesting */ if (tableid < 0x50) diff --git a/src/epggrab/module/opentv.c b/src/epggrab/module/opentv.c index 7a1fbba6..e3d8c1c2 100644 --- a/src/epggrab/module/opentv.c +++ b/src/epggrab/module/opentv.c @@ -189,23 +189,6 @@ static epggrab_channel_t *_opentv_find_epggrab_channel (epggrab_module_t*)mod); } -static service_t *_opentv_find_service ( int onid, int tsid, int sid ) -{ - th_dvb_adapter_t *tda; - th_dvb_mux_instance_t *tdmi; - service_t *t = NULL; - TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) { - LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link) { - if (tdmi->tdmi_transport_stream_id != tsid) continue; - if (tdmi->tdmi_network_id != onid) continue; - LIST_FOREACH(t, &tdmi->tdmi_transports, s_group_link) { - if (t->s_dvb_service_id == sid) return t; - } - } - } - return NULL; -} - /* ************************************************************************ * OpenTV event processing * ***********************************************************************/ @@ -442,8 +425,8 @@ static void _opentv_parse_channels cnum = ((int)buf[i+5] << 8) | buf[i+6]; /* Find the service */ - svc = _opentv_find_service(onid, tsid, sid); - if (svc && svc->s_ch && service_is_primary_epg(svc)) { + svc = dvb_transport_find3(NULL, NULL, NULL, onid, tsid, sid, 1, 1); + if (svc && svc->s_ch) { ec =_opentv_find_epggrab_channel(mod, cid, 1, &save); ecl = LIST_FIRST(&ec->channels); if (!ecl) {