Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WEBUI: Add descrambler info to the subscriptions grid, fixes #2616
  • Loading branch information
perexg committed Oct 13, 2015
1 parent 3e19554 commit dc6cd96
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/descrambler/descrambler.c
Expand Up @@ -146,6 +146,7 @@ descrambler_service_stop ( service_t *t )
{
th_descrambler_t *td;
th_descrambler_runtime_t *dr = t->s_descramble;
void *p;

#if ENABLE_LINUXDVB_CA
dvbcam_service_stop(t);
Expand All @@ -154,6 +155,10 @@ descrambler_service_stop ( service_t *t )
while ((td = LIST_FIRST(&t->s_descramblers)) != NULL)
td->td_stop(td);
t->s_descramble = NULL;
t->s_descrambler = NULL;
p = t->s_descramble_info;
t->s_descramble_info = NULL;
free(p);
if (dr) {
tvhcsa_destroy(&dr->dr_csa);
sbuf_free(&dr->dr_buf);
Expand Down Expand Up @@ -185,9 +190,13 @@ descrambler_notify( th_descrambler_t *td,

tvhlog(LOG_DEBUG, "descrambler", "info - service='%s' caid=%04X(%s) "
"provid=%06X ecmtime=%d hops=%d "
"reader='%s' from='%s' protocol='%s'",
"reader='%s' from='%s' protocol='%s'%s",
t->s_dvb_svcname, caid, cardsystem, provid,
ecmtime, hops, reader, from, protocol);
ecmtime, hops, reader, from, protocol,
t->s_descrambler != td ? " (inactive)" : "");

if (t->s_descrambler != td)
return;

sm = streaming_msg_create(SMT_DESCRAMBLE_INFO);
sm->sm_data = di = calloc(1, sizeof(*di));
Expand All @@ -202,6 +211,10 @@ descrambler_notify( th_descrambler_t *td,
strncpy(di->from, from, sizeof(di->protocol)-1);
strncpy(di->protocol, protocol, sizeof(di->protocol)-1);

if (!t->s_descramble_info)
t->s_descramble_info = calloc(1, sizeof(*di));
memcpy(t->s_descramble_info, di, sizeof(*di));

pthread_mutex_lock(&t->s_stream_mutex);
streaming_pad_deliver(&t->s_streaming_pad, sm);
pthread_mutex_unlock(&t->s_stream_mutex);
Expand Down Expand Up @@ -298,6 +311,7 @@ descrambler_keys ( th_descrambler_t *td, int type,
}
dr->dr_ecm_last_key_time = dispatch_clock;
td->td_keystate = DS_RESOLVED;
td->td_service->s_descrambler = td;
} else {
tvhlog(LOG_DEBUG, "descrambler",
"Empty keys received from %s for service \"%s\"",
Expand Down
2 changes: 2 additions & 0 deletions src/service.h
Expand Up @@ -448,6 +448,8 @@ typedef struct service {
uint8_t s_scrambled_seen;
uint8_t s_scrambled_pass;
th_descrambler_runtime_t *s_descramble;
void *s_descrambler; /* last active descrambler */
descramble_info_t *s_descramble_info;

/**
* List of all and filtered components.
Expand Down
13 changes: 11 additions & 2 deletions src/subscriptions.c
Expand Up @@ -844,6 +844,8 @@ htsmsg_t *
subscription_create_msg(th_subscription_t *s)
{
htsmsg_t *m = htsmsg_create_map();
descramble_info_t *di;
char buf[256];

htsmsg_add_u32(m, "id", s->ths_id);
htsmsg_add_u32(m, "start", s->ths_start);
Expand Down Expand Up @@ -885,10 +887,17 @@ subscription_create_msg(th_subscription_t *s)
if(s->ths_channel != NULL)
htsmsg_add_str(m, "channel", channel_get_name(s->ths_channel));

if(s->ths_service != NULL)
if(s->ths_service != NULL) {
htsmsg_add_str(m, "service", s->ths_service->s_nicename ?: "");

else if(s->ths_dvrfile != NULL)
if ((di = s->ths_service->s_descramble_info) != NULL) {
snprintf(buf, sizeof(buf), "%04X:%06X(%ums)-%s%s%s",
di->caid, di->provid, di->ecmtime, di->from,
di->reader[0] ? "/" : "", di->reader);
htsmsg_add_str(m, "descramble", buf);
}

} else if(s->ths_dvrfile != NULL)
htsmsg_add_str(m, "service", s->ths_dvrfile ?: "");

htsmsg_add_u32(m, "in", s->ths_bytes_in_avg);
Expand Down
8 changes: 8 additions & 0 deletions src/webui/static/app/status.js
Expand Up @@ -20,6 +20,7 @@ tvheadend.status_subs = function(panel, index)
r.data.channel = m.channel;
r.data.service = m.service;
r.data.state = m.state;
if (m.descramble) r.data.descramble = m.descramble;
r.data.errors = m.errors;
r.data['in'] = m['in'];
r.data.out = m.out;
Expand All @@ -44,6 +45,7 @@ tvheadend.status_subs = function(panel, index)
{ name: 'channel' },
{ name: 'service' },
{ name: 'state' },
{ name: 'descramble' },
{ name: 'errors' },
{ name: 'in' },
{ name: 'out' },
Expand Down Expand Up @@ -124,6 +126,12 @@ tvheadend.status_subs = function(panel, index)
header: _("State"),
dataIndex: 'state'
},
{
width: 80,
id: 'descramble',
header: _("Descramble"),
dataIndex: 'descramble'
},
{
width: 50,
id: 'errors',
Expand Down

0 comments on commit dc6cd96

Please sign in to comment.