VLC  2.1.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vlc_input_item.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vlc_input_item.h: Core input item
3  *****************************************************************************
4  * Copyright (C) 1999-2009 VLC authors and VideoLAN
5  * $Id: 0f9800da4dd2cd7febdca74b4787054d6baa5dee $
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
8  * Laurent Aimar <fenrir@via.ecp.fr>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24 
25 #ifndef VLC_INPUT_ITEM_H
26 #define VLC_INPUT_ITEM_H 1
27 
28 /**
29  * \file
30  * This file defines functions, structures and enums for input items in vlc
31  */
32 
33 #include <vlc_meta.h>
34 #include <vlc_epg.h>
35 #include <vlc_events.h>
36 
37 #include <string.h>
38 
39 /*****************************************************************************
40  * input_item_t: Describes an input and is used to spawn input_thread_t objects
41  *****************************************************************************/
42 struct info_t
43 {
44  char *psz_name; /**< Name of this info */
45  char *psz_value; /**< Value of the info */
46 };
47 
48 struct info_category_t
49 {
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 */
53 };
54 
55 struct input_item_t
56 {
57  int i_id; /**< Identifier of the item */
58 
59  char *psz_name; /**< text describing this item */
60  char *psz_uri; /**< mrl of this item */
61 
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 */
65  unsigned optflagc;
66 
67  mtime_t i_duration; /**< Duration in microseconds */
68 
69 
70  int i_categories; /**< Number of info categories */
71  info_category_t **pp_categories; /**< Pointer to the first info category */
72 
73  int i_es; /**< Number of es format descriptions */
74  es_format_t **es; /**< Es formats */
75 
76  input_stats_t *p_stats; /**< Statistics */
77  int i_nb_played; /**< Number of times played */
78 
80 
81  int i_epg; /**< Number of EPG entries */
82  vlc_epg_t **pp_epg; /**< EPG entries */
83 
85 
86  vlc_mutex_t lock; /**< Lock for the item */
87 
88  uint8_t i_type; /**< Type (file, disc, ... see input_item_type_e) */
89  bool b_fixed_name; /**< Can the interface change the name ?*/
90  bool b_error_when_reading;/**< Error When Reading */
91 };
92 
94 {
105  /* This one is not a real type but the number of input_item types. */
107 };
108 
109 struct input_item_node_t
110 {
115 };
116 
117 VLC_API void input_item_CopyOptions( input_item_t *p_parent, input_item_t *p_child );
118 VLC_API void input_item_SetName( input_item_t *p_item, const char *psz_name );
119 
120 /**
121  * Add one subitem to this item
122  *
123  * This won't hold the item, but can tell to interested third parties
124  * Like the playlist, that there is a new sub item. With this design
125  * It is not the input item's responsability to keep all the ref of
126  * the input item children.
127  *
128  * Sends a vlc_InputItemSubItemTreeAdded and a vlc_InputItemSubItemAdded event
129  */
130 VLC_API void input_item_PostSubItem( input_item_t *p_parent, input_item_t *p_child );
131 
132 /**
133  * Start adding multiple subitems.
134  *
135  * Create a root node to hold a tree of subitems for given item
136  */
138 
139 /**
140  * Add a new child node to this parent node that will point to this subitem.
141  */
143 
144 /**
145  * Add an already created node to children of this parent node.
146  */
148 
149 /**
150  * Delete a node created with input_item_node_Create() and all its children.
151  */
153 
154 /**
155  * End adding multiple subitems.
156  *
157  * Sends a vlc_InputItemSubItemTreeAdded event to notify that the item pointed to
158  * by the given root node has created new subitems that are pointed to by all the
159  * children of the node.
160  *
161  * Also sends vlc_InputItemSubItemAdded event for every child under the given root node;
162  *
163  * In the end deletes the node and all its children nodes.
164  */
166 
167 
168 /**
169  * Option flags
170  */
172 {
173  /* Allow VLC to trust the given option.
174  * By default options are untrusted */
177  /* Change the value associated to an option if already present, otherwise
178  * add the option */
179  VLC_INPUT_OPTION_UNIQUE = 0x100,
180 };
181 
182 /**
183  * This function allows to add an option to an existing input_item_t.
184  */
185 VLC_API int input_item_AddOption(input_item_t *, const char *, unsigned i_flags );
186 
187 /* */
189 VLC_API void input_item_SetMeta( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val );
190 VLC_API bool input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz );
195 VLC_API void input_item_SetURI( input_item_t * p_i, const char *psz_uri );
197 VLC_API void input_item_SetDuration( input_item_t * p_i, mtime_t i_duration );
200 
201 #define INPUT_META( name ) \
202 static inline \
203 void input_item_Set ## name (input_item_t *p_input, const char *val) \
204 { \
205  input_item_SetMeta (p_input, vlc_meta_ ## name, val); \
206 } \
207 static inline \
208 char *input_item_Get ## name (input_item_t *p_input) \
209 { \
210  return input_item_GetMeta (p_input, vlc_meta_ ## name); \
211 }
212 
213 INPUT_META(Title)
214 INPUT_META(Artist)
216 INPUT_META(Copyright)
218 INPUT_META(TrackNumber)
219 INPUT_META(Description)
220 INPUT_META(Rating)
222 INPUT_META(Setting)
224 INPUT_META(Language)
225 INPUT_META(NowPlaying)
226 INPUT_META(Publisher)
227 INPUT_META(EncodedBy)
228 INPUT_META(ArtworkURL)
229 INPUT_META(TrackID)
230 INPUT_META(TrackTotal)
232 #define input_item_SetTrackNum input_item_SetTrackNumber
233 #define input_item_GetTrackNum input_item_GetTrackNumber
234 #define input_item_SetArtURL input_item_SetArtworkURL
235 #define input_item_GetArtURL input_item_GetArtworkURL
237 VLC_API char * input_item_GetInfo( input_item_t *p_i, const char *psz_cat,const char *psz_name ) VLC_USED;
238 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 );
239 VLC_API int input_item_DelInfo( input_item_t *p_i, const char *psz_cat, const char *psz_name );
241 VLC_API void input_item_MergeInfos( input_item_t *, info_category_t * );
242 
243 /**
244  * This function creates a new input_item_t with the provided information.
245  *
246  * XXX You may also use input_item_New or input_item_NewExt as they need
247  * less arguments.
248  */
249 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;
250 
251 /**
252  * This function creates a new input_item_t with the provided information.
253  *
254  * Provided for convenience.
255  */
256 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;
257 
258 /**
259  * This function creates a new input_item_t with the provided information.
260  *
261  * Provided for convenience.
262  */
263 #define input_item_New( a,b ) input_item_NewExt( a, b, 0, NULL, 0, -1 )
265 /**
266  * This function creates a new input_item_t as a copy of another.
267  */
268 VLC_API input_item_t * input_item_Copy(input_item_t * ) VLC_USED;
269 
270 /** Holds an input item, i.e. creates a new reference. */
271 VLC_API input_item_t *input_item_Hold(input_item_t *);
272 
273 /** Releases an input item, i.e. decrements its reference counter. */
274 VLC_API void input_item_Release(input_item_t *);
275 
276 /* Historical hack... */
277 #define vlc_gc_incref(i) input_item_Hold(i)
278 #define vlc_gc_decref(i) input_item_Release(i)
280 /******************
281  * Input stats
282  ******************/
283 struct input_stats_t
284 {
287  /* Input */
288  int64_t i_read_packets;
289  int64_t i_read_bytes;
293  /* Demux */
294  int64_t i_demux_read_packets;
301  /* Decoders */
302  int64_t i_decoded_audio;
305  /* Vout */
306  int64_t i_displayed_pictures;
309  /* Sout */
310  int64_t i_sent_packets;
311  int64_t i_sent_bytes;
314  /* Aout */
315  int64_t i_played_abuffers;
317 };
318 
319 #endif