From: Jaroslav Kysela Date: Mon, 30 Nov 2015 21:15:57 +0000 (+0100) Subject: SAT>IP client: implement tvhweight passing X-Git-Tag: v4.2.1~1433 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bed9b61ebe87a4ab1bd24a44871d68a87caa9f46;p=thirdparty%2Ftvheadend.git SAT>IP client: implement tvhweight passing --- diff --git a/src/input/mpegts/satip/satip.c b/src/input/mpegts/satip/satip.c index 3124e7ddd..d30aa976a 100644 --- a/src/input/mpegts/satip/satip.c +++ b/src/input/mpegts/satip/satip.c @@ -475,6 +475,8 @@ satip_device_hack( satip_device_t *sd ) sd->sd_pids_max = 128; sd->sd_pids_len = 2048; sd->sd_no_univ_lnb = 1; + if (strcmp(sd->sd_info.modelnum ?: "", "1.0")) + sd->sd_can_weight = 1; } else if (strstr(sd->sd_info.manufacturer, "AVM Berlin") && strstr(sd->sd_info.modelname, "FRITZ!")) { sd->sd_fullmux_ok = 0; diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index cf0f2e5c7..38f32ef58 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -174,6 +174,13 @@ const idclass_t satip_frontend_class = .opts = PO_ADVANCED, .off = offsetof(satip_frontend_t, sf_teardown_delay), }, + { + .type = PT_BOOL, + .id = "pass_weight", + .name = N_("Pass weight"), + .opts = PO_ADVANCED, + .off = offsetof(satip_frontend_t, sf_pass_weight), + }, { .type = PT_STR, .id = "tunerbindaddr", @@ -512,6 +519,11 @@ satip_frontend_start_mux mpegts_pid_init(&tr->sf_pids); mpegts_pid_init(&tr->sf_pids_tuned); + if (lfe->sf_device->sd_can_weight) { + pthread_mutex_lock(&mi->mi_output_lock); + tr->sf_weight = mpegts_mux_instance_weight(mmi); + pthread_mutex_unlock(&mi->mi_output_lock); + } pthread_mutex_lock(&lfe->sf_dvr_lock); lfe->sf_req = tr; @@ -570,6 +582,28 @@ satip_frontend_update_pids tvh_write(lfe->sf_dvr_pipe.wr, "c", 1); } +static void +satip_frontend_open_service ( mpegts_input_t *mi, mpegts_service_t *s, int flags, int init ) +{ + satip_frontend_t *lfe = (satip_frontend_t*)mi; + satip_tune_req_t *tr; + + mpegts_input_open_service(mi, s, flags, init); + + if (!lfe->sf_device->sd_can_weight) + return; + + pthread_mutex_lock(&lfe->sf_dvr_lock); + if ((tr = lfe->sf_req) != NULL && tr->sf_mmi != NULL) { + pthread_mutex_lock(&mi->mi_output_lock); + tr->sf_weight = mpegts_mux_instance_weight(tr->sf_mmi); + pthread_mutex_unlock(&mi->mi_output_lock); + } + pthread_mutex_unlock(&lfe->sf_dvr_lock); + + tvh_write(lfe->sf_dvr_pipe.wr, "c", 1); +} + static idnode_set_t * satip_frontend_network_list ( mpegts_input_t *mi ) { @@ -750,9 +784,10 @@ all: tr->sf_pids_tuned.all = 1; pthread_mutex_unlock(&lfe->sf_dvr_lock); if (i) - return 0; + goto skip; - r = satip_rtsp_play(rtsp, "all", NULL, NULL, max_pids_len); + tr->sf_weight_tuned = tr->sf_weight; + r = satip_rtsp_play(rtsp, "all", NULL, NULL, max_pids_len, tr->sf_weight); r = r == 0 ? 1 : r; } else if (!lfe->sf_device->sd_pids_deladd || @@ -771,9 +806,10 @@ all: mpegts_pid_done(&wpid); if (!j || add[0] == '\0') - return 0; + goto skip; - r = satip_rtsp_play(rtsp, add, NULL, NULL, max_pids_len); + tr->sf_weight_tuned = tr->sf_weight; + r = satip_rtsp_play(rtsp, add, NULL, NULL, max_pids_len, tr->sf_weight); r = r == 0 ? 1 : r; } else { @@ -811,15 +847,23 @@ all: mpegts_pid_done(&pdel); if (add[0] == '\0' && del[0] == '\0') - return 0; + goto skip; - r = satip_rtsp_play(rtsp, NULL, add, del, max_pids_len); + tr->sf_weight_tuned = tr->sf_weight; + r = satip_rtsp_play(rtsp, NULL, add, del, max_pids_len, tr->sf_weight); r = r == 0 ? 1 : r; } if (r < 0) tvherror("satip", "%s - failed to modify pids: %s", name, strerror(-r)); return r; + +skip: + if (tr->sf_weight_tuned != tr->sf_weight) { + tr->sf_weight_tuned = tr->sf_weight; + r = satip_rtsp_play(rtsp, NULL, NULL, NULL, 0, tr->sf_weight); + } + return 0; } static void @@ -1328,11 +1372,14 @@ new_tune: rtsp_flags |= SATIP_SETUP_PIDS21; r = -12345678; pthread_mutex_lock(&lfe->sf_dvr_lock); - if (lfe->sf_req == lfe->sf_req_thread) + if (lfe->sf_req == lfe->sf_req_thread) { + lfe->sf_req->sf_weight_tuned = lfe->sf_req->sf_weight; r = satip_rtsp_setup(rtsp, position, lfe->sf_number, rtp_port, &lm->lm_tuning, - rtsp_flags); + rtsp_flags, + lfe->sf_req->sf_weight); + } pthread_mutex_unlock(&lfe->sf_dvr_lock); if (r < 0) { if (r != -12345678) @@ -1445,10 +1492,13 @@ new_tune: if (lfe->sf_play2) { r = -12345678; pthread_mutex_lock(&lfe->sf_dvr_lock); - if (lfe->sf_req == lfe->sf_req_thread) + if (lfe->sf_req == lfe->sf_req_thread) { + lfe->sf_req->sf_weight_tuned = lfe->sf_req->sf_weight; r = satip_rtsp_setup(rtsp, position, lfe->sf_number, rtp_port, &lm->lm_tuning, - rtsp_flags | SATIP_SETUP_PLAY); + rtsp_flags | SATIP_SETUP_PLAY, + lfe->sf_req->sf_weight); + } pthread_mutex_unlock(&lfe->sf_dvr_lock); if (r < 0) { tvherror("satip", "%s - failed to tune2 (%i)", buf, r); @@ -1653,6 +1703,7 @@ satip_frontend_hacks( satip_frontend_t *lfe, int *def_positions ) satip_device_t *sd = lfe->sf_device; lfe->sf_tdelay = 50; /* should not hurt anything */ + lfe->sf_pass_weight = 1; if (strstr(sd->sd_info.location, ":8888/octonet.xml")) { if (lfe->sf_type == DVB_TYPE_S) lfe->sf_play2 = 1; @@ -1729,6 +1780,7 @@ satip_frontend_create lfe->sf_type_v2 = v2; lfe->sf_master = master; lfe->sf_type_override = override ? strdup(override) : NULL; + lfe->sf_pass_weight = 1; satip_frontend_hacks(lfe, &def_positions); TAILQ_INIT(&lfe->sf_satconf); pthread_mutex_init(&lfe->sf_dvr_lock, NULL); @@ -1761,6 +1813,7 @@ satip_frontend_create lfe->mi_stop_mux = satip_frontend_stop_mux; lfe->mi_network_list = satip_frontend_network_list; lfe->mi_update_pids = satip_frontend_update_pids; + lfe->mi_open_service = satip_frontend_open_service; lfe->mi_empty_status = mpegts_input_empty_status; /* Adapter link */ diff --git a/src/input/mpegts/satip/satip_private.h b/src/input/mpegts/satip/satip_private.h index 1dbb71897..21fd4a440 100644 --- a/src/input/mpegts/satip/satip_private.h +++ b/src/input/mpegts/satip/satip_private.h @@ -92,6 +92,7 @@ struct satip_device int sd_pids21; int sd_pilot_on; int sd_no_univ_lnb; + int sd_can_weight; int sd_dbus_allow; int sd_skip_ts; int sd_disable_workarounds; @@ -103,6 +104,9 @@ struct satip_tune_req { mpegts_apids_t sf_pids; mpegts_apids_t sf_pids_tuned; + + int sf_weight; + int sf_weight_tuned; }; struct satip_frontend @@ -127,6 +131,7 @@ struct satip_frontend int sf_play2; int sf_tdelay; int sf_teardown_delay; + int sf_pass_weight; char *sf_tuner_bindaddr; /* @@ -244,11 +249,11 @@ int satip_rtsp_setup( http_client_t *hc, int src, int fe, int udp_port, const dvb_mux_conf_t *dmc, - int flags ); + int flags, int weight ); int satip_rtsp_play( http_client_t *hc, const char *pids, const char *addpids, const char *delpids, - int max_pids_len ); + int max_pids_len, int weight ); #endif /* __TVH_SATIP_PRIVATE_H__ */ diff --git a/src/input/mpegts/satip/satip_rtsp.c b/src/input/mpegts/satip/satip_rtsp.c index 10b99ff10..99e168c99 100644 --- a/src/input/mpegts/satip/satip_rtsp.c +++ b/src/input/mpegts/satip/satip_rtsp.c @@ -69,7 +69,8 @@ satip_rtsp_add_val(const char *name, char *buf, uint32_t val) int satip_rtsp_setup( http_client_t *hc, int src, int fe, - int udp_port, const dvb_mux_conf_t *dmc, int flags ) + int udp_port, const dvb_mux_conf_t *dmc, int flags, + int weight ) { static tvh2satip_t msys[] = { { .t = DVB_SYS_DVBT, "dvbt" }, @@ -220,6 +221,8 @@ satip_rtsp_setup( http_client_t *hc, int src, int fe, ADD(dmc_fe_modulation, mtype, dmc->dmc_fe_delsys == DVB_SYS_ATSC ? "8vsb" : "64qam"); } + if (weight > 0) + satip_rtsp_add_val("tvhweight", buf, (uint32_t)weight * 1000); if (flags & SATIP_SETUP_PIDS0) { strcat(buf, "&pids=0"); if (flags & SATIP_SETUP_PIDS21) @@ -260,7 +263,7 @@ satip_rtsp_pids_strip( const char *s, int maxlen ) int satip_rtsp_play( http_client_t *hc, const char *pids, const char *addpids, const char *delpids, - int max_pids_len ) + int max_pids_len, int weight ) { htsbuf_queue_t q; char *stream = NULL; @@ -272,7 +275,7 @@ satip_rtsp_play( http_client_t *hc, const char *pids, addpids = satip_rtsp_pids_strip(addpids, max_pids_len); delpids = satip_rtsp_pids_strip(delpids, max_pids_len); - if (pids == NULL && addpids == NULL && delpids == NULL) + if (pids == NULL && addpids == NULL && delpids == NULL && weight <= 0) return -EINVAL; //printf("pids = '%s' addpids = '%s' delpids = '%s'\n", pids, addpids, delpids); @@ -296,6 +299,8 @@ satip_rtsp_play( http_client_t *hc, const char *pids, htsbuf_qprintf(&q, "addpids=%s", addpids); } } + if (weight) + htsbuf_qprintf(&q, "tvhweight=%d", weight); if (hc->hc_rtsp_stream_id >= 0) snprintf(stream = _stream, sizeof(_stream), "/stream=%li", hc->hc_rtsp_stream_id);