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 62daaac5cd
commit 28c3bd8ffb
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(, 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;
@ -60,6 +63,7 @@ typedef struct channel {
struct channel_tag_mapping_list ch_ctms;
} channel_t;

View file

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

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 )
__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
* ***********************************************************************/
@ -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 )
__attribute__((warn_unused_result));
/* Accessors */
epg_broadcast_t *epg_channel_get_current_broadcast ( epg_channel_t *c );
/* ************************************************************************
* Querying
* ***********************************************************************/

View file

@ -297,6 +297,7 @@ htsp_build_channel(channel_t *ch, const char *method)
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();
@ -309,12 +310,10 @@ htsp_build_channel(channel_t *ch, const char *method)
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;
@ -785,7 +784,7 @@ htsp_build_event(epg_broadcast_t *e)
}
#endif
n = RB_NEXT(e, eb_slink);
n = epg_broadcast_get_next(e);
if(n != NULL)
htsmsg_add_u32(out, "nextEventId", n->eb_id);
@ -818,7 +817,7 @@ htsp_method_getEvents(htsp_connection_t *htsp, htsmsg_t *in)
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));