packetizer: hevc_nal: retrieve source scan
[vlc.git] / include / vlc_input_item.h
blobd0f9587b7a4fa6ab11de681751a4735526cf9f4c
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>
37 #include <string.h>
39 typedef struct input_item_opaque input_item_opaque_t;
40 typedef struct input_item_slave input_item_slave_t;
42 struct info_t
44 char *psz_name; /**< Name of this info */
45 char *psz_value; /**< Value of the info */
48 struct info_category_t
50 char *psz_name; /**< Name of this category */
51 int i_infos; /**< Number of infos in the category */
52 struct info_t **pp_infos; /**< Pointer to an array of infos */
55 /**
56 * Describes an input and is used to spawn input_thread_t objects.
58 struct input_item_t
60 char *psz_name; /**< text describing this item */
61 char *psz_uri; /**< mrl of this item */
63 int i_options; /**< Number of input options */
64 char **ppsz_options; /**< Array of input options */
65 uint8_t *optflagv; /**< Some flags of input options */
66 unsigned optflagc;
67 input_item_opaque_t *opaques; /**< List of opaque pointer values */
69 mtime_t i_duration; /**< Duration in microseconds */
72 int i_categories; /**< Number of info categories */
73 info_category_t **pp_categories; /**< Pointer to the first info category */
75 int i_es; /**< Number of es format descriptions */
76 es_format_t **es; /**< Es formats */
78 input_stats_t *p_stats; /**< Statistics */
80 vlc_meta_t *p_meta;
82 int i_epg; /**< Number of EPG entries */
83 vlc_epg_t **pp_epg; /**< EPG entries */
84 int64_t i_epg_time; /** EPG timedate as epoch time */
85 const vlc_epg_t *p_epg_table; /** running/selected program cur/next EPG table */
87 int i_slaves; /**< Number of slaves */
88 input_item_slave_t **pp_slaves; /**< Slave entries that will be loaded by
89 the input_thread */
91 vlc_event_manager_t event_manager;
93 vlc_mutex_t lock; /**< Lock for the item */
95 uint8_t i_type; /**< Type (file, disc, ... see input_item_type_e) */
96 bool b_net; /**< Net: always true for TYPE_STREAM, it
97 depends for others types */
98 bool b_error_when_reading;/**< Error When Reading */
100 int i_preparse_depth; /**< How many level of sub items can be preparsed:
101 -1: recursive, 0: none, >0: n levels */
103 bool b_preparse_interact; /**< Force interaction with the user when
104 preparsing.*/
107 enum input_item_type_e
109 ITEM_TYPE_UNKNOWN,
110 ITEM_TYPE_FILE,
111 ITEM_TYPE_DIRECTORY,
112 ITEM_TYPE_DISC,
113 ITEM_TYPE_CARD,
114 ITEM_TYPE_STREAM,
115 ITEM_TYPE_PLAYLIST,
116 ITEM_TYPE_NODE,
118 /* This one is not a real type but the number of input_item types. */
119 ITEM_TYPE_NUMBER
122 enum input_item_net_type
124 ITEM_NET_UNKNOWN,
125 ITEM_NET,
126 ITEM_LOCAL
129 enum slave_type
131 SLAVE_TYPE_SPU,
132 SLAVE_TYPE_AUDIO,
135 enum slave_priority
137 SLAVE_PRIORITY_MATCH_NONE = 1,
138 SLAVE_PRIORITY_MATCH_RIGHT,
139 SLAVE_PRIORITY_MATCH_LEFT,
140 SLAVE_PRIORITY_MATCH_ALL,
141 SLAVE_PRIORITY_USER
144 #define SLAVE_SPU_EXTENSIONS \
145 "idx", "sub", "srt", \
146 "ssa", "ass", "smi", \
147 "utf", "utf8", "utf-8", \
148 "rt", "aqt", "txt", \
149 "usf", "jss", "cdg", \
150 "psb", "mpsub","mpl2", \
151 "pjs", "dks", "stl", \
152 "vtt", "sbv", "ttml" \
153 "scc"
154 #define SLAVE_AUDIO_EXTENSIONS \
155 "ac3", "m4a", "aac", \
156 "eac3", "dtshd", "flac", \
157 "pcm", "dts"
159 struct input_item_slave
161 enum slave_type i_type; /**< Slave type (spu, audio) */
162 enum slave_priority i_priority; /**< Slave priority */
163 bool b_forced; /**< Slave should be selected */
164 char psz_uri[]; /**< Slave mrl */
167 struct input_item_node_t
169 input_item_t * p_item;
170 int i_children;
171 input_item_node_t **pp_children;
174 VLC_API void input_item_CopyOptions( input_item_t *p_child, input_item_t *p_parent );
175 VLC_API void input_item_SetName( input_item_t *p_item, const char *psz_name );
178 * Start adding multiple subitems.
180 * Create a root node to hold a tree of subitems for given item
182 VLC_API input_item_node_t * input_item_node_Create( input_item_t *p_input ) VLC_USED;
185 * Add a new child node to this parent node that will point to this subitem.
187 VLC_API input_item_node_t * input_item_node_AppendItem( input_item_node_t *p_node, input_item_t *p_item );
190 * Add an already created node to children of this parent node.
192 VLC_API void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t *p_child );
195 * Remove a node from its parent.
197 void input_item_node_RemoveNode( input_item_node_t *parent,
198 input_item_node_t *child );
201 * Delete a node created with input_item_node_Create() and all its children.
203 VLC_API void input_item_node_Delete( input_item_node_t *p_node );
206 * Option flags
208 enum input_item_option_e
210 /* Allow VLC to trust the given option.
211 * By default options are untrusted */
212 VLC_INPUT_OPTION_TRUSTED = 0x2,
214 /* Add the option, unless the same option
215 * is already present. */
216 VLC_INPUT_OPTION_UNIQUE = 0x100,
220 * This function allows to add an option to an existing input_item_t.
222 VLC_API int input_item_AddOption(input_item_t *, const char *, unsigned i_flags );
224 * This function add several options to an existing input_item_t.
226 VLC_API int input_item_AddOptions(input_item_t *, int i_options,
227 const char *const *ppsz_options,
228 unsigned i_flags );
229 VLC_API int input_item_AddOpaque(input_item_t *, const char *, void *);
231 void input_item_ApplyOptions(vlc_object_t *, input_item_t *);
233 VLC_API bool input_item_slave_GetType(const char *, enum slave_type *);
235 VLC_API input_item_slave_t *input_item_slave_New(const char *, enum slave_type,
236 enum slave_priority);
237 #define input_item_slave_Delete(p_slave) free(p_slave)
240 * This function allows adding a slave to an existing input item.
241 * The slave is owned by the input item after this call.
243 VLC_API int input_item_AddSlave(input_item_t *, input_item_slave_t *);
245 /* */
246 VLC_API bool input_item_HasErrorWhenReading( input_item_t * );
247 VLC_API void input_item_SetMeta( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val );
248 VLC_API bool input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz );
249 VLC_API char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type ) VLC_USED;
250 VLC_API char * input_item_GetName( input_item_t * p_i ) VLC_USED;
251 VLC_API char * input_item_GetTitleFbName( input_item_t * p_i ) VLC_USED;
252 VLC_API char * input_item_GetURI( input_item_t * p_i ) VLC_USED;
253 VLC_API char * input_item_GetNowPlayingFb( input_item_t *p_item ) VLC_USED;
254 VLC_API void input_item_SetURI( input_item_t * p_i, const char *psz_uri );
255 VLC_API mtime_t input_item_GetDuration( input_item_t * p_i );
256 VLC_API void input_item_SetDuration( input_item_t * p_i, mtime_t i_duration );
257 VLC_API bool input_item_IsPreparsed( input_item_t *p_i );
258 VLC_API bool input_item_IsArtFetched( input_item_t *p_i );
260 #define INPUT_META( name ) \
261 static inline \
262 void input_item_Set ## name (input_item_t *p_input, const char *val) \
264 input_item_SetMeta (p_input, vlc_meta_ ## name, val); \
266 static inline \
267 char *input_item_Get ## name (input_item_t *p_input) \
269 return input_item_GetMeta (p_input, vlc_meta_ ## name); \
272 INPUT_META(Title)
273 INPUT_META(Artist)
274 INPUT_META(AlbumArtist)
275 INPUT_META(Genre)
276 INPUT_META(Copyright)
277 INPUT_META(Album)
278 INPUT_META(TrackNumber)
279 INPUT_META(Description)
280 INPUT_META(Rating)
281 INPUT_META(Date)
282 INPUT_META(Setting)
283 INPUT_META(URL)
284 INPUT_META(Language)
285 INPUT_META(NowPlaying)
286 INPUT_META(ESNowPlaying)
287 INPUT_META(Publisher)
288 INPUT_META(EncodedBy)
289 INPUT_META(ArtworkURL)
290 INPUT_META(TrackID)
291 INPUT_META(TrackTotal)
292 INPUT_META(Director)
293 INPUT_META(Season)
294 INPUT_META(Episode)
295 INPUT_META(ShowName)
296 INPUT_META(Actors)
297 INPUT_META(DiscNumber)
299 #define input_item_SetTrackNum input_item_SetTrackNumber
300 #define input_item_GetTrackNum input_item_GetTrackNumber
301 #define input_item_SetArtURL input_item_SetArtworkURL
302 #define input_item_GetArtURL input_item_GetArtworkURL
304 VLC_API char * input_item_GetInfo( input_item_t *p_i, const char *psz_cat,const char *psz_name ) VLC_USED;
305 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 );
306 VLC_API int input_item_DelInfo( input_item_t *p_i, const char *psz_cat, const char *psz_name );
307 VLC_API void input_item_ReplaceInfos( input_item_t *, info_category_t * );
308 VLC_API void input_item_MergeInfos( input_item_t *, info_category_t * );
311 * This function creates a new input_item_t with the provided information.
313 * XXX You may also use input_item_New, as they need less arguments.
315 VLC_API input_item_t * input_item_NewExt( const char *psz_uri,
316 const char *psz_name,
317 mtime_t i_duration, int i_type,
318 enum input_item_net_type i_net ) VLC_USED;
320 #define input_item_New( psz_uri, psz_name ) \
321 input_item_NewExt( psz_uri, psz_name, -1, ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN )
323 #define input_item_NewCard( psz_uri, psz_name ) \
324 input_item_NewExt( psz_uri, psz_name, -1, ITEM_TYPE_CARD, ITEM_LOCAL )
326 #define input_item_NewDisc( psz_uri, psz_name, i_duration ) \
327 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_DISC, ITEM_LOCAL )
329 #define input_item_NewStream( psz_uri, psz_name, i_duration ) \
330 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_STREAM, ITEM_NET )
332 #define input_item_NewDirectory( psz_uri, psz_name, i_net ) \
333 input_item_NewExt( psz_uri, psz_name, -1, ITEM_TYPE_DIRECTORY, i_net )
335 #define input_item_NewFile( psz_uri, psz_name, i_duration, i_net ) \
336 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_FILE, i_net )
339 * This function creates a new input_item_t as a copy of another.
341 VLC_API input_item_t * input_item_Copy(input_item_t * ) VLC_USED;
343 /** Holds an input item, i.e. creates a new reference. */
344 VLC_API input_item_t *input_item_Hold(input_item_t *);
346 /** Releases an input item, i.e. decrements its reference counter. */
347 VLC_API void input_item_Release(input_item_t *);
349 typedef enum input_item_meta_request_option_t
351 META_REQUEST_OPTION_NONE = 0x00,
352 META_REQUEST_OPTION_SCOPE_LOCAL = 0x01,
353 META_REQUEST_OPTION_SCOPE_NETWORK = 0x02,
354 META_REQUEST_OPTION_SCOPE_ANY = 0x03,
355 META_REQUEST_OPTION_DO_INTERACT = 0x04
356 } input_item_meta_request_option_t;
358 /* status of the vlc_InputItemPreparseEnded event */
359 enum input_item_preparse_status
361 ITEM_PREPARSE_SKIPPED,
362 ITEM_PREPARSE_FAILED,
363 ITEM_PREPARSE_TIMEOUT,
364 ITEM_PREPARSE_DONE
367 VLC_API int libvlc_MetadataRequest( libvlc_int_t *, input_item_t *,
368 input_item_meta_request_option_t,
369 int, void * );
370 VLC_API int libvlc_ArtRequest(libvlc_int_t *, input_item_t *,
371 input_item_meta_request_option_t );
372 VLC_API void libvlc_MetadataCancel( libvlc_int_t *, void * );
374 /******************
375 * Input stats
376 ******************/
377 struct input_stats_t
379 vlc_mutex_t lock;
381 /* Input */
382 int64_t i_read_packets;
383 int64_t i_read_bytes;
384 float f_input_bitrate;
385 float f_average_input_bitrate;
387 /* Demux */
388 int64_t i_demux_read_packets;
389 int64_t i_demux_read_bytes;
390 float f_demux_bitrate;
391 float f_average_demux_bitrate;
392 int64_t i_demux_corrupted;
393 int64_t i_demux_discontinuity;
395 /* Decoders */
396 int64_t i_decoded_audio;
397 int64_t i_decoded_video;
399 /* Vout */
400 int64_t i_displayed_pictures;
401 int64_t i_lost_pictures;
403 /* Sout */
404 int64_t i_sent_packets;
405 int64_t i_sent_bytes;
406 float f_send_bitrate;
408 /* Aout */
409 int64_t i_played_abuffers;
410 int64_t i_lost_abuffers;
414 * Access pf_readdir helper struct
415 * \see vlc_readdir_helper_init()
416 * \see vlc_readdir_helper_additem()
417 * \see vlc_readdir_helper_finish()
419 struct vlc_readdir_helper
421 input_item_node_t *p_node;
422 void **pp_slaves;
423 size_t i_slaves;
424 void **pp_dirs;
425 size_t i_dirs;
426 int i_sub_autodetect_fuzzy;
427 bool b_show_hiddenfiles;
428 char *psz_ignored_exts;
432 * Init a vlc_readdir_helper struct
434 * \param p_rdh need to be cleaned with vlc_readdir_helper_finish()
435 * \param p_node node that will be used to add items
437 VLC_API void vlc_readdir_helper_init(struct vlc_readdir_helper *p_rdh,
438 vlc_object_t *p_obj, input_item_node_t *p_node);
439 #define vlc_readdir_helper_init(p_rdh, p_obj, p_node) \
440 vlc_readdir_helper_init(p_rdh, VLC_OBJECT(p_obj), p_node)
443 * Finish adding items to the node
445 * \param b_success if true, items of the node will be sorted.
447 VLC_API void vlc_readdir_helper_finish(struct vlc_readdir_helper *p_rdh, bool b_success);
450 * Add a new input_item_t entry to the node of the vlc_readdir_helper struct.
452 * \param p_rdh previously inited vlc_readdir_helper struct
453 * \param psz_uri uri of the new item
454 * \param psz_flatpath flattened path of the new item. If not NULL, this
455 * function will create an input item for each sub folders (separated
456 * by '/') of psz_flatpath (so, this will un-flatten the folder
457 * hierarchy). Either psz_flatpath or psz_filename must be valid.
458 * \param psz_filename file name of the new item. If NULL, the file part of path
459 * will be used as a filename. Either psz_flatpath or psz_filename must
460 * be valid.
461 * \param i_type see \ref input_item_type_e
462 * \param i_net see \ref input_item_net_type
464 VLC_API int vlc_readdir_helper_additem(struct vlc_readdir_helper *p_rdh,
465 const char *psz_uri, const char *psz_flatpath,
466 const char *psz_filename,
467 int i_type, int i_net);
469 #endif