]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/xspf.c
ts demux: any teletext type of 1-5 is valid.
[vlc] / modules / demux / playlist / xspf.c
index b0ac7b3734b28e602555b810f1edb842c3919e3f..991291522db032594a5c4b9e7eba2fc915147bd3 100644 (file)
@@ -1,3 +1,4 @@
+
 /*******************************************************************************
  * xspf.c : XSPF playlist import functions
  *******************************************************************************
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_demux.h>
 
-#include "playlist.h"
-#include "vlc_xml.h"
-#include "vlc_strings.h"
-#include "vlc_url.h"
+#include <vlc_xml.h>
+#include <vlc_strings.h>
+#include <vlc_url.h>
 #include "xspf.h"
+#include "playlist.h"
 
 struct demux_sys_t
 {
-    playlist_item_t *p_item_in_category;
     input_item_t **pp_tracklist;
     int i_tracklist_entries;
     int i_identifier;
@@ -54,16 +54,22 @@ static int Demux( demux_t * );
 /**
  * \brief XSPF submodule initialization function
  */
-int E_(Import_xspf)( vlc_object_t *p_this )
+int Import_xspf( vlc_object_t *p_this )
 {
     DEMUX_BY_EXTENSION_OR_FORCED_MSG( ".xspf", "xspf-open",
                                       "using XSPF playlist reader" );
     return VLC_SUCCESS;
 }
 
-void E_(Close_xspf)( vlc_object_t *p_this )
+void Close_xspf( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
+    int i;
+    for(i = 0; i < p_demux->p_sys->i_tracklist_entries; i++)
+    {
+        if(p_demux->p_sys->pp_tracklist[i])
+            vlc_gc_decref( p_demux->p_sys->pp_tracklist[i] );
+    }
     FREENULL( p_demux->p_sys->pp_tracklist );
     FREENULL( p_demux->p_sys->psz_base );
     free( p_demux->p_sys );
@@ -121,7 +127,7 @@ int Demux( demux_t *p_demux )
     }
 
     if( i_ret == 1 )
-        i_ret = parse_playlist_node( p_demux, p_playlist, p_current_input,
+        i_ret = parse_playlist_node( p_demux, p_current_input,
                                      p_xml_reader, "playlist" ) ? 0 : -1;
 
     int i;
@@ -130,7 +136,7 @@ int Demux( demux_t *p_demux )
         input_item_t *p_new_input = p_demux->p_sys->pp_tracklist[i];
         if( p_new_input )
         {
-            input_ItemAddSubItem( p_current_input, p_new_input );
+            input_item_AddSubItem( p_current_input, p_new_input );
         }
     }
 
@@ -152,7 +158,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 /**
  * \brief parse the root node of a XSPF playlist
  * \param p_demux demuxer instance
- * \param p_playlist playlist instance
  * \param p_input_item current input item
  * \param p_xml_reader xml reader instance
  * \param psz_element name of element to parse
@@ -250,7 +255,6 @@ static bool parse_playlist_node COMPLEX_INTERFACE
                 if( p_handler->type == COMPLEX_CONTENT )
                 {
                     if( p_handler->pf_handler.cmplx( p_demux,
-                                                     p_playlist,
                                                      p_input_item,
                                                      p_xml_reader,
                                                      p_handler->name ) )
@@ -356,7 +360,7 @@ static bool parse_tracklist_node COMPLEX_INTERFACE
             FREE_NAME();
 
             /* parse the track data in a separate function */
-            if( parse_track_node( p_demux, p_playlist, p_input_item,
+            if( parse_track_node( p_demux, p_input_item,
                                    p_xml_reader,"track" ) == true )
                 i_ntracks++;
         }
@@ -454,7 +458,6 @@ static bool parse_track_node COMPLEX_INTERFACE
                         return false;
                     }
                     if( p_handler->pf_handler.cmplx( p_demux,
-                                                     p_playlist,
                                                      p_new_input,
                                                      p_xml_reader,
                                                      p_handler->name ) )
@@ -549,19 +552,16 @@ static bool parse_track_node COMPLEX_INTERFACE
                                    strlen(p_demux->p_sys->psz_base) +
                                    strlen(psz_uri) +1 );
                            if( !psz_tmp )
-                           {
-                               msg_Err( p_demux, "out of memory");
                                return false;
-                           }
                            sprintf( psz_tmp, "%s%s",
                                     p_demux->p_sys->psz_base, psz_uri );
                            free( psz_uri );
                            psz_uri = psz_tmp;
                         }
-                        p_new_input = input_ItemNewExt( p_playlist, psz_uri,
+                        p_new_input = input_item_NewExt( p_demux, psz_uri,
                                                         NULL, 0, NULL, -1 );
                         free( psz_uri );
-                        input_ItemCopyOptions( p_input_item, p_new_input );
+                        input_item_CopyOptions( p_input_item, p_new_input );
                         psz_uri = NULL;
                         FREE_ATT();
                         p_handler = NULL;
@@ -672,7 +672,7 @@ static bool set_option SIMPLE_INTERFACE
     /* re-convert xml special characters inside psz_value */
     resolve_xml_special_chars( psz_value );
     
-    input_ItemAddOpt( p_input, psz_value, 0 );
+    input_item_AddOpt( p_input, psz_value, 0 );
     
     return true;
 }
