core: "clock-jitter" is in milliseconds
[vlc.git] / include / vlc_input_item.h
blobc815c773c1a0a0fb9d165f5e238fa97e8e7ae300
1 /*****************************************************************************
2 * vlc_input_item.h: Core input item
3 *****************************************************************************
4 * Copyright (C) 1999-2009 VLC authors and VideoLAN
5 * $Id$
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
28 /**
29 * \file
30 * This file defines functions, structures and enums for input items in vlc
33 #include <vlc_meta.h>
34 #include <vlc_epg.h>
35 #include <vlc_events.h>
36 #include <vlc_list.h>
38 #include <string.h>
40 typedef struct input_item_opaque input_item_opaque_t;
41 typedef struct input_item_slave input_item_slave_t;
43 struct info_t
45 char *psz_name; /**< Name of this info */
46 char *psz_value; /**< Value of the info */
47 struct vlc_list node;
50 #define info_foreach(info, cat) vlc_list_foreach(info, cat, node)
52 struct info_category_t
54 char *psz_name; /**< Name of this category */
55 struct vlc_list infos; /**< Infos in the category */
58 /**
59 * Describes an input and is used to spawn input_thread_t objects.
61 struct input_item_t
63 char *psz_name; /**< text describing this item */
64 char *psz_uri; /**< mrl of this item */
66 int i_options; /**< Number of input options */
67 char **ppsz_options; /**< Array of input options */
68 uint8_t *optflagv; /**< Some flags of input options */
69 unsigned optflagc;
70 input_item_opaque_t *opaques; /**< List of opaque pointer values */
72 vlc_tick_t i_duration; /**< Duration in microseconds */
75 int i_categories; /**< Number of info categories */
76 info_category_t **pp_categories; /**< Pointer to the first info category */
78 int i_es; /**< Number of es format descriptions */
79 es_format_t **es; /**< Es formats */
81 input_stats_t *p_stats; /**< Statistics */
83 vlc_meta_t *p_meta;
85 int i_epg; /**< Number of EPG entries */
86 vlc_epg_t **pp_epg; /**< EPG entries */
87 int64_t i_epg_time; /** EPG timedate as epoch time */
88 const vlc_epg_t *p_epg_table; /** running/selected program cur/next EPG table */
90 int i_slaves; /**< Number of slaves */
91 input_item_slave_t **pp_slaves; /**< Slave entries that will be loaded by
92 the input_thread */
94 vlc_event_manager_t event_manager;
96 vlc_mutex_t lock; /**< Lock for the item */
98 uint8_t i_type; /**< Type (file, disc, ... see input_item_type_e) */
99 bool b_net; /**< Net: always true for TYPE_STREAM, it
100 depends for others types */
101 bool b_error_when_reading;/**< Error When Reading */
103 int i_preparse_depth; /**< How many level of sub items can be preparsed:
104 -1: recursive, 0: none, >0: n levels */
106 bool b_preparse_interact; /**< Force interaction with the user when
107 preparsing.*/
110 enum input_item_type_e
112 ITEM_TYPE_UNKNOWN,
113 ITEM_TYPE_FILE,
114 ITEM_TYPE_DIRECTORY,
115 ITEM_TYPE_DISC,
116 ITEM_TYPE_CARD,
117 ITEM_TYPE_STREAM,
118 ITEM_TYPE_PLAYLIST,
119 ITEM_TYPE_NODE,
121 /* This one is not a real type but the number of input_item types. */
122 ITEM_TYPE_NUMBER
125 enum input_item_net_type
127 ITEM_NET_UNKNOWN,
128 ITEM_NET,
129 ITEM_LOCAL
132 enum slave_type
134 SLAVE_TYPE_SPU,
135 SLAVE_TYPE_AUDIO,
138 enum slave_priority
140 SLAVE_PRIORITY_MATCH_NONE = 1,
141 SLAVE_PRIORITY_MATCH_RIGHT,
142 SLAVE_PRIORITY_MATCH_LEFT,
143 SLAVE_PRIORITY_MATCH_ALL,
144 SLAVE_PRIORITY_USER
147 /* Extensions must be in alphabetical order */
148 #define MASTER_EXTENSIONS \
149 "asf", "avi", "divx", \
150 "f4v", "flv", "m1v", \
151 "m2v", "m4v", "mkv", \
152 "mov", "mp2", "mp2v", \
153 "mp4", "mp4v", "mpe", \
154 "mpeg", "mpeg1", "mpeg2", \
155 "mpeg4", "mpg", "mpv2", \
156 "mxf", "ogv", "ogx", \
157 "ps", "vro","webm", \
158 "wmv", "wtv"
160 #define SLAVE_SPU_EXTENSIONS \
161 "aqt", "ass", "cdg", \
162 "dks", "idx", "jss", \
163 "mpl2", "mpsub", "pjs", \
164 "psb", "rt", "sami", "sbv", \
165 "scc", "smi", "srt", \
166 "ssa", "stl", "sub", \
167 "ttml", "tt", "usf", \
168 "vtt", "webvtt"
170 #define SLAVE_AUDIO_EXTENSIONS \
171 "aac", "ac3", "dts", \
172 "dtshd", "eac3", "flac", \
173 "m4a", "mp3", "pcm" \
175 struct input_item_slave
177 enum slave_type i_type; /**< Slave type (spu, audio) */
178 enum slave_priority i_priority; /**< Slave priority */
179 bool b_forced; /**< Slave should be selected */
180 char psz_uri[]; /**< Slave mrl */
183 struct input_item_node_t
185 input_item_t * p_item;
186 int i_children;
187 input_item_node_t **pp_children;
190 VLC_API void input_item_CopyOptions( input_item_t *p_child, input_item_t *p_parent );
191 VLC_API void input_item_SetName( input_item_t *p_item, const char *psz_name );
194 * Start adding multiple subitems.
196 * Create a root node to hold a tree of subitems for given item
198 VLC_API input_item_node_t * input_item_node_Create( input_item_t *p_input ) VLC_USED;
201 * Add a new child node to this parent node that will point to this subitem.
203 VLC_API input_item_node_t * input_item_node_AppendItem( input_item_node_t *p_node, input_item_t *p_item );
206 * Add an already created node to children of this parent node.
208 VLC_API void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t *p_child );
211 * Remove a node from its parent.
213 void input_item_node_RemoveNode( input_item_node_t *parent,
214 input_item_node_t *child );
217 * Delete a node created with input_item_node_Create() and all its children.
219 VLC_API void input_item_node_Delete( input_item_node_t *p_node );
222 * Option flags
224 enum input_item_option_e
226 /* Allow VLC to trust the given option.
227 * By default options are untrusted */
228 VLC_INPUT_OPTION_TRUSTED = 0x2,
230 /* Add the option, unless the same option
231 * is already present. */
232 VLC_INPUT_OPTION_UNIQUE = 0x100,
236 * This function allows to add an option to an existing input_item_t.
238 VLC_API int input_item_AddOption(input_item_t *, const char *, unsigned i_flags );
240 * This function add several options to an existing input_item_t.
242 VLC_API int input_item_AddOptions(input_item_t *, int i_options,
243 const char *const *ppsz_options,
244 unsigned i_flags );
245 VLC_API int input_item_AddOpaque(input_item_t *, const char *, void *);
247 void input_item_ApplyOptions(vlc_object_t *, input_item_t *);
249 VLC_API bool input_item_slave_GetType(const char *, enum slave_type *);
251 VLC_API input_item_slave_t *input_item_slave_New(const char *, enum slave_type,
252 enum slave_priority);
253 #define input_item_slave_Delete(p_slave) free(p_slave)
256 * This function allows adding a slave to an existing input item.
257 * The slave is owned by the input item after this call.
259 VLC_API int input_item_AddSlave(input_item_t *, input_item_slave_t *);
261 /* */
262 VLC_API bool input_item_HasErrorWhenReading( input_item_t * );
263 VLC_API void input_item_SetMeta( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val );
264 VLC_API bool input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz );
265 VLC_API char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type ) VLC_USED;
266 VLC_API char * input_item_GetName( input_item_t * p_i ) VLC_USED;
267 VLC_API char * input_item_GetTitleFbName( input_item_t * p_i ) VLC_USED;
268 VLC_API char * input_item_GetURI( input_item_t * p_i ) VLC_USED;
269 VLC_API char * input_item_GetNowPlayingFb( input_item_t *p_item ) VLC_USED;
270 VLC_API void input_item_SetURI( input_item_t * p_i, const char *psz_uri );
271 VLC_API vlc_tick_t input_item_GetDuration( input_item_t * p_i );
272 VLC_API void input_item_SetDuration( input_item_t * p_i, vlc_tick_t i_duration );
273 VLC_API bool input_item_IsPreparsed( input_item_t *p_i );
274 VLC_API bool input_item_IsArtFetched( input_item_t *p_i );
276 #define INPUT_META( name ) \
277 static inline \
278 void input_item_Set ## name (input_item_t *p_input, const char *val) \
280 input_item_SetMeta (p_input, vlc_meta_ ## name, val); \
282 static inline \
283 char *input_item_Get ## name (input_item_t *p_input) \
285 return input_item_GetMeta (p_input, vlc_meta_ ## name); \
288 INPUT_META(Title)
289 INPUT_META(Artist)
290 INPUT_META(AlbumArtist)
291 INPUT_META(Genre)
292 INPUT_META(Copyright)
293 INPUT_META(Album)
294 INPUT_META(TrackNumber)
295 INPUT_META(Description)
296 INPUT_META(Rating)
297 INPUT_META(Date)
298 INPUT_META(Setting)
299 INPUT_META(URL)
300 INPUT_META(Language)
301 INPUT_META(NowPlaying)
302 INPUT_META(ESNowPlaying)
303 INPUT_META(Publisher)
304 INPUT_META(EncodedBy)
305 INPUT_META(ArtworkURL)
306 INPUT_META(TrackID)
307 INPUT_META(TrackTotal)
308 INPUT_META(Director)
309 INPUT_META(Season)
310 INPUT_META(Episode)
311 INPUT_META(ShowName)
312 INPUT_META(Actors)
313 INPUT_META(DiscNumber)
314 INPUT_META(DiscTotal)
316 #define input_item_SetTrackNum input_item_SetTrackNumber
317 #define input_item_GetTrackNum input_item_GetTrackNumber
318 #define input_item_SetArtURL input_item_SetArtworkURL
319 #define input_item_GetArtURL input_item_GetArtworkURL
321 VLC_API char * input_item_GetInfo( input_item_t *p_i, const char *psz_cat,const char *psz_name ) VLC_USED;
322 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 );
323 VLC_API int input_item_DelInfo( input_item_t *p_i, const char *psz_cat, const char *psz_name );
324 VLC_API void input_item_ReplaceInfos( input_item_t *, info_category_t * );
325 VLC_API void input_item_MergeInfos( input_item_t *, info_category_t * );
328 * This function creates a new input_item_t with the provided information.
330 * XXX You may also use input_item_New, as they need less arguments.
332 VLC_API input_item_t * input_item_NewExt( const char *psz_uri,
333 const char *psz_name,
334 vlc_tick_t i_duration, int i_type,
335 enum input_item_net_type i_net ) VLC_USED;
337 #define input_item_New( psz_uri, psz_name ) \
338 input_item_NewExt( psz_uri, psz_name, VLC_TICK_INVALID, ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN )
340 #define input_item_NewCard( psz_uri, psz_name ) \
341 input_item_NewExt( psz_uri, psz_name, VLC_TICK_INVALID, ITEM_TYPE_CARD, ITEM_LOCAL )
343 #define input_item_NewDisc( psz_uri, psz_name, i_duration ) \
344 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_DISC, ITEM_LOCAL )
346 #define input_item_NewStream( psz_uri, psz_name, i_duration ) \
347 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_STREAM, ITEM_NET )
349 #define input_item_NewDirectory( psz_uri, psz_name, i_net ) \
350 input_item_NewExt( psz_uri, psz_name, VLC_TICK_INVALID, ITEM_TYPE_DIRECTORY, i_net )
352 #define input_item_NewFile( psz_uri, psz_name, i_duration, i_net ) \
353 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_FILE, i_net )
356 * This function creates a new input_item_t as a copy of another.
358 VLC_API input_item_t * input_item_Copy(input_item_t * ) VLC_USED;
360 /** Holds an input item, i.e. creates a new reference. */
361 VLC_API input_item_t *input_item_Hold(input_item_t *);
363 /** Releases an input item, i.e. decrements its reference counter. */
364 VLC_API void input_item_Release(input_item_t *);
366 typedef enum input_item_meta_request_option_t
368 META_REQUEST_OPTION_NONE = 0x00,
369 META_REQUEST_OPTION_SCOPE_LOCAL = 0x01,
370 META_REQUEST_OPTION_SCOPE_NETWORK = 0x02,
371 META_REQUEST_OPTION_SCOPE_ANY = 0x03,
372 META_REQUEST_OPTION_DO_INTERACT = 0x04
373 } input_item_meta_request_option_t;
375 /* status of the vlc_InputItemPreparseEnded event */
376 enum input_item_preparse_status
378 ITEM_PREPARSE_SKIPPED,
379 ITEM_PREPARSE_FAILED,
380 ITEM_PREPARSE_TIMEOUT,
381 ITEM_PREPARSE_DONE
384 VLC_API int libvlc_MetadataRequest( libvlc_int_t *, input_item_t *,
385 input_item_meta_request_option_t,
386 int, void * );
387 VLC_API int libvlc_ArtRequest(libvlc_int_t *, input_item_t *,
388 input_item_meta_request_option_t );
389 VLC_API void libvlc_MetadataCancel( libvlc_int_t *, void * );
391 /******************
392 * Input stats
393 ******************/
394 struct input_stats_t
396 /* Input */
397 int64_t i_read_packets;
398 int64_t i_read_bytes;
399 float f_input_bitrate;
401 /* Demux */
402 int64_t i_demux_read_packets;
403 int64_t i_demux_read_bytes;
404 float f_demux_bitrate;
405 int64_t i_demux_corrupted;
406 int64_t i_demux_discontinuity;
408 /* Decoders */
409 int64_t i_decoded_audio;
410 int64_t i_decoded_video;
412 /* Vout */
413 int64_t i_displayed_pictures;
414 int64_t i_lost_pictures;
416 /* Aout */
417 int64_t i_played_abuffers;
418 int64_t i_lost_abuffers;
422 * Access pf_readdir helper struct
423 * \see vlc_readdir_helper_init()
424 * \see vlc_readdir_helper_additem()
425 * \see vlc_readdir_helper_finish()
427 struct vlc_readdir_helper
429 input_item_node_t *p_node;
430 void **pp_slaves;
431 size_t i_slaves;
432 void **pp_dirs;
433 size_t i_dirs;
434 int i_sub_autodetect_fuzzy;
435 bool b_show_hiddenfiles;
436 bool b_flatten;
437 char *psz_ignored_exts;
441 * Init a vlc_readdir_helper struct
443 * \param p_rdh need to be cleaned with vlc_readdir_helper_finish()
444 * \param p_node node that will be used to add items
446 VLC_API void vlc_readdir_helper_init(struct vlc_readdir_helper *p_rdh,
447 vlc_object_t *p_obj, input_item_node_t *p_node);
448 #define vlc_readdir_helper_init(p_rdh, p_obj, p_node) \
449 vlc_readdir_helper_init(p_rdh, VLC_OBJECT(p_obj), p_node)
452 * Finish adding items to the node
454 * \param b_success if true, items of the node will be sorted.
456 VLC_API void vlc_readdir_helper_finish(struct vlc_readdir_helper *p_rdh, bool b_success);
459 * Add a new input_item_t entry to the node of the vlc_readdir_helper struct.
461 * \param p_rdh previously inited vlc_readdir_helper struct
462 * \param psz_uri uri of the new item
463 * \param psz_flatpath flattened path of the new item. If not NULL, this
464 * function will create an input item for each sub folders (separated
465 * by '/') of psz_flatpath (so, this will un-flatten the folder
466 * hierarchy). Either psz_flatpath or psz_filename must be valid.
467 * \param psz_filename file name of the new item. If NULL, the file part of path
468 * will be used as a filename. Either psz_flatpath or psz_filename must
469 * be valid.
470 * \param i_type see \ref input_item_type_e
471 * \param i_net see \ref input_item_net_type
473 VLC_API int vlc_readdir_helper_additem(struct vlc_readdir_helper *p_rdh,
474 const char *psz_uri, const char *psz_flatpath,
475 const char *psz_filename,
476 int i_type, int i_net);
478 #endif