]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Send signalStatus message over HTSP every second.
authorAndreas Öman <andreas@lonelycoder.com>
Tue, 9 Nov 2010 20:08:58 +0000 (20:08 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Tue, 9 Nov 2010 20:08:58 +0000 (20:08 +0000)
Ticket #300

src/dvb/dvb.h
src/dvb/dvb_fe.c
src/dvb/dvb_transport.c
src/htsp.c
src/transports.c
src/transports.h
src/tvhead.h

index 9f155fe5391624c01cc315aeeb43b41030bbcb51..663fb746aa3e156d67ab85b7eebef5663686314c 100644 (file)
@@ -307,6 +307,8 @@ void dvb_transport_notify_by_adapter(th_dvb_adapter_t *tda);
 
 htsmsg_t *dvb_transport_build_msg(th_transport_t *t);
 
+int dvb_transport_get_signal_status(th_transport_t *t,
+                                   signal_status_t *status);
 
 /**
  * DVB Frontend
index 4fa1f6229c2cdf2b105f6667bc228172db7e0c32..c9e39d7f3db8e2ab5d60b0aedee32815e051782c 100644 (file)
@@ -112,6 +112,18 @@ dvb_fe_monitor(void *aux)
     } else {
       status = TDMI_FE_CONSTANT_FEC;
     }
+
+    /* bit error rate */
+    if(ioctl(tda->tda_fe_fd, FE_READ_BER, &tdmi->tdmi_ber) == -1)
+      tdmi->tdmi_ber = -2;
+
+    /* signal strength */
+    if(ioctl(tda->tda_fe_fd, FE_READ_SIGNAL_STRENGTH, &tdmi->tdmi_signal) == -1)
+      tdmi->tdmi_signal = -2;
+
+    /* signal/noise ratio */
+    if(ioctl(tda->tda_fe_fd, FE_READ_SNR, &tdmi->tdmi_snr) == -1)
+      tdmi->tdmi_snr = -2;
   }
 
   if(status != tdmi->tdmi_fe_status) {
index 48650d819943ca0207826732b87ecf85cf706eee..15fbbeb9f49b1324c0b71d8d9dd96fa5731b4d7f 100644 (file)
@@ -460,3 +460,20 @@ dvb_transport_notify(th_transport_t *t)
   htsmsg_add_str(m, "adapterId", tdmi->tdmi_adapter->tda_identifier);
   notify_by_msg("dvbService", m);
 }
+
+
+/**
+ * Get the signal status from a DVB transport
+ */
+int
+dvb_transport_get_signal_status(th_transport_t *t, signal_status_t *status)
+{
+  th_dvb_mux_instance_t *tdmi = t->tht_dvb_mux_instance;
+
+  status->status_text = dvb_mux_status(tdmi);
+  status->snr         = tdmi->tdmi_snr;
+  status->signal      = tdmi->tdmi_signal;
+  status->ber         = tdmi->tdmi_ber;
+  status->unc         = tdmi->tdmi_uncorrected_blocks;
+  return 0;
+}
index 5f97e6e55346fec45f136b899478fe3b70f2dcef..bc09946c0c8e875778ae761ac8f74ac74bea715d 100644 (file)
@@ -166,7 +166,6 @@ typedef struct htsp_subscription {
 } htsp_subscription_t;
 
 
-
 /**
  *
  */
@@ -1430,7 +1429,9 @@ htsp_stream_deliver(htsp_subscription_t *hs, th_pkt_t *pkt)
   htsp_send(htsp, m, pkt->pkt_payload, &hs->hs_q, pktbuf_len(pkt->pkt_payload));
 
   if(hs->hs_last_report != dispatch_clock) {
-    /* Send a queue status report every second */
+    signal_status_t status;
+
+    /* Send a queue and signal status report every second */
 
     hs->hs_last_report = dispatch_clock;
 
@@ -1461,8 +1462,27 @@ htsp_stream_deliver(htsp_subscription_t *hs, th_pkt_t *pkt)
 
     /* We use a special queue for queue status message so they're not
        blocked by anything else */
-
     htsp_send_message(hs->hs_htsp, m, &hs->hs_htsp->htsp_hmq_qstatus);
+
+
+    if(!transport_get_signal_status(hs->hs_s->ths_transport, &status)) {
+
+      m = htsmsg_create_map();
+      htsmsg_add_str(m, "method", "signalStatus");
+      htsmsg_add_u32(m, "subscriptionId", hs->hs_sid);
+
+      htsmsg_add_str(m, "feStatus",   status.status_text);
+      if(status.snr != -2)
+       htsmsg_add_u32(m, "feSNR",    status.snr);
+      if(status.signal != -2)
+       htsmsg_add_u32(m, "feSignal", status.signal);
+      if(status.ber != -2)
+       htsmsg_add_u32(m, "feBER",    status.ber);
+      if(status.unc != -2)
+       htsmsg_add_u32(m, "feUNC",    status.unc);
+      htsp_send_message(hs->hs_htsp, m, &hs->hs_htsp->htsp_hmq_qstatus);
+    }
+
   }
   pkt_ref_dec(pkt);
 }
index 96c983cefde151ed79f7625ea4cdd59fd1630952..e6449e827b3e7255aa1d277d7e7bd51f39f53ea1 100644 (file)
@@ -1025,3 +1025,21 @@ transport_refresh_channel(th_transport_t *t)
   if(t->tht_ch != NULL)
     htsp_channel_update(t->tht_ch);
 }
+
+
+
+/**
+ * Get the signal status from a transport
+ */
+int
+transport_get_signal_status(th_transport_t *t, signal_status_t *status)
+{
+  // get signal status from the transport
+  switch(t->tht_type) {
+  case TRANSPORT_DVB:
+    return dvb_transport_get_signal_status(t, status);
+  default:
+    return -1;
+  }
+}
+
index 75892b82c452df7253606ebc28b688980b37d840..71fe54fb21cb8e6ecdae781861740faa0115bbc6 100644 (file)
@@ -98,4 +98,6 @@ void transport_refresh_channel(th_transport_t *t);
 
 int tss2errcode(int tss);
 
+int transport_get_signal_status(th_transport_t *t, signal_status_t *status);
+
 #endif /* TRANSPORTS_H */
index e3f26838da3e9c6ad81a466304c7671c7fc60475..13ec36fb957d802ae756e1cf01e4d7603680687e 100644 (file)
@@ -168,6 +168,18 @@ typedef enum {
 #define SCT_ISVIDEO(t) ((t) == SCT_MPEG2VIDEO || (t) == SCT_H264)
 #define SCT_ISAUDIO(t) ((t) == SCT_MPEG2AUDIO || (t) == SCT_AC3 || \
                         (t) == SCT_AAC)
+
+/**
+ * The signal status of a tuner
+ */
+typedef struct signal_status {
+  const char *status_text; /* adapter status text */
+  int snr;      /* signal/noise ratio */
+  int signal;   /* signal strength */
+  int ber;      /* bit error rate */
+  int unc;      /* uncorrected blocks */
+} signal_status_t;
+
 /**
  * A streaming pad generates data.
  * It has one or more streaming targets attached to it.