SUBDIRS += bda dshow
endif
-SOURCES_access_file = file.c
+libfilesystem_plugin_la_SOURCES = \
+ fs.h \
+ file.c \
+ directory.c \
+ fs.c
+libfilesystem_plugin_la_CFLAGS = $(AM_CFLAGS)
+libfilesystem_plugin_la_LIBADD = $(AM_LIBADD)
+libfilesystem_plugin_la_DEPENDENCIES =
+
SOURCES_access_mmap = mmap.c
SOURCES_access_directory = directory.c
SOURCES_access_dv = dv.c
libaccess_rtmp_plugin_la_DEPENDENCIES =
libvlc_LTLIBRARIES += \
- libaccess_file_plugin.la \
- libaccess_directory_plugin.la \
+ libfilesystem_plugin.la \
libaccess_udp_plugin.la \
libaccess_tcp_plugin.la \
libaccess_http_plugin.la \
#endif
#include <vlc_common.h>
-#include <vlc_plugin.h>
+#include "fs.h"
#include <vlc_access.h>
#ifdef HAVE_SYS_TYPES_H
#include <vlc_url.h>
#include <vlc_strings.h>
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-static int Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
-
-#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" )
-
-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 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." )
-
-vlc_module_begin ()
- set_category( CAT_INPUT )
- set_shortname( N_("Directory" ) )
- set_subcategory( SUBCAT_INPUT_ACCESS )
- set_description( N_("Standard filesystem directory input") )
- set_capability( "access", 55 )
- add_shortcut( "directory" )
- add_shortcut( "dir" )
- add_shortcut( "file" )
- add_string( "recursive", "expand" , NULL, RECURSIVE_TEXT,
- RECURSIVE_LONGTEXT, false )
- change_string_list( psz_recursive_list, psz_recursive_list_text, 0 )
- 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",
- NULL, IGNORE_TEXT, IGNORE_LONGTEXT, false )
- set_callbacks( Open, Close )
-vlc_module_end ()
-
-
-/*****************************************************************************
- * Local prototypes, constants, structures
- *****************************************************************************/
-
enum
{
- MODE_EXPAND,
+ MODE_NONE,
MODE_COLLAPSE,
- MODE_NONE
+ MODE_EXPAND,
};
typedef struct directory_t directory_t;
char *psz_xspf_extension;
};
-static block_t *Block( access_t * );
-static int Control( access_t *, int, va_list );
-
/*****************************************************************************
* Open: open the directory
*****************************************************************************/
-static int Open( vlc_object_t *p_this )
+int DirOpen( vlc_object_t *p_this )
{
access_t *p_access = (access_t*)p_this;
- access_sys_t *p_sys;
if( !p_access->psz_path )
return VLC_EGENERIC;
if (handle == NULL)
return VLC_EGENERIC;
- p_sys = malloc (sizeof (*p_sys));
+ return DirInit (p_access, handle);
+}
+
+int DirInit (access_t *p_access, DIR *handle)
+{
+ access_sys_t *p_sys = malloc (sizeof (*p_sys));
if (!p_sys)
{
closedir( handle );
p_sys->mode = MODE_EXPAND;
free( psz );
+ access_InitFields(p_access);
p_access->pf_read = NULL;
- p_access->pf_block = Block;
+ p_access->pf_block = DirBlock;
p_access->pf_seek = NULL;
- p_access->pf_control= Control;
+ p_access->pf_control= DirControl;
free (p_access->psz_demux);
p_access->psz_demux = strdup ("xspf-open");
/*****************************************************************************
* Close: close the target
*****************************************************************************/
-static void Close( vlc_object_t * p_this )
+void DirClose( vlc_object_t * p_this )
{
access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys = p_access->p_sys;
return false;
}
-static block_t *Block (access_t *p_access)
+block_t *DirBlock (access_t *p_access)
{
access_sys_t *p_sys = p_access->p_sys;
directory_t *current = p_sys->current;
/*****************************************************************************
* Control:
*****************************************************************************/
-static int Control( access_t *p_access, int i_query, va_list args )
+int DirControl( access_t *p_access, int i_query, va_list args )
{
switch( i_query )
{
* 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_plugin.h>
+#include "fs.h"
#include <vlc_input.h>
#include <vlc_access.h>
#include <vlc_dialog.h>
#include <vlc_charset.h>
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-static int Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
-
-#define CACHING_TEXT N_("Caching value (ms)")
-#define CACHING_LONGTEXT N_( \
- "Caching value for files, in milliseconds." )
-
-#define NETWORK_CACHING_TEXT N_("Extra network caching value (ms)")
-#define NETWORK_CACHING_LONGTEXT N_( \
- "Supplementary caching value for remote files, in milliseconds." )
-
-vlc_module_begin ()
- set_description( N_("File input") )
- set_shortname( N_("File") )
- set_category( CAT_INPUT )
- set_subcategory( SUBCAT_INPUT_ACCESS )
- add_integer( "file-caching", DEFAULT_PTS_DELAY / 1000, NULL,
- CACHING_TEXT, CACHING_LONGTEXT, true )
- change_safe()
- add_integer( "network-caching", 3 * DEFAULT_PTS_DELAY / 1000, NULL,
- NETWORK_CACHING_TEXT, NETWORK_CACHING_LONGTEXT, true )
- change_safe()
- add_obsolete_string( "file-cat" )
- set_capability( "access", 50 )
- add_shortcut( "file" )
- add_shortcut( "fd" )
- add_shortcut( "stream" )
- set_callbacks( Open, Close )
-vlc_module_end ()
-
-
-/*****************************************************************************
- * Exported prototypes
- *****************************************************************************/
-static int Seek( access_t *, int64_t );
-static int NoSeek( access_t *, int64_t );
-static ssize_t Read( access_t *, uint8_t *, size_t );
-static int Control( access_t *, int, va_list );
-
struct access_sys_t
{
unsigned int i_nb_reads;
/*****************************************************************************
* Open: open the file
*****************************************************************************/
-static int Open( vlc_object_t *p_this )
+int Open( vlc_object_t *p_this )
{
access_t *p_access = (access_t*)p_this;
- access_sys_t *p_sys;
+ access_sys_t *p_sys = malloc (sizeof (*p_sys));
const char *path = p_access->psz_path;
#ifdef WIN32
bool is_remote = false;
#endif
- STANDARD_READ_ACCESS_INIT;
+ if (unlikely(p_sys == NULL))
+ return VLC_ENOMEM;
+
+ access_InitFields (p_access);
+ p_access->pf_read = FileRead;
+ p_access->pf_block = NULL;
+ p_access->pf_control = FileControl;
+ p_access->pf_seek = FileSeek;
+ p_access->p_sys = p_sys;
p_sys->i_nb_reads = 0;
p_sys->b_pace_control = true;
/*****************************************************************************
* Close: close the target
*****************************************************************************/
-static void Close (vlc_object_t * p_this)
+void Close (vlc_object_t * p_this)
{
access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys = p_access->p_sys;
/*****************************************************************************
* Read: standard read on a file descriptor.
*****************************************************************************/
-static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
+ssize_t FileRead( access_t *p_access, uint8_t *p_buffer, size_t i_len )
{
access_sys_t *p_sys = p_access->p_sys;
int fd = p_sys->fd;
/*****************************************************************************
* Seek: seek to a specific location in a file
*****************************************************************************/
-static int Seek (access_t *p_access, int64_t i_pos)
+int FileSeek (access_t *p_access, int64_t i_pos)
{
p_access->info.i_pos = i_pos;
p_access->info.b_eof = false;
return VLC_SUCCESS;
}
-static int NoSeek (access_t *p_access, int64_t i_pos)
+int NoSeek (access_t *p_access, int64_t i_pos)
{
/* assert(0); ?? */
(void) p_access; (void) i_pos;
/*****************************************************************************
* Control:
*****************************************************************************/
-static int Control( access_t *p_access, int i_query, va_list args )
+int FileControl( access_t *p_access, int i_query, va_list args )
{
access_sys_t *p_sys = p_access->p_sys;
bool *pb_bool;