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