Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dvb network discovery: add possibility to select 'new only muxes' and…
… 'allow all changes in mux' behaviour
  • Loading branch information
perexg committed May 30, 2016
1 parent ccf91f3 commit 82edc90
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
6 changes: 6 additions & 0 deletions src/input/mpegts.h
Expand Up @@ -283,6 +283,12 @@ struct mpegts_table_feed {
* Logical network
* *************************************************************************/

typedef enum {
MN_DISCOVERY_DISABLE = 0,
MN_DISCOVERY_NEW = 1,
MN_DISCOVERY_CHANGE = 2
} mpegts_discovery_t;

/* Network/Input linkage */
struct mpegts_network_link
{
Expand Down
18 changes: 15 additions & 3 deletions src/input/mpegts/mpegts_network.c
Expand Up @@ -129,6 +129,17 @@ mpegts_network_class_idlescan_notify ( void *p, const char *lang )
}
}

static htsmsg_t *
mpegts_network_discovery_enum ( void *o, const char *lang )
{
static const struct strtab tab[] = {
{ N_("Disable"), MN_DISCOVERY_DISABLE },
{ N_("New muxes only"), MN_DISCOVERY_NEW },
{ N_("New muxes + change muxes"), MN_DISCOVERY_CHANGE },
};
return strtab2htsmsg(tab, 1, lang);
}

CLASS_DOC(mpegts_network)

const idclass_t mpegts_network_class =
Expand Down Expand Up @@ -166,14 +177,15 @@ const idclass_t mpegts_network_class =
.off = offsetof(mpegts_network_t, mn_nid),
},
{
.type = PT_BOOL,
.type = PT_INT,
.id = "autodiscovery",
.name = N_("Network discovery"),
.desc = N_("Discover more muxes using the Network "
"Information Table (if available)."),
.off = offsetof(mpegts_network_t, mn_autodiscovery),
.list = mpegts_network_discovery_enum,
.opts = PO_ADVANCED,
.def.i = 1
.def.i = MN_DISCOVERY_NEW
},
{
.type = PT_BOOL,
Expand Down Expand Up @@ -426,7 +438,7 @@ mpegts_network_create0
/* Defaults */
mn->mn_satpos = INT_MAX;
mn->mn_skipinitscan = 1;
mn->mn_autodiscovery = 1;
mn->mn_autodiscovery = MN_DISCOVERY_NEW;

/* Load config */
if (conf)
Expand Down
39 changes: 23 additions & 16 deletions src/input/mpegts/mpegts_network_dvb.c
Expand Up @@ -658,7 +658,7 @@ dvb_network_create_mux

ln = (dvb_network_t*)mn;
mm = dvb_network_find_mux(ln, dmc, onid, tsid, 0);
if (!mm && (ln->mn_autodiscovery || force)) {
if (!mm && (ln->mn_autodiscovery != MN_DISCOVERY_DISABLE || force)) {
cls = dvb_network_mux_class((mpegts_network_t *)ln);
save |= cls == &dvb_mux_dvbt_class && dmc->dmc_fe_type == DVB_TYPE_T;
save |= cls == &dvb_mux_dvbc_class && dmc->dmc_fe_type == DVB_TYPE_C;
Expand All @@ -681,7 +681,10 @@ dvb_network_create_mux
}
}
} else if (mm) {
char buf[128];
dvb_mux_conf_t tuning_new, tuning_old;
dvb_mux_t *lm = (dvb_mux_t*)mm;
int change = ln->mn_autodiscovery == MN_DISCOVERY_CHANGE;
/* the nit tables may be inconsistent (like rolloff ping-pong) */
/* accept information only from one origin mux */
if (mm->mm_dmc_origin_expire > mclk() && mm->mm_dmc_origin && mm->mm_dmc_origin != origin)
Expand All @@ -690,32 +693,30 @@ dvb_network_create_mux
int xr = dmc->x != lm->lm_tuning.x; \
if (xr) { \
tvhtrace("mpegts", "create mux dmc->" #x " (%li) != lm->lm_tuning." #x \
" (%li)", (long)dmc->x, (long)lm->lm_tuning.x); \
lm->lm_tuning.x = dmc->x; \
" (%li)", (long)dmc->x, (long)tuning_new.x); \
tuning_new.x = dmc->x; \
} xr ? cbit : 0; })
#define COMPAREN(x, cbit) ({ \
int xr = dmc->x != 0 && dmc->x != 1 && dmc->x != lm->lm_tuning.x; \
int xr = dmc->x != 0 && dmc->x != 1 && dmc->x != tuning_new.x; \
if (xr) { \
tvhtrace("mpegts", "create mux dmc->" #x " (%li) != lm->lm_tuning." #x \
" (%li)", (long)dmc->x, (long)lm->lm_tuning.x); \
lm->lm_tuning.x = dmc->x; \
" (%li)", (long)dmc->x, (long)tuning_new.x); \
tuning_new.x = dmc->x; \
} xr ? cbit : 0; })
dvb_mux_conf_t tuning_old;
char buf[128];
tuning_old = lm->lm_tuning;
tuning_new = tuning_old = lm->lm_tuning;
/* Always save the orbital position */
if (dmc->dmc_fe_type == DVB_TYPE_S) {
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos == INT_MAX ||
dvb_network_check_orbital_pos(lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos,
if (tuning_new.u.dmc_fe_qpsk.orbital_pos == INT_MAX ||
dvb_network_check_orbital_pos(tuning_new.u.dmc_fe_qpsk.orbital_pos,
dmc->u.dmc_fe_qpsk.orbital_pos))
save |= COMPARE(u.dmc_fe_qpsk.orbital_pos, CBIT_ORBITAL_POS);
}
/* Do not change anything else without autodiscovery flag */
if (!ln->mn_autodiscovery)
goto save;
/* Handle big diffs that have been allowed through for DVB-S */
if (deltaU32(dmc->dmc_fe_freq, lm->lm_tuning.dmc_fe_freq) > 4000) {
lm->lm_tuning.dmc_fe_freq = dmc->dmc_fe_freq;
if (deltaU32(dmc->dmc_fe_freq, tuning_new.dmc_fe_freq) > 4000) {
tuning_new.dmc_fe_freq = dmc->dmc_fe_freq;
save |= CBIT_FREQ;
}
save |= COMPAREN(dmc_fe_modulation, CBIT_MODULATION);
Expand Down Expand Up @@ -755,10 +756,16 @@ dvb_network_create_mux
char muxname[128];
mpegts_mux_nice_name((mpegts_mux_t *)mm, muxname, sizeof(muxname));
dvb_mux_conf_str(&tuning_old, buf, sizeof(buf));
tvhwarn("mpegts", "mux %s changed from %s (%08x)", muxname, buf, save);
dvb_mux_conf_str(&lm->lm_tuning, buf, sizeof(buf));
tvhwarn("mpegts", "mux %s changed to %s (%08x)", muxname, buf, save);
tvhlog(change ? LOG_WARNING : LOG_NOTICE, "mpegts",
"mux %s%s from %s (%08x)", muxname,
change ? " changed from" : " old params", buf, save);
dvb_mux_conf_str(&tuning_new, buf, sizeof(buf));
tvhlog(change ? LOG_WARNING : LOG_NOTICE, "mpegts",
"mux %s%s to %s (%08x)", muxname,
change ? " changed to " : " new params", buf, save);
if (!change) save = 0;
}
if (save) lm->lm_tuning = tuning_new;
}
save:
if (mm && save) {
Expand Down

0 comments on commit 82edc90

Please sign in to comment.