[vlc-devel] commit: Move p_meta from 1 input structure to another ( Rafaël Carré )

git version control git at videolan.org
Mon Jun 9 17:54:39 CEST 2008


vlc | branch: 0.8.6-neuros | Rafaël Carré <funman at videolan.org> | Mon Jun  9 17:56:05 2008 +0200| [2c4c20dbe946a6bbac65d60410552c0170b80bd5]

Move p_meta from 1 input structure to another

DBus now supports meta data - backport complete

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

 include/vlc_input.h    |    7 ++---
 include/vlc_meta.h     |    4 ++-
 modules/control/dbus.c |   52 ++++++++++++++++++++++++------------------------
 src/input/input.c      |   36 +++++++++++++++++++-------------
 4 files changed, 53 insertions(+), 46 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 55bde9b..4b5fdf9 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -2,7 +2,7 @@
  * vlc_input.h: Core input structures
  *****************************************************************************
  * Copyright (C) 1999-2004 the VideoLAN team
- * $Id$
+ * $Id: 55bde9bd37aba04960af657bf0c6ba3876932af1 $
  *
  * Authors: Christophe Massiot <massiot at via.ecp.fr>
  *          Laurent Aimar <fenrir at via.ecp.fr>
@@ -47,6 +47,8 @@ struct input_item_t
     char       *psz_name;            /**< text describing this item */
     char       *psz_uri;             /**< mrl of this item */
 
+    vlc_meta_t  *p_meta;
+
     int        i_options;            /**< Number of input options */
     char       **ppsz_options;       /**< Array of input options */
 
@@ -385,9 +387,6 @@ struct input_thread_t
     int         i_bookmark;
     seekpoint_t **bookmark;
 
-    /* Global meta datas FIXME move to input_item_t ? */
-    vlc_meta_t  *p_meta;
-
     /* Output */
     es_out_t    *p_es_out;
     sout_instance_t *p_sout;            /* XXX Move it to es_out ? */
diff --git a/include/vlc_meta.h b/include/vlc_meta.h
index 5041fbf..5ab00ae 100644
--- a/include/vlc_meta.h
+++ b/include/vlc_meta.h
@@ -2,7 +2,7 @@
  * vlc_meta.h: Stream meta-data
  *****************************************************************************
  * Copyright (C) 2004 the VideoLAN team
- * $Id$
+ * $Id: 5041fbfb92458eddc317f780b139afef71d6f938 $
  *
  * Authors: Laurent Aimar <fenrir at via.ecp.fr>
  *
@@ -166,6 +166,8 @@ static inline char *vlc_meta_GetValue( vlc_meta_t *m, const char *name )
 {
     int i;
 
+    if( !m ) return NULL;
+
     for( i = 0; i < m->i_meta; i++ )
     {
         if( !strcmp( m->name[i], name ) )
diff --git a/modules/control/dbus.c b/modules/control/dbus.c
index 158a249..bce8f19 100644
--- a/modules/control/dbus.c
+++ b/modules/control/dbus.c
@@ -1079,9 +1079,8 @@ static int UpdateCaps( intf_thread_t* p_intf, vlc_bool_t b_playlist_locked )
 
 #define ADD_VLC_META_STRING( entry, item ) \
     { \
-        char * psz = input_item_Get##item( p_input );\
-        ADD_META( entry, DBUS_TYPE_STRING, \
-                  psz ); \
+        char *psz = vlc_meta_GetValue( p_input->p_meta, item ); \
+        ADD_META( entry, DBUS_TYPE_STRING, psz ); \
         free( psz ); \
     }
 
@@ -1097,29 +1096,28 @@ static int GetInputMeta( input_item_t* p_input,
     {
     "title", "artist", "genre", "copyright", "album", "tracknum",
     "description", "rating", "date", "setting", "url", "language",
-    "nowplaying", "publisher", "encodedby", "arturl", "trackid",
-    "status", "location", "length", "video-codec", "audio-codec",
-    "video-bitrate", "audio-bitrate", "audio-samplerate"
+    "nowplaying", "publisher", /*"encodedby", "arturl", "trackid",
+    "status", */"location", "length"/*, "video-codec", "audio-codec",
+    "video-bitrate", "audio-bitrate", "audio-samplerate"*/
     };
 
     dbus_message_iter_open_container( args, DBUS_TYPE_ARRAY, "{sv}", &dict );
-/*
- * FIXME : move p_meta in input item
- *
-    ADD_VLC_META_STRING( 0,  Title );
-    ADD_VLC_META_STRING( 1,  Artist );
-    ADD_VLC_META_STRING( 2,  Genre );
-    ADD_VLC_META_STRING( 3,  Copyright );
-    ADD_VLC_META_STRING( 4,  Album );
-    ADD_VLC_META_STRING( 5,  TrackNum );
-    ADD_VLC_META_STRING( 6,  Description );
-    ADD_VLC_META_STRING( 7,  Rating );
-    ADD_VLC_META_STRING( 8,  Date );
-    ADD_VLC_META_STRING( 9,  Setting );
-    ADD_VLC_META_STRING( 10, URL );
-    ADD_VLC_META_STRING( 11, Language );
-    ADD_VLC_META_STRING( 12, NowPlaying );
-    ADD_VLC_META_STRING( 13, Publisher );
+
+    ADD_VLC_META_STRING( 0,  VLC_META_TITLE );
+    ADD_VLC_META_STRING( 1,  VLC_META_ARTIST );
+    ADD_VLC_META_STRING( 2,  VLC_META_GENRE );
+    ADD_VLC_META_STRING( 3,  VLC_META_COPYRIGHT );
+    ADD_VLC_META_STRING( 4,  VLC_META_COLLECTION );
+    ADD_VLC_META_STRING( 5,  VLC_META_SEQ_NUM );
+    ADD_VLC_META_STRING( 6,  VLC_META_DESCRIPTION );
+    ADD_VLC_META_STRING( 7,  VLC_META_RATING );
+    ADD_VLC_META_STRING( 8,  VLC_META_DATE );
+    ADD_VLC_META_STRING( 9,  VLC_META_SETTING );
+    ADD_VLC_META_STRING( 10, VLC_META_URL );
+    ADD_VLC_META_STRING( 11, VLC_META_LANGUAGE );
+    ADD_VLC_META_STRING( 12, VLC_META_NOW_PLAYING );
+    ADD_VLC_META_STRING( 13, VLC_META_PUBLISHER );
+#if 0 /* these don't exist in 0.8.6 */
     ADD_VLC_META_STRING( 14, EncodedBy );
     ADD_VLC_META_STRING( 15, ArtURL );
     ADD_VLC_META_STRING( 16, TrackID );
@@ -1128,10 +1126,12 @@ static int GetInputMeta( input_item_t* p_input,
     if( p_input->p_meta )
         ADD_META( 17, DBUS_TYPE_INT32, p_input->p_meta->i_status );
     vlc_mutex_unlock( &p_input->lock );
+#endif
+
+    ADD_META( 14, DBUS_TYPE_STRING, p_input->psz_uri );
+
+    ADD_META( 15, DBUS_TYPE_INT64, i_length );
 
-    ADD_VLC_META_STRING( 18, URI );
-    ADD_META( 19, DBUS_TYPE_INT64, i_length );
-*/
     dbus_message_iter_close_container( args, &dict );
     return VLC_SUCCESS;
 }
diff --git a/src/input/input.c b/src/input/input.c
index 9c83245..7463635 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2,7 +2,7 @@
  * input.c: input thread
  *****************************************************************************
  * Copyright (C) 1998-2004 the VideoLAN team
- * $Id$
+ * $Id: 9c83245aa343e777ede36c58d652a2e2ea5da0c8 $
  *
  * Authors: Christophe Massiot <massiot at via.ecp.fr>
  *          Laurent Aimar <fenrir at via.ecp.fr>
@@ -133,7 +133,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     p_input->i_rate  = INPUT_RATE_DEFAULT;
     p_input->i_bookmark = 0;
     p_input->bookmark = NULL;
-    p_input->p_meta  = NULL;
     p_input->p_es_out = NULL;
     p_input->p_sout  = NULL;
     p_input->b_out_pace_control = VLC_FALSE;
@@ -141,6 +140,8 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
 
     /* Init Input fields */
     p_input->input.p_item = p_item;
+    if( p_input->input.p_item )
+        p_input->input.p_item->p_meta = NULL;
     p_input->input.p_access = NULL;
     p_input->input.p_stream = NULL;
     p_input->input.p_demux  = NULL;
@@ -347,7 +348,7 @@ int __input_Preparse( vlc_object_t *p_parent, input_item_t *p_item )
     if( p_input->p_es_out ) input_EsOutDelete( p_input->p_es_out );
 
     /* Delete meta */
-    if( p_input->p_meta ) vlc_meta_Delete( p_input->p_meta );
+    if( p_input->input.p_item && p_input->input.p_item->p_meta ) vlc_meta_Delete( p_input->input.p_item->p_meta );
 
     vlc_object_detach( p_input );
     vlc_object_destroy( p_input );
@@ -1088,7 +1089,8 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
         }
     }
 
-    p_input->p_meta = p_meta;
+    if( p_input->input.p_item )
+        p_input->input.p_item->p_meta = p_meta;
     UpdateMeta( p_input, b_quick );
 
     if( !b_quick )
@@ -1191,8 +1193,8 @@ static void End( input_thread_t * p_input )
     }
 
     /* Delete meta */
