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>
39 /*****************************************************************************
40 * input_item_t: Describes an input and is used to spawn input_thread_t objects
41 *****************************************************************************/
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 */
57 int i_id; /**< Identifier of the item */
59 char *psz_name; /**< text describing this item */
60 char *psz_uri; /**< mrl of this item */
62 int i_options; /**< Number of input options */
63 char **ppsz_options; /**< Array of input options */
64 uint8_t *optflagv; /**< Some flags of input options */
67 mtime_t i_duration; /**< Duration in microseconds */
70 int i_categories; /**< Number of info categories */
71 info_category_t **pp_categories; /**< Pointer to the first info category */
73 int i_es; /**< Number of es format descriptions */
74 es_format_t **es; /**< Es formats */
76 input_stats_t *p_stats; /**< Statistics */
80 int i_epg; /**< Number of EPG entries */
81 vlc_epg_t **pp_epg; /**< EPG entries */
83 vlc_event_manager_t event_manager;
85 vlc_mutex_t lock; /**< Lock for the item */
87 uint8_t i_type; /**< Type (file, disc, ... see input_item_type_e) */
88 bool b_net; /**< Net: always true for TYPE_STREAM, it
89 depends for others types */
90 bool b_error_when_reading;/**< Error When Reading */
92 int i_preparse_depth; /**< How many level of sub items can be preparsed:
93 -1: recursive, 0: none, >0: n levels */
96 TYPEDEF_ARRAY(input_item_t*, input_item_array_t)
98 enum input_item_type_e
110 /* This one is not a real type but the number of input_item types. */
114 struct input_item_node_t
116 input_item_t * p_item;
118 input_item_node_t **pp_children;
119 input_item_node_t *p_parent;
122 VLC_API void input_item_CopyOptions( input_item_t *p_parent, input_item_t *p_child );
123 VLC_API void input_item_SetName( input_item_t *p_item, const char *psz_name );
126 * Add one subitem to this item
128 * This won't hold the item, but can tell to interested third parties
129 * Like the playlist, that there is a new sub item. With this design
130 * It is not the input item's responsability to keep all the ref of
131 * the input item children.
133 * Sends a vlc_InputItemSubItemTreeAdded and a vlc_InputItemSubItemAdded event
135 VLC_API void input_item_PostSubItem( input_item_t *p_parent, input_item_t *p_child );
138 * Start adding multiple subitems.
140 * Create a root node to hold a tree of subitems for given item
142 VLC_API input_item_node_t * input_item_node_Create( input_item_t *p_input ) VLC_USED;
145 * Add a new child node to this parent node that will point to this subitem.
147 VLC_API input_item_node_t * input_item_node_AppendItem( input_item_node_t *p_node, input_item_t *p_item );
150 * Add an already created node to children of this parent node.
152 VLC_API void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t *p_child );
155 * Delete a node created with input_item_node_Create() and all its children.
157 VLC_API void input_item_node_Delete( input_item_node_t *p_node );
160 * End adding multiple subitems.
162 * Sends a vlc_InputItemSubItemTreeAdded event to notify that the item pointed to
163 * by the given root node has created new subitems that are pointed to by all the
164 * children of the node.
166 * Also sends vlc_InputItemSubItemAdded event for every child under the given root node;
168 * In the end deletes the node and all its children nodes.
170 VLC_API void input_item_node_PostAndDelete( input_item_node_t *p_node );
176 enum input_item_option_e
178 /* Allow VLC to trust the given option.
179 * By default options are untrusted */
180 VLC_INPUT_OPTION_TRUSTED = 0x2,
182 /* Add the option, unless the same option
183 * is already present. */
184 VLC_INPUT_OPTION_UNIQUE = 0x100,
188 * This function allows to add an option to an existing input_item_t.
190 VLC_API int input_item_AddOption(input_item_t *, const char *, unsigned i_flags );
193 VLC_API bool input_item_HasErrorWhenReading( input_item_t * );
194 VLC_API void input_item_SetMeta( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val );
195 VLC_API bool input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz );
196 VLC_API char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type ) VLC_USED;
197 VLC_API char * input_item_GetName( input_item_t * p_i ) VLC_USED;
198 VLC_API char * input_item_GetTitleFbName( input_item_t * p_i ) VLC_USED;
199 VLC_API char * input_item_GetURI( input_item_t * p_i ) VLC_USED;
200 VLC_API char * input_item_GetNowPlayingFb( input_item_t *p_item ) VLC_USED;
201 VLC_API void input_item_SetURI( input_item_t * p_i, const char *psz_uri );
202 VLC_API mtime_t input_item_GetDuration( input_item_t * p_i );
203 VLC_API void input_item_SetDuration( input_item_t * p_i, mtime_t i_duration );
204 VLC_API bool input_item_IsPreparsed( input_item_t *p_i );
205 VLC_API bool input_item_IsArtFetched( input_item_t *p_i );
207 #define INPUT_META( name ) \
209 void input_item_Set ## name (input_item_t *p_input, const char *val) \
211 input_item_SetMeta (p_input, vlc_meta_ ## name, val); \
214 char *input_item_Get ## name (input_item_t *p_input) \
216 return input_item_GetMeta (p_input, vlc_meta_ ## name); \
222 INPUT_META(Copyright)
224 INPUT_META(TrackNumber)
225 INPUT_META(Description)
231 INPUT_META(NowPlaying)
232 INPUT_META(ESNowPlaying)
233 INPUT_META(Publisher)
234 INPUT_META(EncodedBy)
235 INPUT_META(ArtworkURL)
237 INPUT_META(TrackTotal)
244 #define input_item_SetTrackNum input_item_SetTrackNumber
245 #define input_item_GetTrackNum input_item_GetTrackNumber
246 #define input_item_SetArtURL input_item_SetArtworkURL
247 #define input_item_GetArtURL input_item_GetArtworkURL
249 VLC_API char * input_item_GetInfo( input_item_t *p_i, const char *psz_cat,const char *psz_name ) VLC_USED;
250 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 );
251 VLC_API int input_item_DelInfo( input_item_t *p_i, const char *psz_cat, const char *psz_name );
252 VLC_API void input_item_ReplaceInfos( input_item_t *, info_category_t * );
253 VLC_API void input_item_MergeInfos( input_item_t *, info_category_t * );
256 * This function creates a new input_item_t with the provided information.
258 * XXX You may also use input_item_New or input_item_NewExt as they need
261 VLC_API input_item_t * input_item_NewWithType( const char *psz_uri, const char *psz_name, int i_options, const char *const *ppsz_options, unsigned i_option_flags, mtime_t i_duration, int i_type ) VLC_USED;
264 * This function creates a new input_item_t with the provided information.
266 * \param i_net 1/0: force b_net to true/false, -1: default (guess it)
268 * XXX You may also use input_item_New, input_item_NewExt, or
269 * input_item_NewWithType as they need less arguments.
271 VLC_API input_item_t * input_item_NewWithTypeExt( const char *psz_uri, const char *psz_name, int i_options, const char *const *ppsz_options, unsigned i_option_flags, mtime_t i_duration, int i_type, int i_net ) VLC_USED;
274 * This function creates a new input_item_t with the provided information.
276 * Provided for convenience.
278 VLC_API input_item_t * input_item_NewExt( const char *psz_uri, const char *psz_name, int i_options, const char *const *ppsz_options, unsigned i_option_flags, mtime_t i_duration ) VLC_USED;
281 * This function creates a new input_item_t with the provided information.
283 * Provided for convenience.
285 #define input_item_New( a,b ) input_item_NewExt( a, b, 0, NULL, 0, -1 )
288 * This function creates a new input_item_t as a copy of another.
290 VLC_API input_item_t * input_item_Copy(input_item_t * ) VLC_USED;
292 /** Holds an input item, i.e. creates a new reference. */
293 VLC_API input_item_t *input_item_Hold(input_item_t *);
295 /** Releases an input item, i.e. decrements its reference counter. */
296 VLC_API void input_item_Release(input_item_t *);
298 /* Historical hack... */
299 #define vlc_gc_incref(i) input_item_Hold(i)
300 #define vlc_gc_decref(i) input_item_Release(i)
302 typedef enum input_item_meta_request_option_t
304 META_REQUEST_OPTION_NONE = 0x00,
305 META_REQUEST_OPTION_SCOPE_LOCAL = 0x01,
306 META_REQUEST_OPTION_SCOPE_NETWORK = 0x02,
307 META_REQUEST_OPTION_SCOPE_ANY = 0x03
308 } input_item_meta_request_option_t;
310 VLC_API int libvlc_MetaRequest(libvlc_int_t *, input_item_t *,
311 input_item_meta_request_option_t );
312 VLC_API int libvlc_ArtRequest(libvlc_int_t *, input_item_t *,
313 input_item_meta_request_option_t );
323 int64_t i_read_packets;
324 int64_t i_read_bytes;
325 float f_input_bitrate;
326 float f_average_input_bitrate;
329 int64_t i_demux_read_packets;
330 int64_t i_demux_read_bytes;
331 float f_demux_bitrate;
332 float f_average_demux_bitrate;
333 int64_t i_demux_corrupted;
334 int64_t i_demux_discontinuity;
337 int64_t i_decoded_audio;
338 int64_t i_decoded_video;
341 int64_t i_displayed_pictures;
342 int64_t i_lost_pictures;
345 int64_t i_sent_packets;
346 int64_t i_sent_bytes;
347 float f_send_bitrate;
350 int64_t i_played_abuffers;
351 int64_t i_lost_abuffers;