]> git.sesse.net Git - vlc/blob - include/vlc/libvlc_media.h
LibVLC: add functions to control mouse and keyboard events
[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  */
140 VLC_PUBLIC_API void libvlc_media_add_option(
141                                    libvlc_media_t * p_md,
142                                    const char * ppsz_options );
143
144 /**
145  * Add an option to the media with configurable flags.
146  *
147  * This option will be used to determine how the media_player will
148  * read the media. This allows to use VLC's advanced
149  * reading/streaming options on a per-media basis.
150  *
151  * The options are detailed in vlc --long-help, for instance "--sout-all"
152  *
153  * \param p_instance the instance
154  * \param ppsz_options the options (as a string)
155  * \param i_flags the flags for this option
156  */
157 VLC_PUBLIC_API void libvlc_media_add_option_flag(
158                                    libvlc_media_t * p_md,
159                                    const char * ppsz_options,
160                                    libvlc_media_option_t i_flags );
161
162
163 /**
164  * Retain a reference to a media descriptor object (libvlc_media_t). Use
165  * libvlc_media_release() to decrement the reference count of a
166  * media descriptor object.
167  *
168  * \param p_meta_desc a media descriptor object.
169  */
170 VLC_PUBLIC_API void libvlc_media_retain(
171                                    libvlc_media_t *p_meta_desc );
172
173 /**
174  * Decrement the reference count of a media descriptor object. If the
175  * reference count is 0, then libvlc_media_release() will release the
176  * media descriptor object. It will send out an libvlc_MediaFreed event
177  * to all listeners. If the media descriptor object has been released it
178  * should not be used again.
179  *
180  * \param p_meta_desc a media descriptor object.
181  */
182 VLC_PUBLIC_API void libvlc_media_release(
183                                    libvlc_media_t *p_meta_desc );
184
185
186 /**
187  * Get the media resource locator (mrl) from a media descriptor object
188  *
189  * \param p_md a media descriptor object
190  * \return string with mrl of media descriptor object
191  */
192 VLC_PUBLIC_API char * libvlc_media_get_mrl( libvlc_media_t * p_md );
193
194 /**
195  * Duplicate a media descriptor object.
196  *
197  * \param p_meta_desc a media descriptor object.
198  */
199 VLC_PUBLIC_API libvlc_media_t * libvlc_media_duplicate( libvlc_media_t * );
200
201 /**
202  * Read the meta of the media.
203  *
204  * \param p_meta_desc the media to read
205  * \param e_meta the meta to read
206  * \return the media's meta
207  */
208 VLC_PUBLIC_API char * libvlc_media_get_meta(
209                                    libvlc_media_t *p_meta_desc,
210                                    libvlc_meta_t e_meta );
211
212 /**
213  * Get current state of media descriptor object. Possible media states
214  * are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
215  * libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
216  * libvlc_Stopped, libvlc_Ended,
217  * libvlc_Error).
218  *
219  * @see libvlc_state_t
220  * \param p_meta_desc a media descriptor object
221  * \return state of media descriptor object
222  */
223 VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state(
224                                    libvlc_media_t *p_meta_desc );
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  * \return list of media descriptor subitems or NULL
234  */
235
236 /* This method uses libvlc_media_list_t, however, media_list usage is optionnal
237  * and this is here for convenience */
238 #define VLC_FORWARD_DECLARE_OBJECT(a) struct a
239
240 VLC_PUBLIC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *)
241 libvlc_media_subitems( libvlc_media_t *p_md );
242
243 /**
244  * Get event manager from media descriptor object.
245  * NOTE: this function doesn't increment reference counting.
246  *
247  * \param p_md a media descriptor object
248  * \return event manager object
249  */
250 VLC_PUBLIC_API libvlc_event_manager_t *
251     libvlc_media_event_manager( libvlc_media_t * p_md );
252
253 /**
254  * Get duration (in ms) of media descriptor object item.
255  *
256  * \param p_md media descriptor object
257  * \param p_e an initialized exception object
258  * \return duration of media item
259  */
260 VLC_PUBLIC_API libvlc_time_t
261    libvlc_media_get_duration( libvlc_media_t * p_md,
262                                          libvlc_exception_t * p_e );
263
264 /**
265  * Get preparsed status for media descriptor object.
266  *
267  * \param p_md media descriptor object
268  * \return true if media object has been preparsed otherwise it returns false
269  */
270 VLC_PUBLIC_API int
271    libvlc_media_is_preparsed( libvlc_media_t * p_md );
272
273 /**
274  * Sets media descriptor's user_data. user_data is specialized data
275  * accessed by the host application, VLC.framework uses it as a pointer to
276  * an native object that references a libvlc_media_t pointer
277  *
278  * \param p_md media descriptor object
279  * \param p_new_user_data pointer to user data
280  */
281 VLC_PUBLIC_API void
282     libvlc_media_set_user_data( libvlc_media_t * p_md,
283                                            void * p_new_user_data );
284
285 /**
286  * Get media descriptor's user_data. user_data is specialized data
287  * accessed by the host application, VLC.framework uses it as a pointer to
288  * an native object that references a libvlc_media_t pointer
289  *
290  * \param p_md media descriptor object
291  */
292 VLC_PUBLIC_API void *
293     libvlc_media_get_user_data( libvlc_media_t * p_md );
294
295 /** @}*/
296
297 #endif /* VLC_LIBVLC_MEDIA_H */