]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
IPTV: Add EPG name (id) support to muxes
authorJaroslav Kysela <perex@perex.cz>
Wed, 14 Oct 2015 13:53:30 +0000 (15:53 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 14 Oct 2015 13:53:35 +0000 (15:53 +0200)
src/channels.c
src/channels.h
src/epggrab/channel.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/service.c
src/service.h

index be5d984d6cb60e15e2019454e4f80f460976f6bd..f2b1ea812a5a9b1960e0b3997f377b14908692d0 100644 (file)
@@ -746,6 +746,17 @@ int channel_set_icon ( channel_t *ch, const char *icon )
   return save;
 }
 
+const char *
+channel_get_epgid ( channel_t *ch )
+{
+  const char *s;
+  idnode_list_mapping_t *ilm;
+  LIST_FOREACH(ilm, &ch->ch_services, ilm_in2_link)
+    if ((s = service_get_channel_epgid((service_t *)ilm->ilm_in1)))
+      return s;
+  return channel_get_name(ch);
+}
+
 /* **************************************************************************
  * Creation/Deletion
  * *************************************************************************/
index d77ac75c5a66046ab5e9c768329c78c1740711b6..e542b714a90d064059fe6ce5967d52e9a788d97e 100644 (file)
@@ -175,6 +175,8 @@ int channel_set_number ( channel_t *ch, uint32_t major, uint32_t minor );
 const char *channel_get_icon ( channel_t *ch );
 int channel_set_icon ( channel_t *ch, const char *icon );
 
+const char *channel_get_epgid ( channel_t *ch );
+
 #define channel_get_suuid(ch) idnode_uuid_as_sstr(&(ch)->ch_id)
 
 #define channel_get_id(ch)    idnode_get_short_uuid((&(ch)->ch_id))
index 3ce8dc2f8cc667cbe47d705f279760cf3218a677..4aac0cb7ace3a4946b09160994ce3bd241d97f0c 100644 (file)
@@ -39,7 +39,7 @@ int epggrab_channel_match ( epggrab_channel_t *ec, channel_t *ch )
   if (!ec || !ch || !ch->ch_epgauto || !ch->ch_enabled) return 0;
   if (LIST_FIRST(&ec->channels)) return 0; // ignore already paired
 
-  if (ec->name && !strcmp(ec->name, channel_get_name(ch))) return 1;
+  if (ec->name && !strcmp(ec->name, channel_get_epgid(ch))) return 1;
   int64_t number = channel_get_number(ch);
   if ((ec->major || ec->minor) && ec->major == channel_get_major(number) && ec->minor == channel_get_minor(number)) return 1;
   return 0;
index dcf573544405bf9f1db8fed8913f3e370b0820a6..aaac38fca71fff208f9020af423dea80090f9183 100644 (file)
@@ -58,7 +58,7 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
                                    const char *last_url,
                                    const http_arg_list_t *remove_args,
                                    const char *url, const char *name,
-                                   const char *logo,
+                                   const char *logo, const char *epgid,
                                    int64_t chnum, int *total, int *count)
 {
   htsmsg_t *conf;
@@ -158,6 +158,11 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
         im->mm_iptv_icon = logo ? strdup(logo) : NULL;
         change = 1;
       }
+      if (strcmp(im->mm_iptv_epgid ?: "", epgid ?: "")) {
+        free(im->mm_iptv_epgid);
+        im->mm_iptv_epgid = epgid ? strdup(epgid) : NULL;
+        change = 1;
+      }
       if (change)
         idnode_notify_changed(&im->mm_id);
       (*total)++;
@@ -192,7 +197,7 @@ iptv_auto_network_process_m3u(iptv_network_t *in, char *data,
                               http_arg_list_t *remove_args,
                               int64_t chnum)
 {
-  char *url, *name = NULL, *logo = NULL;
+  char *url, *name = NULL, *logo = NULL, *epgid = NULL;
   int total = 0, count = 0;
 
   while (*data && *data != '\n') data++;
@@ -201,12 +206,15 @@ iptv_auto_network_process_m3u(iptv_network_t *in, char *data,
     if (strncmp(data, "#EXTINF:", 8) == 0) {
       name = NULL;
       logo = NULL;
+      epgid = NULL;
       data += 8;
       while (1) {
         while (*data && *data <= ' ') data++;
         if (*data == ',') break;
         if (strncmp(data, "tvg-logo=", 9) == 0)
           logo = get_m3u_str(data + 9, &data);
+        else if (strncmp(data, "tvg-id=", 7) == 0)
+          epgid = get_m3u_str(data + 7, &data);
         else if (strncmp(data, "logo=", 5) == 0)
           logo = get_m3u_str(data + 5, &data);
         else {
@@ -230,7 +238,7 @@ iptv_auto_network_process_m3u(iptv_network_t *in, char *data,
     if (*data) { *data = '\0'; data++; }
     if (*url)
       iptv_auto_network_process_m3u_item(in, last_url, remove_args,
-                                         url, name, logo,
+                                         url, name, logo, epgid,
                                          chnum, &total, &count);
   }
 
index 0004e22efd5bf43efb8f3aa3170f3709033767f2..ff706e63900493bbb354b53cb34e8dcdb0928d41 100644 (file)
@@ -169,18 +169,24 @@ const idclass_t iptv_mux_class =
       .name     = N_("Channel number"),
       .off      = offsetof(iptv_mux_t, mm_iptv_chnum),
     },
-    {
-      .type     = PT_STR,
-      .id       = "iptv_icon",
-      .name     = N_("Icon URL"),
-      .off      = offsetof(iptv_mux_t, mm_iptv_icon),
-    },
     {
       .type     = PT_STR,
       .id       = "iptv_sname",
       .name     = N_("Service Name"),
       .off      = offsetof(iptv_mux_t, mm_iptv_svcname),
     },
+    {
+      .type     = PT_STR,
+      .id       = "iptv_epgid",
+      .name     = N_("EPG Name"),
+      .off      = offsetof(iptv_mux_t, mm_iptv_epgid),
+    },
+    {
+      .type     = PT_STR,
+      .id       = "iptv_icon",
+      .name     = N_("Icon URL"),
+      .off      = offsetof(iptv_mux_t, mm_iptv_icon),
+    },
     {
       .type     = PT_BOOL,
       .id       = "iptv_respawn",
@@ -247,6 +253,7 @@ iptv_mux_delete ( mpegts_mux_t *mm, int delconf )
   free(im->mm_iptv_svcname);
   free(im->mm_iptv_env);
   free(im->mm_iptv_icon);
+  free(im->mm_iptv_epgid);
   mpegts_mux_delete(mm, delconf);
   free(url);
   free(url_sane);
index 3882eb2aec8cb56d52d1a83cf1046246b167e1a4..3803e8ce22e8b310275229846ed93f6954eff89d 100644 (file)
@@ -118,6 +118,7 @@ struct iptv_mux
   char                 *mm_iptv_svcname;
   int64_t               mm_iptv_chnum;
   char                 *mm_iptv_icon;
+  char                 *mm_iptv_epgid;
 
   int                   mm_iptv_respawn;
   time_t                mm_iptv_respawn_last;
index e19f813a0151566e71277a6613a4736bc620adb5..2b42582a2a517c2ad5be9446aedcb21167453126 100644 (file)
@@ -100,6 +100,14 @@ iptv_service_channel_icon ( service_t *s )
   return NULL;
 }
 
+static const char *
+iptv_service_channel_epgid ( service_t *s )
+{
+  iptv_service_t   *is = (iptv_service_t *)s;
+  iptv_mux_t       *im = (iptv_mux_t *)is->s_dvb_mux;
+  return im->mm_iptv_epgid;
+}
+
 /*
  * Create
  */
@@ -118,6 +126,7 @@ iptv_service_create0
   is->s_channel_name   = iptv_service_channel_name;
   is->s_channel_number = iptv_service_channel_number;
   is->s_channel_icon   = iptv_service_channel_icon;
+  is->s_channel_epgid  = iptv_service_channel_epgid;
 
   /* Set default service name */
   if (!is->s_dvb_svcname || !*is->s_dvb_svcname)
index 74cd125e13ca0c378d65d30847b7b611281dc77f..b1e13ce84868bbb5cf7ece18181b889b775ac184 100644 (file)
@@ -1651,6 +1651,16 @@ service_get_channel_icon ( service_t *s )
   return r;
 }
 
+/*
+ * Get EPG ID for channel from service
+ */
+const char *
+service_get_channel_epgid ( service_t *s )
+{
+  if (s->s_channel_epgid) return s->s_channel_epgid(s);
+  return NULL;
+}
+
 /*
  *
  */
index 6e98ef024b4a465e2b5945bf1a622f7b30862a53..dcaf590c212c6f4e2cab1e8acf0fcfdcbcf09563 100644 (file)
@@ -317,6 +317,7 @@ typedef struct service {
    */
   int64_t     (*s_channel_number) (struct service *);
   const char *(*s_channel_name)   (struct service *);
+  const char *(*s_channel_epgid)  (struct service *);
   const char *(*s_provider_name)  (struct service *);
   const char *(*s_channel_icon)   (struct service *);
   void        (*s_mapped)         (struct service *);
@@ -606,6 +607,7 @@ const char *service_get_channel_name (service_t *s);
 const char *service_get_full_channel_name (service_t *s);
 int64_t     service_get_channel_number (service_t *s);
 const char *service_get_channel_icon (service_t *s);
+const char *service_get_channel_epgid (service_t *s);
 
 void service_mapped (service_t *s);