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,10 +55,21 @@ iptv_pipe_start ( iptv_mux_t *im, const char *_raw, const url_t *url )
while (*s && *s != ' ')
s++;
if (f != s) {
if (*s) {
*(char *)s = '\0';
argv[i++] = f;
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;
}
}
argv[i] = NULL;