]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/xspf.c
live555: remove the liveversion checks, now that we have a required version in config...
[vlc] / modules / demux / playlist / xspf.c
index 5d908628960a640b701cf5d5929c009470f5f806..42c1ed6e0d388007b1250ff1b30d09b1a0594922 100644 (file)
 # 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,14 +53,14 @@ 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;
     FREENULL( p_demux->p_sys->pp_tracklist );
@@ -121,7 +120,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;
@@ -152,7 +151,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 +248,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 +353,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++;
         }
@@ -410,7 +407,7 @@ static bool parse_track_node COMPLEX_INTERFACE
           {"duration",     SIMPLE_CONTENT,  {.smpl = set_item_info} },
           {"link",         SIMPLE_CONTENT,  {NULL} },
           {"meta",         SIMPLE_CONTENT,  {NULL} },
-          {"extension",    COMPLEX_CONTENT, {.cmplx = skip_element} },
+          {"extension",    COMPLEX_CONTENT, {.cmplx = parse_extension_node} },
           {NULL,           UNKNOWN_CONTENT, {NULL} }
         };
 
@@ -454,7 +451,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,16 +545,13 @@ 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_ItemNewExt( p_demux, psz_uri,
                                                         NULL, 0, NULL, -1 );
                         free( psz_uri );
                         input_ItemCopyOptions( p_input_item, p_new_input );
@@ -660,6 +653,22 @@ static bool set_item_info SIMPLE_INTERFACE
     return true;
 }
 
+/**
+ * \brief handles the <option> elements
+ */
+static bool set_option SIMPLE_INTERFACE
+{
+    /* exit if setting is impossible */
+    if( !psz_name || !psz_value || !p_input )
+        return false;
+
+    /* re-convert xml special characters inside psz_value */
+    resolve_xml_special_chars( psz_value );
+    
+    input_ItemAddOpt( p_input, psz_value, 0 );
+    
+    return true;
+}
 
 /**
  * \brief parse the extension node of a XSPF playlist
@@ -677,6 +686,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
     xml_elem_hnd_t pl_elements[] =
         { {"node",  COMPLEX_CONTENT, {.cmplx = parse_extension_node} },
           {"item",  COMPLEX_CONTENT, {.cmplx = parse_extitem_node} },
+          {"option", SIMPLE_CONTENT, {.smpl = set_option} },
           {NULL,    UNKNOWN_CONTENT, {NULL} }
         };
 
@@ -717,7 +727,7 @@ 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_ItemNewWithType( VLC_OBJECT( p_demux ), "vlc://nop",
                                 psz_title, 0, NULL, -1, ITEM_TYPE_DIRECTORY );
         if( p_new_input )
         {
@@ -775,7 +785,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 ) )
@@ -853,7 +862,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
  */
 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 )