From d5fabb89afa91b112e2fc9312b12c4f5f059d75d Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 9 Oct 2015 15:11:40 +0200 Subject: [PATCH] http streaming api: accept descramble=0 parameter, fixes #3142 --- src/descrambler/descrambler.c | 3 +++ src/input/mpegts/tsdemux.c | 8 ++++++-- src/service.c | 1 + src/service.h | 3 ++- src/subscriptions.h | 1 + src/webui/webui.c | 14 +++++++++++--- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/descrambler/descrambler.c b/src/descrambler/descrambler.c index 660cf74e3..c682161c5 100644 --- a/src/descrambler/descrambler.c +++ b/src/descrambler/descrambler.c @@ -112,6 +112,9 @@ descrambler_service_start ( service_t *t ) th_descrambler_runtime_t *dr; elementary_stream_t *st; + if (t->s_scrambled_pass) + return; + if (!((mpegts_service_t *)t)->s_dvb_forcecaid) { TAILQ_FOREACH(st, &t->s_filt_components, es_filt_link) diff --git a/src/input/mpegts/tsdemux.c b/src/input/mpegts/tsdemux.c index 0ba1e7ee6..26e8237fb 100644 --- a/src/input/mpegts/tsdemux.c +++ b/src/input/mpegts/tsdemux.c @@ -100,6 +100,9 @@ ts_recv_packet0 if (st->es_type == SCT_CA) continue; + if (tsb[3] & 0xc0) /* scrambled */ + continue; + if(!streaming_pad_probe_type(&t->s_streaming_pad, SMT_PACKET)) continue; @@ -172,8 +175,9 @@ ts_recv_packet1 avgstat_add(&t->s_rate, len, dispatch_clock); - if((tsb[3] & 0xc0) || - (t->s_scrambled_seen && st && st->es_type != SCT_CA)) { + if(!t->s_scrambled_pass && + ((tsb[3] & 0xc0) || + (t->s_scrambled_seen && st && st->es_type != SCT_CA))) { /** * Lock for descrambling, but only if packet was not in error diff --git a/src/service.c b/src/service.c index 7d9bb1c11..74cd125e1 100644 --- a/src/service.c +++ b/src/service.c @@ -608,6 +608,7 @@ service_start(service_t *t, int instance, int weight, int flags, t->s_streaming_status = 0; t->s_streaming_live = 0; t->s_scrambled_seen = 0; + t->s_scrambled_pass = !!(flags & SUBSCRIPTION_NODESCR); t->s_start_time = dispatch_clock; pthread_mutex_lock(&t->s_stream_mutex); diff --git a/src/service.h b/src/service.h index 82dd15acc..67c733ce0 100644 --- a/src/service.h +++ b/src/service.h @@ -445,7 +445,8 @@ typedef struct service { */ struct th_descrambler_list s_descramblers; - uint16_t s_scrambled_seen; + uint8_t s_scrambled_seen; + uint8_t s_scrambled_pass; th_descrambler_runtime_t *s_descramble; /** diff --git a/src/subscriptions.h b/src/subscriptions.h index 7f5da4351..3ce544288 100644 --- a/src/subscriptions.h +++ b/src/subscriptions.h @@ -35,6 +35,7 @@ extern struct th_subscription_list subscriptions; #define SUBSCRIPTION_ONESHOT 0x080 #define SUBSCRIPTION_TABLES 0x100 #define SUBSCRIPTION_MINIMAL 0x200 +#define SUBSCRIPTION_NODESCR 0x400 ///< no decramble #define SUBSCRIPTION_INITSCAN 0x1000 ///< for mux subscriptions #define SUBSCRIPTION_IDLESCAN 0x2000 ///< for mux subscriptions #define SUBSCRIPTION_USERSCAN 0x4000 ///< for mux subscriptions diff --git a/src/webui/webui.c b/src/webui/webui.c index 32ff121ff..11558f6fd 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -1052,14 +1052,21 @@ http_stream_service(http_connection_t *hc, service_t *service, int weight) const char *name; void *tcp_id; int res = HTTP_STATUS_SERVICE; + int flags, eflags = 0; if(http_access_verify(hc, ACCESS_ADVANCED_STREAMING)) return HTTP_STATUS_UNAUTHORIZED; + if ((str = http_arg_get(&hc->hc_req_args, "descramble"))) + if (strcmp(str ?: "", "0") == 0) + eflags |= SUBSCRIPTION_NODESCR; + + flags = SUBSCRIPTION_MPEGTS | eflags; + if ((eflags & SUBSCRIPTION_NODESCR) == 0) + flags |= SUBSCRIPTION_PACKET; if(!(pro = profile_find_by_list(hc->hc_access->aa_profiles, http_arg_get(&hc->hc_req_args, "profile"), - "service", - SUBSCRIPTION_PACKET | SUBSCRIPTION_MPEGTS))) + "service", flags))) return HTTP_STATUS_NOT_ALLOWED; if((tcp_id = http_stream_preop(hc)) == NULL) @@ -1074,7 +1081,8 @@ http_stream_service(http_connection_t *hc, service_t *service, int weight) if (!profile_chain_open(&prch, NULL, 0, qsize)) { s = subscription_create_from_service(&prch, NULL, weight, "HTTP", - prch.prch_flags | SUBSCRIPTION_STREAMING, + prch.prch_flags | SUBSCRIPTION_STREAMING | + eflags, hc->hc_peer_ipstr, hc->hc_username, http_arg_get(&hc->hc_args, "User-Agent"), -- 2.47.3