]> git.sesse.net Git - vlc/blob - include/vlc/libvlc_media.h
a67778d98aba5b90a81fa9e6843375f44049236f
[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  * Create a media with the given MRL.
104  *
105  * \param p_instance the instance
106  * \param psz_mrl the MRL to read
107  * \param p_e an initialized exception pointer
108  * \return the newly created media
109  */
110 VLC_PUBLIC_API libvlc_media_t * libvlc_media_new(
111                                    libvlc_instance_t *p_instance,
112                                    const char * psz_mrl,
113                                    libvlc_exception_t *p_e );
114
115 /**
116  * Create a media as an empty node with the passed name.
117  *
118  * \param p_instance the instance
119  * \param psz_name the name of the node
120  * \param p_e an initialized exception pointer
121  * \return the new empty media
122  */
123 VLC_PUBLIC_API libvlc_media_t * libvlc_media_new_as_node(
124                                    libvlc_instance_t *p_instance,
125                                    const char * psz_name,
126                                    libvlc_exception_t *p_e );
127
128 /**
129  * Add an option to the media.
130  *
131  * This option will be used to determine how the media_player will
132  * read the media. This allows to use VLC's advanced
133  * reading/streaming options on a per-media basis.
134  *
135  * The options are detailed in vlc --long-help, for instance "--sout-all"
136  *
137  * \param p_instance the instance
138  * \param ppsz_options the options (as a string)
139  * \param p_e an initialized exception pointer
140  */
141 VLC_PUBLIC_API void libvlc_media_add_option(
142                                    libvlc_media_t * p_md,
143                                    const char * ppsz_options,
144                                    libvlc_exception_t * p_e );
145 /**
146  * Add an option to the media with configurable flags.
147  *
148  * This option will be used to determine how the media_player will
149  * read the media. This allows to use VLC's advanced
150  * reading/streaming options on a per-media basis.
151  *
152  * The options are detailed in vlc --long-help, for instance "--sout-all"
153  *
154  * \param p_instance the instance
155  * \param ppsz_options the options (as a string)
156  * \param i_flags the flags for this option
157  * \param p_e an initialized exception pointer
158  */
159 VLC_PUBLIC_API void libvlc_media_add_option_flag(
160                                    libvlc_media_t * p_md,
161                                    const char * ppsz_options,
162                                    libvlc_media_option_t i_flags,
163                                    libvlc_exception_t * p_e );
164
165
166 /**
167  * Retain a reference to a media descriptor object (libvlc_media_t). Use
168  * libvlc_media_release() to decrement the reference count of a
169  * media descriptor object.
170  *
171  * \param p_meta_desc a media descriptor object.
172  */
173 VLC_PUBLIC_API void libvlc_media_retain(
174                                    libvlc_media_t *p_meta_desc );
175
176 /**
177  * Decrement the reference count of a media descriptor object. If the
178  * reference count is 0, then libvlc_media_release() will release the
179  * media descriptor object. It will send out an libvlc_MediaFreed event
180  * to all listeners. If the media descriptor object has been released it
181  * should not be used again.
182  *
183  * \param p_meta_desc a media descriptor object.
184  */
185 VLC_PUBLIC_API void libvlc_media_release(
186                                    libvlc_media_t *p_meta_desc );
187
188
189 /**
190  * Get the media resource locator (mrl) from a media descriptor object
191  *
192  * \param p_md a media descriptor object
193  * \param p_e an initialized exception object
194  * \return string with mrl of media descriptor object
195  */
196 VLC_PUBLIC_API char * libvlc_media_get_mrl( libvlc_media_t * p_md,
197                                                        libvlc_exception_t * p_e );
198
199 /**
200  * Duplicate a media descriptor object.
201  *
202  * \param p_meta_desc a media descriptor object.
203  */
204 VLC_PUBLIC_API libvlc_media_t * libvlc_media_duplicate( libvlc_media_t * );
205
206 /**
207  * Read the meta of the media.
208  *
209  * \param p_meta_desc the media to read
210  * \param e_meta_desc the meta to read
211  * \param p_e an initialized exception pointer
212  * \return the media's meta
213  */
214 VLC_PUBLIC_API char * libvlc_media_get_meta(
215                                    libvlc_media_t *p_meta_desc,
216                                    libvlc_meta_t e_meta,
217                                    libvlc_exception_t *p_e );
218 /**
219  * Get current state of media descriptor object. Possible media states
220  * are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
221  * libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
222  * libvlc_Stopped, libvlc_Ended,
223  * libvlc_Error).
224  *
225  * @see libvlc_state_t
226  * \param p_meta_desc a media descriptor object
227  * \param p_e an initialized exception object
228  * \return state of media descriptor object
229  */
230 VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state(
231                                    libvlc_media_t *p_meta_desc,
232                                    libvlc_exception_t *p_e );
233
234
235 /**
236  * Get subitems of media descriptor object. This will increment
237  * the reference count of supplied media descriptor object. Use
238  * libvlc_media_list_release() to decrement the reference counting.
239  *
240  * \param p_md media descriptor object
241  * \param p_e initalized exception object
242  * \return list of media descriptor subitems or NULL
243  */
244
245 /* This method uses libvlc_media_list_t, however, media_list usage is optionnal
246  * and this is here for convenience */
247 #define VLC_FORWARD_DECLARE_OBJECT(a) struct a
248
249 VLC_PUBLIC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *)
250 libvlc_media_subitems( libvlc_media_t *p_md,
251                       libvlc_exception_t *p_e );
252
253 /**
254  * Get event manager from media descriptor object.
255  * NOTE: this function doesn't increment reference counting.
256  *
257  * \param p_md a media descriptor object
258  * \param p_e an initialized exception object
259  * \return event manager object
260  */
261 VLC_PUBLIC_API libvlc_event_manager_t *
262     libvlc_media_event_manager( libvlc_media_t * p_md,
263                                            libvlc_exception_t * p_e );
264
265 /**
266  * Get duration of media descriptor object item.
267  *
268  * \param p_md media descriptor object
269  * \param p_e an initialized exception object
270  * \return duration of media item
271  */
272 VLC_PUBLIC_API libvlc_time_t
273    libvlc_media_get_duration( libvlc_media_t * p_md,
274                                          libvlc_exception_t * p_e );
275
276 /**
277  * Get preparsed status for media descriptor object.
278  *
279  * \param p_md media descriptor object
280  * \param p_e an initialized exception object
281  * \return true if media object has been preparsed otherwise it returns false
282  */
283 VLC_PUBLIC_API int
284    libvlc_media_is_preparsed( libvlc_media_t * p_md,
285                                          libvlc_exception_t * p_e );
286
287 /**
288  * Sets media descriptor's user_data. user_data is specialized data
289  * accessed by the host application, VLC.framework uses it as a pointer to
290  * an native object that references a libvlc_media_t pointer
291  *
292  * \param p_md media descriptor object
293  * \param p_new_user_data pointer to user data
294  * \param p_e an initialized exception object
295  */
296 VLC_PUBLIC_API void
297     libvlc_media_set_user_data( libvlc_media_t * p_md,
298                                            void * p_new_user_data,
299                                            libvlc_exception_t * p_e);
300
301 /**
302  * Get media descriptor's user_data. user_data is specialized data
303  * accessed by the host application, VLC.framework uses it as a pointer to
304  * an native object that references a libvlc_media_t pointer
305  *
306  * \param p_md media descriptor object
307  * \param p_e an initialized exception object
308  */
309 VLC_PUBLIC_API void *
310     libvlc_media_get_user_data( libvlc_media_t * p_md,
311                                            libvlc_exception_t * p_e);
312
313 /** @}*/
314
315 #endif /* VLC_LIBVLC_MEDIA_H */