Rename some link variables to be a bit clearer and move to using anon structs to remove some of the code ugliness. May need to replace anon structures with MACRO based solution if people are not happy with using anon structs.
This commit is contained in:
parent
2d2aa37064
commit
54fdf52764
9 changed files with 101 additions and 103 deletions
4
Makefile
4
Makefile
|
@ -25,7 +25,7 @@ include ${BUILDDIR}/config.mak
|
|||
PROG=${BUILDDIR}/tvheadend
|
||||
|
||||
CFLAGS += -Wall -Werror -Wwrite-strings -Wno-deprecated-declarations
|
||||
CFLAGS += -Wmissing-prototypes
|
||||
CFLAGS += -Wmissing-prototypes -fms-extensions
|
||||
LDFLAGS += -lrt -ldl
|
||||
|
||||
BUNDLES += docs/html docs/docresources src/webui/static
|
||||
|
@ -77,8 +77,6 @@ SRCS += src/epggrab/pyepg.c\
|
|||
src/epggrab/xmltv.c\
|
||||
src/epggrab/eit.c
|
||||
|
||||
|
||||
|
||||
SRCS += src/plumbing/tsfix.c \
|
||||
src/plumbing/globalheaders.c \
|
||||
|
||||
|
|
|
@ -198,9 +198,9 @@ autorec_entry_destroy(dvr_autorec_entry_t *dae)
|
|||
LIST_REMOVE(dae, dae_channel_tag_link);
|
||||
|
||||
if(dae->dae_brand)
|
||||
dae->dae_brand->_.putref((epg_object_t*)dae->dae_brand);
|
||||
dae->dae_brand->putref((epg_object_t*)dae->dae_brand);
|
||||
if(dae->dae_season)
|
||||
dae->dae_season->_.putref((epg_object_t*)dae->dae_season);
|
||||
dae->dae_season->putref((epg_object_t*)dae->dae_season);
|
||||
|
||||
|
||||
TAILQ_REMOVE(&autorec_entries, dae, dae_link);
|
||||
|
@ -280,9 +280,9 @@ autorec_record_build(dvr_autorec_entry_t *dae)
|
|||
htsmsg_add_str(e, "pri", dvr_val2pri(dae->dae_pri));
|
||||
|
||||
if (dae->dae_brand)
|
||||
htsmsg_add_str(e, "brand", dae->dae_brand->_.uri);
|
||||
htsmsg_add_str(e, "brand", dae->dae_brand->uri);
|
||||
if (dae->dae_season)
|
||||
htsmsg_add_str(e, "season", dae->dae_season->_.uri);
|
||||
htsmsg_add_str(e, "season", dae->dae_season->uri);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
@ -415,12 +415,12 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values,
|
|||
if((s = htsmsg_get_str(values, "brand")) != NULL) {
|
||||
dae->dae_brand = epg_brand_find_by_uri(s, 1, &save);
|
||||
if (dae->dae_brand)
|
||||
dae->dae_brand->_.getref((epg_object_t*)dae->dae_brand);
|
||||
dae->dae_brand->getref((epg_object_t*)dae->dae_brand);
|
||||
}
|
||||
if((s = htsmsg_get_str(values, "season")) != NULL) {
|
||||
dae->dae_season = epg_season_find_by_uri(s, 1, &save);
|
||||
if (dae->dae_season)
|
||||
dae->dae_season->_.getref((epg_object_t*)dae->dae_season);
|
||||
dae->dae_season->getref((epg_object_t*)dae->dae_season);
|
||||
}
|
||||
dvr_autorec_changed(dae);
|
||||
|
||||
|
@ -507,11 +507,11 @@ _dvr_autorec_add(const char *config_name,
|
|||
|
||||
if(brand) {
|
||||
dae->dae_brand = brand;
|
||||
brand->_.getref((epg_object_t*)brand);
|
||||
brand->getref((epg_object_t*)brand);
|
||||
}
|
||||
if(season) {
|
||||
dae->dae_season = season;
|
||||
season->_.getref((epg_object_t*)season);
|
||||
season->getref((epg_object_t*)season);
|
||||
}
|
||||
|
||||
m = autorec_record_build(dae);
|
||||
|
@ -601,7 +601,7 @@ dvr_autorec_changed(dvr_autorec_entry_t *dae)
|
|||
dvr_autorec_purge_spawns(dae);
|
||||
|
||||
RB_FOREACH(ch, &channel_name_tree, ch_name_link) {
|
||||
RB_FOREACH(e, &ch->ch_epg_schedule, glink) {
|
||||
RB_FOREACH(e, &ch->ch_epg_schedule, sched_link) {
|
||||
if(autorec_cmp(dae, e))
|
||||
dvr_entry_create_by_autorec(e, dae);
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ static dvr_entry_t *_dvr_entry_create (
|
|||
de->de_desc = description ? strdup(description) : NULL;
|
||||
de->de_content_type = content_type;
|
||||
de->de_bcast = e;
|
||||
if (e) e->_.getref((epg_object_t*)e);
|
||||
if (e) e->getref((epg_object_t*)e);
|
||||
|
||||
dvr_entry_link(de);
|
||||
|
||||
|
@ -406,7 +406,7 @@ dvr_entry_dec_ref(dvr_entry_t *de)
|
|||
free(de->de_title);
|
||||
free(de->de_ititle);
|
||||
free(de->de_desc);
|
||||
if(de->de_bcast) de->de_bcast->_.putref((epg_object_t*)de->de_bcast);
|
||||
if(de->de_bcast) de->de_bcast->putref((epg_object_t*)de->de_bcast);
|
||||
|
||||
free(de);
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ dvr_entry_save(dvr_entry_t *de)
|
|||
htsmsg_add_u32(m, "contenttype", de->de_content_type);
|
||||
|
||||
if(de->de_bcast)
|
||||
htsmsg_add_u32(m, "broadcast", de->de_bcast->_.id);
|
||||
htsmsg_add_u32(m, "broadcast", de->de_bcast->id);
|
||||
|
||||
hts_settings_save(m, "dvr/log/%d", de->de_id);
|
||||
htsmsg_destroy(m);
|
||||
|
@ -653,9 +653,9 @@ static dvr_entry_t *_dvr_entry_update
|
|||
save = 1;
|
||||
}
|
||||
if (de->de_bcast != e) {
|
||||
de->de_bcast->_.putref((epg_object_t*)de->de_bcast);
|
||||
de->de_bcast->putref((epg_object_t*)de->de_bcast);
|
||||
de->de_bcast = e;
|
||||
e->_.getref((epg_object_t*)e);
|
||||
e->getref((epg_object_t*)e);
|
||||
save = 1;
|
||||
}
|
||||
}
|
||||
|
|
120
src/epg.c
120
src/epg.c
|
@ -134,23 +134,23 @@ void epg_save ( void )
|
|||
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
if ( _epg_write_sect(fd, "brands") ) return;
|
||||
RB_FOREACH(eo, &epg_brands, glink) {
|
||||
RB_FOREACH(eo, &epg_brands, uri_link) {
|
||||
if (_epg_write(fd, epg_brand_serialize((epg_brand_t*)eo))) return;
|
||||
stats.brands.total++;
|
||||
}
|
||||
if ( _epg_write_sect(fd, "seasons") ) return;
|
||||
RB_FOREACH(eo, &epg_seasons, glink) {
|
||||
RB_FOREACH(eo, &epg_seasons, uri_link) {
|
||||
if (_epg_write(fd, epg_season_serialize((epg_season_t*)eo))) return;
|
||||
stats.seasons.total++;
|
||||
}
|
||||
if ( _epg_write_sect(fd, "episodes") ) return;
|
||||
RB_FOREACH(eo, &epg_episodes, glink) {
|
||||
RB_FOREACH(eo, &epg_episodes, uri_link) {
|
||||
if (_epg_write(fd, epg_episode_serialize((epg_episode_t*)eo))) return;
|
||||
stats.episodes.total++;
|
||||
}
|
||||
if ( _epg_write_sect(fd, "broadcasts") ) return;
|
||||
RB_FOREACH(ch, &channel_name_tree, ch_name_link) {
|
||||
RB_FOREACH(ebc, &ch->ch_epg_schedule, glink) {
|
||||
RB_FOREACH(ebc, &ch->ch_epg_schedule, sched_link) {
|
||||
if (_epg_write(fd, epg_broadcast_serialize(ebc))) return;
|
||||
stats.broadcasts.total++;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ void epg_updated ( void )
|
|||
while ((eo = LIST_FIRST(&epg_object_unref))) {
|
||||
tvhlog(LOG_DEBUG, "epg",
|
||||
"unref'd object %lu (%s) created during update", eo->id, eo->uri);
|
||||
LIST_REMOVE(eo, ulink);
|
||||
LIST_REMOVE(eo, un_link);
|
||||
eo->destroy(eo);
|
||||
}
|
||||
// Note: we do things this way around since unref'd objects are not likely
|
||||
|
@ -282,7 +282,7 @@ void epg_updated ( void )
|
|||
/* Update updated */
|
||||
while ((eo = LIST_FIRST(&epg_object_updated))) {
|
||||
eo->updated(eo);
|
||||
LIST_REMOVE(eo, uplink);
|
||||
LIST_REMOVE(eo, up_link);
|
||||
eo->_updated = 0;
|
||||
}
|
||||
}
|
||||
|
@ -296,14 +296,14 @@ static void _epg_object_destroy
|
|||
{
|
||||
assert(eo->refcount == 0);
|
||||
if (eo->uri) free(eo->uri);
|
||||
if (tree) RB_REMOVE(tree, eo, glink);
|
||||
if (eo->_updated) LIST_REMOVE(eo, uplink);
|
||||
LIST_REMOVE(eo, hlink);
|
||||
if (tree) RB_REMOVE(tree, eo, uri_link);
|
||||
if (eo->_updated) LIST_REMOVE(eo, up_link);
|
||||
LIST_REMOVE(eo, id_link);
|
||||
}
|
||||
|
||||
static void _epg_object_getref ( epg_object_t *eo )
|
||||
{
|
||||
if (eo->refcount == 0) LIST_REMOVE(eo, ulink);
|
||||
if (eo->refcount == 0) LIST_REMOVE(eo, un_link);
|
||||
eo->refcount++;
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ static void _epg_object_set_updated ( epg_object_t *eo )
|
|||
{
|
||||
if (!eo->_updated) {
|
||||
eo->_updated = 1;
|
||||
LIST_INSERT_HEAD(&epg_object_updated, eo, uplink);
|
||||
LIST_INSERT_HEAD(&epg_object_updated, eo, up_link);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,8 +329,8 @@ static void _epg_object_create ( epg_object_t *eo )
|
|||
if (!eo->getref) eo->getref = _epg_object_getref;
|
||||
if (!eo->putref) eo->putref = _epg_object_putref;
|
||||
_epg_object_set_updated(eo);
|
||||
LIST_INSERT_HEAD(&epg_object_unref, eo, ulink);
|
||||
LIST_INSERT_HEAD(&epg_objects[eo->id & EPG_HASH_MASK], eo, hlink);
|
||||
LIST_INSERT_HEAD(&epg_object_unref, eo, un_link);
|
||||
LIST_INSERT_HEAD(&epg_objects[eo->id & EPG_HASH_MASK], eo, id_link);
|
||||
}
|
||||
|
||||
static epg_object_t *_epg_object_find_by_uri
|
||||
|
@ -346,11 +346,11 @@ static epg_object_t *_epg_object_find_by_uri
|
|||
|
||||
/* Find only */
|
||||
if ( !create ) {
|
||||
eo = RB_FIND(tree, *skel, glink, _uri_cmp);
|
||||
eo = RB_FIND(tree, *skel, uri_link, _uri_cmp);
|
||||
|
||||
/* Find/create */
|
||||
} else {
|
||||
eo = RB_INSERT_SORTED(tree, *skel, glink, _uri_cmp);
|
||||
eo = RB_INSERT_SORTED(tree, *skel, uri_link, _uri_cmp);
|
||||
if ( !eo ) {
|
||||
*save = 1;
|
||||
eo = *skel;
|
||||
|
@ -365,7 +365,7 @@ static epg_object_t *_epg_object_find_by_uri
|
|||
static epg_object_t *_epg_object_find_by_id ( uint64_t id )
|
||||
{
|
||||
epg_object_t *eo;
|
||||
LIST_FOREACH(eo, &epg_objects[id & EPG_HASH_MASK], hlink) {
|
||||
LIST_FOREACH(eo, &epg_objects[id & EPG_HASH_MASK], id_link) {
|
||||
if (eo->id == id) return eo;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -517,7 +517,7 @@ static void _epg_brand_rem_episode
|
|||
htsmsg_t *epg_brand_serialize ( epg_brand_t *brand )
|
||||
{
|
||||
htsmsg_t *m;
|
||||
if ( !brand || !brand->_.uri ) return NULL;
|
||||
if ( !brand || !brand->uri ) return NULL;
|
||||
if ( !(m = _epg_object_serialize((epg_object_t*)brand)) ) return NULL;
|
||||
if (brand->title)
|
||||
htsmsg_add_str(m, "title", brand->title);
|
||||
|
@ -555,7 +555,7 @@ htsmsg_t *epg_brand_list ( void )
|
|||
htsmsg_t *a, *e;
|
||||
a = htsmsg_create_list();
|
||||
for ( i = 0; i < EPG_HASH_WIDTH; i++ ) {
|
||||
LIST_FOREACH(eo, &epg_objects[i], hlink) {
|
||||
LIST_FOREACH(eo, &epg_objects[i], id_link) {
|
||||
if (eo->type == EPG_BRAND) {
|
||||
e = epg_brand_serialize((epg_brand_t*)eo);
|
||||
htsmsg_add_msg(a, NULL, e);
|
||||
|
@ -579,7 +579,7 @@ static void _epg_season_destroy ( epg_object_t *eo )
|
|||
_epg_object_destroy(eo, &epg_seasons);
|
||||
if (es->brand) {
|
||||
_epg_brand_rem_season(es->brand, es);
|
||||
es->brand->_.putref((epg_object_t*)es->brand);
|
||||
es->brand->putref((epg_object_t*)es->brand);
|
||||
}
|
||||
if (es->summary) free(es->summary);
|
||||
if (es->image) free(es->image);
|
||||
|
@ -658,11 +658,11 @@ int epg_season_set_brand ( epg_season_t *season, epg_brand_t *brand, int u )
|
|||
if ( season->brand != brand ) {
|
||||
if ( season->brand ) {
|
||||
_epg_brand_rem_season(season->brand, season);
|
||||
season->brand->_.putref((epg_object_t*)season->brand);
|
||||
season->brand->putref((epg_object_t*)season->brand);
|
||||
}
|
||||
season->brand = brand;
|
||||
_epg_brand_add_season(brand, season);
|
||||
brand->_.getref((epg_object_t*)brand);
|
||||
brand->getref((epg_object_t*)brand);
|
||||
_epg_object_set_updated((epg_object_t*)season);
|
||||
save = 1;
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ static void _epg_season_rem_episode
|
|||
htsmsg_t *epg_season_serialize ( epg_season_t *season )
|
||||
{
|
||||
htsmsg_t *m;
|
||||
if (!season || !season->_.uri) return NULL;
|
||||
if (!season || !season->uri) return NULL;
|
||||
if (!(m = _epg_object_serialize((epg_object_t*)season))) return NULL;
|
||||
if (season->summary)
|
||||
htsmsg_add_str(m, "summary", season->summary);
|
||||
|
@ -695,7 +695,7 @@ htsmsg_t *epg_season_serialize ( epg_season_t *season )
|
|||
if (season->episode_count)
|
||||
htsmsg_add_u32(m, "episode-count", season->episode_count);
|
||||
if (season->brand)
|
||||
htsmsg_add_str(m, "brand", season->brand->_.uri);
|
||||
htsmsg_add_str(m, "brand", season->brand->uri);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -738,11 +738,11 @@ static void _epg_episode_destroy ( epg_object_t *eo )
|
|||
_epg_object_destroy(eo, &epg_episodes);
|
||||
if (ee->brand) {
|
||||
_epg_brand_rem_episode(ee->brand, ee);
|
||||
ee->brand->_.putref((epg_object_t*)ee->brand);
|
||||
ee->brand->putref((epg_object_t*)ee->brand);
|
||||
}
|
||||
if (ee->season) {
|
||||
_epg_season_rem_episode(ee->season, ee);
|
||||
ee->season->_.putref((epg_object_t*)ee->season);
|
||||
ee->season->putref((epg_object_t*)ee->season);
|
||||
}
|
||||
if (ee->title) free(ee->title);
|
||||
if (ee->subtitle) free(ee->subtitle);
|
||||
|
@ -844,11 +844,11 @@ int epg_episode_set_brand ( epg_episode_t *episode, epg_brand_t *brand )
|
|||
if ( episode->brand != brand ) {
|
||||
if ( episode->brand ) {
|
||||
_epg_brand_rem_episode(episode->brand, episode);
|
||||
episode->brand->_.putref((epg_object_t*)episode->brand);
|
||||
episode->brand->putref((epg_object_t*)episode->brand);
|
||||
}
|
||||
episode->brand = brand;
|
||||
_epg_brand_add_episode(brand, episode);
|
||||
brand->_.getref((epg_object_t*)brand);
|
||||
brand->getref((epg_object_t*)brand);
|
||||
_epg_object_set_updated((epg_object_t*)episode);
|
||||
save = 1;
|
||||
}
|
||||
|
@ -862,11 +862,11 @@ int epg_episode_set_season ( epg_episode_t *episode, epg_season_t *season )
|
|||
if ( episode->season != season ) {
|
||||
if ( episode->season ) {
|
||||
_epg_season_rem_episode(episode->season, episode);
|
||||
episode->season->_.putref((epg_object_t*)episode->season);
|
||||
episode->season->putref((epg_object_t*)episode->season);
|
||||
}
|
||||
episode->season = season;
|
||||
_epg_season_add_episode(season, episode);
|
||||
season->_.getref((epg_object_t*)season);
|
||||
season->getref((epg_object_t*)season);
|
||||
if ( season->brand ) save |= epg_episode_set_brand(episode, season->brand);
|
||||
_epg_object_set_updated((epg_object_t*)episode);
|
||||
save = 1;
|
||||
|
@ -920,14 +920,14 @@ int epg_episode_set_genre_str ( epg_episode_t *ee, const char **gstr )
|
|||
static void _epg_episode_add_broadcast
|
||||
( epg_episode_t *episode, epg_broadcast_t *broadcast )
|
||||
{
|
||||
LIST_INSERT_SORTED(&episode->broadcasts, broadcast, elink, _ebc_start_cmp);
|
||||
LIST_INSERT_SORTED(&episode->broadcasts, broadcast, ep_link, _ebc_start_cmp);
|
||||
_epg_object_set_updated((epg_object_t*)episode);
|
||||
}
|
||||
|
||||
static void _epg_episode_rem_broadcast
|
||||
( epg_episode_t *episode, epg_broadcast_t *broadcast )
|
||||
{
|
||||
LIST_REMOVE(broadcast, elink);
|
||||
LIST_REMOVE(broadcast, ep_link);
|
||||
_epg_object_set_updated((epg_object_t*)episode);
|
||||
}
|
||||
|
||||
|
@ -962,7 +962,7 @@ int epg_episode_fuzzy_match
|
|||
// TODO: this is pretty noddy and likely to fail!
|
||||
// hence the reason I don't recommend mixing external grabbers and EIT
|
||||
if ( !episode ) return 0;
|
||||
if ( uri && episode->_.uri && !strcmp(episode->_.uri, uri) ) return 1;
|
||||
if ( uri && episode->uri && !strcmp(episode->uri, uri) ) return 1;
|
||||
if ( title && episode->title && (strstr(title, episode->title) || strstr(episode->title, title)) ) return 1;
|
||||
// TODO: could we do fuzzy string matching on the description/summary
|
||||
// : there are a few algorithms that might work, but some early testing
|
||||
|
@ -973,9 +973,9 @@ int epg_episode_fuzzy_match
|
|||
htsmsg_t *epg_episode_serialize ( epg_episode_t *episode )
|
||||
{
|
||||
htsmsg_t *m;
|
||||
if (!episode || !episode->_.uri) return NULL;
|
||||
if (!episode || !episode->uri) return NULL;
|
||||
if (!(m = _epg_object_serialize((epg_object_t*)episode))) return NULL;
|
||||
htsmsg_add_str(m, "uri", episode->_.uri);
|
||||
htsmsg_add_str(m, "uri", episode->uri);
|
||||
if (episode->title)
|
||||
htsmsg_add_str(m, "title", episode->title);
|
||||
if (episode->subtitle)
|
||||
|
@ -991,9 +991,9 @@ htsmsg_t *epg_episode_serialize ( epg_episode_t *episode )
|
|||
htsmsg_add_u32(m, "part-count", episode->part_count);
|
||||
}
|
||||
if (episode->brand)
|
||||
htsmsg_add_str(m, "brand", episode->brand->_.uri);
|
||||
htsmsg_add_str(m, "brand", episode->brand->uri);
|
||||
if (episode->season)
|
||||
htsmsg_add_str(m, "season", episode->season->_.uri);
|
||||
htsmsg_add_str(m, "season", episode->season->uri);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -1052,10 +1052,10 @@ static void _epg_channel_timer_callback ( void *p )
|
|||
|
||||
/* Expire */
|
||||
if ( ebc->stop <= dispatch_clock ) {
|
||||
RB_REMOVE(&ch->ch_epg_schedule, ebc, glink);
|
||||
RB_REMOVE(&ch->ch_epg_schedule, ebc, sched_link);
|
||||
tvhlog(LOG_DEBUG, "epg", "expire event %lu from %s",
|
||||
ebc->_.id, ch->ch_name);
|
||||
ebc->_.putref((epg_object_t*)ebc);
|
||||
ebc->id, ch->ch_name);
|
||||
ebc->putref((epg_object_t*)ebc);
|
||||
continue; // skip to next
|
||||
|
||||
/* No now */
|
||||
|
@ -1066,14 +1066,14 @@ static void _epg_channel_timer_callback ( void *p )
|
|||
/* Now/Next */
|
||||
} else {
|
||||
ch->ch_epg_now = ebc;
|
||||
ch->ch_epg_next = RB_NEXT(ebc, glink);
|
||||
ch->ch_epg_next = RB_NEXT(ebc, sched_link);
|
||||
next = ebc->stop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
tvhlog(LOG_DEBUG, "epg", "now/next %lu/%lu set on %s",
|
||||
ch->ch_epg_now ? ch->ch_epg_now->_.id : 0,
|
||||
ch->ch_epg_next ? ch->ch_epg_next->_.id : 0,
|
||||
ch->ch_epg_now ? ch->ch_epg_now->id : 0,
|
||||
ch->ch_epg_next ? ch->ch_epg_next->id : 0,
|
||||
ch->ch_name);
|
||||
|
||||
/* re-arm */
|
||||
|
@ -1095,8 +1095,8 @@ static void _epg_channel_rem_broadcast
|
|||
( channel_t *ch, epg_broadcast_t *ebc, epg_broadcast_t *new )
|
||||
{
|
||||
if (new) dvr_event_replaced(ebc, new);
|
||||
RB_REMOVE(&ch->ch_epg_schedule, ebc, glink);
|
||||
ebc->_.putref((epg_object_t*)ebc);
|
||||
RB_REMOVE(&ch->ch_epg_schedule, ebc, sched_link);
|
||||
ebc->putref((epg_object_t*)ebc);
|
||||
}
|
||||
|
||||
static epg_broadcast_t *_epg_channel_add_broadcast
|
||||
|
@ -1111,11 +1111,11 @@ static epg_broadcast_t *_epg_channel_add_broadcast
|
|||
|
||||
/* Find (only) */
|
||||
if ( !create ) {
|
||||
ret = RB_FIND(&ch->ch_epg_schedule, *bcast, glink, _ebc_start_cmp);
|
||||
ret = RB_FIND(&ch->ch_epg_schedule, *bcast, sched_link, _ebc_start_cmp);
|
||||
|
||||
/* Find/Create */
|
||||
} else {
|
||||
ret = RB_INSERT_SORTED(&ch->ch_epg_schedule, *bcast, glink, _ebc_start_cmp);
|
||||
ret = RB_INSERT_SORTED(&ch->ch_epg_schedule, *bcast, sched_link, _ebc_start_cmp);
|
||||
if (!ret) {
|
||||
save2 = 1;
|
||||
ret = *bcast;
|
||||
|
@ -1133,18 +1133,18 @@ static epg_broadcast_t *_epg_channel_add_broadcast
|
|||
// the rest of this code will happen infrequently (hopefully)
|
||||
|
||||
/* Grab ref */
|
||||
ret->_.getref((epg_object_t*)ret);
|
||||
ret->getref((epg_object_t*)ret);
|
||||
*save |= 1;
|
||||
|
||||
/* Remove overlapping (before) */
|
||||
while ( (ebc = RB_PREV(ret, glink)) != NULL ) {
|
||||
while ( (ebc = RB_PREV(ret, sched_link)) != NULL ) {
|
||||
if ( ebc->stop <= ret->start ) break;
|
||||
if ( ch->ch_epg_now == ebc ) ch->ch_epg_now = NULL;
|
||||
_epg_channel_rem_broadcast(ch, ebc, ret);
|
||||
}
|
||||
|
||||
/* Remove overlapping (after) */
|
||||
while ( (ebc = RB_NEXT(ret, glink)) != NULL ) {
|
||||
while ( (ebc = RB_NEXT(ret, sched_link)) != NULL ) {
|
||||
if ( ebc->start >= ret->stop ) break;
|
||||
_epg_channel_rem_broadcast(ch, ebc, ret);
|
||||
}
|
||||
|
@ -1153,7 +1153,7 @@ static epg_broadcast_t *_epg_channel_add_broadcast
|
|||
if ( RB_FIRST(&ch->ch_epg_schedule) == ret ) {
|
||||
timer = 1;
|
||||
} else if ( ch->ch_epg_now &&
|
||||
RB_NEXT(ch->ch_epg_now, glink) == ret ) {
|
||||
RB_NEXT(ch->ch_epg_now, sched_link) == ret ) {
|
||||
timer = 1;
|
||||
}
|
||||
|
||||
|
@ -1181,7 +1181,7 @@ static void _epg_broadcast_destroy ( epg_object_t *eo )
|
|||
_epg_object_destroy(eo, NULL);
|
||||
if (ebc->episode) {
|
||||
_epg_episode_rem_broadcast(ebc->episode, ebc);
|
||||
ebc->episode->_.putref((epg_object_t*)ebc->episode);
|
||||
ebc->episode->putref((epg_object_t*)ebc->episode);
|
||||
}
|
||||
free(ebc);
|
||||
}
|
||||
|
@ -1197,9 +1197,9 @@ static epg_broadcast_t **_epg_broadcast_skel ( void )
|
|||
static epg_broadcast_t *skel = NULL;
|
||||
if ( !skel ) {
|
||||
skel = calloc(1, sizeof(epg_broadcast_t));
|
||||
skel->_.type = EPG_BROADCAST;
|
||||
skel->_.destroy = _epg_broadcast_destroy;
|
||||
skel->_.updated = _epg_broadcast_updated;
|
||||
skel->type = EPG_BROADCAST;
|
||||
skel->destroy = _epg_broadcast_destroy;
|
||||
skel->updated = _epg_broadcast_updated;
|
||||
}
|
||||
return &skel;
|
||||
}
|
||||
|
@ -1234,11 +1234,11 @@ int epg_broadcast_set_episode
|
|||
if ( broadcast->episode != episode ) {
|
||||
if ( broadcast->episode ) {
|
||||
_epg_episode_rem_broadcast(broadcast->episode, broadcast);
|
||||
broadcast->episode->_.putref((epg_object_t*)broadcast->episode);
|
||||
broadcast->episode->putref((epg_object_t*)broadcast->episode);
|
||||
}
|
||||
_epg_episode_add_broadcast(episode, broadcast);
|
||||
broadcast->episode = episode;
|
||||
episode->_.getref((epg_object_t*)episode);
|
||||
episode->getref((epg_object_t*)episode);
|
||||
_epg_object_set_updated((epg_object_t*)broadcast);
|
||||
save = 1;
|
||||
}
|
||||
|
@ -1248,18 +1248,18 @@ int epg_broadcast_set_episode
|
|||
epg_broadcast_t *epg_broadcast_get_next ( epg_broadcast_t *broadcast )
|
||||
{
|
||||
if ( !broadcast ) return NULL;
|
||||
return RB_NEXT(broadcast, glink);
|
||||
return RB_NEXT(broadcast, sched_link);
|
||||
}
|
||||
|
||||
htsmsg_t *epg_broadcast_serialize ( epg_broadcast_t *broadcast )
|
||||
{
|
||||
htsmsg_t *m;
|
||||
if (!broadcast) return NULL;
|
||||
if (!broadcast->episode || !broadcast->episode->_.uri) return NULL;
|
||||
if (!broadcast->episode || !broadcast->episode->uri) return NULL;
|
||||
if (!(m = _epg_object_serialize((epg_object_t*)broadcast))) return NULL;
|
||||
htsmsg_add_u32(m, "start", broadcast->start);
|
||||
htsmsg_add_u32(m, "stop", broadcast->stop);
|
||||
htsmsg_add_str(m, "episode", broadcast->episode->_.uri);
|
||||
htsmsg_add_str(m, "episode", broadcast->episode->uri);
|
||||
if (broadcast->channel)
|
||||
htsmsg_add_u32(m, "channel", broadcast->channel->ch_id);
|
||||
|
||||
|
@ -1535,7 +1535,7 @@ static void _eqr_add_channel
|
|||
regex_t *preg, time_t start )
|
||||
{
|
||||
epg_broadcast_t *ebc;
|
||||
RB_FOREACH(ebc, &ch->ch_epg_schedule, glink) {
|
||||
RB_FOREACH(ebc, &ch->ch_epg_schedule, sched_link) {
|
||||
if ( ebc->episode ) _eqr_add(eqr, ebc, genre, preg, start);
|
||||
}
|
||||
}
|
||||
|
|
20
src/epg.h
20
src/epg.h
|
@ -71,10 +71,10 @@ typedef enum epg_object_type
|
|||
/* Object */
|
||||
struct epg_object
|
||||
{
|
||||
RB_ENTRY(epg_object) glink; ///< Global URI link
|
||||
LIST_ENTRY(epg_object) hlink; ///< Global (ID) link
|
||||
LIST_ENTRY(epg_object) ulink; ///< Global unref'd link
|
||||
LIST_ENTRY(epg_object) uplink; ///< Global updated link
|
||||
RB_ENTRY(epg_object) uri_link; ///< Global URI link
|
||||
LIST_ENTRY(epg_object) id_link; ///< Global (ID) link
|
||||
LIST_ENTRY(epg_object) un_link; ///< Global unref'd link
|
||||
LIST_ENTRY(epg_object) up_link; ///< Global updated link
|
||||
|
||||
epg_object_type_t type; ///< Specific object type
|
||||
uint64_t id; ///< Internal ID
|
||||
|
@ -98,7 +98,7 @@ struct epg_object
|
|||
/* Object */
|
||||
struct epg_brand
|
||||
{
|
||||
epg_object_t _; ///< Base object
|
||||
epg_object_t; ///< Base object
|
||||
|
||||
char *title; ///< Brand name
|
||||
char *summary; ///< Brand summary
|
||||
|
@ -138,7 +138,7 @@ htsmsg_t *epg_brand_list ( void );
|
|||
/* Object */
|
||||
struct epg_season
|
||||
{
|
||||
epg_object_t _; ///< Parent object
|
||||
epg_object_t; ///< Parent object
|
||||
|
||||
char *summary; ///< Season summary
|
||||
uint16_t number; ///< The season number
|
||||
|
@ -179,7 +179,7 @@ epg_season_t *epg_season_deserialize ( htsmsg_t *m, int create, int *save );
|
|||
/* Object */
|
||||
struct epg_episode
|
||||
{
|
||||
epg_object_t _; ///< Parent object
|
||||
epg_object_t; ///< Parent object
|
||||
|
||||
char *title; ///< Title
|
||||
char *subtitle; ///< Sub-title
|
||||
|
@ -264,7 +264,7 @@ epg_episode_t *epg_episode_deserialize ( htsmsg_t *m, int create, int *save );
|
|||
/* Object */
|
||||
struct epg_broadcast
|
||||
{
|
||||
epg_object_t _; ///< Parent object
|
||||
epg_object_t; ///< Parent object
|
||||
|
||||
time_t start; ///< Start time
|
||||
time_t stop; ///< End time
|
||||
|
@ -284,8 +284,8 @@ struct epg_broadcast
|
|||
uint8_t is_new; ///< New series / file premiere
|
||||
uint8_t is_repeat; ///< Repeat screening
|
||||
|
||||
RB_ENTRY(epg_broadcast) glink; ///< Schedule link
|
||||
LIST_ENTRY(epg_broadcast) elink; ///< Episode link
|
||||
RB_ENTRY(epg_broadcast) sched_link; ///< Schedule link
|
||||
LIST_ENTRY(epg_broadcast) ep_link; ///< Episode link
|
||||
epg_episode_t *episode; ///< Episode shown
|
||||
struct channel *channel; ///< Channel being broadcast on
|
||||
|
||||
|
|
14
src/htsp.c
14
src/htsp.c
|
@ -312,8 +312,8 @@ htsp_build_channel(channel_t *ch, const char *method)
|
|||
|
||||
now = ch->ch_epg_now;
|
||||
next = ch->ch_epg_next;
|
||||
htsmsg_add_u32(out, "eventId", now ? now->_.id : 0);
|
||||
htsmsg_add_u32(out, "nextEventId", next ? next->_.id : 0);
|
||||
htsmsg_add_u32(out, "eventId", now ? now->id : 0);
|
||||
htsmsg_add_u32(out, "nextEventId", next ? next->id : 0);
|
||||
|
||||
LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) {
|
||||
ct = ctm->ctm_tag;
|
||||
|
@ -735,7 +735,7 @@ htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in)
|
|||
if( c ) {
|
||||
eventIds = htsmsg_create_list();
|
||||
for(i = 0; i < c; ++i) {
|
||||
htsmsg_add_u32(eventIds, NULL, eqr.eqr_array[i]->_.id);
|
||||
htsmsg_add_u32(eventIds, NULL, eqr.eqr_array[i]->id);
|
||||
}
|
||||
htsmsg_add_msg(out, "eventIds", eventIds);
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ htsp_build_event(epg_broadcast_t *e)
|
|||
|
||||
out = htsmsg_create_map();
|
||||
|
||||
htsmsg_add_u32(out, "eventId", e->_.id);
|
||||
htsmsg_add_u32(out, "eventId", e->id);
|
||||
htsmsg_add_u32(out, "channelId", e->channel->ch_id);
|
||||
htsmsg_add_u32(out, "start", e->start);
|
||||
htsmsg_add_u32(out, "stop", e->stop);
|
||||
|
@ -778,7 +778,7 @@ htsp_build_event(epg_broadcast_t *e)
|
|||
|
||||
n = epg_broadcast_get_next(e);
|
||||
if(n != NULL)
|
||||
htsmsg_add_u32(out, "nextEventId", n->_.id);
|
||||
htsmsg_add_u32(out, "nextEventId", n->id);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -1419,8 +1419,8 @@ htsp_channel_update_current(channel_t *ch)
|
|||
|
||||
now = ch->ch_epg_now;
|
||||
next = ch->ch_epg_next;
|
||||
htsmsg_add_u32(m, "eventId", now ? now->_.id : 0);
|
||||
htsmsg_add_u32(m, "nextEventId", next ? next->_.id : 0);
|
||||
htsmsg_add_u32(m, "eventId", now ? now->id : 0);
|
||||
htsmsg_add_u32(m, "nextEventId", next ? next->id : 0);
|
||||
htsp_async_send(m);
|
||||
}
|
||||
|
||||
|
|
|
@ -713,7 +713,7 @@ extjs_epg(http_connection_t *hc, const char *remain, void *opaque)
|
|||
if (epg_episode_number_format(ee, buf, 100, NULL, "Season %d", ".", "Episode %d", "/%d"))
|
||||
htsmsg_add_str(m, "episode", buf);
|
||||
|
||||
htsmsg_add_u32(m, "id", e->_.id);
|
||||
htsmsg_add_u32(m, "id", e->id);
|
||||
htsmsg_add_u32(m, "start", e->start);
|
||||
htsmsg_add_u32(m, "end", e->stop);
|
||||
htsmsg_add_u32(m, "duration", e->stop - e->start);
|
||||
|
@ -767,13 +767,13 @@ extjs_epgrelated(http_connection_t *hc, const char *remain, void *opaque)
|
|||
|
||||
/* Alternative broadcasts */
|
||||
if (!strcmp(type, "alternative")) {
|
||||
LIST_FOREACH(ebc, &ee->broadcasts, elink) {
|
||||
LIST_FOREACH(ebc, &ee->broadcasts, ep_link) {
|
||||
ch = ebc->channel;
|
||||
if ( !ch ) continue; // skip something not viewable
|
||||
if ( ebc == e ) continue; // skip self
|
||||
count++;
|
||||
m = htsmsg_create_map();
|
||||
htsmsg_add_u32(m, "id", ebc->_.id);
|
||||
htsmsg_add_u32(m, "id", ebc->id);
|
||||
if ( ch->ch_name ) htsmsg_add_str(m, "channel", ch->ch_name);
|
||||
if ( ch->ch_icon ) htsmsg_add_str(m, "chicon", ch->ch_icon);
|
||||
htsmsg_add_u32(m, "start", ebc->start);
|
||||
|
@ -788,7 +788,7 @@ extjs_epgrelated(http_connection_t *hc, const char *remain, void *opaque)
|
|||
if (!ee2->title) continue;
|
||||
count++;
|
||||
m = htsmsg_create_map();
|
||||
htsmsg_add_str(m, "uri", ee2->_.uri);
|
||||
htsmsg_add_str(m, "uri", ee2->uri);
|
||||
htsmsg_add_str(m, "title", ee2->title);
|
||||
if (ee2->subtitle) htsmsg_add_str(m, "subtitle", ee2->subtitle);
|
||||
if (epg_episode_number_format(ee2, buf, 100, NULL, "Season %d", ".", "Episode %d", "/%d"))
|
||||
|
@ -801,7 +801,7 @@ extjs_epgrelated(http_connection_t *hc, const char *remain, void *opaque)
|
|||
if (!ee2->title) continue;
|
||||
count++;
|
||||
m = htsmsg_create_map();
|
||||
htsmsg_add_str(m, "uri", ee2->_.uri);
|
||||
htsmsg_add_str(m, "uri", ee2->uri);
|
||||
htsmsg_add_str(m, "title", ee2->title);
|
||||
if (ee2->subtitle) htsmsg_add_str(m, "subtitle", ee2->subtitle);
|
||||
if (epg_episode_number_format(ee2, buf, 100, NULL, "Season %d", ".", "Episode %d", "/%d"))
|
||||
|
|
|
@ -126,7 +126,7 @@ page_simple(http_connection_t *hc,
|
|||
htsbuf_qprintf(hq,
|
||||
"<a href=\"/eventinfo/%d\">"
|
||||
"%02d:%02d-%02d:%02d %s%s%s</a><br>",
|
||||
e->_.id,
|
||||
e->id,
|
||||
a.tm_hour, a.tm_min, b.tm_hour, b.tm_min,
|
||||
e->episode->title,
|
||||
rstatus ? " " : "", rstatus ?: "");
|
||||
|
@ -236,7 +236,7 @@ page_einfo(http_connection_t *hc, const char *remain, void *opaque)
|
|||
htsbuf_qprintf(hq, "Recording status: %s<br>", rstatus);
|
||||
|
||||
htsbuf_qprintf(hq, "<form method=\"post\" action=\"/eventinfo/%d\">",
|
||||
e->_.id);
|
||||
e->id);
|
||||
|
||||
switch(dvr_status) {
|
||||
case DVR_SCHEDULED:
|
||||
|
|
|
@ -183,8 +183,8 @@ http_stream_run(http_connection_t *hc, streaming_queue_t *sq, th_subscription_t
|
|||
epg_broadcast_t *e = NULL;
|
||||
if(s->ths_channel) e = s->ths_channel->ch_epg_now;
|
||||
|
||||
if(e && event_id != e->_.id) {
|
||||
event_id = e->_.id;
|
||||
if(e && event_id != e->id) {
|
||||
event_id = e->id;
|
||||
run = !mk_mux_append_meta(mkm, e);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue