[vlc-commits] itml: convert to stream filter

Rémi Denis-Courmont git at videolan.org
Sat Jun 3 22:02:20 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon May 22 20:42:37 2017 +0300| [de982dbd7e46260a81e00c3cad24ba0cb7167f2b] | committer: Rémi Denis-Courmont

itml: convert to stream filter

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=de982dbd7e46260a81e00c3cad24ba0cb7167f2b
---

 modules/demux/playlist/itml.c     | 39 +++++++++++++++++----------------------
 modules/demux/playlist/itml.h     |  2 +-
 modules/demux/playlist/playlist.c |  4 ++--
 3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/modules/demux/playlist/itml.c b/modules/demux/playlist/itml.c
index 9eb60bdc5e..bd1b1bebe4 100644
--- a/modules/demux/playlist/itml.c
+++ b/modules/demux/playlist/itml.c
@@ -30,38 +30,37 @@
 #endif
 
 #include <vlc_common.h>
-#include <vlc_demux.h>
+#include <vlc_access.h>
 #include <vlc_xml.h>
 #include <vlc_strings.h>
 #include <vlc_url.h>
-#include <vlc_fixups.h>
 
 #include "itml.h"
 #include "playlist.h"
 
-static int Demux( demux_t * );
+static int ReadDir( stream_t *, input_item_node_t * );
 
 /**
  * \brief iTML submodule initialization function
  */
 int Import_iTML( vlc_object_t *p_this )
 {
-    demux_t *p_demux = (demux_t *)p_this;
+    stream_t *p_demux = (stream_t *)p_this;
     CHECK_FILE(p_demux);
-    if( !demux_IsPathExtension( p_demux, ".xml" )
-     && !demux_IsForced( p_demux, "itml" ) )
-        return VLC_EGENERIC; \
+    if( !stream_HasExtension( p_demux, ".xml" )
+     && !p_demux->obj.force )
+        return VLC_EGENERIC;
 
     const uint8_t *p_peek;
-    const ssize_t i_peek = vlc_stream_Peek( p_demux->s, &p_peek, 128 );
+    const ssize_t i_peek = vlc_stream_Peek( p_demux->p_source, &p_peek, 128 );
     if ( i_peek < 32 ||
          !strnstr( (const char *) p_peek, "<!DOCTYPE plist ", i_peek ) )
         return VLC_EGENERIC;
 
     msg_Dbg( p_demux, "using iTunes Media Library reader" );
 
-    p_demux->pf_demux = Demux;
-    p_demux->pf_control = Control;
+    p_demux->pf_readdir = ReadDir;
+    p_demux->pf_control = access_vaDirectoryControlHelper;
 
     return VLC_SUCCESS;
 }
@@ -69,17 +68,15 @@ int Import_iTML( vlc_object_t *p_this )
 /**
  * \brief demuxer function for iTML parsing
  */
-int Demux( demux_t *p_demux )
+static int ReadDir( stream_t *p_demux, input_item_node_t *p_subitems )
 {
     xml_reader_t *p_xml_reader;
     const char *node;
 
-    input_item_t *p_current_input = GetCurrentItem(p_demux);
-
     p_demux->p_sys = (void *)(uintptr_t)0;
 
     /* create new xml parser from stream */
-    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
+    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->p_source );
     if( !p_xml_reader )
         goto end;
 
@@ -103,12 +100,10 @@ int Demux( demux_t *p_demux )
         goto end;
     }
 
-    input_item_node_t *p_subitems = input_item_node_Create( p_current_input );
     xml_elem_hnd_t pl_elements[] =
         { {"dict",    COMPLEX_CONTENT, {.cmplx = parse_plist_dict} } };
     parse_plist_node( p_demux, p_subitems, NULL, p_xml_reader, "plist",
                       pl_elements );
-    input_item_node_PostAndDelete( p_subitems );
 
 end:
     if( p_xml_reader )
@@ -121,7 +116,7 @@ end:
 /**
  * \brief parse the root node of the playlist
  */
