[vlc-commits] directory: separate directory and playlist demuxer plugins

Rémi Denis-Courmont git at videolan.org
Tue Apr 18 20:55:47 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Apr 17 19:05:10 2017 +0300| [a61747e2477cd256779740e1214d750a0e16804b] | committer: Rémi Denis-Courmont

directory: separate directory and playlist demuxer plugins

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

 modules/demux/Makefile.am          |   4 +-
 modules/demux/directory.c          | 128 +++++++++++++++++++++++++++++++++++++
 modules/demux/playlist/directory.c |  70 --------------------
 modules/demux/playlist/playlist.c  |  34 ----------
 4 files changed, 131 insertions(+), 105 deletions(-)

diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 271af342ea..644fcbbccf 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -160,6 +160,9 @@ demux_LTLIBRARIES += libavformat_plugin.la
 endif
 endif
 
+libdirectory_demux_plugin_la_SOURCES = demux/directory.c
+demux_LTLIBRARIES += libdirectory_demux_plugin.la
+
 libes_plugin_la_SOURCES  = demux/mpeg/es.c \
                            meta_engine/ID3Tag.h \
                            packetizer/dts_header.c packetizer/dts_header.h
@@ -230,7 +233,6 @@ libplaylist_plugin_la_SOURCES = \
 	demux/playlist/shoutcast.c \
 	demux/playlist/wpl.c \
 	demux/playlist/xspf.c \
-	demux/playlist/directory.c \
 	demux/playlist/playlist.c demux/playlist/playlist.h
 demux_LTLIBRARIES += libplaylist_plugin.la
 
diff --git a/modules/demux/directory.c b/modules/demux/directory.c
new file mode 100644
index 0000000000..65e19e2527
--- /dev/null
+++ b/modules/demux/directory.c
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * directory.c : Use access readdir to output folder content to playlist
+ *****************************************************************************
+ * Copyright (C) 2014 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Julien 'Lta' BALLET <contact # lta . io >
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_demux.h>
+#include <vlc_input.h>
+#include <vlc_plugin.h>
+
+static int Demux( demux_t *p_demux )
+{
+    input_item_t *p_input = input_GetItem( p_demux->p_input );
+    input_item_node_t *p_node = input_item_node_Create( p_input );
+
+    if( vlc_stream_ReadDir( p_demux->s, p_node ) )
+    {
+        msg_Warn( p_demux, "unable to read directory" );
+        input_item_node_Delete( p_node );
+        return VLC_EGENERIC;
+    }
+
+    input_item_node_PostAndDelete( p_node );
+    return VLC_SUCCESS;
+}
+
+static int Control(demux_t *demux, int query, va_list args)
+{
+    (void) demux;
+    switch( query )
+    {
+        case DEMUX_IS_PLAYLIST:
+        {
+            bool *pb_bool = (bool*)va_arg( args, bool * );
+            *pb_bool = true;
+            return VLC_SUCCESS;
+        }
+        case DEMUX_GET_META:
+        {
+            return vlc_stream_vaControl(demux->s, STREAM_GET_META, args);
+        }
+        case DEMUX_HAS_UNSUPPORTED_META:
+        {
+            *(va_arg( args, bool * )) = false;
+            return VLC_SUCCESS;
+        }
+    }
+    return VLC_EGENERIC;
+}
+
+static int Import_Dir( vlc_object_t *p_this )
+{
+    demux_t *p_demux = (demux_t *)p_this;
+
+    if( vlc_stream_Control( p_demux->s, STREAM_IS_DIRECTORY ) )
+        return VLC_EGENERIC;
+
+    p_demux->pf_demux = Demux;
+    p_demux->pf_control = Control;
+
+    return VLC_SUCCESS;
+}
+
+static const char *const psz_recursive_list[] = {
+    "none", "collapse", "expand" };
+static const char *const psz_recursive_list_text[] = {
+    N_("None"), N_("Collapse"), N_("Expand") };
+
+#define RECURSIVE_TEXT N_("Subdirectory behavior")
+#define RECURSIVE_LONGTEXT N_( \
+        "Select whether subdirectories must be expanded.\n" \
+        "none: subdirectories do not appear in the playlist.\n" \
+        "collapse: subdirectories appear but are expanded on first play.\n" \
+        "expand: all subdirectories are expanded.\n" )
+
+#define IGNORE_TEXT N_("Ignored extensions")
+#define IGNORE_LONGTEXT N_( \
+        "Files with these extensions will not be added to playlist when " \
+        "opening a directory.\n" \
+        "This is useful if you add directories that contain playlist files " \
+        "for instance. Use a comma-separated list of extensions." )
+
+#define SHOW_HIDDENFILES_TEXT N_("Show hidden files")
+#define SHOW_HIDDENFILES_LONGTEXT N_( \
+        "Ignore files starting with '.'" )
+
+vlc_module_begin()
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_DEMUX )
+
+    set_shortname( N_("Directory") )
+    set_description( N_("Directory import") )
+    add_shortcut( "directory" )
+    set_capability( "demux", 10 )
+    set_callbacks( Import_Dir, NULL )
+
+    add_string( "recursive", "collapse" , RECURSIVE_TEXT,
+                RECURSIVE_LONGTEXT, false )
+        change_string_list( psz_recursive_list, psz_recursive_list_text )
+    add_string( "ignore-filetypes", "m3u,db,nfo,ini,jpg,jpeg,ljpg,gif,png,pgm,"
+                "pgmyuv,pbm,pam,tga,bmp,pnm,xpm,xcf,pcx,tif,tiff,lbm,sfv,txt,"
+                "sub,idx,srt,cue,ssa",
+                IGNORE_TEXT, IGNORE_LONGTEXT, false )
+    add_bool( "show-hiddenfiles", false,
+              SHOW_HIDDENFILES_TEXT, SHOW_HIDDENFILES_LONGTEXT, false )
+vlc_module_end()
diff --git a/modules/demux/playlist/directory.c b/modules/demux/playlist/directory.c
deleted file mode 100644
index 6cb1be462e..0000000000
--- a/modules/demux/playlist/directory.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*****************************************************************************
- * directory.c : Use access readdir to output folder content to playlist
- *****************************************************************************
- * Copyright (C) 2014 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Julien 'Lta' BALLET <contact # lta . io >
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <vlc_common.h>
-#include <vlc_demux.h>
-
-#include "playlist.h"
-
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-static int Demux( demux_t *p_demux );
-
-
-int Import_Dir ( vlc_object_t *p_this)
-{
-    demux_t  *p_demux = (demux_t *)p_this;
-
-    if( vlc_stream_Control( p_demux->s, STREAM_IS_DIRECTORY ) )
-        return VLC_EGENERIC;
-
-    p_demux->pf_demux = Demux;
-    p_demux->pf_control = Control;
-
-    return VLC_SUCCESS;
-}
-
-static int Demux( demux_t *p_demux )
-{
-    input_item_t *p_input = GetCurrentItem(p_demux);
-    input_item_node_t *p_node = input_item_node_Create( p_input );
-    input_item_Release(p_input);
-
-    if( vlc_stream_ReadDir( p_demux->s, p_node ) )
-    {
-        msg_Warn( p_demux, "unable to read directory" );
-        input_item_node_Delete( p_node );
-        return VLC_EGENERIC;
-    }
-
-    input_item_node_PostAndDelete( p_node );
-    return VLC_SUCCESS;
-}
diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c
index c31143169b..0f304edf1a 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -51,28 +51,6 @@
 #define SKIP_ADS_LONGTEXT N_( "Use playlist options usually used to prevent " \
     "ads skipping to detect ads and prevent adding them to the playlist." )
 
