]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
IPTV: mux - add channel number, autonet - channel numbers from
authorJaroslav Kysela <perex@perex.cz>
Tue, 13 Oct 2015 18:54:09 +0000 (20:54 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 13 Oct 2015 18:54:09 +0000 (20:54 +0200)
src/input/mpegts/iptv/iptv.c
src/input/mpegts/iptv/iptv_auto.c
src/input/mpegts/iptv/iptv_mux.c
src/input/mpegts/iptv/iptv_private.h
src/input/mpegts/iptv/iptv_service.c
src/input/mpegts/mpegts_dvb.h
src/input/mpegts/mpegts_service.c

index 95445d1ee12c3bc384c78dc8f1eb9a9bc5d8e623..d5bb165c0cbd2278feaf802b7e676f5d09a5afcf 100644 (file)
@@ -22,6 +22,7 @@
 #include "tcp.h"
 #include "settings.h"
 #include "htsstr.h"
+#include "channels.h"
 
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -559,6 +560,13 @@ const idclass_t iptv_auto_network_class = {
       .name     = N_("URL"),
       .off      = offsetof(iptv_network_t, in_url),
     },
+    {
+      .type     = PT_S64,
+      .intsplit = CHANNEL_SPLIT,
+      .id       = "channel_number",
+      .name     = N_("Channel numbers from"),
+      .off      = offsetof(iptv_network_t, in_channel_number),
+    },
     {
       .type     = PT_U32,
       .id       = "refetch_period",
index 929050fecbcf5d0767c5b87f62c14d0ee84bc0d4..d9b8bb41fa8e94a575a6be9eccf9f3befd8d3dfa 100644 (file)
@@ -20,6 +20,7 @@
 #include "tvheadend.h"
 #include "http.h"
 #include "iptv_private.h"
+#include "channels.h"
 
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -31,7 +32,7 @@ static void
 iptv_auto_network_process_m3u_item(iptv_network_t *in,
                                    const http_arg_list_t *remove_args,
                                    const char *url, const char *name,
-                                   int *total, int *count)
+                                   int64_t chnum, int *total, int *count)
 {
   htsmsg_t *conf;
   mpegts_mux_t *mm;
@@ -50,6 +51,13 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
        strncmp(url, "https://", 8)))
     return;
 
+  if (chnum) {
+    if (chnum % CHANNEL_SPLIT)
+      chnum += *total;
+    else
+      chnum += (int64_t)*total * CHANNEL_SPLIT;
+  }
+
   memset(&u, 0, sizeof(u));
   if (urlparse(url, &u))
     return;
@@ -102,6 +110,10 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
         im->mm_iptv_svcname = name ? strdup(name) : NULL;
         change = 1;
       }
+      if (im->mm_iptv_chnum != chnum) {
+        im->mm_iptv_chnum = chnum;
+        change = 1;
+      }
       if (change)
         idnode_notify_changed(&im->mm_id);
       (*total)++;