-static bool parse_plist_node( demux_t *p_demux, input_item_node_t *p_input_node,
+static bool parse_plist_node( stream_t *p_demux, input_item_node_t *p_input_node,
                               track_elem_t *p_track, xml_reader_t *p_xml_reader,
                               const char *psz_element,
                               xml_elem_hnd_t *p_handlers )
@@ -157,7 +152,7 @@ static bool parse_plist_node( demux_t *p_demux, input_item_node_t *p_input_node,
  * \brief parse a <dict>
  * \param COMPLEX_INTERFACE
  */
-static bool parse_dict( demux_t *p_demux, input_item_node_t *p_input_node,
+static bool parse_dict( stream_t *p_demux, input_item_node_t *p_input_node,
                         track_elem_t *p_track, xml_reader_t *p_xml_reader,
                         const char *psz_element, xml_elem_hnd_t *p_handlers )
 {
@@ -247,7 +242,7 @@ end:
     return b_ret;
 }
 
-static bool parse_plist_dict( demux_t *p_demux, input_item_node_t *p_input_node,
+static bool parse_plist_dict( stream_t *p_demux, input_item_node_t *p_input_node,
                               track_elem_t *p_track, xml_reader_t *p_xml_reader,
                               const char *psz_element,
                               xml_elem_hnd_t *p_handlers )
@@ -269,7 +264,7 @@ static bool parse_plist_dict( demux_t *p_demux, input_item_node_t *p_input_node,
                        "dict", pl_elements );
 }
 
-static bool parse_tracks_dict( demux_t *p_demux, input_item_node_t *p_input_node,
+static bool parse_tracks_dict( stream_t *p_demux, input_item_node_t *p_input_node,
                                track_elem_t *p_track, xml_reader_t *p_xml_reader,
                                const char *psz_element,
                                xml_elem_hnd_t *p_handlers )
@@ -290,7 +285,7 @@ static bool parse_tracks_dict( demux_t *p_demux, input_item_node_t *p_input_node
     return true;
 }
 
-static bool parse_track_dict( demux_t *p_demux, input_item_node_t *p_input_node,
+static bool parse_track_dict( stream_t *p_demux, input_item_node_t *p_input_node,
                               track_elem_t *p_track, xml_reader_t *p_xml_reader,
                               const char *psz_element,
                               xml_elem_hnd_t *p_handlers )
@@ -420,7 +415,7 @@ static bool add_meta( input_item_t *p_input_item, track_elem_t *p_track )
 /**
  * \brief skips complex element content that we can't manage
  */
-static bool skip_element( demux_t *p_demux, input_item_node_t *p_input_node,
+static bool skip_element( stream_t *p_demux, input_item_node_t *p_input_node,
                           track_elem_t *p_track, xml_reader_t *p_xml_reader,
                           const char *psz_element, xml_elem_hnd_t *p_handlers )
 {
diff --git a/modules/demux/playlist/itml.h b/modules/demux/playlist/itml.h
index 87c69a6263..e93987bff2 100644
--- a/modules/demux/playlist/itml.h
+++ b/modules/demux/playlist/itml.h
@@ -33,7 +33,7 @@
 #define SIMPLE_INTERFACE  (track_elem_t    *p_track,\
                            const char      *psz_name,\
                            char            *psz_value)
-#define COMPLEX_INTERFACE (demux_t         *p_demux,\
+#define COMPLEX_INTERFACE (stream_t        *p_demux,\
                            input_item_node_t    *p_input_node,\
                            track_elem_t    *p_track,\
                            xml_reader_t    *p_xml_reader,\
diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c
index 4d38c61bc6..8271340bd6 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -124,8 +124,8 @@ vlc_module_begin ()
         set_callbacks( Import_IFO, NULL )
     add_submodule ()
         set_description( N_("iTunes Music Library importer") )
-        add_shortcut( "playlist", "itml" )
-        set_capability( "demux", 10 )
+        add_shortcut( "itml" )
+        set_capability( "stream_filter", 10 )
         set_callbacks( Import_iTML, NULL )
     add_submodule ()
         set_description( N_("WPL playlist import") )



More information about the vlc-commits mailing list