]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Added some new transport/multiplex search routines and used them in epg modules.
authorAdam Sutton <dev@adamsutton.me.uk>
Mon, 17 Sep 2012 15:13:27 +0000 (16:13 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Mon, 15 Oct 2012 10:54:36 +0000 (11:54 +0100)
src/dvb/dvb.h
src/dvb/dvb_multiplex.c
src/dvb/dvb_transport.c
src/epggrab/module/eit.c
src/epggrab/module/opentv.c

index 25e2ea2a1b8fae143e30645fc1f37ff6e0d75f7c..571431b59e0ccd0a9c0fedb4a4c02a39018b409e 100644 (file)
@@ -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);
index 0c4c1273bc0ac95d1aed2c75a2b0994d560d827a..3b13f15e3e1d28035e8cec1457854bab018a73cb 100644 (file)
@@ -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;
+}
index 7106d1332a002a9c0cdbfc4303f4cb597322fd3c..8552780d634527a8b2b645f8cb2d3fde92648463 100644 (file)
@@ -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
index 54925cccf8cd3c9c4639b9c52d500ef5c0e73ba9..3da8da57633fb354056897d808ef8ce1f856e6a5 100644 (file)
@@ -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)
index 7a1fbba6d94acf33ccade6fc77a8f3c5d02af568..e3d8c1c2c569036026beb87ed0414d7e7bac20fa 100644 (file)
@@ -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) {