Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
http streaming api: accept descramble=0 parameter, fixes #3142
  • Loading branch information
perexg committed Oct 9, 2015
1 parent dbeee1c commit d5fabb8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/descrambler/descrambler.c
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/input/mpegts/tsdemux.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/service.c
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/service.h
Expand Up @@ -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;

/**
Expand Down
1 change: 1 addition & 0 deletions src/subscriptions.h
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions src/webui/webui.c
Expand Up @@ -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)
Expand All @@ -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"),
Expand Down

0 comments on commit d5fabb8

Please sign in to comment.