Some more additions back into the HTSP, not all underlying code is actually functional.

This commit is contained in:
Adam Sutton 2012-05-18 17:23:56 +01:00
parent f2012eefa5
commit 816396709f
4 changed files with 30 additions and 8 deletions

View file

@ -43,9 +43,12 @@ typedef struct channel {
LIST_HEAD(, service) ch_services; LIST_HEAD(, service) ch_services;
LIST_HEAD(, th_subscription) ch_subscriptions; 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_tree ch_epg_events;
struct event *ch_epg_current; struct event *ch_epg_current;
struct event *ch_epg_next; struct event *ch_epg_next;
#endif
gtimer_t ch_epg_timer_head; gtimer_t ch_epg_timer_head;
gtimer_t ch_epg_timer_current; gtimer_t ch_epg_timer_current;
@ -60,6 +63,7 @@ typedef struct channel {
struct channel_tag_mapping_list ch_ctms; struct channel_tag_mapping_list ch_ctms;
} channel_t; } channel_t;

View file

@ -627,6 +627,12 @@ int epg_broadcast_set_episode
return save; return save;
} }
epg_broadcast_t *epg_broadcast_get_next ( epg_broadcast_t *broadcast )
{
if ( !broadcast ) return NULL;
return RB_NEXT(broadcast, eb_slink);
}
/* ************************************************************************** /* **************************************************************************
* Channel * Channel
* *************************************************************************/ * *************************************************************************/
@ -670,6 +676,13 @@ int epg_channel_set_name ( epg_channel_t *channel, const char *name )
return save; 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 * Querying
* *************************************************************************/ * *************************************************************************/

View file

@ -223,6 +223,9 @@ epg_broadcast_t *epg_broadcast_find_by_id ( int id );
int epg_broadcast_set_episode ( epg_broadcast_t *b, epg_episode_t *e, int u ) int epg_broadcast_set_episode ( epg_broadcast_t *b, epg_episode_t *e, int u )
__attribute__((warn_unused_result)); __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 * Channel - provides mapping from EPG channels to real channels
* ***********************************************************************/ * ***********************************************************************/
@ -250,6 +253,9 @@ epg_channel_t *epg_channel_find_by_uri ( const char *uri, int create );
int epg_channel_set_name ( epg_channel_t *c, const char *n ) int epg_channel_set_name ( epg_channel_t *c, const char *n )
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
/* Accessors */
epg_broadcast_t *epg_channel_get_current_broadcast ( epg_channel_t *c );
/* ************************************************************************ /* ************************************************************************
* Querying * Querying
* ***********************************************************************/ * ***********************************************************************/

View file

@ -295,6 +295,7 @@ htsp_build_channel(channel_t *ch, const char *method)
channel_tag_mapping_t *ctm; channel_tag_mapping_t *ctm;
channel_tag_t *ct; channel_tag_t *ct;
service_t *t; service_t *t;
epg_broadcast_t *now, *next = NULL;
htsmsg_t *out = htsmsg_create_map(); htsmsg_t *out = htsmsg_create_map();
htsmsg_t *tags = htsmsg_create_list(); htsmsg_t *tags = htsmsg_create_list();
@ -307,12 +308,10 @@ htsp_build_channel(channel_t *ch, const char *method)
if(ch->ch_icon != NULL) if(ch->ch_icon != NULL)
htsmsg_add_str(out, "channelIcon", ch->ch_icon); htsmsg_add_str(out, "channelIcon", ch->ch_icon);
#if TODO_EPG_CHANNEL now = epg_channel_get_current_broadcast(ch->ch_epg_channel);
htsmsg_add_u32(out, "eventId", if ( now ) next = epg_broadcast_get_next(now);
ch->ch_epg_current != NULL ? ch->ch_epg_current->e_id : 0); htsmsg_add_u32(out, "eventId", now ? now->eb_id : 0);
htsmsg_add_u32(out, "nextEventId", htsmsg_add_u32(out, "nextEventId", next ? next->eb_id : 0);
ch->ch_epg_next ? ch->ch_epg_next->e_id : 0);
#endif
LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) { LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) {
ct = ctm->ctm_tag; ct = ctm->ctm_tag;
@ -783,7 +782,7 @@ htsp_build_event(epg_broadcast_t *e)
} }
#endif #endif
n = RB_NEXT(e, eb_slink); n = epg_broadcast_get_next(e);
if(n != NULL) if(n != NULL)
htsmsg_add_u32(out, "nextEventId", n->eb_id); htsmsg_add_u32(out, "nextEventId", n->eb_id);
@ -816,7 +815,7 @@ htsp_method_getEvents(htsp_connection_t *htsp, htsmsg_t *in)
htsmsg_add_msg(events, NULL, htsp_build_event(e)); htsmsg_add_msg(events, NULL, htsp_build_event(e));
while( numFollowing-- > 0 ) { while( numFollowing-- > 0 ) {
e = RB_NEXT(e, eb_slink); e = epg_broadcast_get_next(e);
if( e == NULL ) if( e == NULL )
break; break;
htsmsg_add_msg(events, NULL, htsp_build_event(e)); htsmsg_add_msg(events, NULL, htsp_build_event(e));