[vlc-devel] [PATCH] chromecast: demux: use DEMUX_GET_META by default to get the title and artwork URL

Steve Lhomme robux4 at videolabs.io
Thu Jun 23 15:14:12 CEST 2016


---
 modules/stream_out/chromecast/chromecast_demux.cpp | 44 +++++++++++++++++-----
 1 file changed, 35 insertions(+), 9 deletions(-)

diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index e671043..2185439 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -46,20 +46,46 @@ struct demux_sys_t
         ,canSeek(false)
         ,m_seektime( VLC_TS_INVALID )
     {
+        const char *title = NULL;
+        const char *artwork = NULL;
+        vlc_meta_t *p_meta = vlc_meta_New();
+        if( likely(p_meta != NULL) )
+        {
+            if (demux_Control( demux->p_next, DEMUX_GET_META, p_meta) == VLC_SUCCESS)
+            {
+                title = vlc_meta_Get( p_meta, vlc_meta_Title );
+                if ( title != NULL )
+                    p_renderer->pf_set_title( p_renderer->p_opaque, title );
+                artwork = vlc_meta_Get( p_meta, vlc_meta_ArtworkURL );
+                if ( artwork != NULL )
+                    p_renderer->pf_set_artwork( p_renderer->p_opaque, artwork );
+            }
+            vlc_meta_Delete(p_meta);
+        }
+
         demux_t *p_last_demux = demux->p_next;
         while (p_last_demux->p_next)
             p_last_demux = p_last_demux->p_next;
         input_thread_t *p_input = p_last_demux->p_input;
-        input_item_t *p_item = input_GetItem( p_input );
-        if ( p_item )
+        if ( title == NULL || artwork == NULL )
         {
-            char *psz_title = input_item_GetTitleFbName( p_item );
-            p_renderer->pf_set_title( p_renderer->p_opaque, psz_title );
-            free( psz_title );
-
-            psz_title = input_item_GetArtworkURL( p_item );
-            p_renderer->pf_set_artwork( p_renderer->p_opaque, psz_title );
-            free( psz_title );
+            input_item_t *p_item = input_GetItem( p_input );
+            if ( p_item )
+            {
+                if ( title == NULL )
+                {
+                    char *psz_title = input_item_GetTitleFbName( p_item );
+                    p_renderer->pf_set_title( p_renderer->p_opaque, psz_title );
+                    free( psz_title );
+                }
+
+                if ( artwork == NULL )
+                {
+                    char *psz_artwork = input_item_GetArtworkURL( p_item );
+                    p_renderer->pf_set_artwork( p_renderer->p_opaque, psz_artwork );
+                    free( psz_artwork );
+                }
+            }
         }
 
         p_renderer->pf_set_input_state( p_renderer->p_opaque,
-- 
2.8.2



More information about the vlc-devel mailing list