Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
IPTV: Add EPG name (id) support to muxes
  • Loading branch information
perexg committed Oct 14, 2015
1 parent 85bfb78 commit af1d6c0
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/channels.c
Expand Up @@ -746,6 +746,17 @@ int channel_set_icon ( channel_t *ch, const char *icon )
return save;
}

const char *
channel_get_epgid ( channel_t *ch )
{
const char *s;
idnode_list_mapping_t *ilm;
LIST_FOREACH(ilm, &ch->ch_services, ilm_in2_link)
if ((s = service_get_channel_epgid((service_t *)ilm->ilm_in1)))
return s;
return channel_get_name(ch);
}

/* **************************************************************************
* Creation/Deletion
* *************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions src/channels.h
Expand Up @@ -175,6 +175,8 @@ int channel_set_number ( channel_t *ch, uint32_t major, uint32_t minor );
const char *channel_get_icon ( channel_t *ch );
int channel_set_icon ( channel_t *ch, const char *icon );

const char *channel_get_epgid ( channel_t *ch );

#define channel_get_suuid(ch) idnode_uuid_as_sstr(&(ch)->ch_id)

#define channel_get_id(ch) idnode_get_short_uuid((&(ch)->ch_id))
Expand Down
2 changes: 1 addition & 1 deletion src/epggrab/channel.c
Expand Up @@ -39,7 +39,7 @@ int epggrab_channel_match ( epggrab_channel_t *ec, channel_t *ch )
if (!ec || !ch || !ch->ch_epgauto || !ch->ch_enabled) return 0;
if (LIST_FIRST(&ec->channels)) return 0; // ignore already paired

if (ec->name && !strcmp(ec->name, channel_get_name(ch))) return 1;
if (ec->name && !strcmp(ec->name, channel_get_epgid(ch))) return 1;
int64_t number = channel_get_number(ch);
if ((ec->major || ec->minor) && ec->major == channel_get_major(number) && ec->minor == channel_get_minor(number)) return 1;
return 0;
Expand Down
14 changes: 11 additions & 3 deletions src/input/mpegts/iptv/iptv_auto.c
Expand Up @@ -58,7 +58,7 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
const char *last_url,
const http_arg_list_t *remove_args,
const char *url, const char *name,
const char *logo,
const char *logo, const char *epgid,
int64_t chnum, int *total, int *count)
{
htsmsg_t *conf;
Expand Down Expand Up @@ -158,6 +158,11 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
im->mm_iptv_icon = logo ? strdup(logo) : NULL;
change = 1;
}
if (strcmp(im->mm_iptv_epgid ?: "", epgid ?: "")) {
free(im->mm_iptv_epgid);
im->mm_iptv_epgid = epgid ? strdup(epgid) : NULL;
change = 1;
}
if (change)
idnode_notify_changed(&im->mm_id);
(*total)++;
Expand Down Expand Up @@ -192,7 +197,7 @@ iptv_auto_network_process_m3u(iptv_network_t *in, char *data,
http_arg_list_t *remove_args,
int64_t chnum)
{
char *url, *name = NULL, *logo = NULL;
char *url, *name = NULL, *logo = NULL, *epgid = NULL;
int total = 0, count = 0;

while (*data && *data != '\n') data++;
Expand All @@ -201,12 +206,15 @@ iptv_auto_network_process_m3u(iptv_network_t *in, char *data,
if (strncmp(data, "#EXTINF:", 8) == 0) {
name = NULL;
logo = NULL;
epgid = NULL;
data += 8;
while (1) {
while (*data && *data <= ' ') data++;
if (*data == ',') break;
if (strncmp(data, "tvg-logo=", 9) == 0)
logo = get_m3u_str(data + 9, &data);
else if (strncmp(data, "tvg-id=", 7) == 0)
epgid = get_m3u_str(data + 7, &data);
else if (strncmp(data, "logo=", 5) == 0)
logo = get_m3u_str(data + 5, &data);
else {
Expand All @@ -230,7 +238,7 @@ iptv_auto_network_process_m3u(iptv_network_t *in, char *data,
if (*data) { *data = '\0'; data++; }
if (*url)
iptv_auto_network_process_m3u_item(in, last_url, remove_args,
url, name, logo,
url, name, logo, epgid,
chnum, &total, &count);
}

Expand Down
19 changes: 13 additions & 6 deletions src/input/mpegts/iptv/iptv_mux.c
Expand Up @@ -169,18 +169,24 @@ const idclass_t iptv_mux_class =
.name = N_("Channel number"),
.off = offsetof(iptv_mux_t, mm_iptv_chnum),
},
{
.type = PT_STR,
.id = "iptv_icon",
.name = N_("Icon URL"),
.off = offsetof(iptv_mux_t, mm_iptv_icon),
},
{
.type = PT_STR,
.id = "iptv_sname",
.name = N_("Service Name"),
.off = offsetof(iptv_mux_t, mm_iptv_svcname),
},
{
.type = PT_STR,
.id = "iptv_epgid",
.name = N_("EPG Name"),
.off = offsetof(iptv_mux_t, mm_iptv_epgid),
},
{
.type = PT_STR,
.id = "iptv_icon",
.name = N_("Icon URL"),
.off = offsetof(iptv_mux_t, mm_iptv_icon),
},
{
.type = PT_BOOL,
.id = "iptv_respawn",
Expand Down Expand Up @@ -247,6 +253,7 @@ iptv_mux_delete ( mpegts_mux_t *mm, int delconf )
free(im->mm_iptv_svcname);
free(im->mm_iptv_env);
free(im->mm_iptv_icon);
free(im->mm_iptv_epgid);
mpegts_mux_delete(mm, delconf);
free(url);
free(url_sane);
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/iptv/iptv_private.h
Expand Up @@ -118,6 +118,7 @@ struct iptv_mux
char *mm_iptv_svcname;
int64_t mm_iptv_chnum;
char *mm_iptv_icon;
char *mm_iptv_epgid;

int mm_iptv_respawn;
time_t mm_iptv_respawn_last;
Expand Down
9 changes: 9 additions & 0 deletions src/input/mpegts/iptv/iptv_service.c
Expand Up @@ -100,6 +100,14 @@ iptv_service_channel_icon ( service_t *s )
return NULL;
}

static const char *
iptv_service_channel_epgid ( service_t *s )
{
iptv_service_t *is = (iptv_service_t *)s;
iptv_mux_t *im = (iptv_mux_t *)is->s_dvb_mux;
return im->mm_iptv_epgid;
}

/*
* Create
*/
Expand All @@ -118,6 +126,7 @@ iptv_service_create0
is->s_channel_name = iptv_service_channel_name;
is->s_channel_number = iptv_service_channel_number;
is->s_channel_icon = iptv_service_channel_icon;
is->s_channel_epgid = iptv_service_channel_epgid;