@@ -687,6 +687,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
     char *psz_title = NULL;
     char *psz_application = NULL;
     int i_node;
+    bool b_release_input_item = false;
     xml_elem_hnd_t *p_handler = NULL;
     input_item_t *p_new_input = NULL;
 
@@ -734,13 +735,13 @@ static bool parse_extension_node COMPLEX_INTERFACE
             msg_Warn( p_demux, "<node> requires \"title\" attribute" );
             return false;
         }
-        p_new_input = input_ItemNewWithType( VLC_OBJECT( p_playlist ), "vlc://nop",
+        p_new_input = input_item_NewWithType( VLC_OBJECT( p_demux ), "vlc://nop",
                                 psz_title, 0, NULL, -1, ITEM_TYPE_DIRECTORY );
         if( p_new_input )
         {
-            input_ItemAddSubItem( p_input_item, p_new_input );
+            input_item_AddSubItem( p_input_item, p_new_input );
             p_input_item = p_new_input;
-            vlc_gc_decref( p_new_input );
+            b_release_input_item = true;
         }
         free( psz_title );
     }
@@ -775,6 +776,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 {
                     msg_Err( p_demux, "invalid xml stream" );
                     FREE_ATT();
+                    if(b_release_input_item) vlc_gc_decref( p_new_input );
                     return false;
                 }
                 /* choose handler */
@@ -785,6 +787,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 {
                     msg_Err( p_demux, "unexpected element <%s>", psz_name );
                     FREE_ATT();
+                    if(b_release_input_item) vlc_gc_decref( p_new_input );
                     return false;
                 }
                 FREE_NAME();
@@ -792,7 +795,6 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 if( p_handler->type == COMPLEX_CONTENT )
                 {
                     if( p_handler->pf_handler.cmplx( p_demux,
-                                                     p_playlist,
                                                      p_input_item,
                                                      p_xml_reader,
                                                      p_handler->name ) )
@@ -803,6 +805,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                     else
                     {
                         FREE_ATT();
+                        if(b_release_input_item) vlc_gc_decref( p_new_input );
                         return false;
                     }
                 }
@@ -816,6 +819,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 {
                     msg_Err( p_demux, "invalid xml stream" );
                     FREE_ATT();
+                    if(b_release_input_item) vlc_gc_decref( p_new_input );
                     return false;
                 }
                 break;
@@ -827,12 +831,14 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 {
                     msg_Err( p_demux, "invalid xml stream" );
                     FREE_ATT();
+                    if(b_release_input_item) vlc_gc_decref( p_new_input );
                     return false;
                 }
                 /* leave if the current parent node is terminated */
                 if( !strcmp( psz_name, psz_element ) )
                 {
                     FREE_ATT();
+                    if(b_release_input_item) vlc_gc_decref( p_new_input );
                     return true;
                 }
                 /* there MUST have been a start tag for that element name */
@@ -842,6 +848,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                     msg_Err( p_demux, "there's no open element left for <%s>",
                              psz_name );
                     FREE_ATT();
+                    if(b_release_input_item) vlc_gc_decref( p_new_input );
                     return false;
                 }
 
@@ -858,10 +865,12 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 /* unknown/unexpected xml node */
                 msg_Err( p_demux, "unexpected xml node %i", i_node );
                 FREE_ATT();
+                if(b_release_input_item) vlc_gc_decref( p_new_input );
                 return false;
         }
         FREE_NAME();
     }
+    if(b_release_input_item) vlc_gc_decref( p_new_input );
     return false;
 }
 
@@ -870,7 +879,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
  */
 static bool parse_extitem_node COMPLEX_INTERFACE
 {
-    VLC_UNUSED(p_playlist); VLC_UNUSED(psz_element);
+    VLC_UNUSED(psz_element);
     input_item_t *p_new_input = NULL;
     char *psz_name = NULL;
     char *psz_value = NULL;
@@ -915,7 +924,7 @@ static bool parse_extitem_node COMPLEX_INTERFACE
     p_new_input = p_demux->p_sys->pp_tracklist[ i_href ];
     if( p_new_input )
     {
-        input_ItemAddSubItem( p_input_item, p_new_input );
+        input_item_AddSubItem( p_input_item, p_new_input );
         vlc_gc_decref( p_new_input );
         p_demux->p_sys->pp_tracklist[i_href] = NULL;
     }
@@ -932,7 +941,7 @@ static bool parse_extitem_node COMPLEX_INTERFACE
  */
 static bool skip_element COMPLEX_INTERFACE
 {
-    VLC_UNUSED(p_demux); VLC_UNUSED(p_playlist); VLC_UNUSED(p_input_item);
+    VLC_UNUSED(p_demux); VLC_UNUSED(p_input_item);
     char *psz_endname;
 
     while( xml_ReaderRead( p_xml_reader ) == 1 )