]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Some more additions back into the HTSP, not all underlying code is actually functional.
authorAdam Sutton <dev@adamsutton.me.uk>
Fri, 18 May 2012 16:23:56 +0000 (17:23 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Fri, 18 May 2012 16:23:56 +0000 (17:23 +0100)
src/channels.h
src/epg.c
src/epg.h
src/htsp.c

index 0ccd334956bef6642d4f77be7cd61b47602c929e..dfe1b332ec73e01c5688f464c40477acbf9334d7 100644 (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;
 
 
index 3f070d08166fae986edc20036e7e1ce27d509dd2..45e23fa1545d9bc45efa7b0d85eb260e053a2856 100644 (file)
--- a/src/epg.c
+++ b/src/epg.c
@@ -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
  * *************************************************************************/
index 8a5ca3c84ffda37d7ea16c5d35f64cd30d7fec20..3485c66403deab497d99373da4ab1081eab6af25 100644 (file)
--- a/src/epg.h
+++ b/src/epg.h
@@ -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
  * ***********************************************************************/
index 5aee796f4781df1536aa9eab315e6569fbd31320..050f95634446056c9942258203920d7e847e7199 100644 (file)
@@ -295,6 +295,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();
@@ -307,12 +308,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;
@@ -783,7 +782,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);
 
@@ -816,7 +815,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));