LIST_HEAD(, service) ch_services;
LIST_HEAD(, th_subscription) ch_subscriptions;
+ struct epg_channel *ch_epg_channel;
+#if 1 //TODO_REMOVE_THESE
struct event_tree ch_epg_events;
struct event *ch_epg_current;
struct event *ch_epg_next;
+#endif
gtimer_t ch_epg_timer_head;
gtimer_t ch_epg_timer_current;
struct channel_tag_mapping_list ch_ctms;
+
} channel_t;
return save;
}
+epg_broadcast_t *epg_broadcast_get_next ( epg_broadcast_t *broadcast )
+{
+ if ( !broadcast ) return NULL;
+ return RB_NEXT(broadcast, eb_slink);
+}
+
/* **************************************************************************
* Channel
* *************************************************************************/
return save;
}
+epg_broadcast_t *epg_channel_get_current_broadcast ( epg_channel_t *channel )
+{
+ // TODO: its not really the head!
+ if ( !channel ) return NULL;
+ return RB_FIRST(&channel->ec_schedule);
+}
+
/* **************************************************************************
* Querying
* *************************************************************************/
int epg_broadcast_set_episode ( epg_broadcast_t *b, epg_episode_t *e, int u )
__attribute__((warn_unused_result));
+/* Accessors */
+epg_broadcast_t *epg_broadcast_get_next ( epg_broadcast_t *b );
+
/* ************************************************************************
* Channel - provides mapping from EPG channels to real channels
* ***********************************************************************/
int epg_channel_set_name ( epg_channel_t *c, const char *n )
__attribute__((warn_unused_result));
+/* Accessors */
+epg_broadcast_t *epg_channel_get_current_broadcast ( epg_channel_t *c );
+
/* ************************************************************************
* Querying
* ***********************************************************************/
channel_tag_mapping_t *ctm;
channel_tag_t *ct;
service_t *t;
+ epg_broadcast_t *now, *next = NULL;
htsmsg_t *out = htsmsg_create_map();
htsmsg_t *tags = htsmsg_create_list();
if(ch->ch_icon != NULL)
htsmsg_add_str(out, "channelIcon", ch->ch_icon);
-#if TODO_EPG_CHANNEL
- htsmsg_add_u32(out, "eventId",
- ch->ch_epg_current != NULL ? ch->ch_epg_current->e_id : 0);
- htsmsg_add_u32(out, "nextEventId",
- ch->ch_epg_next ? ch->ch_epg_next->e_id : 0);
-#endif
+ now = epg_channel_get_current_broadcast(ch->ch_epg_channel);
+ if ( now ) next = epg_broadcast_get_next(now);
+ htsmsg_add_u32(out, "eventId", now ? now->eb_id : 0);
+ htsmsg_add_u32(out, "nextEventId", next ? next->eb_id : 0);
LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) {
ct = ctm->ctm_tag;
}
#endif
- n = RB_NEXT(e, eb_slink);
+ n = epg_broadcast_get_next(e);
if(n != NULL)
htsmsg_add_u32(out, "nextEventId", n->eb_id);
htsmsg_add_msg(events, NULL, htsp_build_event(e));
while( numFollowing-- > 0 ) {
- e = RB_NEXT(e, eb_slink);
+ e = epg_broadcast_get_next(e);
if( e == NULL )
break;
htsmsg_add_msg(events, NULL, htsp_build_event(e));