]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
add satpos and subsription status
authorGlenn-1990 <g_christiaensen@msn.com>
Sun, 22 Mar 2015 22:55:17 +0000 (23:55 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 15 Apr 2015 16:14:16 +0000 (18:14 +0200)
src/htsp_server.c
src/htsp_server.h
src/input/mpegts/mpegts_service.c
src/tvheadend.h

index b99d44fd5ba81d657ab32d25883ace270b7bbad2..83b9d846604c420f6913a5d4fc44de7be3fbcb8e 100644 (file)
@@ -94,6 +94,7 @@ static struct htsp_connection_list htsp_async_connections;
 static struct htsp_connection_list htsp_connections;
 
 static void htsp_streaming_input(void *opaque, streaming_message_t *sm);
+const char * _htsp_get_subscription_status(int smcode);
 
 /**
  *
@@ -663,7 +664,7 @@ static htsmsg_t *
 htsp_build_dvrentry(dvr_entry_t *de, const char *method)
 {
   htsmsg_t *out = htsmsg_create_map();
-  const char *s = NULL, *error = NULL;
+  const char *s = NULL, *error = NULL, *subscriptionError = NULL;
   const char *p;
 
   htsmsg_add_u32(out, "id", idnode_get_short_uuid(&de->de_id));
@@ -708,8 +709,11 @@ htsp_build_dvrentry(dvr_entry_t *de, const char *method)
   case DVR_RECORDING:
     s = "recording";
     if (de->de_rec_state == DVR_RS_ERROR ||
-       (de->de_rec_state == DVR_RS_PENDING && de->de_last_error != SM_CODE_OK))
+       (de->de_rec_state == DVR_RS_PENDING && de->de_last_error))
+    {
       error = streaming_code2txt(de->de_last_error);
+      subscriptionError = _htsp_get_subscription_status(de->de_last_error);
+    }
     break;
   case DVR_COMPLETED:
     s = "completed";
@@ -729,6 +733,8 @@ htsp_build_dvrentry(dvr_entry_t *de, const char *method)
   htsmsg_add_str(out, "state", s);
   if(error)
     htsmsg_add_str(out, "error", error);
+  if (subscriptionError)
+    htsmsg_add_str(out, "subscriptionError", subscriptionError);
   if (de->de_errors)
     htsmsg_add_u32(out, "streamErrors", de->de_errors);
   if (de->de_data_errors)
@@ -3445,6 +3451,7 @@ htsp_subscription_start(htsp_subscription_t *hs, const streaming_start_t *ss)
   if(si->si_network ) htsmsg_add_str(sourceinfo, "network",  si->si_network );
   if(si->si_provider) htsmsg_add_str(sourceinfo, "provider", si->si_provider);
   if(si->si_service ) htsmsg_add_str(sourceinfo, "service",  si->si_service );
+  if(si->si_satpos  ) htsmsg_add_str(sourceinfo, "satpos",   si->si_satpos  );
   
   htsmsg_add_msg(m, "sourceinfo", sourceinfo);
  
@@ -3457,7 +3464,7 @@ htsp_subscription_start(htsp_subscription_t *hs, const streaming_start_t *ss)
  * Send a 'subscriptionStop' stop
  */
 static void
-htsp_subscription_stop(htsp_subscription_t *hs, const char *err)
+htsp_subscription_stop(htsp_subscription_t *hs, const char *err, const char *subscriptionErr)
 {
   htsmsg_t *m = htsmsg_create_map();
   htsmsg_add_str(m, "method", "subscriptionStop");
@@ -3467,6 +3474,9 @@ htsp_subscription_stop(htsp_subscription_t *hs, const char *err)
   if(err != NULL)
     htsmsg_add_str(m, "status", err);
 
+  if(subscriptionErr != NULL)
+    htsmsg_add_str(m, "subscriptionError", subscriptionErr);
+
   htsp_send(hs->hs_htsp, m, NULL, &hs->hs_q, 0);
 }
 
@@ -3489,7 +3499,7 @@ htsp_subscription_grace(htsp_subscription_t *hs, int grace)
  * Send a 'subscriptionStatus' message
  */
 static void
-htsp_subscription_status(htsp_subscription_t *hs, const char *err)
+htsp_subscription_status(htsp_subscription_t *hs, const char *err, const char *subscriptionErr)
 {
   htsmsg_t *m = htsmsg_create_map();
   htsmsg_add_str(m, "method", "subscriptionStatus");
@@ -3498,9 +3508,39 @@ htsp_subscription_status(htsp_subscription_t *hs, const char *err)
   if(err != NULL)
     htsmsg_add_str(m, "status", err);
 
+  if(subscriptionErr != NULL)
+    htsmsg_add_str(m, "subscriptionError", subscriptionErr);
+
   htsp_send(hs->hs_htsp, m, NULL, &hs->hs_q, 0);
 }
 
+/**
+ * Convert the SM_CODE to an understandable string
+ */
+const char *
+_htsp_get_subscription_status(int smcode)
+{
+  switch (smcode)
+  {
+  case SM_CODE_NOT_FREE:
+  case SM_CODE_NO_FREE_ADAPTER:
+    return "noFreeAdapter";
+  case SM_CODE_NO_DESCRAMBLER:
+    return "scrambled";
+  case SM_CODE_NO_INPUT:
+  case SM_CODE_BAD_SIGNAL:
+    return "badSignal";
+  case SM_CODE_TUNING_FAILED:
+    return "tuningFailed";
+  case SM_CODE_SUBSCRIPTION_OVERRIDDEN:
+    return "subscriptionOverridden";
+  case SM_CODE_MUX_NOT_ENABLED:
+    return "muxNotEnabled";
+  default:
+    return streaming_code2txt(smcode);
+  }
+}
+
 /**
  *
  */
@@ -3508,9 +3548,9 @@ static void
 htsp_subscription_service_status(htsp_subscription_t *hs, int status)
 {
   if(status & TSS_PACKETS) {
-    htsp_subscription_status(hs, NULL);
+    htsp_subscription_status(hs, NULL, NULL);
   } else if(status & TSS_ERRORS) {
-    htsp_subscription_status(hs, service_tss2text(status));
+    htsp_subscription_status(hs, service_tss2text(status), NULL);
   }
 }
 
@@ -3620,7 +3660,8 @@ htsp_streaming_input(void *opaque, streaming_message_t *sm)
     break;
 
   case SMT_STOP:
-    htsp_subscription_stop(hs, streaming_code2txt(sm->sm_code));
+    htsp_subscription_stop(hs, streaming_code2txt(sm->sm_code),
+        sm->sm_code ? _htsp_get_subscription_status(sm->sm_code) : NULL);
     break;
 
   case SMT_GRACE:
@@ -3636,7 +3677,8 @@ htsp_streaming_input(void *opaque, streaming_message_t *sm)
     break;
 
   case SMT_NOSTART:
-    htsp_subscription_status(hs,  streaming_code2txt(sm->sm_code));
+    htsp_subscription_status(hs,  streaming_code2txt(sm->sm_code),
+        sm->sm_code ? _htsp_get_subscription_status(sm->sm_code) : NULL);
     break;
 
   case SMT_MPEGTS:
index 9867e368e9ad91ea49235750e88b3770976d9621..5db074a9a6972c9de69b5d1713a2ab4223992d83 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  tvheadend, HTSP interface
- *  Copyright (C) 2007 Andreas Öman
+ *  Copyright (C) 2007 Andreas man
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
index eca45a7187b0d85d32d65005117e5561bac32507..d43423d4fe0922221414b58810712085ff4a3bf4 100644 (file)
@@ -406,6 +406,11 @@ mpegts_service_setsourceinfo(service_t *t, source_info_t *si)
 
   if(s->s_dvb_svcname != NULL)
     si->si_service = strdup(s->s_dvb_svcname);
+
+  if(m->mm_network != NULL && m->mm_network->mn_satpos != INT_MAX) {
+    dvb_sat_position_to_str(m->mm_network->mn_satpos, buf, sizeof(buf));
+    si->si_satpos = strdup(buf);
+  }
 }
 
 /*
index 7bd0c8c3371989257f3457c159f97b6986e77785..0a01c59cda37ea68f9a0645ec37b7ba5620831ff 100644 (file)
@@ -111,6 +111,7 @@ typedef struct source_info {
   char *si_device;
   char *si_adapter;
   char *si_network;
+  char *si_satpos;
   char *si_mux;
   char *si_provider;
   char *si_service;