]> git.sesse.net Git - vlc/commitdiff
* XSPF nested playlist
authorYoann Peronneau <yoann@videolan.org>
Tue, 13 Nov 2007 22:10:58 +0000 (22:10 +0000)
committerYoann Peronneau <yoann@videolan.org>
Tue, 13 Nov 2007 22:10:58 +0000 (22:10 +0000)
modules/demux/playlist/xspf.c
modules/misc/playlist/xspf.c
src/playlist/loadsave.c

index 6738f058b5862947332ca491d1ccbbafbbb2e893..4565780c4f6c41f5207377f1719aad78c1f23dfb 100644 (file)
@@ -477,7 +477,6 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE
                 if( !strcmp( psz_name, psz_element ) )
                 {
                     FREE_ATT();
-                    input_ItemAddSubItem( p_input_item, p_new_input );
                     if( p_demux->p_sys->i_identifier <
                         p_demux->p_sys->i_tracklist_entries )
                     {
@@ -655,6 +654,7 @@ static vlc_bool_t parse_extension_node COMPLEX_INTERFACE
     char *psz_application = NULL;
     int i_node;
     xml_elem_hnd_t *p_handler = NULL;
+    input_item_t *p_new_input = NULL;
 
     xml_elem_hnd_t pl_elements[] =
         { {"node",  COMPLEX_CONTENT, {.cmplx = parse_extension_node} },
@@ -691,14 +691,24 @@ static vlc_bool_t parse_extension_node COMPLEX_INTERFACE
     }
 
     /* attribute title is mandatory except for <extension> */
-    if( !strcmp( psz_element, "node" ) && !psz_title )
+    if( !strcmp( psz_element, "node" ) )
     {
-        msg_Warn( p_demux, "<node> requires \"title\" attribute" );
-        return VLC_FALSE;
-    }
-    free( psz_title );
+        if( !psz_title )
+        {
+            msg_Warn( p_demux, "<node> requires \"title\" attribute" );
+            return VLC_FALSE;
+        }
 
-    if( !strcmp( psz_element, "extension" ) )
+        p_new_input = input_ItemNewWithType( p_playlist, "", psz_title,
+                                             0, NULL, -1, ITEM_TYPE_DIRECTORY );
+        if( p_new_input )
+        {
+            input_ItemAddSubItem( p_input_item, p_new_input );
+            p_input_item = p_new_input;
+        }
+        free( psz_title );
+    }
+    else if( !strcmp( psz_element, "extension" ) )
     {
         if( !psz_application )
         {
@@ -824,6 +834,7 @@ static vlc_bool_t parse_extension_node COMPLEX_INTERFACE
  */
 static vlc_bool_t parse_extitem_node COMPLEX_INTERFACE
 {
+    input_item_t *p_new_input = NULL;
     char *psz_name = NULL;
     char *psz_value = NULL;
     int i_href = -1;
@@ -858,13 +869,17 @@ static vlc_bool_t parse_extitem_node COMPLEX_INTERFACE
         return VLC_FALSE;
     }
 
-    /* XXX: We can't check the validity of the 'href' attribute if we do parse
-            the extension before the TrackList
     if( i_href > p_demux->p_sys->i_tracklist_entries )
     {
         msg_Warn( p_demux, "invalid \"href\" attribute" );
         return VLC_FALSE;
-    }*/
+    }
+
+    p_new_input = p_demux->p_sys->pp_tracklist[ i_href ];
+    if( p_new_input )
+    {
+        input_ItemAddSubItem( p_input_item, p_new_input );
+    }
 
     /* fix for #1293 - XTAG sends ENDELEM for self closing tag */
     /* (libxml sends NONE) */
index 0f97da845cb491a78c7932245e9699c0fd624394..d2bbc8e594992488a230a93f68470fded0d5f285 100644 (file)
@@ -73,16 +73,6 @@ int E_(xspf_export_playlist)( vlc_object_t *p_this )
         free( psz_temp );
     }
 
-    /* export the tree structure in <extension> */
-    fprintf( p_export->p_file, "\t<extension application=\"http://www.videolan.org/vlc/playlist/0\">\n" );
-    i_count = 0;
-    for( i = 0; i < p_node->i_children; i++ )
-    {
-        xspf_extension_item( p_node->pp_children[i], p_export->p_file,
-                             &i_count );
-    }
-    fprintf( p_export->p_file, "\t</extension>\n" );
-
     /* export all items in a flat format */
     fprintf( p_export->p_file, "\t<trackList>\n" );
     i_count = 0;
@@ -93,6 +83,16 @@ int E_(xspf_export_playlist)( vlc_object_t *p_this )
     }
     fprintf( p_export->p_file, "\t</trackList>\n" );
 
+    /* export the tree structure in <extension> */
+    fprintf( p_export->p_file, "\t<extension application=\"http://www.videolan.org/vlc/playlist/0\">\n" );
+    i_count = 0;
+    for( i = 0; i < p_node->i_children; i++ )
+    {
+        xspf_extension_item( p_node->pp_children[i], p_export->p_file,
+                             &i_count );
+    }
+    fprintf( p_export->p_file, "\t</extension>\n" );
+
     /* close the header elements */
     fprintf( p_export->p_file, "</playlist>\n" );
 
index 655bea32007e980024d18081cc3d6914e852b465..9286a92036621bc530374b90b35800ad8cc27fd7 100644 (file)
@@ -99,8 +99,11 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
 
     /* The media library input has one and only one option: "meta-file"
      * So we remove that unneeded option. */
-    free( p_item->ppsz_options[0] );
-    p_item->i_options = 0;
+    if( p_item->i_options == 1 )
+    {
+        free( p_item->ppsz_options[0] );
+        p_item->i_options = 0;
+    }
 
     playlist_AddInput( p_playlist, p_item, PLAYLIST_APPEND, PLAYLIST_END,
             VLC_FALSE, VLC_FALSE );