epg: add tune callback for ota modules (fixes opentv)

This commit is contained in:
Jaroslav Kysela 2014-06-28 15:34:33 +02:00
parent 93c7403f07
commit 680b5fb202
7 changed files with 52 additions and 36 deletions

View file

@ -221,7 +221,8 @@ struct epggrab_module_ota
/* Transponder tuning */
void (*start) ( epggrab_module_ota_t *m, struct mpegts_mux *mm );
void (*done) ( epggrab_module_ota_t *m );
void (*done) ( epggrab_module_ota_t *m );
int (*tune) ( epggrab_module_ota_t *m, struct mpegts_mux *mm );
};
/*

View file

@ -448,10 +448,7 @@ epggrab_module_ext_t *epggrab_module_ext_create
epggrab_module_ota_t *epggrab_module_ota_create
( epggrab_module_ota_t *skel,
const char *id, const char *name, int priority,
void (*start) (epggrab_module_ota_t*m,
struct mpegts_mux *dm),
int (*enable) (void *m, uint8_t e ),
void (*done) (epggrab_module_ota_t *m),
epggrab_ota_module_ops_t *ops,
epggrab_channel_tree_t *channels )
{
if (!skel) skel = calloc(1, sizeof(epggrab_module_ota_t));
@ -461,9 +458,10 @@ epggrab_module_ota_t *epggrab_module_ota_create
/* Setup */
skel->type = EPGGRAB_OTA;
skel->enable = enable;
skel->start = start;
skel->done = done;
skel->enable = ops->enable;
skel->start = ops->start;
skel->done = ops->done;
skel->tune = ops->tune;
//TAILQ_INIT(&skel->muxes);
return skel;

View file

@ -676,14 +676,29 @@ static void _eit_start
tvhlog(LOG_DEBUG, m->id, "installed table handlers");
}
static int _eit_tune
( epggrab_module_ota_t *m, mpegts_mux_t *mm )
{
mpegts_service_t *s;
lock_assert(&global_lock);
LIST_FOREACH(s, &mm->mm_services, s_dvb_mux_link)
if (LIST_FIRST(&s->s_channels))
break;
return s ? 1 : 0;
}
void eit_init ( void )
{
epggrab_module_ota_create(NULL, "eit", "EIT: DVB Grabber", 1,
_eit_start, NULL, NULL, NULL);
epggrab_module_ota_create(NULL, "uk_freesat", "UK: Freesat", 5,
_eit_start, NULL, NULL, NULL);
epggrab_module_ota_create(NULL, "uk_freeview", "UK: Freeview", 5,
_eit_start, NULL, NULL, NULL);
epggrab_module_ota_create(NULL, "viasat_baltic", "VIASAT: Baltic", 5,
_eit_start, NULL, NULL, NULL);
static epggrab_ota_module_ops_t ops = {
.start = _eit_start,
.tune = _eit_tune,
};
epggrab_module_ota_create(NULL, "eit", "EIT: DVB Grabber", 1, &ops, NULL);
epggrab_module_ota_create(NULL, "uk_freesat", "UK: Freesat", 5, &ops, NULL);
epggrab_module_ota_create(NULL, "uk_freeview", "UK: Freeview", 5, &ops, NULL);
epggrab_module_ota_create(NULL, "viasat_baltic", "VIASAT: Baltic", 5, &ops, NULL);
}

View file

@ -692,6 +692,11 @@ static void _opentv_done( epggrab_module_ota_t *m )
free(mod->summary);
}
static int _opentv_tune ( epggrab_module_ota_t *m, mpegts_mux_t *mm )
{
return 1;
}
static int _opentv_prov_load_one ( const char *id, htsmsg_t *m )
{
char ibuf[100], nbuf[1000];
@ -701,6 +706,11 @@ static int _opentv_prov_load_one ( const char *id, htsmsg_t *m )
opentv_dict_t *dict;
opentv_genre_t *genre;
opentv_module_t *mod;
static epggrab_ota_module_ops_t ops = {
.start = _opentv_start,
.done = _opentv_done,
.tune = _opentv_tune,
};
/* Check config */
if (!(name = htsmsg_get_str(m, "name"))) return -1;
@ -730,9 +740,7 @@ static int _opentv_prov_load_one ( const char *id, htsmsg_t *m )
sprintf(nbuf, "OpenTV: %s", name);
mod = (opentv_module_t*)
epggrab_module_ota_create(calloc(1, sizeof(opentv_module_t)),
ibuf, nbuf, 2,
_opentv_start, NULL,
_opentv_done, NULL);
ibuf, nbuf, 2, &ops, NULL);
/* Add provider details */
mod->dict = dict;

View file

@ -325,7 +325,8 @@ next_one:
/* Check we have modules attached and enabled */
LIST_FOREACH(map, &om->om_modules, om_link) {
if (map->om_module->enabled)
if (map->om_module->enabled &&
map->om_module->tune && map->om_module->tune(map->om_module, mm))
break;
}
if (!map) {

View file

@ -85,13 +85,17 @@ epggrab_module_ext_t *epggrab_module_ext_create
* OTA module routines
* *************************************************************************/
typedef struct epggrab_ota_module_ops {
void (*start) (epggrab_module_ota_t *m, struct mpegts_mux *mm);
int (*enable) (void *m, uint8_t e );
void (*done) (epggrab_module_ota_t*m);
int (*tune) (epggrab_module_ota_t *m, struct mpegts_mux *mm);
} epggrab_ota_module_ops_t;
epggrab_module_ota_t *epggrab_module_ota_create
( epggrab_module_ota_t *skel,
const char *id, const char *name, int priority,
void (*start) (epggrab_module_ota_t*m,
struct mpegts_mux *mm),
int (*enable) (void *m, uint8_t e ),
void (*done) (epggrab_module_ota_t*m),
epggrab_ota_module_ops_t *ops,
epggrab_channel_tree_t *channels );
/* **************************************************************************

View file

@ -449,18 +449,7 @@ mpegts_mux_is_enabled ( mpegts_mux_t *mm )
static int
mpegts_mux_is_epg ( mpegts_mux_t *mm )
{
mpegts_service_t *s;
lock_assert(&global_lock);
if (!mm->mm_epg)
return 0;
LIST_FOREACH(s, &mm->mm_services, s_dvb_mux_link)
if (LIST_FIRST(&s->s_channels))
break;
return s ? 1 : 0;
return mm->mm_epg;
}
static void