]> git.sesse.net Git - vlc/blob - include/vlc/libvlc_media.h
libvlc: add two functions
[vlc] / include / vlc / libvlc_media.h
1 /*****************************************************************************
2  * libvlc.h:  libvlc external API
3  *****************************************************************************
4  * Copyright (C) 1998-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Jean-Paul Saman <jpsaman@videolan.org>
9  *          Pierre d'Herbemont <pdherbemont@videolan.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 /**
27  * \file
28  * This file defines libvlc_media external API
29  */
30
31 #ifndef VLC_LIBVLC_MEDIA_H
32 #define VLC_LIBVLC_MEDIA_H 1
33
34 /*****************************************************************************
35  * media
36  *****************************************************************************/
37 /** \defgroup libvlc_media libvlc_media
38  * \ingroup libvlc
39  * LibVLC Media
40  * @{
41  */
42
43 typedef struct libvlc_media_t libvlc_media_t;
44
45 /* Meta Handling */
46 /** defgroup libvlc_meta libvlc_meta
47  * \ingroup libvlc_media
48  * LibVLC Media Meta
49  * @{
50  */
51
52 typedef enum libvlc_meta_t {
53     libvlc_meta_Title,
54     libvlc_meta_Artist,
55     libvlc_meta_Genre,
56     libvlc_meta_Copyright,
57     libvlc_meta_Album,
58     libvlc_meta_TrackNumber,
59     libvlc_meta_Description,
60     libvlc_meta_Rating,
61     libvlc_meta_Date,
62     libvlc_meta_Setting,
63     libvlc_meta_URL,
64     libvlc_meta_Language,
65     libvlc_meta_NowPlaying,
66     libvlc_meta_Publisher,
67     libvlc_meta_EncodedBy,
68     libvlc_meta_ArtworkURL,
69     libvlc_meta_TrackID,
70     /* Add new meta types HERE */
71 } libvlc_meta_t;
72
73 /** @}*/
74
75 /**
76  * Note the order of libvlc_state_t enum must match exactly the order of
77  * @see mediacontrol_PlayerStatus, @see input_state_e enums,
78  * and VideoLAN.LibVLC.State (at bindings/cil/src/media.cs).
79  *
80  * Expected states by web plugins are:
81  * IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, PAUSED=4,
82  * STOPPING=5, ENDED=6, ERROR=7
83  */
84 typedef enum libvlc_state_t
85 {
86     libvlc_NothingSpecial=0,
87     libvlc_Opening,
88     libvlc_Buffering,
89     libvlc_Playing,
90     libvlc_Paused,
91     libvlc_Stopped,
92     libvlc_Ended,
93     libvlc_Error
94 } libvlc_state_t;
95
96 typedef enum libvlc_media_option_t
97 {
98     libvlc_media_option_trusted = 0x2,
99     libvlc_media_option_unique = 0x100
100 } libvlc_media_option_t;
101
102
103 /** defgroup libvlc_media_stats_t libvlc_media_stats_t
104  * \ingroup libvlc_media
105  * LibVLC Media statistics
106  * @{
107  */
108 typedef struct libvlc_media_stats_t
109 {
110     /* Input */
111     int         i_read_bytes;
112     float       f_input_bitrate;
113
114     /* Demux */
115     int         i_demux_read_bytes;
116     float       f_demux_bitrate;
117     int         i_demux_corrupted;
118     int         i_demux_discontinuity;
119
120     /* Decoders */
121     int         i_decoded_video;
122     int         i_decoded_audio;
123
124     /* Video Output */
125     int         i_displayed_pictures;
126     int         i_lost_pictures;
127
128     /* Audio output */
129     int         i_played_abuffers;
130     int         i_lost_abuffers;
131
132     /* Stream output */
133     int         i_sent_packets;
134     int         i_sent_bytes;
135     float       f_send_bitrate;
136 } libvlc_media_stats_t;
137 /** @}*/
138
139
140 /**
141  * Create a media with the given MRL.
142  *
143  * \param p_instance the instance
144  * \param psz_mrl the MRL to read
145  * \param p_e an initialized exception pointer
146  * \return the newly created media
147  */
148 VLC_PUBLIC_API libvlc_media_t * libvlc_media_new(
149                                    libvlc_instance_t *p_instance,
150                                    const char * psz_mrl,
151                                    libvlc_exception_t *p_e );
152
153 /**
154  * Create a media as an empty node with the passed name.
155  *
156  * \param p_instance the instance
157  * \param psz_name the name of the node
158  * \param p_e an initialized exception pointer
159  * \return the new empty media
160  */
161 VLC_PUBLIC_API libvlc_media_t * libvlc_media_new_as_node(
162                                    libvlc_instance_t *p_instance,
163                                    const char * psz_name,
164                                    libvlc_exception_t *p_e );
165
166 /**
167  * Add an option to the media.
168  *
169  * This option will be used to determine how the media_player will
170  * read the media. This allows to use VLC's advanced
171  * reading/streaming options on a per-media basis.
172  *
173  * The options are detailed in vlc --long-help, for instance "--sout-all"
174  *
175  * \param p_instance the instance
176  * \param ppsz_options the options (as a string)
177  */
178 VLC_PUBLIC_API void libvlc_media_add_option(
179                                    libvlc_media_t * p_md,
180                                    const char * ppsz_options );
181
182 /**
183  * Add an option to the media with configurable flags.
184  *
185  * This option will be used to determine how the media_player will
186  * read the media. This allows to use VLC's advanced
187  * reading/streaming options on a per-media basis.
188  *
189  * The options are detailed in vlc --long-help, for instance "--sout-all"
190  *
191  * \param p_instance the instance
192  * \param ppsz_options the options (as a string)
193  * \param i_flags the flags for this option
194  */
195 VLC_PUBLIC_API void libvlc_media_add_option_flag(
196                                    libvlc_media_t * p_md,
197                                    const char * ppsz_options,
198                                    libvlc_media_option_t i_flags );
199
200
201 /**
202  * Retain a reference to a media descriptor object (libvlc_media_t). Use
203  * libvlc_media_release() to decrement the reference count of a
204  * media descriptor object.
205  *
206  * \param p_meta_desc a media descriptor object.
207  */
208 VLC_PUBLIC_API void libvlc_media_retain(
209                                    libvlc_media_t *p_meta_desc );
210
211 /**
212  * Decrement the reference count of a media descriptor object. If the
213  * reference count is 0, then libvlc_media_release() will release the
214  * media descriptor object. It will send out an libvlc_MediaFreed event
215  * to all listeners. If the media descriptor object has been released it
216  * should not be used again.
217  *
218  * \param p_meta_desc a media descriptor object.
219  */
220 VLC_PUBLIC_API void libvlc_media_release(
221                                    libvlc_media_t *p_meta_desc );
222
223
224 /**
225  * Get the media resource locator (mrl) from a media descriptor object
226  *
227  * \param p_md a media descriptor object
228  * \return string with mrl of media descriptor object
229  */
230 VLC_PUBLIC_API char * libvlc_media_get_mrl( libvlc_media_t * p_md );
231
232 /**
233  * Duplicate a media descriptor object.
234  *
235  * \param p_meta_desc a media descriptor object.
236  */
237 VLC_PUBLIC_API libvlc_media_t * libvlc_media_duplicate( libvlc_media_t * );
238
239 /**
240  * Read the meta of the media.
241  *
242  * \param p_meta_desc the media to read
243  * \param e_meta the meta to read
244  * \return the media's meta
245  */
246 VLC_PUBLIC_API char * libvlc_media_get_meta(
247                                    libvlc_media_t *p_meta_desc,
248                                    libvlc_meta_t e_meta );
249
250 /**
251  * Set the meta of the media (this function will not save the meta, call
252  * libvlc_media_save_meta in order to save the meta)
253  *
254  * \param p_md the media descriptor
255  * \param e_meta the meta to read
256  * \param the media's meta
257  */
258 VLC_PUBLIC_API void libvlc_media_set_meta( libvlc_media_t *p_md,
259                                            libvlc_meta_t e_meta,
260                                            const char *psz_value );
261
262
263 /**
264  * Save the meta previously set
265  *
266  * \param p_md the media desriptor
267  * \return true if the werite was successfull
268  */
269 VLC_PUBLIC_API int libvlc_media_save_meta( libvlc_media_t *p_md );
270
271
272 /**
273  * Get current state of media descriptor object. Possible media states
274  * are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
275  * libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
276  * libvlc_Stopped, libvlc_Ended,
277  * libvlc_Error).
278  *
279  * @see libvlc_state_t
280  * \param p_meta_desc a media descriptor object
281  * \return state of media descriptor object
282  */
283 VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state(
284                                    libvlc_media_t *p_meta_desc );
285
286
287 /**
288  * get the current statistics about the media
289  * @param p_md: media descriptor object
290  * @param p_stats: structure that contain the statistics about the media
291  *                 (this structure must be allocated by the caller)
292  * @return true if the statistics are available, false otherwise
293  */
294 VLC_PUBLIC_API int libvlc_media_get_stats( libvlc_media_t *p_md,
295                                            libvlc_media_stats_t *p_stats );
296
297 /**
298  * Get subitems of media descriptor object. This will increment
299  * the reference count of supplied media descriptor object. Use
300  * libvlc_media_list_release() to decrement the reference counting.
301  *
302  * \param p_md media descriptor object
303  * \return list of media descriptor subitems or NULL
304  */
305
306 /* This method uses libvlc_media_list_t, however, media_list usage is optionnal
307  * and this is here for convenience */
308 #define VLC_FORWARD_DECLARE_OBJECT(a) struct a
309
310 VLC_PUBLIC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *)
311 libvlc_media_subitems( libvlc_media_t *p_md );
312
313 /**
314  * Get event manager from media descriptor object.
315  * NOTE: this function doesn't increment reference counting.
316  *
317  * \param p_md a media descriptor object
318  * \return event manager object
319  */
320 VLC_PUBLIC_API libvlc_event_manager_t *
321     libvlc_media_event_manager( libvlc_media_t * p_md );
322
323 /**
324  * Get duration (in ms) of media descriptor object item.
325  *
326  * \param p_md media descriptor object
327  * \param p_e an initialized exception object
328  * \return duration of media item
329  */
330 VLC_PUBLIC_API libvlc_time_t
331    libvlc_media_get_duration( libvlc_media_t * p_md,
332                                          libvlc_exception_t * p_e );
333
334 /**
335  * Get preparsed status for media descriptor object.
336  *
337  * \param p_md media descriptor object
338  * \return true if media object has been preparsed otherwise it returns false
339  */
340 VLC_PUBLIC_API int
341    libvlc_media_is_preparsed( libvlc_media_t * p_md );
342
343 /**
344  * Sets media descriptor's user_data. user_data is specialized data
345  * accessed by the host application, VLC.framework uses it as a pointer to
346  * an native object that references a libvlc_media_t pointer
347  *
348  * \param p_md media descriptor object
349  * \param p_new_user_data pointer to user data
350  */
351 VLC_PUBLIC_API void
352     libvlc_media_set_user_data( libvlc_media_t * p_md,
353                                            void * p_new_user_data );
354
355 /**
356  * Get media descriptor's user_data. user_data is specialized data
357  * accessed by the host application, VLC.framework uses it as a pointer to
358  * an native object that references a libvlc_media_t pointer
359  *
360  * \param p_md media descriptor object
361  */
362 VLC_PUBLIC_API void *
363     libvlc_media_get_user_data( libvlc_media_t * p_md );
364
365 /** @}*/
366
367 #endif /* VLC_LIBVLC_MEDIA_H */