From: Jaroslav Kysela Date: Mon, 18 Jan 2016 16:37:28 +0000 (+0100) Subject: more wizard tuner / network creation work X-Git-Tag: v4.2.1~1156 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=366f419e271f221c0eec76a4110b0183ad716ec9;p=thirdparty%2Ftvheadend.git more wizard tuner / network creation work --- diff --git a/src/input.h b/src/input.h index 0decc89cb..6718f7793 100644 --- a/src/input.h +++ b/src/input.h @@ -90,7 +90,7 @@ struct tvh_input { void (*ti_get_streams) (tvh_input_t *, tvh_input_stream_list_t*); void (*ti_clear_stats) (tvh_input_t *); struct htsmsg *(*ti_wizard_get) (tvh_input_t *, const char *); - void (*ti_wizard_set) (tvh_input_t *, struct htsmsg *); + void (*ti_wizard_set) (tvh_input_t *, struct htsmsg *, const char *); }; /* diff --git a/src/input/mpegts.h b/src/input/mpegts.h index fbe1668e0..07e38ddd8 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -803,6 +803,8 @@ void mpegts_network_register_builder void mpegts_network_unregister_builder ( const idclass_t *idc ); +mpegts_network_builder_t *mpegts_network_builder_find ( const char *clazz ); + mpegts_network_t *mpegts_network_build ( const char *clazz, htsmsg_t *conf ); @@ -830,6 +832,10 @@ int mpegts_network_set_network_name ( mpegts_network_t *mn, const char *name ); void mpegts_network_scan ( mpegts_network_t *mn ); void mpegts_network_get_type_str( mpegts_network_t *mn, char *buf, size_t buflen ); +htsmsg_t * mpegts_network_wizard_get ( mpegts_input_t *mi, const idclass_t *idc, + mpegts_network_t *mn, const char *lang ); +void mpegts_network_wizard_create ( const char *clazz, htsmsg_t **nlist, const char *lang ); + mpegts_mux_t *mpegts_mux_create0 ( mpegts_mux_t *mm, const idclass_t *class, const char *uuid, mpegts_network_t *mn, uint16_t onid, uint16_t tsid, diff --git a/src/input/mpegts/iptv/iptv.c b/src/input/mpegts/iptv/iptv.c index 66fe4a593..05882a892 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -1001,6 +1001,37 @@ iptv_network_init ( void ) htsmsg_destroy(c); } +static mpegts_network_t * +iptv_input_wizard_network ( iptv_input_t *lfe ) +{ + return (mpegts_network_t *)LIST_FIRST(&lfe->mi_networks); +} + +static htsmsg_t * +iptv_input_wizard_get( tvh_input_t *ti, const char *lang ) +{ + iptv_input_t *mi = (iptv_input_t*)ti; + mpegts_network_t *mn; + const idclass_t *idc; + + mn = iptv_input_wizard_network(mi); + if (mn == NULL || (mn && mn->mn_wizard)) + idc = &iptv_auto_network_class; + return mpegts_network_wizard_get((mpegts_input_t *)mi, idc, mn, lang); +} + +static void +iptv_input_wizard_set( tvh_input_t *ti, htsmsg_t *conf, const char *lang ) +{ + iptv_input_t *mi = (iptv_input_t*)ti; + const char *ntype = htsmsg_get_str(conf, "mpegts_network_type"); + mpegts_network_t *mn; + + mn = iptv_input_wizard_network(mi); + if ((mn == NULL || mn->mn_wizard)) + mpegts_network_wizard_create(ntype, NULL, lang); +} + void iptv_init ( void ) { /* Register handlers */ @@ -1015,6 +1046,8 @@ void iptv_init ( void ) /* Init Input */ mpegts_input_create0((mpegts_input_t*)iptv_input, &iptv_input_class, NULL, NULL); + iptv_input->ti_wizard_get = iptv_input_wizard_get; + iptv_input->ti_wizard_set = iptv_input_wizard_set; iptv_input->mi_warm_mux = iptv_input_warm_mux; iptv_input->mi_start_mux = iptv_input_start_mux; iptv_input->mi_stop_mux = iptv_input_stop_mux; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index 4e8f4091f..ef0f90e9b 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -1720,6 +1720,60 @@ linuxdvb_frontend_tune1 * Creation/Config * *************************************************************************/ +static mpegts_network_t * +linuxdvb_frontend_wizard_network ( linuxdvb_frontend_t *lfe ) +{ + linuxdvb_satconf_ele_t *ele = NULL; + + if (lfe->lfe_satconf) { + ele = TAILQ_FIRST(&lfe->lfe_satconf->ls_elements); + if (ele && ele->lse_networks && ele->lse_networks->is_count > 0) + return (mpegts_network_t *)ele->lse_networks->is_array[0]; + } + return (mpegts_network_t *)LIST_FIRST(&lfe->mi_networks); +} + +static htsmsg_t * +linuxdvb_frontend_wizard_get( tvh_input_t *ti, const char *lang ) +{ + linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)ti; + mpegts_network_t *mn; + const idclass_t *idc = NULL; + + mn = linuxdvb_frontend_wizard_network(lfe); + if ((lfe->lfe_master == 0 && mn == NULL) || (mn && mn->mn_wizard)) + idc = dvb_network_class_by_fe_type(lfe->lfe_type); + return mpegts_network_wizard_get((mpegts_input_t *)lfe, idc, mn, lang); +} + +static void +linuxdvb_frontend_wizard_set( tvh_input_t *ti, htsmsg_t *conf, const char *lang ) +{ + linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)ti; + const char *ntype = htsmsg_get_str(conf, "mpegts_network_type"); + mpegts_network_t *mn; + + mn = linuxdvb_frontend_wizard_network(lfe); + if (ntype && (mn == NULL || mn->mn_wizard)) { + htsmsg_t *nlist; + mpegts_network_wizard_create(ntype, &nlist, lang); + if (lfe->lfe_satconf) { + htsmsg_t *conf = htsmsg_create_map(); + htsmsg_add_msg(conf, "networks", nlist); + linuxdvb_satconf_create(lfe, NULL, NULL, conf); + mn = linuxdvb_frontend_wizard_network(lfe); + htsmsg_destroy(conf); + } else { + mpegts_input_set_networks((mpegts_input_t *)lfe, nlist); + htsmsg_destroy(nlist); + } + if (mn) { + mn->mn_wizard = 1; + mn->mn_config_save(mn); + } + } +} + linuxdvb_frontend_t * linuxdvb_frontend_create ( htsmsg_t *conf, linuxdvb_adapter_t *la, int number, @@ -1815,6 +1869,8 @@ linuxdvb_frontend_create lfe->lfe_dvr_path = strdup(dvr_path); /* Input callbacks */ + lfe->ti_wizard_get = linuxdvb_frontend_wizard_get; + lfe->ti_wizard_set = linuxdvb_frontend_wizard_set; lfe->mi_is_enabled = linuxdvb_frontend_is_enabled; lfe->mi_start_mux = linuxdvb_frontend_start_mux; lfe->mi_stop_mux = linuxdvb_frontend_stop_mux; diff --git a/src/input/mpegts/mpegts_network.c b/src/input/mpegts/mpegts_network.c index 35b8475b9..6d22087e2 100644 --- a/src/input/mpegts/mpegts_network.c +++ b/src/input/mpegts/mpegts_network.c @@ -469,6 +469,59 @@ mpegts_network_get_type_str( mpegts_network_t *mn, char *buf, size_t buflen ) snprintf(buf, buflen, "%s", s); } +/****************************************************************************** + * Wizard + *****************************************************************************/ + +htsmsg_t * +mpegts_network_wizard_get + ( mpegts_input_t *mi, const idclass_t *idc, + mpegts_network_t *mn, const char *lang ) +{ + htsmsg_t *m = htsmsg_create_map(), *l, *e; + char ubuf[UUID_HEX_SIZE], buf[256]; + + if (mi && idc) { + mi->mi_display_name(mi, buf, sizeof(buf)); + htsmsg_add_str(m, "input_name", buf); + l = htsmsg_create_list(); + e = htsmsg_create_map(); + htsmsg_add_str(e, "key", idc->ic_class); + htsmsg_add_str(e, "val", idclass_get_caption(idc, lang)); + htsmsg_add_msg(l, NULL, e); + htsmsg_add_msg(m, "mpegts_network_types", l); + if (mn) + htsmsg_add_str(m, "mpegts_network", idnode_uuid_as_str(&mn->mn_id, ubuf)); + } + return m; +} + +void +mpegts_network_wizard_create + ( const char *clazz, htsmsg_t **nlist, const char *lang ) +{ + char buf[256]; + mpegts_network_t *mn; + mpegts_network_builder_t *mnb; + htsmsg_t *conf; + + if (nlist) + *nlist = NULL; + mnb = mpegts_network_builder_find(clazz); + if (mnb == NULL) + return; + + conf = htsmsg_create_map(); + htsmsg_add_str(conf, "networkname", idclass_get_caption(mnb->idc, lang)); + htsmsg_add_bool(conf, "wizard", 1); + mn = mnb->build(mnb->idc, conf); + htsmsg_destroy(conf); + if (mn && nlist) { + *nlist = htsmsg_create_list(); + htsmsg_add_str(*nlist, NULL, idnode_uuid_as_str(&mn->mn_id, buf)); + } +} + /****************************************************************************** * Network classes/creation *****************************************************************************/ @@ -500,18 +553,29 @@ mpegts_network_unregister_builder } } -mpegts_network_t * -mpegts_network_build - ( const char *clazz, htsmsg_t *conf ) +mpegts_network_builder_t * +mpegts_network_builder_find + ( const char *clazz ) { mpegts_network_builder_t *mnb; LIST_FOREACH(mnb, &mpegts_network_builders, link) { if (!strcmp(mnb->idc->ic_class, clazz)) - return mnb->build(mnb->idc, conf); + return mnb; } return NULL; } +mpegts_network_t * +mpegts_network_build + ( const char *clazz, htsmsg_t *conf ) +{ + mpegts_network_builder_t *mnb; + mnb = mpegts_network_builder_find(clazz); + if (mnb) + return mnb->build(mnb->idc, conf); + return NULL; +} + /****************************************************************************** * Search *****************************************************************************/ diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index a725825d8..fd7b86eb1 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -1762,52 +1762,44 @@ satip_frontend_default_positions ( satip_frontend_t *lfe ) return sd->sd_info.srcs; } +static mpegts_network_t * +satip_frontend_wizard_network ( satip_frontend_t *lfe ) +{ + satip_satconf_t *sfc; + + sfc = TAILQ_FIRST(&lfe->sf_satconf); + if (sfc && sfc->sfc_networks) + if (sfc->sfc_networks->is_count > 0) + return (mpegts_network_t *)sfc->sfc_networks->is_array[0]; + return NULL; +} + static htsmsg_t * satip_frontend_wizard_get( tvh_input_t *ti, const char *lang ) { satip_frontend_t *lfe = (satip_frontend_t*)ti; - htsmsg_t *m = htsmsg_create_map(), *l, *e; - satip_satconf_t *sfc; - const idclass_t *idc; - char ubuf[UUID_HEX_SIZE], buf[256]; + mpegts_network_t *mn; + const idclass_t *idc = NULL; - sfc = TAILQ_FIRST(&lfe->sf_satconf); - if (sfc == NULL || (sfc && sfc->sfc_wizard)) { - lfe->mi_display_name((mpegts_input_t*)lfe, buf, sizeof(buf)); - htsmsg_add_str(m, "input_name", buf); + mn = satip_frontend_wizard_network(lfe); + if (lfe->sf_master == 0 && (mn == NULL || (mn && mn->mn_wizard))) idc = dvb_network_class_by_fe_type(lfe->sf_type); - if (idc) { - l = htsmsg_create_list(); - e = htsmsg_create_map(); - htsmsg_add_str(e, "key", idc->ic_class); - htsmsg_add_str(e, "val", idclass_get_caption(idc, lang)); - htsmsg_add_msg(l, NULL, e); - htsmsg_add_msg(m, "mpegts_network_types", l); - } - if (sfc && sfc->sfc_wizard) { - lfe->mi_display_name((mpegts_input_t*)lfe, buf, sizeof(buf)); - htsmsg_add_str(m, "input_name", buf); - htsmsg_add_str(m, "mpegts_network", - idnode_uuid_as_str(sfc->sfc_networks->is_array[0], ubuf)); - } - } - return m; + return mpegts_network_wizard_get((mpegts_input_t *)lfe, idc, mn, lang); } static void -satip_frontend_wizard_set( tvh_input_t *ti, htsmsg_t *conf ) +satip_frontend_wizard_set( tvh_input_t *ti, htsmsg_t *conf, const char *lang ) { satip_frontend_t *lfe = (satip_frontend_t*)ti; - const char *uuid = htsmsg_get_str(conf, "mpegts_network_type"); - satip_satconf_t *sfc; + const char *ntype = htsmsg_get_str(conf, "mpegts_network_type"); + mpegts_network_t *mn; - sfc = TAILQ_FIRST(&lfe->sf_satconf); - if (uuid && (sfc == NULL || sfc->sfc_wizard)) { + mn = satip_frontend_wizard_network(lfe); + if (ntype && lfe->sf_master == 0 && (mn == NULL || mn->mn_wizard)) { htsmsg_t *conf = htsmsg_create_map(); - htsmsg_t *nlist = htsmsg_create_list(); - htsmsg_add_str(nlist, NULL, uuid); + htsmsg_t *nlist; + mpegts_network_wizard_create(ntype, &nlist, lang); htsmsg_add_msg(conf, "networks", nlist); - htsmsg_add_bool(conf, "wizard", 1); satip_satconf_create(lfe, conf, satip_frontend_default_positions(lfe)); htsmsg_destroy(conf); } diff --git a/src/input/mpegts/satip/satip_private.h b/src/input/mpegts/satip/satip_private.h index e0a349479..21fd4a440 100644 --- a/src/input/mpegts/satip/satip_private.h +++ b/src/input/mpegts/satip/satip_private.h @@ -177,7 +177,6 @@ struct satip_satconf /* * Config */ - int sfc_wizard; int sfc_enabled; int sfc_position; int sfc_priority; diff --git a/src/input/mpegts/satip/satip_satconf.c b/src/input/mpegts/satip/satip_satconf.c index e60f7e102..35254c09e 100644 --- a/src/input/mpegts/satip/satip_satconf.c +++ b/src/input/mpegts/satip/satip_satconf.c @@ -183,13 +183,6 @@ const idclass_t satip_satconf_class = .ic_get_title = satip_satconf_class_get_title, .ic_save = satip_satconf_class_save, .ic_properties = (const property_t[]) { - { - .type = PT_BOOL, - .id = "wizard", - .name = N_("Wizard"), - .off = offsetof(satip_satconf_t, sfc_wizard), - .opts = PO_NOUI, - }, { .type = PT_BOOL, .id = "enabled", diff --git a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c index f3aff35c0..3b5d10755 100644 --- a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c +++ b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c @@ -593,6 +593,42 @@ const idclass_t tvhdhomerun_frontend_atsc_c_class = } }; +static mpegts_network_t * +tvhdhomerun_frontend_wizard_network ( tvhdhomerun_frontend_t *hfe ) +{ + return (mpegts_network_t *)LIST_FIRST(&hfe->mi_networks); +} + +static htsmsg_t * +tvhdhomerun_frontend_wizard_get( tvh_input_t *ti, const char *lang ) +{ + tvhdhomerun_frontend_t *hfe = (tvhdhomerun_frontend_t*)ti; + mpegts_network_t *mn; + const idclass_t *idc = NULL; + + mn = tvhdhomerun_frontend_wizard_network(hfe); + if (mn == NULL || (mn && mn->mn_wizard)) + idc = dvb_network_class_by_fe_type(hfe->hf_type); + return mpegts_network_wizard_get((mpegts_input_t *)hfe, idc, mn, lang); +} + +static void +tvhdhomerun_frontend_wizard_set( tvh_input_t *ti, htsmsg_t *conf, const char *lang ) +{ + tvhdhomerun_frontend_t *hfe = (tvhdhomerun_frontend_t*)ti; + const char *ntype = htsmsg_get_str(conf, "mpegts_network_type"); + mpegts_network_t *mn; + + mn = tvhdhomerun_frontend_wizard_network(hfe); + if (ntype && (mn == NULL || mn->mn_wizard)) { + htsmsg_t *nlist = htsmsg_create_list(); + mpegts_network_wizard_create(ntype, &nlist, lang); + htsmsg_add_str(nlist, NULL, ntype); + mpegts_input_set_networks((mpegts_input_t *)hfe, nlist); + htsmsg_destroy(nlist); + } +} + void tvhdhomerun_frontend_delete ( tvhdhomerun_frontend_t *hfe ) { @@ -677,6 +713,8 @@ tvhdhomerun_frontend_create(tvhdhomerun_device_t *hd, struct hdhomerun_discover_ } /* Input callbacks */ + hfe->ti_wizard_get = tvhdhomerun_frontend_wizard_get; + hfe->ti_wizard_set = tvhdhomerun_frontend_wizard_set; hfe->mi_is_enabled = tvhdhomerun_frontend_is_enabled; hfe->mi_start_mux = tvhdhomerun_frontend_start_mux; hfe->mi_stop_mux = tvhdhomerun_frontend_stop_mux; diff --git a/src/wizard.c b/src/wizard.c index ef693ca9d..4529aced3 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -482,6 +482,7 @@ wizard_page_t *wizard_login(const char *lang) #define WIZARD_NETWORKS 6 typedef struct wizard_network { + char lang [64]; property_t props [WIZARD_NETWORKS * 3 + 10]; char tuner [WIZARD_NETWORKS][64]; char tunerid [WIZARD_NETWORKS][UUID_HEX_SIZE]; @@ -519,7 +520,7 @@ static void network_save(idnode_t *in) continue; m = htsmsg_create_map(); htsmsg_add_str(m, "mpegts_network_type", w->network_type[idx]); - ti->ti_wizard_set(ti, m); + ti->ti_wizard_set(ti, m, w->lang[0] ? w->lang : NULL); htsmsg_destroy(m); } for (mn = LIST_FIRST(&mpegts_network_all); mn != NULL; mn = mn_next) { @@ -646,6 +647,7 @@ wizard_page_t *wizard_network(const char *lang) ic->ic_properties = w->props; ic->ic_save = network_save; page->free = network_free; + snprintf(w->lang, sizeof(w->lang), "%s", lang ?: ""); for (idx = 0; idx < ARRAY_SIZE(props); idx++) w->props[idx] = props[idx];