]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
use callbacks for transport start/stop
authorAndreas Öman <andreas@lonelycoder.com>
Tue, 27 Nov 2007 12:59:06 +0000 (12:59 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Tue, 27 Nov 2007 12:59:06 +0000 (12:59 +0000)
dvb.c
dvb_dvr.c
dvb_dvr.h
dvb_muxconfig.c
iptv_input.c
iptv_input.h
transports.c
tvhead.h
v4l.c
v4l.h

diff --git a/dvb.c b/dvb.c
index 0cd24a6a635ea81ab9853c7823c4df3dc61ee661..40bc5ef9180f599a704196a6126c98ea2b11c378 100644 (file)
--- a/dvb.c
+++ b/dvb.c
@@ -375,8 +375,11 @@ dvb_find_transport(th_dvb_mux_instance_t *tdmi, uint16_t nid, uint16_t tid,
   t->tht_dvb_transport_id = tid;
   t->tht_dvb_service_id   = sid;
 
-  t->tht_dvb_mux = tdm;
   t->tht_type = TRANSPORT_DVB;
+  t->tht_start_feed = dvb_start_feed;
+  t->tht_stop_feed  = dvb_stop_feed;
+  t->tht_dvb_mux = tdm;
+
   t->tht_prio = 50;
 
  
index 712cca53133e8b9525059b4ea00a3d0b920c94fb..edf4dca83769ee7aea8b5cab49da90d31d08b2a9 100644 (file)
--- a/dvb_dvr.c
+++ b/dvb_dvr.c
@@ -137,7 +137,7 @@ dvb_stop_feed(th_transport_t *t)
  *
  */
 int
-dvb_start_feed(th_transport_t *t, unsigned int weight)
+dvb_start_feed(th_transport_t *t, unsigned int weight, int status)
 {
   th_dvb_adapter_t *tda;
   struct dmx_pes_filter_params dmx_param;
index db1a1baaf95b339a91b20471e1759d6414931b18..ec0052643226ca7d321ccdff7e3dccf81c00dff1 100644 (file)
--- a/dvb_dvr.h
+++ b/dvb_dvr.h
@@ -21,7 +21,7 @@
 
 int dvb_dvr_init(th_dvb_adapter_t *tda);
 
-int dvb_start_feed(th_transport_t *t, unsigned int weight);
+int dvb_start_feed(struct th_transport *t, unsigned int weight, int status);
 
 void dvb_stop_feed(th_transport_t *t);
 
index 60f54362efbc38d1dc2d2cc5b9e8c091c64322c5..5a988f88a46838d35cfe1d11503b2751bbe68ce9 100644 (file)
@@ -27,6 +27,7 @@
 #include "tvhead.h"
 #include "channels.h"
 #include "dvb.h"
+#include "dvb_dvr.h"
 #include "dvb_muxconfig.h"
 #include "strtab.h"
 #include "transports.h"
@@ -277,6 +278,8 @@ dvb_configure_transport(th_transport_t *t, const char *muxname,
     return -1;
 
   t->tht_type = TRANSPORT_DVB;
+  t->tht_start_feed = dvb_start_feed;
+  t->tht_stop_feed  = dvb_stop_feed;
   t->tht_dvb_mux = tdm;
   t->tht_name = strdup(tdm->tdm_title);
 
index 8c7bd855aaf3d2c656b44b113b3e6358cdffbbb2..a99b724bd8c6c53cdc2babaf1f1f7cc8b5aee158 100644 (file)
@@ -68,8 +68,8 @@ iptv_fd_callback(int events, void *opaque, int fd)
   }
 }
 
-int
-iptv_start_feed(th_transport_t *t, int status)
+static int
+iptv_start_feed(th_transport_t *t, unsigned int weight, int status)
 {
   int fd;
   struct ip_mreqn m;
@@ -116,18 +116,17 @@ iptv_start_feed(th_transport_t *t, int status)
   return 0;
 }
 
-int
+static void
 iptv_stop_feed(th_transport_t *t)
 {
   if(t->tht_status == TRANSPORT_IDLE)
-    return 0;
+    return;
 
   t->tht_status = TRANSPORT_IDLE;
   dispatch_delfd(t->tht_iptv_dispatch_handle);
   close(t->tht_iptv_fd);
 
   syslog(LOG_ERR, "iptv: \"%s\" left group", t->tht_name);
-  return 0;
 }
 
 
@@ -183,7 +182,9 @@ iptv_configure_transport(th_transport_t *t, const char *iptv_type,
     return -1;
 
   t->tht_type = TRANSPORT_IPTV;
-  
+  t->tht_start_feed = iptv_start_feed;
+  t->tht_stop_feed  = iptv_stop_feed;
+
   if((s = config_get_str_sub(head, "group-address", NULL)) == NULL)
     return -1;
   t->tht_iptv_group_addr.s_addr = inet_addr(s);
@@ -241,7 +242,7 @@ static void
 iptv_probe_transport(th_transport_t *t)
 {
   syslog(LOG_INFO, "iptv: Probing transport %s", t->tht_name);
-  iptv_start_feed(t, TRANSPORT_PROBING);
+  iptv_start_feed(t, 1, TRANSPORT_PROBING);
 }
 
 
index 2a86706f82f993d32e2a5dc3b1176439044b4429..b9918516154d2f7e9bc4a1c8fa92be5097d13b7b 100644 (file)
@@ -23,10 +23,6 @@ int iptv_configure_transport(th_transport_t *t, const char *muxname,
                             struct config_head *head, 
                             const char *channel_name);
 
-int iptv_start_feed(th_transport_t *t, int status);
-
-int iptv_stop_feed(th_transport_t *t);
-
 extern struct th_transport_list iptv_probing_transports;
 extern struct th_transport_list iptv_stale_transports;
 
index ea5b470f4bae13b75662be4c8e22af64e3bb6b27..20cdbee54e41e4ab793cce5bacd1ff8e72e4d207 100644 (file)
@@ -66,25 +66,7 @@ transport_purge(th_transport_t *t)
   if(LIST_FIRST(&t->tht_subscriptions))
     return;
 
-  switch(t->tht_type) {
-#ifdef ENABLE_INPUT_DVB
-  case TRANSPORT_DVB:
-    dvb_stop_feed(t);
-    break;
-#endif
-#ifdef ENABLE_INPUT_IPTV
-  case TRANSPORT_IPTV:
-    iptv_stop_feed(t);
-    break;
-#endif
-#ifdef ENABLE_INPUT_V4L
-  case TRANSPORT_V4L:
-    v4l_stop_feed(t);
-    break;
-#endif
-  default:
-    break;
-  }
+  t->tht_stop_feed(t);
 
   t->tht_tt_commercial_advice = COMMERCIAL_UNKNOWN;
  
@@ -186,24 +168,7 @@ transport_start(th_transport_t *t, unsigned int weight)
     }
   }
   
-
-  switch(t->tht_type) {
-#ifdef ENABLE_INPUT_DVB
-  case TRANSPORT_DVB:
-    return dvb_start_feed(t, weight);
-#endif
-#ifdef ENABLE_INPUT_IPTV
-  case TRANSPORT_IPTV:
-    return iptv_start_feed(t, TRANSPORT_RUNNING);
-#endif
-#ifdef ENABLE_INPUT_V4L
-  case TRANSPORT_V4L:
-    return v4l_start_feed(t, weight);
-#endif
-  default:
-    return 1;
-  }
-  return 1;
+  return t->tht_start_feed(t, weight, TRANSPORT_RUNNING);
 }
 
 
