diff --git a/src/epggrab.h b/src/epggrab.h index b42b83ae..61577ec0 100644 --- a/src/epggrab.h +++ b/src/epggrab.h @@ -212,7 +212,8 @@ struct epggrab_ota_map LIST_ENTRY(epggrab_ota_map) om_link; epggrab_module_ota_t *om_module; int om_complete; - int om_first; + uint8_t om_first; + uint8_t om_forced; uint64_t om_tune_count; RB_HEAD(,epggrab_ota_svc_link) om_svcs; ///< Muxes we carry data for }; diff --git a/src/epggrab/module/eit.c b/src/epggrab/module/eit.c index fcc86fe7..fca3da18 100644 --- a/src/epggrab/module/eit.c +++ b/src/epggrab/module/eit.c @@ -662,7 +662,7 @@ static void _eit_start int pid, opts = 0; /* Disabled */ - if (!m->enabled) return; + if (!m->enabled && !map->om_forced) return; /* Freeview (switch to EIT, ignore if explicitly enabled) */ // Note: do this as PID is the same diff --git a/src/epggrab/module/opentv.c b/src/epggrab/module/opentv.c index a83a4d81..74bf0dd9 100644 --- a/src/epggrab/module/opentv.c +++ b/src/epggrab/module/opentv.c @@ -552,7 +552,7 @@ static void _opentv_start }; /* Ignore */ - if (!m->enabled) return; + if (!m->enabled && !map->om_forced) return; if (mod->tsid != mm->mm_tsid) return; /* Install tables */ diff --git a/src/epggrab/otamux.c b/src/epggrab/otamux.c index 225fb5fc..116cc7cf 100644 --- a/src/epggrab/otamux.c +++ b/src/epggrab/otamux.c @@ -140,15 +140,27 @@ epggrab_ota_done ( epggrab_ota_mux_t *om, int reason ) } static void -epggrab_ota_start ( epggrab_ota_mux_t *om, int grace ) +epggrab_ota_start ( epggrab_ota_mux_t *om, mpegts_mux_t *mm, int grace, + const char *modname ) { + epggrab_module_t *m; epggrab_ota_map_t *map; TAILQ_INSERT_TAIL(&epggrab_ota_active, om, om_q_link); gtimer_arm(&om->om_timer, epggrab_ota_timeout_cb, om, epggrab_ota_timeout_get() + grace); + if (modname) { + LIST_FOREACH(m, &epggrab_modules, link) + if (!strcmp(m->id, modname)) { + epggrab_ota_register((epggrab_module_ota_t *)m, om, mm); + break; + } + } LIST_FOREACH(map, &om->om_modules, om_link) { map->om_first = 1; + map->om_forced = 0; + if (modname && !strcmp(modname, map->om_module->id)) + map->om_forced = 1; map->om_complete = 0; tvhdebug(map->om_module->id, "grab started"); } @@ -315,7 +327,20 @@ epggrab_ota_kick_cb ( void *p ) mpegts_network_t *net; int failed; } networks[64], *net; /* more than 64 networks? - you're a king */ - int i, r, networks_count = 0; + int i, r, networks_count = 0, epg_flag; + const char *modname; + static const char *modnames[] = { + [MM_EPG_DISABLE] = NULL, + [MM_EPG_ENABLE] = NULL, + [MM_EPG_FORCE] = NULL, + [MM_EPG_FORCE_EIT] = "eit", + [MM_EPG_FORCE_UK_FREESAT] = "uk_freesat", + [MM_EPG_FORCE_UK_FREEVIEW] = "uk_freeview", + [MM_EPG_FORCE_VIASAT_BALTIC] = "viasat_baltic", + [MM_EPG_FORCE_OPENTV_SKY_UK] = "opentv-skyuk", + [MM_EPG_FORCE_OPENTV_SKY_ITALIA] = "opentv-skyit", + [MM_EPG_FORCE_OPENTV_SKY_AUSAT] = "opentv-ausat", + }; lock_assert(&global_lock); @@ -347,7 +372,12 @@ next_one: net->failed = 0; } - if (mm->mm_is_epg(mm) <= 0) { + epg_flag = mm->mm_is_epg(mm); + if (ARRAY_SIZE(modnames) >= epg_flag) + epg_flag = MM_EPG_ENABLE; + modname = modnames[epg_flag]; + + if (epg_flag < 0 || epg_flag == MM_EPG_DISABLE) { #if TRACE_ENABLE char name[256]; mm->mm_display_name(mm, name, sizeof(name)); @@ -356,16 +386,18 @@ next_one: goto done; } - /* Check we have modules attached and enabled */ - LIST_FOREACH(map, &om->om_modules, om_link) { - if (map->om_module->tune(map, om, mm)) - break; - } - if (!map) { - char name[256]; - mm->mm_display_name(mm, name, sizeof(name)); - tvhdebug("epggrab", "no modules attached to %s, check again next time", name); - goto done; + if (epg_flag != MM_EPG_FORCE) { + /* Check we have modules attached and enabled */ + LIST_FOREACH(map, &om->om_modules, om_link) { + if (map->om_module->tune(map, om, mm)) + break; + } + if (!map) { + char name[256]; + mm->mm_display_name(mm, name, sizeof(name)); + tvhdebug("epggrab", "no modules attached to %s, check again next time", name); + goto done; + } } /* Subscribe to the mux */ @@ -377,7 +409,7 @@ next_one: first = om; } else { mpegts_mux_instance_t *mmi = mm->mm_active; - epggrab_ota_start(om, mpegts_input_grace(mmi->mmi_input, mm)); + epggrab_ota_start(om, mm, mpegts_input_grace(mmi->mmi_input, mm), modname); } done: diff --git a/src/input/mpegts.h b/src/input/mpegts.h index e1e0a02e..a5a635d1 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -299,6 +299,20 @@ typedef enum mpegts_mux_scan_result MM_SCAN_FAIL } mpegts_mux_scan_result_t; +enum mpegts_mux_epg_flag +{ + MM_EPG_DISABLE, + MM_EPG_ENABLE, + MM_EPG_FORCE, + MM_EPG_FORCE_EIT, + MM_EPG_FORCE_UK_FREESAT, + MM_EPG_FORCE_UK_FREEVIEW, + MM_EPG_FORCE_VIASAT_BALTIC, + MM_EPG_FORCE_OPENTV_SKY_UK, + MM_EPG_FORCE_OPENTV_SKY_ITALIA, + MM_EPG_FORCE_OPENTV_SKY_AUSAT, +}; + /* Multiplex */ struct mpegts_mux { diff --git a/src/input/mpegts/mpegts_mux.c b/src/input/mpegts/mpegts_mux.c index 4518313d..23228922 100644 --- a/src/input/mpegts/mpegts_mux.c +++ b/src/input/mpegts/mpegts_mux.c @@ -293,6 +293,24 @@ mpegts_mux_class_enabled_notify ( void *p ) } } +static htsmsg_t * +mpegts_mux_epg_list ( void *o ) +{ + static const struct strtab tab[] = { + { "Disable", MM_EPG_DISABLE }, + { "Enable (auto)", MM_EPG_ENABLE }, + { "Force (auto)", MM_EPG_FORCE }, + { "Force EIT", MM_EPG_FORCE_EIT }, + { "Force UK Freesat", MM_EPG_FORCE_UK_FREESAT }, + { "Force UK Freeview", MM_EPG_FORCE_UK_FREEVIEW }, + { "Force Viasat Baltic", MM_EPG_FORCE_VIASAT_BALTIC }, + { "Force OpenTV Sky UK", MM_EPG_FORCE_OPENTV_SKY_UK }, + { "Force OpenTV Sky Italia", MM_EPG_FORCE_OPENTV_SKY_ITALIA }, + { "Force OpenTV Sky Ausat", MM_EPG_FORCE_OPENTV_SKY_AUSAT }, + }; + return strtab2htsmsg(tab); +} + const idclass_t mpegts_mux_class = { .ic_class = "mpegts_mux", @@ -311,11 +329,12 @@ const idclass_t mpegts_mux_class = .notify = mpegts_mux_class_enabled_notify, }, { - .type = PT_BOOL, + .type = PT_INT, .id = "epg", - .name = "EPG", + .name = "EPG Scan", .off = offsetof(mpegts_mux_t, mm_epg), - .def.i = 1, + .def.i = MM_EPG_ENABLE, + .list = mpegts_mux_epg_list, }, { .type = PT_STR,