]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
profile: add descrambling timeout, add switch to another service on error
authorJaroslav Kysela <perex@perex.cz>
Wed, 5 Apr 2017 07:05:37 +0000 (09:05 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 5 Apr 2017 07:05:37 +0000 (09:05 +0200)
src/profile.c
src/profile.h
src/service.c
src/subscriptions.c
src/subscriptions.h

index f022a51cd22011bd67697eab9e80f85b7b2a5d10..85d015ad46981d98853b4d951f41f6566944b72d 100644 (file)
@@ -395,6 +395,29 @@ const idclass_t profile_class =
       .def.i    = 1,
       .group    = 1
     },
+    {
+      .type     = PT_INT,
+      .id       = "catimeout",
+      .name     = N_("Descrambling timeout (ms)"),
+      .desc     = N_("Check the descrambling status after this timeout."),
+      .off      = offsetof(profile_t, pro_timeout),
+      .opts     = PO_EXPERT,
+      .def.i    = 2000,
+      .group    = 1
+    },
+    {
+      .type     = PT_BOOL,
+      .id       = "swservice",
+      .name     = N_("Switch to another service"),
+      .desc     = N_("If something fails, try to switch to a different "
+                     "service on another network. Do not try to iterate "
+                     "through all inputs/tuners which are capable to "
+                     "receive the service."),
+      .off      = offsetof(profile_t, pro_swservice),
+      .opts     = PO_EXPERT,
+      .def.i    = 1,
+      .group    = 1
+    },
     {
       .type     = PT_INT,
       .id       = "svfilter",
index b5f22f6c3e89e927db4a3dcb9886f237f556661d..cd518c52e76948f8da470c98a252bdb34b5a6567 100644 (file)
@@ -131,6 +131,8 @@ typedef struct profile {
   int pro_timeout;
   int pro_restart;
   int pro_contaccess;
+  int pro_ca_timeout;
+  int pro_swservice;
   int pro_svfilter;
 
   void (*pro_free)(struct profile *pro);
index 6d1fd8d6cac6f690261e030dcda3e601bec2a35c..da036a8cf8af93b5d75eaf8f88f8a89fde39cfd2 100644 (file)
@@ -744,8 +744,15 @@ service_find_instance
   lock_assert(&global_lock);
 
   /* Build list */
-  TAILQ_FOREACH(si, sil, si_link)
+  TAILQ_FOREACH(si, sil, si_link) {
     si->si_mark = 1;
+    if (flags & SUBSCRIPTION_SWSERVICE) {
+      for (next = TAILQ_NEXT(si, si_link); next;
+           next = TAILQ_NEXT(next, si_link))
+        if (si->si_s == next->si_s)
+          next->si_error = si->si_error;
+    }
+  }
 
   r = 0;
   if (ch) {
index a39fe2e32f33c5fc18b6fc2cf9b8530db20cb437..56162477bd6d94316bd3d8ebe5d7899ffbe6502e 100644 (file)
@@ -546,7 +546,8 @@ subscription_input(void *opaque, streaming_message_t *sm)
   th_subscription_t *s = opaque;
 
   /* handle NO_ACCESS condition with some delay */
-  if(sm->sm_code & TSS_NO_ACCESS && s->ths_service_start + sec2mono(2) < mclk())
+  if(sm->sm_code & TSS_NO_ACCESS &&
+     s->ths_service_start + sec2mono(s->ths_ca_timeout) < mclk())
     mask2 |= TSS_NO_ACCESS;
 
   if(subgetstate(s) == SUBSCRIPTION_TESTING_SERVICE) {
@@ -788,8 +789,15 @@ subscription_create
       s->ths_flags |= SUBSCRIPTION_RESTART;
     if (pro->pro_contaccess)
       s->ths_flags |= SUBSCRIPTION_CONTACCESS;
+    if (pro->pro_swservice)
+      s->ths_flags |= SUBSCRIPTION_SWSERVICE;
   }
 
+  if (pro->pro_ca_timeout)
+    s->ths_ca_timeout = ms2mono(MINMAX(pro->pro_ca_timeout, 100, 5000));
+  else
+    s->ths_ca_timeout = sec2mono(2);
+
   time(&s->ths_start);
 
   s->ths_id = ++tally;
index 622495a92db0994291388781b8dbe096330a420f..4915841c8b330a27974bfcb0ae2ba2aa3476c802 100644 (file)
@@ -25,23 +25,24 @@ struct profile_chain;
 
 extern struct th_subscription_list subscriptions;
 
-#define SUBSCRIPTION_NONE       0x000
-#define SUBSCRIPTION_MPEGTS     0x001
-#define SUBSCRIPTION_PACKET     0x002
-#define SUBSCRIPTION_TYPE_MASK  0x00f
-#define SUBSCRIPTION_STREAMING  0x010
-#define SUBSCRIPTION_RESTART    0x020
-#define SUBSCRIPTION_CONTACCESS 0x040
-#define SUBSCRIPTION_ONESHOT    0x080
-#define SUBSCRIPTION_TABLES     0x100
-#define SUBSCRIPTION_MINIMAL    0x200
-#define SUBSCRIPTION_NODESCR    0x400 ///< no decramble
-#define SUBSCRIPTION_EMM        0x800 ///< add EMM PIDs for no descramble subscription
-#define SUBSCRIPTION_INITSCAN  0x1000 ///< for mux subscriptions
-#define SUBSCRIPTION_IDLESCAN  0x2000 ///< for mux subscriptions
-#define SUBSCRIPTION_USERSCAN  0x4000 ///< for mux subscriptions
-#define SUBSCRIPTION_EPG       0x8000 ///< for mux subscriptions
-#define SUBSCRIPTION_HTSP     0x10000
+#define SUBSCRIPTION_NONE        0x000
+#define SUBSCRIPTION_MPEGTS      0x001
+#define SUBSCRIPTION_PACKET      0x002
+#define SUBSCRIPTION_TYPE_MASK   0x00f
+#define SUBSCRIPTION_STREAMING   0x010
+#define SUBSCRIPTION_RESTART     0x020
+#define SUBSCRIPTION_CONTACCESS  0x040
+#define SUBSCRIPTION_ONESHOT     0x080
+#define SUBSCRIPTION_TABLES      0x100
+#define SUBSCRIPTION_MINIMAL     0x200
+#define SUBSCRIPTION_NODESCR     0x400 ///< no decramble
+#define SUBSCRIPTION_EMM         0x800 ///< add EMM PIDs for no descramble subscription
+#define SUBSCRIPTION_INITSCAN   0x1000 ///< for mux subscriptions
+#define SUBSCRIPTION_IDLESCAN   0x2000 ///< for mux subscriptions
+#define SUBSCRIPTION_USERSCAN   0x4000 ///< for mux subscriptions
+#define SUBSCRIPTION_EPG        0x8000 ///< for mux subscriptions
+#define SUBSCRIPTION_HTSP      0x10000
+#define SUBSCRIPTION_SWSERVICE 0x20000
 
 /* Some internal priorities */
 #define SUBSCRIPTION_PRIO_KEEP        1 ///< Keep input rolling
@@ -111,6 +112,7 @@ typedef struct th_subscription {
 
   int ths_flags;
   int ths_timeout;
+  int ths_ca_timeout;
 
   int64_t ths_last_find;
   int ths_last_error;