-    if( p_input->p_meta )
-        vlc_meta_Delete( p_input->p_meta );
+    if( p_input->input.p_item && p_input->input.p_item->p_meta )
+        vlc_meta_Delete( p_input->input.p_item->p_meta );
 
     /* Tell we're dead */
     p_input->b_dead = VLC_TRUE;
@@ -1715,14 +1717,14 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
                     /* Update meta */
                     if( p_meta_new )
                     {
-                        if( p_input->p_meta )
+                        if( p_input->input.p_item && p_input->input.p_item->p_meta )
                         {
-                            vlc_meta_Merge( p_input->p_meta, p_meta_new );
+                            vlc_meta_Merge( p_input->input.p_item->p_meta, p_meta_new );
                             vlc_meta_Delete( p_meta_new );
                         }
-                        else
+                        else if( p_input->input.p_item )
                         {
-                            p_input->p_meta = p_meta_new;
+                            p_input->input.p_item->p_meta = p_meta_new;
                         }
                         UpdateMeta( p_input, VLC_FALSE );
                     }
@@ -1834,14 +1836,14 @@ static int UpdateFromAccess( input_thread_t *p_input )
         vlc_meta_t *p_meta;
         if( !access2_Control( p_input->input.p_access,ACCESS_GET_META,&p_meta))
         {
-            if( p_input->p_meta )
+            if( p_input->input.p_item && p_input->input.p_item->p_meta )
             {
-                vlc_meta_Merge( p_input->p_meta, p_meta );
+                vlc_meta_Merge( p_input->input.p_item->p_meta, p_meta );
                 vlc_meta_Delete( p_meta );
             }
-            else
+            else if( p_input->input.p_item )
             {
-                p_input->p_meta = p_meta;
+                p_input->input.p_item->p_meta = p_meta;
             }
 
             UpdateMeta( p_input, VLC_FALSE );
@@ -1884,9 +1886,13 @@ static int UpdateFromAccess( input_thread_t *p_input )
  *****************************************************************************/
 static int  UpdateMeta( input_thread_t *p_input, vlc_bool_t b_quick )
 {
-    vlc_meta_t *p_meta = p_input->p_meta;
+    vlc_meta_t *p_meta;
     int i;
 
+    if( !p_input->input.p_item ) return VLC_EGENERIC; /* no meta */
+
+    p_meta = p_input->input.p_item->p_meta;
+
     if( !p_meta || p_meta->i_meta == 0 )
         return VLC_SUCCESS;
 




More information about the vlc-devel mailing list