From: Jaroslav Kysela Date: Tue, 13 Oct 2015 07:41:22 +0000 (+0200) Subject: WEBUI: Add descrambler info to the subscriptions grid, fixes #2616 X-Git-Tag: v4.2.1~1929 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc6cd96486c3ce874ab36fef407db30fdb6d38f2;p=thirdparty%2Ftvheadend.git WEBUI: Add descrambler info to the subscriptions grid, fixes #2616 --- diff --git a/src/descrambler/descrambler.c b/src/descrambler/descrambler.c index c682161c5..1c41ff52d 100644 --- a/src/descrambler/descrambler.c +++ b/src/descrambler/descrambler.c @@ -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); @@ -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); @@ -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)); @@ -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); @@ -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\"", diff --git a/src/service.h b/src/service.h index 67c733ce0..6e98ef024 100644 --- a/src/service.h +++ b/src/service.h @@ -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. diff --git a/src/subscriptions.c b/src/subscriptions.c index b9118e2d1..8b36cc5f2 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -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); @@ -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); diff --git a/src/webui/static/app/status.js b/src/webui/static/app/status.js index 2aea43430..06d750cc4 100644 --- a/src/webui/static/app/status.js +++ b/src/webui/static/app/status.js @@ -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; @@ -44,6 +45,7 @@ tvheadend.status_subs = function(panel, index) { name: 'channel' }, { name: 'service' }, { name: 'state' }, + { name: 'descramble' }, { name: 'errors' }, { name: 'in' }, { name: 'out' }, @@ -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',