1 /*****************************************************************************
2 * vlc_input_item.h: Core input item
3 *****************************************************************************
4 * Copyright (C) 1999-2009 the VideoLAN team
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
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 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 General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, 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
38 /*****************************************************************************
39 * input_item_t: Describes an input and is used to spawn input_thread_t objects
40 *****************************************************************************/
43 char *psz_name; /**< Name of this info */
44 char *psz_value; /**< Value of the info */
47 struct info_category_t
49 char *psz_name; /**< Name of this category */
50 int i_infos; /**< Number of infos in the category */
51 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 */
77 int i_nb_played; /**< Number of times played */
81 int i_epg; /**< Number of EPG entries */
82 vlc_epg_t **pp_epg; /**< EPG entries */
84 vlc_event_manager_t event_manager;
86 vlc_mutex_t lock; /**< Lock for the item */
88 uint8_t i_type; /**< Type (file, disc, ... see input_item_type_e) */
89 bool b_prefers_tree; /**< Do we prefer being displayed as tree*/
90 bool b_fixed_name; /**< Can the interface change the name ?*/
91 bool b_error_when_reading;/**< Error When Reading */
94 enum input_item_type_e
106 /* This one is not a real type but the number of input_item types. */
110 struct input_item_node_t
112 input_item_t * p_item;
114 input_item_node_t **pp_children;
115 input_item_node_t *p_parent;
118 VLC_EXPORT( void, input_item_CopyOptions, ( input_item_t *p_parent, input_item_t *p_child ) );
119 VLC_EXPORT( void, input_item_SetName, ( input_item_t *p_item, const char *psz_name ) );
122 * Add one subitem to this item
124 * This won't hold the item, but can tell to interested third parties
125 * Like the playlist, that there is a new sub item. With this design
126 * It is not the input item's responsability to keep all the ref of
127 * the input item children. */
128 VLC_EXPORT( void, input_item_PostSubItem, ( input_item_t *p_parent, input_item_t *p_child ) );
132 * Start adding multiple subitems.
134 * Create a root node to hold a tree of subitems for given item
136 VLC_EXPORT( input_item_node_t *, input_item_node_Create, ( input_item_t *p_input ) );
139 * Add a subitem to this input_item and to this input_item_node.
141 * A vlc_InputItemSubItemAdded event will be sent right away.
143 VLC_EXPORT( input_item_node_t *, input_item_node_AppendItem, ( input_item_node_t *p_node, input_item_t *p_item ) );
146 * Add a subitem to this input_item and to this input_item_node.
148 * A vlc_InputItemSubItemAdded event will be sent right away for the subitem
149 * pointed by input_item_node_t.
151 VLC_EXPORT( void, input_item_node_AppendNode, ( input_item_node_t *p_node, input_item_node_t *p_item ) );
154 * Delete a node created with input_item_node_Create() and all its children.
156 VLC_EXPORT( void, input_item_node_Delete, ( input_item_node_t *p_node ) );
159 * End adding multiple subitems.
161 * Send a notification that the item pointed to by the given root node
162 * has created new subitems that are pointed to by all the children of the node.
163 * Then delete the node and all its children.
165 * A vlc_InputItemSubItemTreeAdded event will be sent.
167 VLC_EXPORT( void, input_item_node_PostAndDelete, ( input_item_node_t *p_node ) );
173 enum input_item_option_e
175 /* Allow VLC to trust the given option.
176 * By default options are untrusted */
177 VLC_INPUT_OPTION_TRUSTED = 0x2,
179 /* Change the value associated to an option if already present, otherwise
181 VLC_INPUT_OPTION_UNIQUE = 0x100,
185 * This function allows to add an option to an existing input_item_t.
187 VLC_EXPORT( int, input_item_AddOption, (input_item_t *, const char *, unsigned i_flags ) );
190 VLC_EXPORT( bool, input_item_HasErrorWhenReading, ( input_item_t * ) );
191 VLC_EXPORT( void, input_item_SetMeta, ( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val ));
192 VLC_EXPORT( bool, input_item_MetaMatch, ( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz ) );
193 VLC_EXPORT( char *, input_item_GetMeta, ( input_item_t *p_i, vlc_meta_type_t meta_type ) );
194 VLC_EXPORT( char *, input_item_GetName, ( input_item_t * p_i ) );
195 VLC_EXPORT( char *, input_item_GetTitleFbName, ( input_item_t * p_i ) );
196 VLC_EXPORT( char *, input_item_GetURI, ( input_item_t * p_i ) );
197 VLC_EXPORT( void, input_item_SetURI, ( input_item_t * p_i, const char *psz_uri ));
198 VLC_EXPORT(mtime_t, input_item_GetDuration, ( input_item_t * p_i ) );
199 VLC_EXPORT( void, input_item_SetDuration, ( input_item_t * p_i, mtime_t i_duration ));
200 VLC_EXPORT( bool, input_item_IsPreparsed, ( input_item_t *p_i ));
201 VLC_EXPORT( bool, input_item_IsArtFetched, ( input_item_t *p_i ));
203 #define INPUT_META( name ) \
205 void input_item_Set ## name (input_item_t *p_input, const char *val) \
207 input_item_SetMeta (p_input, vlc_meta_ ## name, val); \
210 char *input_item_Get ## name (input_item_t *p_input) \
212 return input_item_GetMeta (p_input, vlc_meta_ ## name); \
218 INPUT_META(Copyright)
220 INPUT_META(TrackNumber)
221 INPUT_META(Description)
227 INPUT_META(NowPlaying)
228 INPUT_META(Publisher)
229 INPUT_META(EncodedBy)
230 INPUT_META(ArtworkURL)
233 #define input_item_SetTrackNum input_item_SetTrackNumber
234 #define input_item_GetTrackNum input_item_GetTrackNumber
235 #define input_item_SetArtURL input_item_SetArtworkURL
236 #define input_item_GetArtURL input_item_GetArtworkURL
238 VLC_EXPORT( char *, input_item_GetInfo, ( input_item_t *p_i, const char *psz_cat,const char *psz_name ) );
239 VLC_EXPORT( int, input_item_AddInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name, const char *psz_format, ... ) LIBVLC_FORMAT( 4, 5 ) );
240 VLC_EXPORT( int, input_item_DelInfo, ( input_item_t *p_i, const char *psz_cat, const char *psz_name ) );
243 * This function creates a new input_item_t with the provided informations.
245 * XXX You may also use input_item_New or input_item_NewExt as they need
248 VLC_EXPORT( input_item_t *, input_item_NewWithType, ( vlc_object_t *, 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 ) );
251 * This function creates a new input_item_t with the provided informations.
253 * Provided for convenience.
255 #define input_item_NewExt(a,b,c,d,e,f,g) __input_item_NewExt( VLC_OBJECT(a),b,c,d,e,f,g)
256 VLC_EXPORT( input_item_t *, __input_item_NewExt, (vlc_object_t *, const char *psz_uri, const char *psz_name, int i_options, const char *const *ppsz_options, unsigned i_option_flags, mtime_t i_duration ) );
259 * This function creates a new input_item_t with the provided informations.
261 * Provided for convenience.
263 #define input_item_New( a,b,c ) input_item_NewExt( a, b, c, 0, NULL, 0, -1 )
275 float f_input_bitrate;
276 float f_average_input_bitrate;
279 int i_demux_read_packets;
280 int i_demux_read_bytes;
281 float f_demux_bitrate;
282 float f_average_demux_bitrate;
283 int i_demux_corrupted;
284 int i_demux_discontinuity;
291 int i_displayed_pictures;
297 float f_send_bitrate;
300 int i_played_abuffers;