]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Add service type override.
authorspdfrk <spdfrk123456@gmail.com>
Mon, 22 Feb 2016 20:19:47 +0000 (21:19 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 24 Feb 2016 08:08:03 +0000 (09:08 +0100)
Some providers don't set the service type correctly. This causes a problem when, for instance,
the client doesn't know if it's Radio or TV and chooses the wrong one.

This override will let the user set the service type.

src/service.c
src/service.h

index a3ef64490c302d1d842edcc2275ce30d7cf9f93c..cc03d04189b7ca4f8ff69e07ad94771002fab6e2 100644 (file)
@@ -211,6 +211,15 @@ const idclass_t service_class = {
       .get      = service_class_caid_get,
       .opts     = PO_NOSAVE | PO_RDONLY | PO_HIDDEN | PO_EXPERT,
     },
+    {
+      .type     = PT_INT,
+      .id       = "s_type_user",
+      .name     = N_("Type override"),
+      .desc     = N_("Service type override. This value will override the "
+                     "service type provided by the stream."),
+      .off      = offsetof(service_t, s_type_user),
+      .opts     = PO_ADVANCED
+    },
     {}
   }
 };
@@ -938,6 +947,7 @@ service_create0
   pthread_mutex_init(&t->s_stream_mutex, NULL);
   pthread_cond_init(&t->s_tss_cond, NULL);
   t->s_type = service_type;
+  t->s_type_user = -1;
   t->s_source_type = source_type;
   t->s_refcount = 1;
   t->s_enabled = 1;
@@ -1134,9 +1144,14 @@ service_has_audio_or_video(service_t *t)
 int
 service_is_sdtv(service_t *t)
 {
-  if (t->s_servicetype == ST_SDTV)
+  char s_type;
+  if(t->s_type_user > -1)
+    s_type = t->s_type_user;
+  else
+    s_type = t->s_servicetype;
+  if (s_type == ST_SDTV)
     return 1;
-  else if (t->s_servicetype == ST_NONE) {
+  else if (s_type == ST_NONE) {
     elementary_stream_t *st;
     TAILQ_FOREACH(st, &t->s_components, es_link)
       if (SCT_ISVIDEO(st->es_type) && st->es_height < 720)
@@ -1148,9 +1163,14 @@ service_is_sdtv(service_t *t)
 int
 service_is_hdtv(service_t *t)
 {
-  if (t->s_servicetype == ST_HDTV)
+  char s_type;
+  if(t->s_type_user > -1)
+    s_type = t->s_type_user;
+  else
+    s_type = t->s_servicetype;
+  if (s_type == ST_HDTV)
     return 1;
-  else if (t->s_servicetype == ST_NONE) {
+  else if (s_type == ST_NONE) {
     elementary_stream_t *st;
     TAILQ_FOREACH(st, &t->s_components, es_link)
       if (SCT_ISVIDEO(st->es_type) && st->es_height >= 720)
@@ -1166,9 +1186,14 @@ int
 service_is_radio(service_t *t)
 {
   int ret = 0;
-  if (t->s_servicetype == ST_RADIO)
+  char s_type;
+  if(t->s_type_user > -1)
+    s_type = t->s_type_user;
+  else
+    s_type = t->s_servicetype;
+  if (s_type == ST_RADIO)
     return 1;
-  else if (t->s_servicetype == ST_NONE) {
+  else if (s_type == ST_NONE) {
     elementary_stream_t *st;
     TAILQ_FOREACH(st, &t->s_components, es_link) {
       if (SCT_ISVIDEO(st->es_type))
index 8783823a3af8aa5640b46137f529746699f1f54c..c721ccd123f2c395bf25d7a81bf4e60f87c14c83 100644 (file)
@@ -303,6 +303,7 @@ typedef struct service {
   int s_enabled;
   int s_auto;
   int s_prio;
+  int s_type_user;
 
   LIST_ENTRY(service) s_active_link;