diff --git a/dvb.c b/dvb.c index 0cd24a6a..40bc5ef9 100644 --- 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; diff --git a/dvb_dvr.c b/dvb_dvr.c index 712cca53..edf4dca8 100644 --- 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; diff --git a/dvb_dvr.h b/dvb_dvr.h index db1a1baa..ec005264 100644 --- 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); diff --git a/dvb_muxconfig.c b/dvb_muxconfig.c index 60f54362..5a988f88 100644 --- a/dvb_muxconfig.c +++ b/dvb_muxconfig.c @@ -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); diff --git a/iptv_input.c b/iptv_input.c index 8c7bd855..a99b724b 100644 --- a/iptv_input.c +++ b/iptv_input.c @@ -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); } diff --git a/iptv_input.h b/iptv_input.h index 2a86706f..b9918516 100644 --- a/iptv_input.h +++ b/iptv_input.h @@ -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; diff --git a/transports.c b/transports.c index ea5b470f..20cdbee5 100644 --- a/transports.c +++ b/transports.c @@ -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); } diff --git a/tvhead.h b/tvhead.h index 573e694b..0ddb2657 100644 --- 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 a061bd6b..0c272619 100644 --- 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 2d6b4647..6986940e 100644 --- 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 */