1 /*****************************************************************************
2 * directory.c : Use access readdir to output folder content to playlist
3 *****************************************************************************
4 * Copyright (C) 2014 VLC authors and VideoLAN
6 * Authors: Julien 'Lta' BALLET <contact # lta . io >
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
27 #include <vlc_common.h>
28 #include <vlc_demux.h>
29 #include <vlc_input.h>
30 #include <vlc_plugin.h>
32 static int Demux( demux_t
*p_demux
)
34 input_item_node_t
*p_node
= input_item_node_Create( p_demux
->p_input_item
);
36 if( vlc_stream_ReadDir( p_demux
->s
, p_node
) )
38 msg_Warn( p_demux
, "unable to read directory" );
39 input_item_node_Delete( p_node
);
43 if (es_out_Control(p_demux
->out
, ES_OUT_POST_SUBNODE
, p_node
))
44 input_item_node_Delete(p_node
);
49 static int Control(demux_t
*demux
, int query
, va_list args
)
54 case DEMUX_IS_PLAYLIST
:
56 bool *pb_bool
= va_arg( args
, bool * );
62 return vlc_stream_vaControl(demux
->s
, STREAM_GET_META
, args
);
64 case DEMUX_HAS_UNSUPPORTED_META
:
66 *(va_arg( args
, bool * )) = false;
73 static int Import_Dir( vlc_object_t
*p_this
)
75 demux_t
*p_demux
= (demux_t
*)p_this
;
77 if( p_demux
->s
->pf_readdir
== NULL
)
79 if( p_demux
->p_input_item
== NULL
)
82 p_demux
->pf_demux
= Demux
;
83 p_demux
->pf_control
= Control
;
89 set_category( CAT_INPUT
)
90 set_subcategory( SUBCAT_INPUT_DEMUX
)
91 set_shortname( N_("Directory") )
92 set_description( N_("Directory import") )
93 add_shortcut( "directory" )
94 set_capability( "demux", 10 )
95 set_callbacks( Import_Dir
, NULL
)