Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SAT>IP Server: handle tvhweight
  • Loading branch information
perexg committed Nov 30, 2015
1 parent bed9b61 commit 82669f4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/satip/rtsp.c
Expand Up @@ -50,6 +50,7 @@ typedef struct session {
int findex;
int src;
int state;
int weight;
http_connection_t *shutdown_on_close;
int perm_lock;
uint32_t nsession;
Expand Down Expand Up @@ -487,7 +488,7 @@ rtsp_start
mpegts_service_t *svc;
dvb_mux_conf_t dmc;
char buf[384];
int res = HTTP_STATUS_SERVICE, qsize = 3000000, created = 0;
int res = HTTP_STATUS_SERVICE, qsize = 3000000, created = 0, weight;

pthread_mutex_lock(&global_lock);
dmc = rs->dmc_tuned;
Expand Down Expand Up @@ -550,8 +551,11 @@ rtsp_start
rs->mux_created = created;
if (profile_chain_raw_open(&rs->prch, (mpegts_mux_t *)rs->mux, qsize, 0))
goto endclean;
weight = satip_server_conf.satip_weight;
if (satip_server_conf.satip_allow_remote_weight && rs->weight)
weight = rs->weight;
rs->subs = subscription_create_from_mux(&rs->prch, NULL,
satip_server_conf.satip_weight,
weight,
"SAT>IP",
rs->prch.prch_flags |
SUBSCRIPTION_STREAMING,
Expand Down Expand Up @@ -835,7 +839,7 @@ rtsp_parse_cmd
session_t **rrs, int *valid, int *oldstate)
{
session_t *rs = NULL;
int errcode = HTTP_STATUS_BAD_REQUEST, r, findex = 0, has_args;
int errcode = HTTP_STATUS_BAD_REQUEST, r, findex = 0, has_args, weight = 0;
int delsys = DVB_SYS_NONE, msys, fe, src, freq, pol, sr;
int fec, ro, plts, bw, tmode, mtype, gi, plp, t2id, sm, c2tft, ds, specinv;
char *s;
Expand Down Expand Up @@ -870,6 +874,7 @@ rtsp_parse_cmd
msys = msys_to_tvh(hc);
freq = atof(http_arg_get_remove(&hc->hc_req_args, "freq")) * 1000;
*valid = freq >= 10000;
weight = atoi(http_arg_get_remove(&hc->hc_req_args, "tvhweight"));

if (addpids.count > 0 || delpids.count > 0) {
if (cmd)
Expand Down Expand Up @@ -1069,6 +1074,7 @@ rtsp_parse_cmd
rs->delsys = delsys;
rs->frontend = fe;
rs->findex = findex;
rs->weight = weight > 0 ? weight : 0;
rs->old_hc = hc;

if (cmd) {
Expand Down
12 changes: 10 additions & 2 deletions src/satip/server.c
Expand Up @@ -68,7 +68,7 @@ satip_server_http_xml(http_connection_t *hc)
<manufacturerURL>http://tvheadend.org</manufacturerURL>\n\
<modelDescription>TVHeadend %s</modelDescription>\n\
<modelName>TVHeadend SAT>IP</modelName>\n\
<modelNumber>1.0</modelNumber>\n\
<modelNumber>1.1</modelNumber>\n\
<modelURL></modelURL>\n\
<serialNumber>123456</serialNumber>\n\
<UDN>uuid:%s</UDN>\n\
Expand Down Expand Up @@ -544,7 +544,8 @@ static void satip_server_info(const char *prefix, int descramble, int muxcnf)
struct satip_server_conf satip_server_conf = {
.idnode.in_class = &satip_server_class,
.satip_descramble = 1,
.satip_weight = 100
.satip_weight = 100,
.satip_allow_remote_weight = 1
};

static void satip_server_class_save(idnode_t *self)
Expand Down Expand Up @@ -604,6 +605,13 @@ const idclass_t satip_server_class = {
.off = offsetof(struct satip_server_conf, satip_weight),
.group = 1,
},
{
.type = PT_BOOL,
.id = "satip_remote_weight",
.name = N_("Allow remote subscription weight"),
.off = offsetof(struct satip_server_conf, satip_allow_remote_weight),
.group = 1,
},
{
.type = PT_INT,
.id = "satip_descramble",
Expand Down
1 change: 1 addition & 0 deletions src/satip/server.h
Expand Up @@ -41,6 +41,7 @@ struct satip_server_conf {
char *satip_uuid;
int satip_rtsp;
int satip_weight;
int satip_allow_remote_weight;
int satip_descramble;
int satip_rewrite_pmt;
int satip_muxcnf;
Expand Down

0 comments on commit 82669f4

Please sign in to comment.