index 573e694b0b3faea0d4f1fbafa6e648bf9eae531a..0ddb2657f745101ed6dc1b09001d065a4afcac3e 100644 (file)
--- a/tvhead.h
+++ b/tvhead.h
@@ -356,6 +356,11 @@ typedef struct th_transport {
 
   LIST_HEAD(, th_subscription) tht_subscriptions;
 
+  int (*tht_start_feed)(struct th_transport *t, unsigned int weight,
+                       int status);
+
+  void (*tht_stop_feed)(struct th_transport *t);
+
 
   struct th_muxer_list tht_muxers; /* muxers */
 
diff --git a/v4l.c b/v4l.c
index a061bd6bee6d2db69c334bdb590c8e98c2ec4df9..0c2726191eb7ac3d37ea51b1f54cb6f681387a6b 100644 (file)
--- a/v4l.c
+++ b/v4l.c
@@ -54,7 +54,9 @@ static int v4l_setfreq(th_v4l_adapter_t *tva, int frequency);
 static void v4l_add_adapter(const char *path);
 
 
+static void v4l_stop_feed(th_transport_t *t);
 
+static int v4l_start_feed(th_transport_t *t, unsigned int weight, int status);
 
 /* 
  *
@@ -81,6 +83,8 @@ v4l_configure_transport(th_transport_t *t, const char *muxname,
     return -1;
 
   t->tht_type = TRANSPORT_V4L;
+  t->tht_start_feed = v4l_start_feed;
+  t->tht_stop_feed  = v4l_stop_feed;
 
   t->tht_v4l_frequency = 
     atoi(config_get_str_sub(&ce->ce_sub, "frequency", "0"));
@@ -187,7 +191,7 @@ v4l_stop(th_v4l_adapter_t *tva)
 /* 
  *
  */
-void
+static void
 v4l_stop_feed(th_transport_t *t)
 {
   th_v4l_adapter_t *tva = t->tht_v4l_adapter;
@@ -225,8 +229,8 @@ v4l_adapter_clean(th_v4l_adapter_t *tva)
 /* 
  *
  */
-int 
-v4l_start_feed(th_transport_t *t, unsigned int weight)
+static int 
+v4l_start_feed(th_transport_t *t, unsigned int weight, int status)
 {
   th_v4l_adapter_t *tva, *cand = NULL;
   int w, fd;
diff --git a/v4l.h b/v4l.h
index 2d6b4647f07becee91f1558bea91790aa5b039cd..6986940e05d386a828de77820574eb0107bc747f 100644 (file)
--- a/v4l.h
+++ b/v4l.h
@@ -26,8 +26,4 @@ void v4l_init(void);
 int v4l_configure_transport(th_transport_t *t, const char *muxname,
                            const char *channel_name);
 
-int v4l_start_feed(th_transport_t *t, unsigned int weight);
-
-void v4l_stop_feed(th_transport_t *t);
-
 #endif /* V4L_H */