diff --git a/epg.c b/epg.c index b9f5368b..c9b37e4d 100644 --- a/epg.c +++ b/epg.c @@ -268,7 +268,7 @@ check_overlap(th_channel_t *ch, event_t *e) static void epg_event_create(th_channel_t *ch, time_t start, int duration, const char *title, const char *desc, int source, - uint16_t id) + uint16_t id, refstr_t *icon) { unsigned int l; time_t now; @@ -303,6 +303,11 @@ epg_event_create(th_channel_t *ch, time_t start, int duration, LIST_INSERT_HEAD(&epg_hash[l], e, e_hash_link); } + if(e->e_icon == NULL) + e->e_icon = refstr_dup(icon); + else + refstr_free(icon); + if(source > e->e_source) { e->e_source = source; @@ -370,7 +375,7 @@ epg_update_event_by_id(th_channel_t *ch, uint16_t event_id, } else { epg_event_create(ch, start, duration, title, desc, - EVENT_SRC_DVB, event_id); + EVENT_SRC_DVB, event_id, NULL); } } @@ -380,7 +385,14 @@ epg_update_event_by_id(th_channel_t *ch, uint16_t event_id, static void epg_locate_current_event(th_channel_t *ch, time_t now) { - ch->ch_epg_cur_event = epg_event_find_by_time(ch, now); + event_t *e; + e = epg_event_find_by_time(ch, now); + + if(e != NULL && e->e_icon != NULL) { + refstr_free(ch->ch_icon); + ch->ch_icon = refstr_dup(e->e_icon); + } + ch->ch_epg_cur_event = e; } @@ -426,17 +438,20 @@ epg_channel_maintain(void) void epg_transfer_events(th_channel_t *ch, struct event_queue *src, - const char *srcname) + const char *srcname, refstr_t *icon) { event_t *e; int cnt = 0; epg_lock(); + if(ch->ch_icon == NULL) + ch->ch_icon = refstr_dup(icon); + TAILQ_FOREACH(e, src, e_link) { epg_event_create(ch, e->e_start, e->e_duration, e->e_title, - e->e_desc, EVENT_SRC_XMLTV, 0); + e->e_desc, EVENT_SRC_XMLTV, 0, refstr_dup(icon)); cnt++; } epg_unlock(); diff --git a/epg.h b/epg.h index c9318d5a..4a9414bf 100644 --- a/epg.h +++ b/epg.h @@ -46,7 +46,7 @@ void epg_update_event_by_id(th_channel_t *ch, uint16_t event_id, const char *desc); void epg_transfer_events(th_channel_t *ch, struct event_queue *src, - const char *srcname); + const char *srcname, refstr_t *icon); void event_time_txt(time_t start, int duration, char *out, int outlen); diff --git a/epg_xmltv.c b/epg_xmltv.c index 64315f0d..88917b3c 100644 --- a/epg_xmltv.c +++ b/epg_xmltv.c @@ -35,6 +35,7 @@ #include "channels.h" #include "epg.h" #include "epg_xmltv.h" +#include "refstr.h" extern int xmltvreload; @@ -55,7 +56,7 @@ typedef struct xmltv_channel { LIST_ENTRY(xmltv_channel) xc_link; const char *xc_name; const char *xc_displayname; - const char *xc_icon; + refstr_t *xc_icon; LIST_HEAD(, xmltv_map) xc_maps; @@ -105,8 +106,8 @@ xmltv_parse_channel(xmlNode *n, char *chid) if(!strcmp((char *)n->name, "icon")) { t = (char *)xmlGetProp(n, (unsigned char *)"src"); - free((void *)xc->xc_icon); - xc->xc_icon = strdup(t); + refstr_free(xc->xc_icon); + xc->xc_icon = refstr_alloc(t); xmlFree(t); } xmlFree(c); @@ -359,7 +360,8 @@ xmltv_transfer(void) if(xm->xm_isupdated) continue; - epg_transfer_events(xm->xm_channel, &xc->xc_events, xc->xc_name); + epg_transfer_events(xm->xm_channel, &xc->xc_events, xc->xc_name, + xc->xc_icon); xm->xm_isupdated = 1; } } diff --git a/htsclient.c b/htsclient.c index 088f0032..2adab71e 100644 --- a/htsclient.c +++ b/htsclient.c @@ -324,7 +324,7 @@ cr_channel_info(client_t *c, char **argv, int argc) "icon = %s\n" "tag = %d\n", ch->ch_name, - ch->ch_icon ?: "", + ch->ch_icon ? refstr_get(ch->ch_icon) : "", ch->ch_tag); return 0; diff --git a/tvhead.h b/tvhead.h index e25fdd64..729e0e6c 100644 --- a/tvhead.h +++ b/tvhead.h @@ -28,7 +28,7 @@ #include #include #include - +#include "refstr.h" LIST_HEAD(th_subscription_list, th_subscription); TAILQ_HEAD(th_channel_queue, th_channel); @@ -339,7 +339,6 @@ typedef struct th_channel { int ch_index; const char *ch_name; - const char *ch_icon; struct pvr_rec *ch_rec; @@ -351,6 +350,7 @@ typedef struct th_channel { struct event_queue ch_epg_events; struct event *ch_epg_cur_event; + refstr_t *ch_icon; } th_channel_t; @@ -446,6 +446,8 @@ typedef struct event { #define EVENT_SRC_XMLTV 1 #define EVENT_SRC_DVB 2 + refstr_t *e_icon; + } event_t;