]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
WEBUI: Add descrambler info to the subscriptions grid, fixes #2616
authorJaroslav Kysela <perex@perex.cz>
Tue, 13 Oct 2015 07:41:22 +0000 (09:41 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 13 Oct 2015 07:41:22 +0000 (09:41 +0200)
src/descrambler/descrambler.c
src/service.h
src/subscriptions.c
src/webui/static/app/status.js

index c682161c5ad1b07f8b05a6f65b1511d1971e24c7..1c41ff52d910ecb8a2d261b2360c552e90f36bb4 100644 (file)
@@ -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\"",
index 67c733ce0916b7733743dddf695d08a7c82449a3..6e98ef024b4a465e2b5945bf1a622f7b30862a53 100644 (file)
@@ -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.
index b9118e2d17a1a76d4993f598ac7ae32ca5aa50fc..8b36cc5f2688c1a17508cafaffcb4266521c4111 100644 (file)
@@ -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);
index 2aea43430614d3973ee770f2c2338d8f6a6512ef..06d750cc40afcc65ac152b196660101cf71b362f 100644 (file)
@@ -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',