use callbacks for transport start/stop

This commit is contained in:
Andreas Öman 2007-11-27 12:59:06 +00:00
parent fc7705205e
commit 3bb05551da
10 changed files with 31 additions and 58 deletions

5
dvb.c
View file

@ -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;

View file

@ -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;

View file

@ -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);

View 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);

View 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);
}

View 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;

View 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);
}

View file

@ -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 */

10
v4l.c
View file

@ -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;

4
v4l.h
View file

@ -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 */