IPTV: create sane mux name without username/password in URL
This commit is contained in:
parent
47bb0efca7
commit
294fe5eefa
2 changed files with 52 additions and 2 deletions
|
@ -26,6 +26,54 @@
|
|||
extern const idclass_t mpegts_mux_class;
|
||||
extern const idclass_t mpegts_mux_instance_class;
|
||||
|
||||
static int
|
||||
iptv_mux_url_set ( void *p, const void *v )
|
||||
{
|
||||
iptv_mux_t *im = p;
|
||||
const char *str = v;
|
||||
char *buf, port[16] = "";
|
||||
size_t len;
|
||||
url_t url;
|
||||
|
||||
if (strcmp(str, im->mm_iptv_url ?: "")) {
|
||||
if (str == NULL || *str == '\0') {
|
||||
free(im->mm_iptv_url);
|
||||
free(im->mm_iptv_url_sane);
|
||||
im->mm_iptv_url = NULL;
|
||||
im->mm_iptv_url_sane = NULL;
|
||||
return 1;
|
||||
}
|
||||
memset(&url, 0, sizeof(url));
|
||||
if (!urlparse(str ?: "", &url)) {
|
||||
free(im->mm_iptv_url);
|
||||
free(im->mm_iptv_url_sane);
|
||||
im->mm_iptv_url = str ? strdup(str) : NULL;
|
||||
if (im->mm_iptv_url) {
|
||||
len = strlen(url.scheme) + 3 +
|
||||
strlen(url.host) + 1 +
|
||||
/* port */ 16 +
|
||||
strlen(url.path) + 1 +
|
||||
strlen(url.query) + 2;
|
||||
buf = alloca(len);
|
||||
if (url.port)
|
||||
snprintf(port, sizeof(port), "%d", url.port);
|
||||
snprintf(buf, len, "%s%s%s%s%s%s",
|
||||
url.scheme ?: "", url.scheme ? "://" : "",
|
||||
url.host ?: "",
|
||||
url.path ?: "", url.query ? "?" : "",
|
||||
url.query);
|
||||
im->mm_iptv_url_sane = strdup(buf);
|
||||
} else {
|
||||
im->mm_iptv_url_sane = NULL;
|
||||
}
|
||||
urlreset(&url);
|
||||
return 1;
|
||||
}
|
||||
urlreset(&url);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const idclass_t iptv_mux_class =
|
||||
{
|
||||
.ic_super = &mpegts_mux_class,
|
||||
|
@ -37,6 +85,7 @@ const idclass_t iptv_mux_class =
|
|||
.id = "iptv_url",
|
||||
.name = "URL",
|
||||
.off = offsetof(iptv_mux_t, mm_iptv_url),
|
||||
.set = iptv_mux_url_set,
|
||||
},
|
||||
{
|
||||
.type = PT_STR,
|
||||
|
@ -93,8 +142,8 @@ static void
|
|||
iptv_mux_display_name ( mpegts_mux_t *mm, char *buf, size_t len )
|
||||
{
|
||||
iptv_mux_t *im = (iptv_mux_t*)mm;
|
||||
if(im->mm_iptv_url)
|
||||
strncpy(buf, im->mm_iptv_url, len);
|
||||
if(im->mm_iptv_url_sane)
|
||||
strncpy(buf, im->mm_iptv_url_sane, len);
|
||||
else
|
||||
*buf = 0;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ struct iptv_mux
|
|||
int mm_iptv_fd;
|
||||
udp_connection_t *mm_iptv_connection;
|
||||
char *mm_iptv_url;
|
||||
char *mm_iptv_url_sane;
|
||||
char *mm_iptv_interface;
|
||||
|
||||
int mm_iptv_atsc;
|
||||
|
|
Loading…
Add table
Reference in a new issue