Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
IPTV: Add automatic network (m3u)
  • Loading branch information
perexg committed Oct 13, 2015
1 parent 7d9cb9b commit 68b9892
Show file tree
Hide file tree
Showing 6 changed files with 398 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -364,7 +364,8 @@ SRCS-IPTV = \
src/input/mpegts/iptv/iptv_udp.c \
src/input/mpegts/iptv/iptv_rtsp.c \
src/input/mpegts/iptv/iptv_rtcp.c \
src/input/mpegts/iptv/iptv_pipe.c
src/input/mpegts/iptv/iptv_pipe.c \
src/input/mpegts/iptv/iptv_auto.c
SRCS-${CONFIG_IPTV} += $(SRCS-IPTV)
I18N-C += $(SRCS-IPTV)

Expand Down
3 changes: 1 addition & 2 deletions src/httpc.c
Expand Up @@ -1414,7 +1414,7 @@ http_client_connect
void
http_client_register( http_client_t *hc )
{
assert(hc->hc_data_received || hc->hc_conn_closed);
assert(hc->hc_data_received || hc->hc_conn_closed || hc->hc_data_complete);
assert(hc->hc_efd == NULL);

pthread_mutex_lock(&http_lock);
Expand Down Expand Up @@ -1507,7 +1507,6 @@ http_client_done ( void )
http_running = 0;
tvh_write(http_pipe.wr, "", 1);
pthread_join(http_client_tid, NULL);
assert(TAILQ_FIRST(&http_clients) == NULL);
tvh_pipe_close(&http_pipe);
tvhpoll_destroy(http_poll);
free(http_user_agent);
Expand Down
50 changes: 44 additions & 6 deletions src/input/mpegts/iptv/iptv.c
Expand Up @@ -485,6 +485,9 @@ iptv_network_class_delete ( idnode_t *in )
{
mpegts_network_t *mn = (mpegts_network_t*)in;

if (in->in_class == &iptv_auto_network_class)
iptv_auto_network_done((iptv_network_t *)in);

/* Remove config */
hts_settings_remove("input/iptv/networks/%s",
idnode_uuid_as_sstr(in));
Expand Down Expand Up @@ -541,6 +544,34 @@ const idclass_t iptv_network_class = {
}
};

const idclass_t iptv_auto_network_class = {
.ic_super = &iptv_network_class,
.ic_class = "iptv_auto_network",
.ic_caption = N_("IPTV Automatic Network"),
.ic_properties = (const property_t[]){
{
.type = PT_STR,
.id = "url",
.name = N_("URL"),
.off = offsetof(iptv_network_t, in_url),
},
{
.type = PT_U32,
.id = "refetch_period",
.name = N_("Re-fetch period (mins)"),
.off = offsetof(iptv_network_t, in_refetch_period),
.def.i = 60,
},
{
.type = PT_BOOL,
.id = "ssl_peer_verify",
.name = N_("SSL verify peer"),
.off = offsetof(iptv_network_t, in_ssl_peer_verify),
},
{}
}
};

static mpegts_mux_t *
iptv_network_create_mux2
( mpegts_network_t *mn, htsmsg_t *conf )
Expand Down Expand Up @@ -575,16 +606,15 @@ iptv_network_config_save ( mpegts_network_t *mn )

iptv_network_t *
iptv_network_create0
( const char *uuid, htsmsg_t *conf )
( const char *uuid, htsmsg_t *conf, const idclass_t *idc )
{
iptv_network_t *in = calloc(1, sizeof(*in));
htsmsg_t *c;

/* Init Network */
in->in_priority = 1;
in->in_streaming_priority = 1;
if (!mpegts_network_create0((mpegts_network_t *)in,
&iptv_network_class,
if (!mpegts_network_create0((mpegts_network_t *)in, idc,
uuid, NULL, conf)) {
free(in);
return NULL;
Expand Down Expand Up @@ -614,6 +644,9 @@ iptv_network_create0
}
htsmsg_destroy(c);
}

if (idc == &iptv_auto_network_class)
iptv_auto_network_init(in);

return in;
}
Expand All @@ -622,7 +655,7 @@ static mpegts_network_t *
iptv_network_builder
( const idclass_t *idc, htsmsg_t *conf )
{
return (mpegts_network_t*)iptv_network_create0(NULL, conf);
return (mpegts_network_t*)iptv_network_create0(NULL, conf, idc);
}

/* **************************************************************************
Expand All @@ -635,9 +668,11 @@ iptv_network_init ( void )
htsmsg_t *c, *e;
htsmsg_field_t *f;

/* Register builder */
/* Register builders */
mpegts_network_register_builder(&iptv_network_class,
iptv_network_builder);
mpegts_network_register_builder(&iptv_auto_network_class,
iptv_network_builder);

/* Load settings */
if (!(c = hts_settings_load_r(1, "input/iptv/networks")))
Expand All @@ -646,7 +681,10 @@ iptv_network_init ( void )
HTSMSG_FOREACH(f, c) {
if (!(e = htsmsg_get_map_by_field(f))) continue;
if (!(e = htsmsg_get_map(e, "config"))) continue;
iptv_network_create0(f->hmf_name, e);
if (htsmsg_get_str(e, "url"))
iptv_network_create0(f->hmf_name, e, &iptv_auto_network_class);
else
iptv_network_create0(f->hmf_name, e, &iptv_network_class);
}
htsmsg_destroy(c);
}
Expand Down

0 comments on commit 68b9892

Please sign in to comment.