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 typedef struct input_item_opaque input_item_opaque_t
;
40 typedef struct input_item_slave input_item_slave_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 */
56 * Describes an input and is used to spawn input_thread_t objects.
60 int i_id
; /**< Identifier of the item */
62 char *psz_name
; /**< text describing this item */
63 char *psz_uri
; /**< mrl of this item */
65 int i_options
; /**< Number of input options */
66 char **ppsz_options
; /**< Array of input options */
67 uint8_t *optflagv
; /**< Some flags of input options */
69 input_item_opaque_t
*opaques
; /**< List of opaque pointer values */
71 mtime_t i_duration
; /**< Duration in microseconds */
74 int i_categories
; /**< Number of info categories */
75 info_category_t
**pp_categories
; /**< Pointer to the first info category */
77 int i_es
; /**< Number of es format descriptions */
78 es_format_t
**es
; /**< Es formats */
80 input_stats_t
*p_stats
; /**< Statistics */
84 int i_epg
; /**< Number of EPG entries */
85 vlc_epg_t
**pp_epg
; /**< EPG entries */
87 int i_slaves
; /**< Number of slaves */
88 input_item_slave_t
**pp_slaves
; /**< Slave entries that will be loaded by
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
107 TYPEDEF_ARRAY(input_item_t
*, input_item_array_t
)
109 enum input_item_type_e
120 /* This one is not a real type but the number of input_item types. */
124 enum input_item_net_type
139 SLAVE_PRIORITY_MATCH_NONE
= 1,
140 SLAVE_PRIORITY_MATCH_RIGHT
,
141 SLAVE_PRIORITY_MATCH_LEFT
,
142 SLAVE_PRIORITY_MATCH_ALL
,
146 #define SLAVE_SPU_EXTENSIONS \
147 "idx", "sub", "srt", \
148 "ssa", "ass", "smi", \
149 "utf", "utf8", "utf-8", \
150 "rt", "aqt", "txt", \
151 "usf", "jss", "cdg", \
152 "psb", "mpsub","mpl2", \
153 "pjs", "dks", "stl", \
155 #define SLAVE_AUDIO_EXTENSIONS \
156 "ac3", "m4a", "aac", \
157 "eac3", "dtshd", "flac", \
160 struct input_item_slave
162 enum slave_type i_type
; /**< Slave type (spu, audio) */
163 enum slave_priority i_priority
; /**< Slave priority */
164 bool b_forced
; /**< Slave should be selected */
165 char psz_uri
[]; /**< Slave mrl */
168 typedef int (*input_item_compar_cb
)( input_item_t
*, input_item_t
* );
170 struct input_item_node_t
172 input_item_t
* p_item
;
174 input_item_node_t
**pp_children
;
175 input_item_node_t
*p_parent
;
176 input_item_compar_cb compar_cb
;
180 VLC_API
void input_item_CopyOptions( input_item_t
*p_child
, input_item_t
*p_parent
);
181 VLC_API
void input_item_SetName( input_item_t
*p_item
, const char *psz_name
);
184 * Add one subitem to this item
186 * This won't hold the item, but can tell to interested third parties
187 * Like the playlist, that there is a new sub item. With this design
188 * It is not the input item's responsibility to keep all the ref of
189 * the input item children.
191 * Sends a vlc_InputItemSubItemTreeAdded and a vlc_InputItemSubItemAdded event
193 VLC_API
void input_item_PostSubItem( input_item_t
*p_parent
, input_item_t
*p_child
);
196 * Start adding multiple subitems.
198 * Create a root node to hold a tree of subitems for given item
200 VLC_API input_item_node_t
* input_item_node_Create( input_item_t
*p_input
) VLC_USED
;
203 * Add a new child node to this parent node that will point to this subitem.
205 VLC_API input_item_node_t
* input_item_node_AppendItem( input_item_node_t
*p_node
, input_item_t
*p_item
);
208 * Add an already created node to children of this parent node.
210 VLC_API
void input_item_node_AppendNode( input_item_node_t
*p_parent
, input_item_node_t
*p_child
);
213 * Sort all p_item children of the node recursively.
215 VLC_API
void input_item_node_Sort( input_item_node_t
*p_node
,
216 input_item_compar_cb compar_cb
);
219 * Delete a node created with input_item_node_Create() and all its children.
221 VLC_API
void input_item_node_Delete( input_item_node_t
*p_node
);
224 * End adding multiple subitems.
226 * Sends a vlc_InputItemSubItemTreeAdded event to notify that the item pointed to
227 * by the given root node has created new subitems that are pointed to by all the
228 * children of the node.
230 * Also sends vlc_InputItemSubItemAdded event for every child under the given root node;
232 * In the end deletes the node and all its children nodes.
234 VLC_API
void input_item_node_PostAndDelete( input_item_node_t
*p_node
);
240 enum input_item_option_e
242 /* Allow VLC to trust the given option.
243 * By default options are untrusted */
244 VLC_INPUT_OPTION_TRUSTED
= 0x2,
246 /* Add the option, unless the same option
247 * is already present. */
248 VLC_INPUT_OPTION_UNIQUE
= 0x100,
252 * This function allows to add an option to an existing input_item_t.
254 VLC_API
int input_item_AddOption(input_item_t
*, const char *, unsigned i_flags
);
256 * This function add several options to an existing input_item_t.
258 VLC_API
int input_item_AddOptions(input_item_t
*, int i_options
,
259 const char *const *ppsz_options
,
261 VLC_API
int input_item_AddOpaque(input_item_t
*, const char *, void *);
263 void input_item_ApplyOptions(vlc_object_t
*, input_item_t
*);
265 VLC_API
bool input_item_slave_GetType(const char *, enum slave_type
*);
267 VLC_API input_item_slave_t
*input_item_slave_New(const char *, enum slave_type
,
268 enum slave_priority
);
269 #define input_item_slave_Delete(p_slave) free(p_slave)
272 * This function allows adding a slave to an existing input item.
273 * The slave is owned by the input item after this call.
275 VLC_API
int input_item_AddSlave(input_item_t
*, input_item_slave_t
*);
278 VLC_API
bool input_item_HasErrorWhenReading( input_item_t
* );
279 VLC_API
void input_item_SetMeta( input_item_t
*, vlc_meta_type_t meta_type
, const char *psz_val
);
280 VLC_API
bool input_item_MetaMatch( input_item_t
*p_i
, vlc_meta_type_t meta_type
, const char *psz
);
281 VLC_API
char * input_item_GetMeta( input_item_t
*p_i
, vlc_meta_type_t meta_type
) VLC_USED
;
282 VLC_API
char * input_item_GetName( input_item_t
* p_i
) VLC_USED
;
283 VLC_API
char * input_item_GetTitleFbName( input_item_t
* p_i
) VLC_USED
;
284 VLC_API
char * input_item_GetURI( input_item_t
* p_i
) VLC_USED
;
285 VLC_API
char * input_item_GetNowPlayingFb( input_item_t
*p_item
) VLC_USED
;
286 VLC_API
void input_item_SetURI( input_item_t
* p_i
, const char *psz_uri
);
287 VLC_API mtime_t
input_item_GetDuration( input_item_t
* p_i
);
288 VLC_API
void input_item_SetDuration( input_item_t
* p_i
, mtime_t i_duration
);
289 VLC_API
bool input_item_IsPreparsed( input_item_t
*p_i
);
290 VLC_API
bool input_item_IsArtFetched( input_item_t
*p_i
);
292 #define INPUT_META( name ) \
294 void input_item_Set ## name (input_item_t *p_input, const char *val) \
296 input_item_SetMeta (p_input, vlc_meta_ ## name, val); \
299 char *input_item_Get ## name (input_item_t *p_input) \
301 return input_item_GetMeta (p_input, vlc_meta_ ## name); \
306 INPUT_META(AlbumArtist
)
308 INPUT_META(Copyright
)
310 INPUT_META(TrackNumber
)
311 INPUT_META(Description
)
317 INPUT_META(NowPlaying
)
318 INPUT_META(ESNowPlaying
)
319 INPUT_META(Publisher
)
320 INPUT_META(EncodedBy
)
321 INPUT_META(ArtworkURL
)
323 INPUT_META(TrackTotal
)
329 INPUT_META(DiscNumber
)
331 #define input_item_SetTrackNum input_item_SetTrackNumber
332 #define input_item_GetTrackNum input_item_GetTrackNumber
333 #define input_item_SetArtURL input_item_SetArtworkURL
334 #define input_item_GetArtURL input_item_GetArtworkURL
336 VLC_API
char * input_item_GetInfo( input_item_t
*p_i
, const char *psz_cat
,const char *psz_name
) VLC_USED
;
337 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 );
338 VLC_API
int input_item_DelInfo( input_item_t
*p_i
, const char *psz_cat
, const char *psz_name
);
339 VLC_API
void input_item_ReplaceInfos( input_item_t
*, info_category_t
* );
340 VLC_API
void input_item_MergeInfos( input_item_t
*, info_category_t
* );
343 * This function creates a new input_item_t with the provided information.
345 * XXX You may also use input_item_New, as they need less arguments.
347 VLC_API input_item_t
* input_item_NewExt( const char *psz_uri
,
348 const char *psz_name
,
349 mtime_t i_duration
, int i_type
,
350 enum input_item_net_type i_net
) VLC_USED
;
352 #define input_item_New( psz_uri, psz_name ) \
353 input_item_NewExt( psz_uri, psz_name, -1, ITEM_TYPE_UNKNOWN, ITEM_NET_UNKNOWN )
355 #define input_item_NewCard( psz_uri, psz_name ) \
356 input_item_NewExt( psz_uri, psz_name, -1, ITEM_TYPE_CARD, ITEM_LOCAL )
358 #define input_item_NewDisc( psz_uri, psz_name, i_duration ) \
359 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_DISC, ITEM_LOCAL )
361 #define input_item_NewStream( psz_uri, psz_name, i_duration ) \
362 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_STREAM, ITEM_NET )
364 #define input_item_NewDirectory( psz_uri, psz_name, i_net ) \
365 input_item_NewExt( psz_uri, psz_name, -1, ITEM_TYPE_DIRECTORY, i_net )
367 #define input_item_NewFile( psz_uri, psz_name, i_duration, i_net ) \
368 input_item_NewExt( psz_uri, psz_name, i_duration, ITEM_TYPE_FILE, i_net )
371 * This function creates a new input_item_t as a copy of another.
373 VLC_API input_item_t
* input_item_Copy(input_item_t
* ) VLC_USED
;
375 /** Holds an input item, i.e. creates a new reference. */
376 VLC_API input_item_t
*input_item_Hold(input_item_t
*);
378 /** Releases an input item, i.e. decrements its reference counter. */
379 VLC_API
void input_item_Release(input_item_t
*);
381 /* Historical hack... */
382 #define vlc_gc_incref(i) input_item_Hold(i)
383 #define vlc_gc_decref(i) input_item_Release(i)
385 typedef enum input_item_meta_request_option_t
387 META_REQUEST_OPTION_NONE
= 0x00,
388 META_REQUEST_OPTION_SCOPE_LOCAL
= 0x01,
389 META_REQUEST_OPTION_SCOPE_NETWORK
= 0x02,
390 META_REQUEST_OPTION_SCOPE_ANY
= 0x03,
391 META_REQUEST_OPTION_DO_INTERACT
= 0x04
392 } input_item_meta_request_option_t
;
394 /* status of the vlc_InputItemPreparseEnded event */
395 enum input_item_preparse_status
397 ITEM_PREPARSE_SKIPPED
,
398 ITEM_PREPARSE_FAILED
,
399 ITEM_PREPARSE_TIMEOUT
,
403 VLC_API
int libvlc_MetadataRequest( libvlc_int_t
*, input_item_t
*,
404 input_item_meta_request_option_t
,
406 VLC_API
int libvlc_ArtRequest(libvlc_int_t
*, input_item_t
*,
407 input_item_meta_request_option_t
);
408 VLC_API
void libvlc_MetadataCancel( libvlc_int_t
*, void * );
418 int64_t i_read_packets
;
419 int64_t i_read_bytes
;
420 float f_input_bitrate
;
421 float f_average_input_bitrate
;
424 int64_t i_demux_read_packets
;
425 int64_t i_demux_read_bytes
;
426 float f_demux_bitrate
;
427 float f_average_demux_bitrate
;
428 int64_t i_demux_corrupted
;
429 int64_t i_demux_discontinuity
;
432 int64_t i_decoded_audio
;
433 int64_t i_decoded_video
;
436 int64_t i_displayed_pictures
;
437 int64_t i_lost_pictures
;
440 int64_t i_sent_packets
;
441 int64_t i_sent_bytes
;
442 float f_send_bitrate
;
445 int64_t i_played_abuffers
;
446 int64_t i_lost_abuffers
;