demux: libmp4: fix reading last iinf entry v0
[vlc.git] / modules / demux / directory.c
blobab46082d1ca756017f53125d080fb5c9e9f4de87
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_node_t *p_node = input_item_node_Create( p_demux->p_input_item );
37 if( vlc_stream_ReadDir( p_demux->s, p_node ) )
39 msg_Warn( p_demux, "unable to read directory" );
40 input_item_node_Delete( p_node );
41 return VLC_EGENERIC;
44 if (es_out_Control(p_demux->out, ES_OUT_POST_SUBNODE, p_node))
45 input_item_node_Delete(p_node);
47 return VLC_SUCCESS;
50 static int Control(demux_t *demux, int query, va_list args)
52 (void) demux;
53 switch( query )
55 case DEMUX_IS_PLAYLIST:
57 bool *pb_bool = va_arg( args, bool * );
58 *pb_bool = true;
59 return VLC_SUCCESS;
61 case DEMUX_GET_META:
63 return vlc_stream_vaControl(demux->s, STREAM_GET_META, args);
65 case DEMUX_HAS_UNSUPPORTED_META:
67 *(va_arg( args, bool * )) = false;
68 return VLC_SUCCESS;
71 return VLC_EGENERIC;
74 static int Import_Dir( vlc_object_t *p_this )
76 demux_t *p_demux = (demux_t *)p_this;
78 if( p_demux->s->pf_readdir == NULL )
79 return VLC_EGENERIC;
80 if( p_demux->p_input_item == NULL )
81 return VLC_ETIMEOUT;
83 p_demux->pf_demux = Demux;
84 p_demux->pf_control = Control;
86 return VLC_SUCCESS;
89 vlc_module_begin()
90 set_category( CAT_INPUT )
91 set_subcategory( SUBCAT_INPUT_DEMUX )
92 set_shortname( N_("Directory") )
93 set_description( N_("Directory import") )
94 add_shortcut( "directory" )
95 set_capability( "demux", 10 )
96 set_callbacks( Import_Dir, NULL )
97 vlc_module_end()