From: Jaroslav Kysela Date: Wed, 5 Apr 2017 07:05:37 +0000 (+0200) Subject: profile: add descrambling timeout, add switch to another service on error X-Git-Tag: v4.2.1~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f73412467b1afba0a2058a98268b47240a58430;p=thirdparty%2Ftvheadend.git profile: add descrambling timeout, add switch to another service on error --- diff --git a/src/profile.c b/src/profile.c index f022a51cd..85d015ad4 100644 --- a/src/profile.c +++ b/src/profile.c @@ -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", diff --git a/src/profile.h b/src/profile.h index b5f22f6c3..cd518c52e 100644 --- a/src/profile.h +++ b/src/profile.h @@ -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); diff --git a/src/service.c b/src/service.c index 6d1fd8d6c..da036a8cf 100644 --- a/src/service.c +++ b/src/service.c @@ -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) { diff --git a/src/subscriptions.c b/src/subscriptions.c index a39fe2e32..56162477b 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -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; diff --git a/src/subscriptions.h b/src/subscriptions.h index 622495a92..4915841c8 100644 --- a/src/subscriptions.h +++ b/src/subscriptions.h @@ -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;