1 /*****************************************************************************
2 * vlc_input_item.h: Core input item
3 *****************************************************************************
4 * Copyright (C) 1999-2009 VLC authors and VideoLAN
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
8 * Laurent Aimar <fenrir@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef VLC_INPUT_ITEM_H
26 #define VLC_INPUT_ITEM_H 1
30 * This file defines functions, structures and enums for input items in vlc
35 #include <vlc_events.h>
40 typedef struct input_item_opaque input_item_opaque_t
;
41 typedef struct input_item_slave input_item_slave_t
;
42 typedef struct input_preparser_callbacks_t input_preparser_callbacks_t
;
46 char *psz_name
; /**< Name of this info */
47 char *psz_value
; /**< Value of the info */
51 #define info_foreach(info, cat) vlc_list_foreach(info, cat, node)
53 struct info_category_t
55 char *psz_name
; /**< Name of this category */
56 struct vlc_list infos
; /**< Infos in the category */
59 enum input_item_type_e
70 /* This one is not a real type but the number of input_item types. */
75 * Describes an input and is used to spawn input_thread_t objects.
79 char *psz_name
; /**< text describing this item */
80 char *psz_uri
; /**< mrl of this item */
82 int i_options
; /**< Number of input options */
83 char **ppsz_options
; /**< Array of input options */
84 uint8_t *optflagv
; /**< Some flags of input options */
86 input_item_opaque_t
*opaques
; /**< List of opaque pointer values */
88 vlc_tick_t i_duration
; /**< Duration in vlc ticks */
91 int i_categories
; /**< Number of info categories */
92 info_category_t
**pp_categories
; /**< Pointer to the first info category */
94 int i_es
; /**< Number of es format descriptions */
95 es_format_t
**es
; /**< Es formats */
97 input_stats_t
*p_stats
; /**< Statistics */
101 int i_epg
; /**< Number of EPG entries */
102 vlc_epg_t
**pp_epg
; /**< EPG entries */
103 int64_t i_epg_time
; /** EPG timedate as epoch time */
104 const vlc_epg_t
*p_epg_table
; /** running/selected program cur/next EPG table */
106 int i_slaves
; /**< Number of slaves */
107 input_item_slave_t
**pp_slaves
; /**< Slave entries that will be loaded by
110 vlc_event_manager_t event_manager
;
112 vlc_mutex_t lock
; /**< Lock for the item */
114 enum input_item_type_e i_type
; /**< Type (file, disc, ... see input_item_type_e) */
115 bool b_net
; /**< Net: always true for TYPE_STREAM, it
116 depends for others types */
117 bool b_error_when_reading
;/**< Error When Reading */
119 int i_preparse_depth
; /**< How many level of sub items can be preparsed:
120 -1: recursive, 0: none, >0: n levels */
122 bool b_preparse_interact
; /**< Force interaction with the user when
126 #define INPUT_ITEM_URI_NOP "vlc://nop" /* dummy URI for node/directory items */
128 /* placeholder duration for items with no known duration at time of creation
129 * it may remain the duration for items like a node/directory */
130 #define INPUT_DURATION_UNSET VLC_TICK_INVALID
131 #define INPUT_DURATION_INDEFINITE (-1) /* item with a known indefinite duration (live/continuous source) */
133 enum input_item_net_type
148 SLAVE_PRIORITY_MATCH_NONE
= 1,
149 SLAVE_PRIORITY_MATCH_RIGHT
,
150 SLAVE_PRIORITY_MATCH_LEFT
,
151 SLAVE_PRIORITY_MATCH_ALL
,
155 /* Extensions must be in alphabetical order */
156 #define MASTER_EXTENSIONS \
157 "asf", "avi", "divx", \
158 "f4v", "flv", "m1v", \
159 "m2v", "m4v", "mkv", \
160 "mov", "mp2", "mp2v", \
161 "mp4", "mp4v", "mpe", \
162 "mpeg", "mpeg1", "mpeg2", \
163 "mpeg4", "mpg", "mpv2", \
164 "mxf", "ogv", "ogx", \
165 "ps", "vro","webm", \
168 #define SLAVE_SPU_EXTENSIONS \
169 "aqt", "ass", "cdg", \
170 "dks", "idx", "jss", \
171 "mpl2", "mpsub", "pjs", \
172 "psb", "rt", "sami", "sbv", \
173 "scc", "smi", "srt", \
174 "ssa", "stl", "sub", \
175 "ttml", "tt", "usf", \
178 #define SLAVE_AUDIO_EXTENSIONS \
179 "aac", "ac3", "dts", \
180 "dtshd", "eac3", "flac", \
181 "m4a", "mp3", "pcm" \
183 struct input_item_slave
185 enum slave_type i_type
; /**< Slave type (spu, audio) */
186 enum slave_priority i_priority
; /**< Slave priority */
187 bool b_forced
; /**< Slave should be selected */
188 char psz_uri
[]; /**< Slave mrl */
191 struct input_item_node_t
193 input_item_t
* p_item
;
195 input_item_node_t
**pp_children
;
198 VLC_API
void input_item_CopyOptions( input_item_t
*p_child
, input_item_t
*p_parent
);
199 VLC_API
void input_item_SetName( input_item_t
*p_item
, const char *psz_name
);
202 * Start adding multiple subitems.
204 * Create a root node to hold a tree of subitems for given item
206 VLC_API input_item_node_t
* input_item_node_Create( input_item_t
*p_input
) VLC_USED
;
209 * Add a new child node to this parent node that will point to this subitem.
211 VLC_API input_item_node_t
* input_item_node_AppendItem( input_item_node_t
*p_node
, input_item_t
*p_item
);
214 * Add an already created node to children of this parent node.
216 VLC_API
void input_item_node_AppendNode( input_item_node_t
*p_parent
, input_item_node_t
*p_child
);
219 * Remove a node from its parent.
221 void input_item_node_RemoveNode( input_item_node_t
*parent
,
222 input_item_node_t
*child
);
225 * Delete a node created with input_item_node_Create() and all its children.
227 VLC_API
void input_item_node_Delete( input_item_node_t
*p_node
);
232 enum input_item_option_e
234 /* Allow VLC to trust the given option.
235 * By default options are untrusted */
236 VLC_INPUT_OPTION_TRUSTED
= 0x2,
238 /* Add the option, unless the same option
239 * is already present. */
240 VLC_INPUT_OPTION_UNIQUE
= 0x100,
244 * This function allows to add an option to an existing input_item_t.
246 VLC_API
int input_item_AddOption(input_item_t
*, const char *, unsigned i_flags
);
248 * This function add several options to an existing input_item_t.
250 VLC_API
int input_item_AddOptions(input_item_t
*, int i_options
,
251 const char *const *ppsz_options
,
253 VLC_API
int input_item_AddOpaque(input_item_t
*, const char *, void *);
255 void input_item_ApplyOptions(vlc_object_t
*, input_item_t
*);
257 VLC_API
bool input_item_slave_GetType(const char *, enum slave_type
*);
259 VLC_API input_item_slave_t
*input_item_slave_New(const char *, enum slave_type
,
260 enum slave_priority
);
261 #define input_item_slave_Delete(p_slave) free(p_slave)
264 * This function allows adding a slave to an existing input item.
265 * The slave is owned by the input item after this call.
267 VLC_API
int input_item_AddSlave(input_item_t
*, input_item_slave_t
*);
270 VLC_API
bool input_item_HasErrorWhenReading( input_item_t
* );
271 VLC_API
void input_item_SetMeta( input_item_t
*, vlc_meta_type_t meta_type
, const char *psz_val
);
272 VLC_API
bool input_item_MetaMatch( input_item_t
*p_i
, vlc_meta_type_t meta_type
, const char *psz
);
273 VLC_API
char * input_item_GetMeta( input_item_t
*p_i
, vlc_meta_type_t meta_type
) VLC_USED
;
274 VLC_API
const char *input_item_GetMetaLocked(input_item_t
*, vlc_meta_type_t meta_type
);
275 VLC_API
char * input_item_GetName( input_item_t
* p_i
) VLC_USED
;
276 VLC_API
char * input_item_GetTitleFbName( input_item_t
* p_i
) VLC_USED
;
277 VLC_API
char * input_item_GetURI( input_item_t
* p_i
) VLC_USED
;
278 VLC_API
char * input_item_GetNowPlayingFb( input_item_t
*p_item
) VLC_USED
;
279 VLC_API
void input_item_SetURI( input_item_t
* p_i
, const char *psz_uri
);
280 VLC_API vlc_tick_t
input_item_GetDuration( input_item_t
* p_i
);
281 VLC_API
void input_item_SetDuration( input_item_t
* p_i
, vlc_tick_t i_duration
);
282 VLC_API
bool input_item_IsPreparsed( input_item_t
*p_i
);
283 VLC_API
bool input_item_IsArtFetched( input_item_t
*p_i
);
285 #define INPUT_META( name ) \
287 void input_item_Set ## name (input_item_t *p_input, const char *val) \
289 input_item_SetMeta (p_input, vlc_meta_ ## name, val); \
292 char *input_item_Get ## name (input_item_t *p_input) \
294 return input_item_GetMeta (p_input, vlc_meta_ ## name); \
299 INPUT_META(AlbumArtist
)
301 INPUT_META(Copyright
)
303 INPUT_META(TrackNumber
)
304 INPUT_META(Description
)
310 INPUT_META(NowPlaying
)
311 INPUT_META(ESNowPlaying
)
312 INPUT_META(Publisher
)
313 INPUT_META(EncodedBy
)
314 INPUT_META(ArtworkURL
)
316 INPUT_META(TrackTotal
)
322 INPUT_META(DiscNumber
)
323 INPUT_META(DiscTotal
)
325 #define input_item_SetTrackNum input_item_SetTrackNumber
326 #define input_item_GetTrackNum input_item_GetTrackNumber
327 #define input_item_SetArtURL input_item_SetArtworkURL
328 #define input_item_GetArtURL input_item_GetArtworkURL
330 VLC_API
char * input_item_GetInfo( input_item_t
*p_i
, const char *psz_cat
,const char *psz_name
) VLC_USED
;
331 VLC_API
int input_item_AddInfo( input_item_t
*p_i
, const char *psz_cat
, const char *psz_name
, const char *psz_format
, ... ) VLC_FORMAT( 4, 5 );
332 VLC_API
int input_item_DelInfo( input_item_t
*p_i
, const char *psz_cat
, const char *psz_name
);
333 VLC_API
void input_item_ReplaceInfos( input_item_t
*, info_category_t
* );
334 VLC_API
void input_item_MergeInfos( input_item_t
*, info_category_t
* );
337 * This function creates a new input_item_t with the provided information.
339 * XXX You may also use input_item_New, as they need less arguments.
341 VLC_API input_item_t
* input_item_NewExt( const char *psz_uri
,
342 const char *psz_name
,
343 vlc_tick_t i_duration
, enum input_item_type_e i_type
,
344 enum input_item_net_type i_net
) VLC_USED
;
346 #define input_item_New( psz_uri, psz_name ) \
347 input_item_NewExt( psz_uri, psz_name, INPUT_DURATION_UNSET, ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN )
349 #define input_item_NewCard( psz_uri, psz_name ) \
350 input_item_NewExt( psz_uri, psz_name, INPUT_DURATION_INDEFINITE, ITEM_TYPE_CARD, ITEM_LOCAL )
352 #define input_item_NewDisc( psz_uri, psz_name, i_duration ) \
353 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_DISC, ITEM_LOCAL )
355 #define input_item_NewStream( psz_uri, psz_name, i_duration ) \
356 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_STREAM, ITEM_NET )
358 #define input_item_NewDirectory( psz_uri, psz_name, i_net ) \
359 input_item_NewExt( psz_uri, psz_name, INPUT_DURATION_UNSET, ITEM_TYPE_DIRECTORY, i_net )
361 #define input_item_NewFile( psz_uri, psz_name, i_duration, i_net ) \
362 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_FILE, i_net )
365 * This function creates a new input_item_t as a copy of another.
367 VLC_API input_item_t
* input_item_Copy(input_item_t
* ) VLC_USED
;
369 /** Holds an input item, i.e. creates a new reference. */
370 VLC_API input_item_t
*input_item_Hold(input_item_t
*);
372 /** Releases an input item, i.e. decrements its reference counter. */
373 VLC_API
void input_item_Release(input_item_t
*);
375 typedef enum input_item_meta_request_option_t
377 META_REQUEST_OPTION_NONE
= 0x00,
378 META_REQUEST_OPTION_SCOPE_LOCAL
= 0x01,
379 META_REQUEST_OPTION_SCOPE_NETWORK
= 0x02,
380 META_REQUEST_OPTION_SCOPE_ANY
= 0x03,
381 META_REQUEST_OPTION_DO_INTERACT
= 0x04
382 } input_item_meta_request_option_t
;
384 /* status of the on_preparse_ended() callback */
385 enum input_item_preparse_status
387 ITEM_PREPARSE_SKIPPED
,
388 ITEM_PREPARSE_FAILED
,
389 ITEM_PREPARSE_TIMEOUT
,
393 typedef struct input_preparser_callbacks_t
{
394 void (*on_preparse_ended
)(input_item_t
*, enum input_item_preparse_status status
, void *userdata
);
395 void (*on_subtree_added
)(input_item_t
*, input_item_node_t
*subtree
, void *userdata
);
396 } input_preparser_callbacks_t
;
398 typedef struct input_fetcher_callbacks_t
{
399 void (*on_art_fetch_ended
)(input_item_t
*, bool fetched
, void *userdata
);
400 } input_fetcher_callbacks_t
;
402 VLC_API
int libvlc_MetadataRequest( libvlc_int_t
*, input_item_t
*,
403 input_item_meta_request_option_t
,
404 const input_preparser_callbacks_t
*cbs
,
407 VLC_API
int libvlc_ArtRequest(libvlc_int_t
*, input_item_t
*,
408 input_item_meta_request_option_t
,
409 const input_fetcher_callbacks_t
*cbs
,
410 void *cbs_userdata
);
411 VLC_API
void libvlc_MetadataCancel( libvlc_int_t
*, void * );
419 int64_t i_read_packets
;
420 int64_t i_read_bytes
;
421 float f_input_bitrate
;
424 int64_t i_demux_read_packets
;
425 int64_t i_demux_read_bytes
;
426 float f_demux_bitrate
;
427 int64_t i_demux_corrupted
;
428 int64_t i_demux_discontinuity
;
431 int64_t i_decoded_audio
;
432 int64_t i_decoded_video
;
435 int64_t i_displayed_pictures
;
436 int64_t i_lost_pictures
;
439 int64_t i_played_abuffers
;
440 int64_t i_lost_abuffers
;
444 * Access pf_readdir helper struct
445 * \see vlc_readdir_helper_init()
446 * \see vlc_readdir_helper_additem()
447 * \see vlc_readdir_helper_finish()
449 struct vlc_readdir_helper
451 input_item_node_t
*p_node
;
456 int i_sub_autodetect_fuzzy
;
457 bool b_show_hiddenfiles
;
459 char *psz_ignored_exts
;
463 * Init a vlc_readdir_helper struct
465 * \param p_rdh need to be cleaned with vlc_readdir_helper_finish()
466 * \param p_node node that will be used to add items
468 VLC_API
void vlc_readdir_helper_init(struct vlc_readdir_helper
*p_rdh
,
469 vlc_object_t
*p_obj
, input_item_node_t
*p_node
);
470 #define vlc_readdir_helper_init(p_rdh, p_obj, p_node) \
471 vlc_readdir_helper_init(p_rdh, VLC_OBJECT(p_obj), p_node)
474 * Finish adding items to the node
476 * \param b_success if true, items of the node will be sorted.
478 VLC_API
void vlc_readdir_helper_finish(struct vlc_readdir_helper
*p_rdh
, bool b_success
);
481 * Add a new input_item_t entry to the node of the vlc_readdir_helper struct.
483 * \param p_rdh previously inited vlc_readdir_helper struct
484 * \param psz_uri uri of the new item
485 * \param psz_flatpath flattened path of the new item. If not NULL, this
486 * function will create an input item for each sub folders (separated
487 * by '/') of psz_flatpath (so, this will un-flatten the folder
488 * hierarchy). Either psz_flatpath or psz_filename must be valid.
489 * \param psz_filename file name of the new item. If NULL, the file part of path
490 * will be used as a filename. Either psz_flatpath or psz_filename must
492 * \param i_type see \ref input_item_type_e
493 * \param i_net see \ref input_item_net_type
495 VLC_API
int vlc_readdir_helper_additem(struct vlc_readdir_helper
*p_rdh
,
496 const char *psz_uri
, const char *psz_flatpath
,
497 const char *psz_filename
,
498 int i_type
, int i_net
);