chromecast: refactor, make place for SPUs
[vlc.git] / modules / demux / directory.c
blob31a7cb7ecee5bea98580630a2ad31f7979d2567e
1 /*****************************************************************************
2 * directory.c : Use access readdir to output folder content to playlist
3 *****************************************************************************
4 * Copyright (C) 2014 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Julien 'Lta' BALLET <contact # lta . io >
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
28 #include <vlc_common.h>
29 #include <vlc_demux.h>
30 #include <vlc_input.h>
31 #include <vlc_plugin.h>
33 static int Demux( demux_t *p_demux )
35 input_item_t *p_input = input_GetItem( p_demux->p_input );
36 input_item_node_t *p_node = input_item_node_Create( p_input );
38 if( vlc_stream_ReadDir( p_demux->s, p_node ) )
40 msg_Warn( p_demux, "unable to read directory" );
41 input_item_node_Delete( p_node );
42 return VLC_EGENERIC;
45 if (es_out_Control(p_demux->out, ES_OUT_POST_SUBNODE, p_node))
46 input_item_node_Delete(p_node);
48 return VLC_SUCCESS;
51 static int Control(demux_t *demux, int query, va_list args)
53 (void) demux;
54 switch( query )
56 case DEMUX_IS_PLAYLIST:
58 bool *pb_bool = va_arg( args, bool * );
59 *pb_bool = true;
60 return VLC_SUCCESS;
62 case DEMUX_GET_META:
64 return vlc_stream_vaControl(demux->s, STREAM_GET_META, args);
66 case DEMUX_HAS_UNSUPPORTED_META:
68 *(va_arg( args, bool * )) = false;
69 return VLC_SUCCESS;
72 return VLC_EGENERIC;
75 static int Import_Dir( vlc_object_t *p_this )
77 demux_t *p_demux = (demux_t *)p_this;
79 if( vlc_stream_Control( p_demux->s, STREAM_IS_DIRECTORY ) )
80 return VLC_EGENERIC;
81 if( p_demux->p_input == NULL )
82 return VLC_ETIMEOUT;
84 p_demux->pf_demux = Demux;
85 p_demux->pf_control = Control;
87 return VLC_SUCCESS;
90 vlc_module_begin()
91 set_category( CAT_INPUT )
92 set_subcategory( SUBCAT_INPUT_DEMUX )
93 set_shortname( N_("Directory") )
94 set_description( N_("Directory import") )
95 add_shortcut( "directory" )
96 set_capability( "demux", 10 )
97 set_callbacks( Import_Dir, NULL )
98 vlc_module_end()