]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/xspf.c
XML: simplify demuxers
[vlc] / modules / demux / playlist / xspf.c
index 84df57d78f67af91a741b86b856132f174c4aa35..ed6f135f69c88b33944d2f9079e5fb614cff246e 100644 (file)
@@ -80,7 +80,6 @@ void Close_xspf( vlc_object_t *p_this )
 int Demux( demux_t *p_demux )
 {
     int i_ret = -1;
-    xml_t *p_xml = NULL;
     xml_reader_t *p_xml_reader = NULL;
     char *psz_name = NULL;
     input_item_t *p_current_input = GetCurrentItem(p_demux);
@@ -90,11 +89,7 @@ int Demux( demux_t *p_demux )
     p_demux->p_sys->psz_base = NULL;
 
     /* create new xml parser from stream */
-    p_xml = xml_Create( p_demux );
-    if( !p_xml )
-        goto end;
-
-    p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
+    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
     if( !p_xml_reader )
         goto end;
 
@@ -129,20 +124,16 @@ int Demux( demux_t *p_demux )
         input_item_t *p_new_input = p_demux->p_sys->pp_tracklist[i];
         if( p_new_input )
         {
-            input_item_AddSubItem( p_current_input, p_new_input );
             input_item_node_AppendItem( p_subitems, p_new_input );
         }
     }
 
-    input_item_AddSubItemTree( p_subitems );
-    input_item_node_Delete( p_subitems );
+    input_item_node_PostAndDelete( p_subitems );
 
 end:
     vlc_gc_decref(p_current_input);
     if( p_xml_reader )
-        xml_ReaderDelete( p_xml, p_xml_reader );
-    if( p_xml )
-        xml_Delete( p_xml );
+        xml_ReaderDelete( p_xml_reader );
     return i_ret; /* Needed for correct operation of go back */
 }
 
@@ -508,7 +499,6 @@ static bool parse_track_node COMPLEX_INTERFACE
 
                     if( p_sys->i_track_id < 0 )
                     {
-                        input_item_AddSubItem( p_input_item, p_new_input );
                         input_item_node_AppendNode( p_input_node, p_new_node );
                         vlc_gc_decref( p_new_input );
                         return true;
@@ -541,6 +531,9 @@ static bool parse_track_node COMPLEX_INTERFACE
                 /* special case: location */
                 if( !strcmp( p_handler->name, "location" ) )
                 {
+                    if( psz_value == NULL )
+                        input_item_SetURI( p_new_input, "vlc://nop" );
+                    else
                     /* FIXME: This is broken. Scheme-relative (//...) locations
                      * and anchors (#...) are not resolved correctly. Also,
                      * host-relative (/...) and directory-relative locations
@@ -724,7 +717,6 @@ static bool parse_extension_node COMPLEX_INTERFACE
                           ITEM_TYPE_DIRECTORY );
         if( p_new_input )
         {
-            input_item_AddSubItem( p_input_item, p_new_input );
             p_input_node =
                 input_item_node_AppendItem( p_input_node, p_new_input );
             p_input_item = p_new_input;
@@ -739,11 +731,28 @@ static bool parse_extension_node COMPLEX_INTERFACE
             msg_Warn( p_demux, "<extension> requires \"application\" attribute" );
             return false;
         }
+        /* Skip the extension if the application is not vlc
+           This will skip all children of the current node */
         else if( strcmp( psz_application, "http://www.videolan.org/vlc/playlist/0" ) )
         {
             msg_Dbg( p_demux, "Skipping \"%s\" extension tag", psz_application );
             free( psz_application );
-            return false;
+            /* Skip all children */
+            while( xml_ReaderRead( p_xml_reader ) == 1 )
+            {
+                if( xml_ReaderNodeType( p_xml_reader ) == XML_READER_ENDELEM )
+                {
+                    char *psz_name = xml_ReaderName( p_xml_reader );
+                    if( !strcmp( psz_name, "extension" ) )
+                    {
+                        free( psz_name );
+                        break;
+                    }
+                    msg_Dbg( p_demux, "\tskipping \"%s\" extension child", psz_name );
+                    free( psz_name );
+                }
+            }
+            return true;
         }
     }
     free( psz_application );
@@ -917,7 +926,6 @@ static bool parse_extitem_node COMPLEX_INTERFACE
     p_new_input = p_demux->p_sys->pp_tracklist[ i_tid ];
     if( p_new_input )
     {
-        input_item_AddSubItem( p_input_node->p_item, p_new_input );
         input_item_node_AppendItem( p_input_node, p_new_input );
         vlc_gc_decref( p_new_input );
         p_demux->p_sys->pp_tracklist[i_tid] = NULL;