iptv pipe: fix url / arg parsing bug, add ${service_name} substitution

This commit is contained in:
Jaroslav Kysela 2014-11-17 14:36:40 +01:00
parent 7548fc5c3e
commit c4f30d1e51
3 changed files with 18 additions and 5 deletions

View 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>

View 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;

View 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);