Commit ba70ee5a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Merge file and directory plugins

parent 4c0ab7ff
...@@ -12,7 +12,15 @@ if HAVE_WIN32 ...@@ -12,7 +12,15 @@ if HAVE_WIN32
SUBDIRS += bda dshow SUBDIRS += bda dshow
endif 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_mmap = mmap.c
SOURCES_access_directory = directory.c SOURCES_access_directory = directory.c
SOURCES_access_dv = dv.c SOURCES_access_dv = dv.c
...@@ -57,8 +65,7 @@ libaccess_rtmp_plugin_la_LIBADD = $(AM_LIBADD) ...@@ -57,8 +65,7 @@ libaccess_rtmp_plugin_la_LIBADD = $(AM_LIBADD)
libaccess_rtmp_plugin_la_DEPENDENCIES = libaccess_rtmp_plugin_la_DEPENDENCIES =
libvlc_LTLIBRARIES += \ libvlc_LTLIBRARIES += \
libaccess_file_plugin.la \ libfilesystem_plugin.la \
libaccess_directory_plugin.la \
libaccess_udp_plugin.la \ libaccess_udp_plugin.la \
libaccess_tcp_plugin.la \ libaccess_tcp_plugin.la \
libaccess_http_plugin.la \ libaccess_http_plugin.la \
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#endif #endif
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include "fs.h"
#include <vlc_access.h> #include <vlc_access.h>
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
...@@ -61,57 +61,11 @@ static inline int dirfd (DIR *dir) ...@@ -61,57 +61,11 @@ static inline int dirfd (DIR *dir)
#include <vlc_url.h> #include <vlc_url.h>
#include <vlc_strings.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 enum
{ {
MODE_EXPAND, MODE_NONE,
MODE_COLLAPSE, MODE_COLLAPSE,
MODE_NONE MODE_EXPAND,
}; };
typedef struct directory_t directory_t; typedef struct directory_t directory_t;
...@@ -136,16 +90,12 @@ struct access_sys_t ...@@ -136,16 +90,12 @@ struct access_sys_t
char *psz_xspf_extension; char *psz_xspf_extension;
}; };
static block_t *Block( access_t * );
static int Control( access_t *, int, va_list );
/***************************************************************************** /*****************************************************************************
* Open: open the directory * 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_t *p_access = (access_t*)p_this;
access_sys_t *p_sys;
if( !p_access->psz_path ) if( !p_access->psz_path )
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -169,7 +119,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -169,7 +119,12 @@ static int Open( vlc_object_t *p_this )
if (handle == NULL) if (handle == NULL)
return VLC_EGENERIC; 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) if (!p_sys)
{ {
closedir( handle ); closedir( handle );
...@@ -193,10 +148,11 @@ static int Open( vlc_object_t *p_this ) ...@@ -193,10 +148,11 @@ static int Open( vlc_object_t *p_this )
p_sys->mode = MODE_EXPAND; p_sys->mode = MODE_EXPAND;
free( psz ); free( psz );
access_InitFields(p_access);
p_access->pf_read = NULL; p_access->pf_read = NULL;
p_access->pf_block = Block; p_access->pf_block = DirBlock;
p_access->pf_seek = NULL; p_access->pf_seek = NULL;
p_access->pf_control= Control; p_access->pf_control= DirControl;
free (p_access->psz_demux); free (p_access->psz_demux);
p_access->psz_demux = strdup ("xspf-open"); p_access->psz_demux = strdup ("xspf-open");
...@@ -206,7 +162,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -206,7 +162,7 @@ static int Open( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* Close: close the target * 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_t *p_access = (access_t*)p_this;
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
...@@ -245,7 +201,7 @@ static bool has_inode_loop (const directory_t *dir) ...@@ -245,7 +201,7 @@ static bool has_inode_loop (const directory_t *dir)
return false; 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; access_sys_t *p_sys = p_access->p_sys;
directory_t *current = p_sys->current; directory_t *current = p_sys->current;
...@@ -473,7 +429,7 @@ fatal: ...@@ -473,7 +429,7 @@ fatal:
/***************************************************************************** /*****************************************************************************
* Control: * 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 ) switch( i_query )
{ {
......
...@@ -23,15 +23,12 @@ ...@@ -23,15 +23,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include "fs.h"
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_dialog.h> #include <vlc_dialog.h>
...@@ -79,48 +76,6 @@ ...@@ -79,48 +76,6 @@
#include <vlc_charset.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 struct access_sys_t
{ {
unsigned int i_nb_reads; unsigned int i_nb_reads;
...@@ -174,16 +129,24 @@ static bool IsRemote (int fd) ...@@ -174,16 +129,24 @@ static bool IsRemote (int fd)
/***************************************************************************** /*****************************************************************************
* Open: open the file * 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_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; const char *path = p_access->psz_path;
#ifdef WIN32 #ifdef WIN32
bool is_remote = false; bool is_remote = false;
#endif #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->i_nb_reads = 0;
p_sys->b_pace_control = true; p_sys->b_pace_control = true;
...@@ -278,7 +241,7 @@ error: ...@@ -278,7 +241,7 @@ error:
/***************************************************************************** /*****************************************************************************
* Close: close the target * 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_t *p_access = (access_t*)p_this;
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
...@@ -293,7 +256,7 @@ static void Close (vlc_object_t * p_this) ...@@ -293,7 +256,7 @@ static void Close (vlc_object_t * p_this)
/***************************************************************************** /*****************************************************************************
* Read: standard read on a file descriptor. * 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; access_sys_t *p_sys = p_access->p_sys;
int fd = p_sys->fd; int fd = p_sys->fd;
...@@ -350,7 +313,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len ) ...@@ -350,7 +313,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
/***************************************************************************** /*****************************************************************************
* Seek: seek to a specific location in a file * 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.i_pos = i_pos;
p_access->info.b_eof = false; p_access->info.b_eof = false;
...@@ -359,7 +322,7 @@ static int Seek (access_t *p_access, int64_t i_pos) ...@@ -359,7 +322,7 @@ static int Seek (access_t *p_access, int64_t i_pos)
return VLC_SUCCESS; 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); ?? */ /* assert(0); ?? */
(void) p_access; (void) i_pos; (void) p_access; (void) i_pos;
...@@ -369,7 +332,7 @@ static int NoSeek (access_t *p_access, int64_t i_pos) ...@@ -369,7 +332,7 @@ static int NoSeek (access_t *p_access, int64_t i_pos)
/***************************************************************************** /*****************************************************************************
* Control: * 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; access_sys_t *p_sys = p_access->p_sys;
bool *pb_bool; bool *pb_bool;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment