[vlc-devel] [PATCH 4/7] Add a new playlist module whose job is to output pf_readdir modules items to the playlist
Julien 'Lta' BALLET
elthariel at gmail.com
Sat Jun 21 15:55:12 CEST 2014
From: Julien 'Lta' BALLET <contact at lta.io>
---
modules/demux/Makefile.am | 1 +
modules/demux/playlist/directory.c | 78 ++++++++++++++++++++++++++++++++++++++
modules/demux/playlist/playlist.c | 5 +++
modules/demux/playlist/playlist.h | 4 ++
4 files changed, 88 insertions(+)
create mode 100644 modules/demux/playlist/directory.c
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 75f5b52..47d2782 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -216,6 +216,7 @@ libplaylist_plugin_la_SOURCES = \
demux/playlist/wpl.c \
demux/playlist/xspf.c \
demux/playlist/zpl.c \
+ demux/playlist/directory.c \
demux/playlist/playlist.c demux/playlist/playlist.h
demux_LTLIBRARIES += libplaylist_plugin.la
diff --git a/modules/demux/playlist/directory.c b/modules/demux/playlist/directory.c
new file mode 100644
index 0000000..d031682
--- /dev/null
+++ b/modules/demux/playlist/directory.c
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * 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;
+
+ bool b_is_dir = false;
+ int i_err = stream_Control( p_demux->s, STREAM_IS_DIRECTORY, &b_is_dir );
+
+ if ( !( i_err == VLC_SUCCESS && b_is_dir ) )
+ return VLC_EGENERIC;
+
+ p_demux->pf_control = Control;
+ p_demux->pf_demux = Demux;
+ msg_Dbg( p_demux, "%s", "reading directory content" );
+
+ return VLC_SUCCESS;
+}
+
+void Close_Dir ( vlc_object_t *p_this )
+{
+ VLC_UNUSED(p_this);
+}
+
+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( stream_ReadDir( p_demux->s, p_node ) )
+ {
+ 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 0b4a053..076d4fe 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -145,6 +145,11 @@ vlc_module_begin ()
add_shortcut( "playlist", "zpl" )
set_capability( "demux", 10 )
set_callbacks( Import_ZPL, Close_ZPL )
+ add_submodule ()
+ set_description( N_("Directory import") )
+ add_shortcut( "playlist", "directory" )
+ set_capability( "demux", 10 )
+ set_callbacks( Import_Dir, Close_Dir )
vlc_module_end ()
int Control(demux_t *demux, int query, va_list args)
diff --git a/modules/demux/playlist/playlist.h b/modules/demux/playlist/playlist.h
index 5f7db99..c1230cf 100644
--- a/modules/demux/playlist/playlist.h
+++ b/modules/demux/playlist/playlist.h
@@ -78,6 +78,10 @@ void Close_WPL ( vlc_object_t * );
int Import_ZPL ( vlc_object_t * );
void Close_ZPL ( vlc_object_t * );
+int Import_Dir ( vlc_object_t * );
+void Close_Dir ( vlc_object_t * );
+
+
extern input_item_t * GetCurrentItem(demux_t *p_demux);
bool CheckContentType( stream_t * p_stream, const char * psz_ctype );
--
2.0.0
More information about the vlc-devel
mailing list