[vlc-commits] vout: use current table info for epg

Francois Cartegnie git at videolan.org
Wed Dec 28 11:14:08 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Dec 27 14:42:11 2016 +0100| [e22bb098f46e48b6512a1cc26e9a5747915b47f5] | committer: Francois Cartegnie

vout: use current table info for epg

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e22bb098f46e48b6512a1cc26e9a5747915b47f5
---

 src/video_output/video_epg.c | 52 ++++++++++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 21 deletions(-)

diff --git a/src/video_output/video_epg.c b/src/video_output/video_epg.c
index ef2326e..9e493f2 100644
--- a/src/video_output/video_epg.c
+++ b/src/video_output/video_epg.c
@@ -165,13 +165,13 @@ static subpicture_region_t * vout_BuildOSDEpg(vlc_epg_t *epg,
 
     /* Display the name of the current program. */
     last_ptr = &(*last_ptr)->p_next;
-    *last_ptr = vout_OSDEpgText(epg->p_current->psz_name,
+    *last_ptr = vout_OSDEpgText(epg->p_current ? epg->p_current->psz_name : NULL,
                                 x + visible_width  * (EPG_LEFT + 0.025),
                                 y + visible_height * (EPG_TOP + 0.05),
                                 visible_height * EPG_PROGRAM_SIZE,
                                 0x00ffffff);
 
-    if (!*last_ptr)
+    if (!*last_ptr || !epg->p_current)
         return head;
 
     /* Display the current program time slider. */
@@ -276,37 +276,47 @@ static void OSDEpgDestroy(subpicture_t *subpic)
  */
 int vout_OSDEpg(vout_thread_t *vout, input_item_t *input)
 {
-    char *now_playing = input_item_GetNowPlayingFb(input);
     vlc_epg_t *epg = NULL;
 
     /* Look for the current program EPG event */
-    if(now_playing){
-        vlc_mutex_lock(&input->lock);
-
-        for (int i = 0; i < input->i_epg; i++) {
-            const vlc_epg_t *tmp = input->pp_epg[i];
-
-            if (tmp->p_current &&
-                tmp->p_current->psz_name &&
-                !strcmp(tmp->p_current->psz_name, now_playing)) {
-                 epg = vlc_epg_New(tmp->i_id, tmp->i_source_id);
-                if(epg){
-                    if(tmp->psz_name)
-                        epg->psz_name = strdup(tmp->psz_name);
-                    vlc_epg_Merge(epg, tmp);
+
+    vlc_mutex_lock(&input->lock);
+
+    const vlc_epg_t *tmp = input->p_epg_table;
+    if ( tmp )
+    {
+        /* Pick table designated event, or first/next one */
+        const vlc_epg_event_t *p_current_event = tmp->p_current;
+        epg = vlc_epg_New(tmp->i_id, tmp->i_source_id);
+        if(epg)
+        {
+            if( p_current_event )
+            {
+                vlc_epg_event_t *p_event = vlc_epg_event_Duplicate(p_current_event);
+                if(p_event)
+                {
+                    if(!vlc_epg_AddEvent(epg, p_event))
+                    {
+                        vlc_epg_Delete(epg);
+                        vlc_epg_event_Delete(p_event);
+                        epg = NULL;
+                    }
+                    else vlc_epg_SetCurrent(epg, p_event->i_start);
                 }
-                break;
             }
+            if(tmp->psz_name)
+                epg->psz_name = strdup(tmp->psz_name);
         }
-
-        vlc_mutex_unlock(&input->lock);
-        free(now_playing);
     }
+    vlc_mutex_unlock(&input->lock);
 
     /* If no EPG event has been found. */
     if (epg == NULL)
         return VLC_EGENERIC;
 
+    if(epg->psz_name == NULL) /* Fallback (title == channel name) */
+        epg->psz_name = input_item_GetMeta( input, vlc_meta_Title );
+
     subpicture_updater_sys_t *sys = malloc(sizeof(*sys));
     if (!sys) {
         vlc_epg_Delete(epg);



More information about the vlc-commits mailing list