/* Set default service name */
if (!is->s_dvb_svcname || !*is->s_dvb_svcname)
Expand Down
10 changes: 10 additions & 0 deletions src/service.c
Expand Up @@ -1651,6 +1651,16 @@ service_get_channel_icon ( service_t *s )
return r;
}

/*
* Get EPG ID for channel from service
*/
const char *
service_get_channel_epgid ( service_t *s )
{
if (s->s_channel_epgid) return s->s_channel_epgid(s);
return NULL;
}

/*
*
*/
Expand Down
2 changes: 2 additions & 0 deletions src/service.h
Expand Up @@ -317,6 +317,7 @@ typedef struct service {
*/
int64_t (*s_channel_number) (struct service *);
const char *(*s_channel_name) (struct service *);
const char *(*s_channel_epgid) (struct service *);
const char *(*s_provider_name) (struct service *);
const char *(*s_channel_icon) (struct service *);
void (*s_mapped) (struct service *);
Expand Down Expand Up @@ -606,6 +607,7 @@ const char *service_get_channel_name (service_t *s);
const char *service_get_full_channel_name (service_t *s);
int64_t service_get_channel_number (service_t *s);
const char *service_get_channel_icon (service_t *s);
const char *service_get_channel_epgid (service_t *s);

void service_mapped (service_t *s);

Expand Down

0 comments on commit af1d6c0

Please sign in to comment.