Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more wizard tuner / network creation work
  • Loading branch information
perexg committed Jan 19, 2016
1 parent 3f70394 commit 366f419
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/input.h
Expand Up @@ -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 *);
};

/*
Expand Down
6 changes: 6 additions & 0 deletions src/input/mpegts.h
Expand Up @@ -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 );

Expand Down Expand Up @@ -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,
Expand Down
33 changes: 33 additions & 0 deletions src/input/mpegts/iptv/iptv.c
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down
56 changes: 56 additions & 0 deletions src/input/mpegts/linuxdvb/linuxdvb_frontend.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
72 changes: 68 additions & 4 deletions src/input/mpegts/mpegts_network.c
Expand Up @@ -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
*****************************************************************************/
Expand Down Expand Up @@ -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
*****************************************************************************/
Expand Down
56 changes: 24 additions & 32 deletions src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/input/mpegts/satip/satip_private.h
Expand Up @@ -177,7 +177,6 @@ struct satip_satconf
/*
* Config
*/
int sfc_wizard;
int sfc_enabled;
int sfc_position;
int sfc_priority;
Expand Down
7 changes: 0 additions & 7 deletions src/input/mpegts/satip/satip_satconf.c
Expand Up @@ -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",
Expand Down
38 changes: 38 additions & 0 deletions src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 366f419

Please sign in to comment.