]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/pls.c
input_item: compress two functions into one and rename "Add" into "Post" for clarity...
[vlc] / modules / demux / playlist / pls.c
index 7006b49a023a9a6843eb01d24dd2bacdeace3db0..7bbdcb4e4f002d9ab0ccdb3e6d7b291f37f58ca0 100644 (file)
@@ -29,7 +29,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_demux.h>
 
 #include "playlist.h"
@@ -48,21 +48,21 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
 /*****************************************************************************
  * Import_PLS: main import function
  *****************************************************************************/
-int E_(Import_PLS)( vlc_object_t *p_this )
+int Import_PLS( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
     const uint8_t *p_peek;
     CHECK_PEEK( p_peek, 10 );
 
     if( POKE( p_peek, "[playlist]", 10 ) || POKE( p_peek, "[Reference]", 10 ) ||
-        demux2_IsPathExtension( p_demux, ".pls" )   || demux2_IsForced( p_demux, "pls" ) )
+        demux_IsPathExtension( p_demux, ".pls" )   || demux_IsForced( p_demux, "pls" ) )
     {
         ;
     }
     else return VLC_EGENERIC;
 
     STANDARD_DEMUX_INIT_MSG(  "found valid PLS playlist file");
-    p_demux->p_sys->psz_prefix = E_(FindPrefix)( p_demux );
+    p_demux->p_sys->psz_prefix = FindPrefix( p_demux );
 
     return VLC_SUCCESS;
 }
@@ -70,7 +70,7 @@ int E_(Import_PLS)( vlc_object_t *p_this )
 /*****************************************************************************
  * Deactivate: frees unused data
  *****************************************************************************/
-void E_(Close_PLS)( vlc_object_t *p_this )
+void Close_PLS( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
     free( p_demux->p_sys->psz_prefix );
@@ -91,7 +91,9 @@ static int Demux( demux_t *p_demux )
     int            i_key_length;
     input_item_t *p_input;
 
-    INIT_PLAYLIST_STUFF;
+    input_item_t *p_current_input = GetCurrentItem(p_demux);
+
+    input_item_node_t *p_subitems = input_item_node_Create( p_current_input );
 
     while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
     {
@@ -159,10 +161,9 @@ static int Demux( demux_t *p_demux )
         {
             if( psz_mrl )
             {
-                p_input = input_ItemNewExt( p_playlist, psz_mrl, psz_name,
-                                            0, NULL, -1 );
-                input_ItemCopyOptions( p_current_input, p_input );
-                input_ItemAddSubItem( p_current_input, p_input );
+                p_input = input_item_New( p_demux, psz_mrl, psz_name );
+                input_item_CopyOptions( p_current_input, p_input );
+                input_item_node_AppendItem( p_subitems, p_input );
                 vlc_gc_decref( p_input );
             }
             else
@@ -180,7 +181,7 @@ static int Demux( demux_t *p_demux )
         {
             free( psz_mrl_orig );
             psz_mrl_orig =
-            psz_mrl = E_(ProcessMRL)( psz_value, p_demux->p_sys->psz_prefix );
+            psz_mrl = ProcessMRL( psz_value, p_demux->p_sys->psz_prefix );
 
             if( !strncasecmp( psz_key, "Ref", sizeof("Ref") -1 ) )
             {
@@ -215,9 +216,9 @@ static int Demux( demux_t *p_demux )
     /* Add last object */
     if( psz_mrl )
     {
-        p_input = input_ItemNewExt( p_playlist, psz_mrl, psz_name,0, NULL, -1 );
-        input_ItemCopyOptions( p_current_input, p_input );
-        input_ItemAddSubItem( p_current_input, p_input );
+        p_input = input_item_New( p_demux, psz_mrl, psz_name );
+        input_item_CopyOptions( p_current_input, p_input );
+        input_item_node_AppendItem( p_subitems, p_input );
         vlc_gc_decref( p_input );
         free( psz_mrl_orig );
         psz_mrl = NULL;
@@ -229,7 +230,9 @@ static int Demux( demux_t *p_demux )
     free( psz_name );
     psz_name = NULL;
 
-    HANDLE_PLAY_AND_RELEASE;
+    input_item_node_PostAndDelete( p_subitems );
+
+    vlc_gc_decref(p_current_input);
     return 0; /* Needed for correct operation of go back */
 }