-static const char *const psz_recursive_list[] = { "none", "collapse", "expand" };
-static const char *const psz_recursive_list_text[] = {
-    N_("None"), N_("Collapse"), N_("Expand"), N_("Expand distant files") };
-
-#define RECURSIVE_TEXT N_("Subdirectory behavior")
-#define RECURSIVE_LONGTEXT N_( \
-        "Select whether subdirectories must be expanded.\n" \
-        "none: subdirectories do not appear in the playlist.\n" \
-        "collapse: subdirectories appear but are expanded on first play.\n" \
-        "expand: all subdirectories are expanded.\n" )
-
-#define IGNORE_TEXT N_("Ignored extensions")
-#define IGNORE_LONGTEXT N_( \
-        "Files with these extensions will not be added to playlist when " \
-        "opening a directory.\n" \
-        "This is useful if you add directories that contain playlist files " \
-        "for instance. Use a comma-separated list of extensions." )
-
-#define SHOW_HIDDENFILES_TEXT N_("Show hidden files")
-#define SHOW_HIDDENFILES_LONGTEXT N_( \
-        "Ignore files starting with '.'" )
-
 vlc_module_begin ()
     add_shortcut( "playlist" )
     set_category( CAT_INPUT )
@@ -162,18 +140,6 @@ vlc_module_begin ()
         add_shortcut( "playlist", "wpl" )
         set_capability( "demux", 10 )
         set_callbacks( Import_WPL, Close_WPL )
-    add_submodule ()
-        set_description( N_("Directory import") )
-        add_shortcut( "playlist", "directory" )
-        set_capability( "demux", 10 )
-        set_callbacks( Import_Dir, NULL )
-        add_string( "recursive", "collapse" , RECURSIVE_TEXT,
-                    RECURSIVE_LONGTEXT, false )
-          change_string_list( psz_recursive_list, psz_recursive_list_text )
-        add_string( "ignore-filetypes", "m3u,db,nfo,ini,jpg,jpeg,ljpg,gif,png,pgm,pgmyuv,pbm,pam,tga,bmp,pnm,xpm,xcf,pcx,tif,tiff,lbm,sfv,txt,sub,idx,srt,cue,ssa",
-                    IGNORE_TEXT, IGNORE_LONGTEXT, false )
-        add_bool( "show-hiddenfiles", false,
-                   SHOW_HIDDENFILES_TEXT, SHOW_HIDDENFILES_LONGTEXT, false )
 vlc_module_end ()
 
 int Control(demux_t *demux, int query, va_list args)



More information about the vlc-commits mailing list