Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SAT>IP Client: add configurable grace timeout
  • Loading branch information
perexg committed Apr 27, 2015
1 parent 2623cc5 commit 08c4c75
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -378,7 +378,7 @@ satip_frontend_get_grace ( mpegts_input_t *mi, mpegts_mux_t *mm )
satip_frontend_t *lfe = (satip_frontend_t*)mi;
int r = 5;
if (lfe->sf_positions)
r = 10;
r = MIN(60, MAX(r, satip_satconf_get_grace(lfe, mm) ?: 10));
return r;
}

Expand Down
4 changes: 4 additions & 0 deletions src/input/mpegts/satip/satip_private.h
Expand Up @@ -160,6 +160,7 @@ struct satip_satconf
int sfc_enabled;
int sfc_position;
int sfc_priority;
int sfc_grace;
char *sfc_name;

/*
Expand Down Expand Up @@ -208,6 +209,9 @@ void satip_satconf_updated_positions
int satip_satconf_get_priority
( satip_frontend_t *lfe, mpegts_mux_t *mm );

int satip_satconf_get_grace
( satip_frontend_t *lfe, mpegts_mux_t *mm );

int satip_satconf_get_position
( satip_frontend_t *lfe, mpegts_mux_t *mm );

Expand Down
42 changes: 30 additions & 12 deletions src/input/mpegts/satip/satip_satconf.c
Expand Up @@ -29,6 +29,19 @@ static satip_satconf_t *
satip_satconf_find_ele( satip_frontend_t *lfe, mpegts_mux_t *mux )
{
satip_satconf_t *sfc;
satip_frontend_t *lfe2;

if (lfe->sf_master) {
TAILQ_FOREACH(lfe2, &lfe->sf_device->sd_frontends, sf_link)
if (lfe2->sf_number != lfe->sf_number &&
lfe2->sf_number == lfe->sf_master &&
lfe2->sf_master == 0) {
lfe = lfe2;
goto found;
}
return 0;
}
found:
TAILQ_FOREACH(sfc, &lfe->sf_satconf, sfc_link) {
if (idnode_set_exists(sfc->sfc_networks, &mux->mm_network->mn_id))
return sfc;
Expand All @@ -44,23 +57,19 @@ satip_satconf_get_priority
return sfc ? sfc->sfc_priority : 0;
}

int
satip_satconf_get_grace
( satip_frontend_t *lfe, mpegts_mux_t *mm )
{
satip_satconf_t *sfc = satip_satconf_find_ele(lfe, mm);
return sfc ? sfc->sfc_grace : 0;
}

int
satip_satconf_get_position
( satip_frontend_t *lfe, mpegts_mux_t *mm )
{
satip_satconf_t *sfc;
satip_frontend_t *lfe2;
if (lfe->sf_master) {
TAILQ_FOREACH(lfe2, &lfe->sf_device->sd_frontends, sf_link)
if (lfe2->sf_number != lfe->sf_number &&
lfe2->sf_number == lfe->sf_master &&
lfe2->sf_master == 0) {
lfe = lfe2;
goto found;
}
return 0;
}
found:
sfc = satip_satconf_find_ele(lfe, mm);
return sfc && sfc->sfc_enabled ? sfc->sfc_position : 0;
}
Expand Down Expand Up @@ -193,6 +202,14 @@ const idclass_t satip_satconf_class =
.off = offsetof(satip_satconf_t, sfc_priority),
.opts = PO_ADVANCED,
},
{
.type = PT_INT,
.id = "timeout",
.name = "Timeout (seconds)",
.off = offsetof(satip_satconf_t, sfc_grace),
.opts = PO_ADVANCED,
.def.i = 10
},
{
.type = PT_INT,
.id = "position",
Expand Down Expand Up @@ -241,6 +258,7 @@ satip_satconf_create0
sfc->sfc_networks = idnode_set_create(0);
sfc->sfc_lfe = lfe;
sfc->sfc_position = position + 1;
sfc->sfc_grace = 10;
TAILQ_INSERT_TAIL(&lfe->sf_satconf, sfc, sfc_link);
if (conf)
idnode_load(&sfc->sfc_id, conf);
Expand Down

0 comments on commit 08c4c75

Please sign in to comment.