@@ -129,7 +141,8 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
  */
 static int
 iptv_auto_network_process_m3u(iptv_network_t *in, char *data,
-                              http_arg_list_t *remove_args)
+                              http_arg_list_t *remove_args,
+                              int64_t chnum)
 {
   char *url, *name = NULL;
   int total = 0, count = 0;
@@ -156,7 +169,8 @@ iptv_auto_network_process_m3u(iptv_network_t *in, char *data,
     while (*data && *data != '\n') data++;
     if (*data) { *data = '\0'; data++; }
     if (*url)
-      iptv_auto_network_process_m3u_item(in, remove_args, url, name, &total, &count);
+      iptv_auto_network_process_m3u_item(in, remove_args, url, name,
+                                         chnum, &total, &count);
   }
 
   if (total == 0)
@@ -195,7 +209,7 @@ iptv_auto_network_process(iptv_network_t *in, char *data, size_t len)
   while (*data && *data <= ' ') data++;
 
   if (!strncmp(data, "#EXTM3U", 7))
-    r = iptv_auto_network_process_m3u(in, data, &remove_args);
+    r = iptv_auto_network_process_m3u(in, data, &remove_args, in->in_channel_number);
 
   if (r == 0) {
     count = 0;
index 7d4cc921060ad28d8d5250d9dea225270a7e306b..4a90d017e86fa83db2d8e787a739febf32486e8f 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "iptv_private.h"
 #include "settings.h"
+#include "channels.h"
 
 /*
  * Class
@@ -153,6 +154,13 @@ const idclass_t iptv_mux_class =
       .name     = N_("Mux Name"),
       .off      = offsetof(iptv_mux_t, mm_iptv_muxname),
     },
+    {
+      .type     = PT_S64,
+      .intsplit = CHANNEL_SPLIT,
+      .id       = "channel_number",
+      .name     = N_("Channel number"),
+      .off      = offsetof(iptv_mux_t, mm_iptv_chnum),
+    },
     {
       .type     = PT_STR,
       .id       = "iptv_sname",
index ee8ad231fb05cba81a59d3e6892e08724e747f5a..1af8fe38668858b288ae4ff1b70837aa84f6ab5b 100644 (file)
@@ -82,6 +82,7 @@ struct iptv_network
   uint32_t in_max_timeout;
 
   char    *in_url;
+  int64_t  in_channel_number;
   uint32_t in_refetch_period;
   int      in_ssl_peer_verify;
   char    *in_remove_args;
@@ -112,6 +113,7 @@ struct iptv_mux
 
   char                 *mm_iptv_muxname;
   char                 *mm_iptv_svcname;
+  int64_t               mm_iptv_chnum;
 
   int                   mm_iptv_respawn;
   time_t                mm_iptv_respawn_last;
index b274f19c4e6563786a6760cf5a9832cce6d4ea67..19e1d61e5c0f63a76642227c605dced74ee286f6 100644 (file)
@@ -67,6 +67,16 @@ iptv_service_channel_name ( service_t *s )
   return is->s_dvb_svcname;
 }
 
+static int64_t
+iptv_service_channel_number ( service_t *s )
+{
+  iptv_service_t   *is = (iptv_service_t *)s;
+  iptv_mux_t       *im = (iptv_mux_t *)is->s_dvb_mux;
+  if (im->mm_iptv_chnum)
+    return im->mm_iptv_chnum;
+  return mpegts_service_channel_number(s);
+}
+
 /*
  * Create
  */
@@ -80,9 +90,10 @@ iptv_service_create0
                            &mpegts_service_class, uuid,
                            (mpegts_mux_t*)im, sid, pmt, conf);
   
-  is->s_config_save  = iptv_service_config_save;
-  is->s_delete       = iptv_service_delete;
-  is->s_channel_name = iptv_service_channel_name;
+  is->s_config_save    = iptv_service_config_save;
+  is->s_delete         = iptv_service_delete;
+  is->s_channel_name   = iptv_service_channel_name;
+  is->s_channel_number = iptv_service_channel_number;
 
   /* Set default service name */
   if (!is->s_dvb_svcname || !*is->s_dvb_svcname)
index f786ecc45a64e985100169bd8a31484e5eecc04b..a780a07309ea3707c800f96c50cdfa0bcffcdaf6 100644 (file)
@@ -78,4 +78,9 @@ dvb_mux_t *dvb_mux_create0
 #define dvb_mux_create1(n, u, c)\
   dvb_mux_create0(n, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE, NULL, u, c)
 
+/*
+ *
+ */
+int64_t mpegts_service_channel_number ( service_t *s );
+
 #endif /* __TVH_MPEGTS_DVB_H__ */
index c97a1702f4c716dad9ab5bbbaf8dc38623698970..bd145dc538d8c84a2a7471628d9679b02548954f 100644 (file)
@@ -439,7 +439,7 @@ mpegts_service_grace_period(service_t *t)
 /*
  * Channel number
  */
-static int64_t
+int64_t
 mpegts_service_channel_number ( service_t *s )
 {
   mpegts_service_t *ms = (mpegts_service_t*)s;