From 82669f4da770e676881d3aeb3fea32e3bca98e68 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 30 Nov 2015 22:33:17 +0100 Subject: [PATCH] SAT>IP Server: handle tvhweight --- src/satip/rtsp.c | 12 +++++++++--- src/satip/server.c | 12 ++++++++++-- src/satip/server.h | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/satip/rtsp.c b/src/satip/rtsp.c index 576e58bbd..864319467 100644 --- a/src/satip/rtsp.c +++ b/src/satip/rtsp.c @@ -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; @@ -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; @@ -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, @@ -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; @@ -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) @@ -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) { diff --git a/src/satip/server.c b/src/satip/server.c index 1da69b3a0..9b90cae3a 100644 --- a/src/satip/server.c +++ b/src/satip/server.c @@ -68,7 +68,7 @@ satip_server_http_xml(http_connection_t *hc) http://tvheadend.org\n\ TVHeadend %s\n\ TVHeadend SAT>IP\n\ -1.0\n\ +1.1\n\ \n\ 123456\n\ uuid:%s\n\ @@ -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) @@ -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", diff --git a/src/satip/server.h b/src/satip/server.h index ea618d295..7f4af315c 100644 --- a/src/satip/server.h +++ b/src/satip/server.h @@ -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; -- 2.47.3