[vlc-commits] avformat: refactor meta getter, fix title & language and add items

Rémi Denis-Courmont git at videolan.org
Sat Apr 6 23:03:52 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr  7 00:01:34 2013 +0300| [f77e83aba1b92c1fb6dccabcdb14c1d4774af6af] | committer: Rémi Denis-Courmont

avformat: refactor meta getter, fix title & language and add items

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

 modules/demux/avformat/demux.c |   50 +++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index da81d59..4e48d31 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -868,24 +868,38 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_META:
         {
-            vlc_meta_t *p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* );
-
-            AVDictionaryEntry *title = av_dict_get( p_sys->ic->metadata, "language", NULL, 0 );
-            AVDictionaryEntry *artist = av_dict_get( p_sys->ic->metadata, "artist", NULL, 0 );
-            AVDictionaryEntry *copyright = av_dict_get( p_sys->ic->metadata, "copyright", NULL, 0 );
-            AVDictionaryEntry *comment = av_dict_get( p_sys->ic->metadata, "comment", NULL, 0 );
-            AVDictionaryEntry *genre = av_dict_get( p_sys->ic->metadata, "genre", NULL, 0 );
-
-            if( title && title->value )
-                vlc_meta_SetTitle( p_meta, title->value );
-            if( artist && artist->value )
-                vlc_meta_SetArtist( p_meta, artist->value );
-            if( copyright && copyright->value )
-                vlc_meta_SetCopyright( p_meta, copyright->value );
-            if( comment && comment->value )
-                vlc_meta_SetDescription( p_meta, comment->value );
-            if( genre && genre->value )
-                vlc_meta_SetGenre( p_meta, genre->value );
+            static const char names[][10] = {
+                [vlc_meta_Title] = "title",
+                [vlc_meta_Artist] = "artist",
+                [vlc_meta_Genre] = "genre",
+                [vlc_meta_Copyright] = "copyright",
+                [vlc_meta_Album] = "album",
+                //[vlc_meta_TrackNumber] -- TODO: parse number/total value
+                [vlc_meta_Description] = "comment",
+                //[vlc_meta_Rating]
+                [vlc_meta_Date] = "date",
+                [vlc_meta_Setting] = "encoder",
+                //[vlc_meta_URL]
+                [vlc_meta_Language] = "language",
+                //[vlc_meta_NowPlaying]
+                [vlc_meta_Publisher] = "publisher",
+                [vlc_meta_EncodedBy] = "encoded_by",
+                //[vlc_meta_ArtworkURL]
+                //[vlc_meta_TrackID]
+                //[vlc_meta_TrackTotal]
+            };
+            vlc_meta_t *p_meta = va_arg( args, vlc_meta_t * );
+            AVDictionary *dict = p_sys->ic->metadata;
+
+            for( unsigned i = 0; i < sizeof(names) / sizeof(*names); i++)
+            {
+                if( !names[i][0] )
+                    continue;
+
+                AVDictionaryEntry *e = av_dict_get( dict, names[i], NULL, 0 );
+                if( e != NULL && e->value != NULL )
+                    vlc_meta_Set( p_meta, i, e->value );
+            }
             return VLC_SUCCESS;
         }
 



More information about the vlc-commits mailing list