forked from videolan/vlc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirectory.c
98 lines (86 loc) · 2.92 KB
/
directory.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*****************************************************************************
* 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;
}
if (es_out_Control(p_demux->out, ES_OUT_POST_SUBNODE, p_node))
input_item_node_Delete(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 = 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( p_demux->s->pf_readdir == NULL )
return VLC_EGENERIC;
if( p_demux->p_input == NULL )
return VLC_ETIMEOUT;
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
return VLC_SUCCESS;
}
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 )
vlc_module_end()