]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
iptv pipe: fix url / arg parsing bug, add ${service_name} substitution
authorJaroslav Kysela <perex@perex.cz>
Mon, 17 Nov 2014 13:36:40 +0000 (14:36 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 17 Nov 2014 13:57:35 +0000 (14:57 +0100)
docs/html/config_muxes.html
src/input/mpegts/iptv/iptv_pipe.c
src/spawn.c

index 3c616b23c66221096d6086e3a26ef2c26893e180..fb23d2a11e94dfcc3c4273e4dc41c4b701ba82c7 100644 (file)
@@ -94,7 +94,9 @@
                                    directories specified by PATH.
                                    Additional arguments may be separated
                                    using spaces. A raw MPEG-TS stream is
-                                   expected.
+                                   expected. The string ${service_name}
+                                   is substituted with the service name
+                                   field contents.
 
                        </dl>
                 
index 2c6766403d9d4b652e4661ef05aae9f555cb8c24..5c0484f8c3e959c9b1420ce2b4a87d26a7bca0b7 100644 (file)
@@ -33,7 +33,7 @@
 static int
 iptv_pipe_start ( iptv_mux_t *im, const char *_raw, const url_t *url )
 {
-  char *argv[32], *f, *raw, *s;
+  char *argv[32], *f, *raw, *s, *p, *a;
   int i = 1, rd;
 
   if (strncmp(_raw, "pipe://", 7))
@@ -55,9 +55,20 @@ iptv_pipe_start ( iptv_mux_t *im, const char *_raw, const url_t *url )
     while (*s && *s != ' ')
       s++;
     if (f != s) {
-      *(char *)s = '\0';
+      if (*s) {
+        *(char *)s = '\0';
+        s++;
+      }
+      p = strstr(f, "${service_name}");
+      if (p) {
+        a = alloca(strlen(f) + strlen(im->mm_iptv_svcname ?: ""));
+        *p = '\0';
+        strcpy(a, f);
+        strcat(a, im->mm_iptv_svcname ?: "");
+        strcat(a, p + 15);
+        f = a;
+      }
       argv[i++] = f;
-      s++;
     }
   }
   argv[i] = NULL;
index 419fa459f262e18e513ca95e88267310e20c2c9a..a770351f65451450c7eb254aa0df2644e51b9e9c 100644 (file)
@@ -381,7 +381,7 @@ spawn_and_give_stdout(const char *prog, char *argv[], int *rd, int redir_stderr)
     prog = bin;
   }
 
-  if(!argv) argv = (void *)local_argv;
+  if (!argv) argv = (void *)local_argv;
   if (!argv[0]) argv[0] = (char*)prog;
 
   pthread_mutex_lock(&fork_lock);