1 /*****************************************************************************
2 * libvlc.h: libvlc external API
3 *****************************************************************************
4 * Copyright (C) 1998-2009 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Paul Saman <jpsaman@videolan.org>
9 * Pierre d'Herbemont <pdherbemont@videolan.org>
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.
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.
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 *****************************************************************************/
28 * This file defines libvlc_media external API
31 #ifndef VLC_LIBVLC_MEDIA_H
32 #define VLC_LIBVLC_MEDIA_H 1
34 /*****************************************************************************
36 *****************************************************************************/
37 /** \defgroup libvlc_media libvlc_media
43 typedef struct libvlc_media_t libvlc_media_t;
46 /** defgroup libvlc_meta libvlc_meta
47 * \ingroup libvlc_media
52 typedef enum libvlc_meta_t {
56 libvlc_meta_Copyright,
58 libvlc_meta_TrackNumber,
59 libvlc_meta_Description,
65 libvlc_meta_NowPlaying,
66 libvlc_meta_Publisher,
67 libvlc_meta_EncodedBy,
68 libvlc_meta_ArtworkURL,
70 /* Add new meta types HERE */
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).
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
84 typedef enum libvlc_state_t
86 libvlc_NothingSpecial=0,
96 typedef enum libvlc_media_option_t
98 libvlc_media_option_trusted = 0x2,
99 libvlc_media_option_unique = 0x100
100 } libvlc_media_option_t;
103 * Create a media with the given MRL.
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
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 );
116 * Create a media as an empty node with the passed name.
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
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 );
129 * Add an option to the media.
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.
135 * The options are detailed in vlc --long-help, for instance "--sout-all"
137 * \param p_instance the instance
138 * \param ppsz_options the options (as a string)
140 VLC_PUBLIC_API void libvlc_media_add_option(
141 libvlc_media_t * p_md,
142 const char * ppsz_options );
145 * Add an option to the media with configurable flags.
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.
151 * The options are detailed in vlc --long-help, for instance "--sout-all"
153 * \param p_instance the instance
154 * \param ppsz_options the options (as a string)
155 * \param i_flags the flags for this option
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 );
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.
168 * \param p_meta_desc a media descriptor object.
170 VLC_PUBLIC_API void libvlc_media_retain(
171 libvlc_media_t *p_meta_desc );
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.
180 * \param p_meta_desc a media descriptor object.
182 VLC_PUBLIC_API void libvlc_media_release(
183 libvlc_media_t *p_meta_desc );
187 * Get the media resource locator (mrl) from a media descriptor object
189 * \param p_md a media descriptor object
190 * \return string with mrl of media descriptor object
192 VLC_PUBLIC_API char * libvlc_media_get_mrl( libvlc_media_t * p_md );
195 * Duplicate a media descriptor object.
197 * \param p_meta_desc a media descriptor object.
199 VLC_PUBLIC_API libvlc_media_t * libvlc_media_duplicate( libvlc_media_t * );
202 * Read the meta of the media.
204 * \param p_meta_desc the media to read
205 * \param e_meta the meta to read
206 * \return the media's meta
208 VLC_PUBLIC_API char * libvlc_media_get_meta(
209 libvlc_media_t *p_meta_desc,
210 libvlc_meta_t e_meta );
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,
219 * @see libvlc_state_t
220 * \param p_meta_desc a media descriptor object
221 * \return state of media descriptor object
223 VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state(
224 libvlc_media_t *p_meta_desc );
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.
232 * \param p_md media descriptor object
233 * \return list of media descriptor subitems or NULL
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
240 VLC_PUBLIC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *)
241 libvlc_media_subitems( libvlc_media_t *p_md );
244 * Get event manager from media descriptor object.
245 * NOTE: this function doesn't increment reference counting.
247 * \param p_md a media descriptor object
248 * \return event manager object
250 VLC_PUBLIC_API libvlc_event_manager_t *
251 libvlc_media_event_manager( libvlc_media_t * p_md );
254 * Get duration (in ms) of media descriptor object item.
256 * \param p_md media descriptor object
257 * \param p_e an initialized exception object
258 * \return duration of media item
260 VLC_PUBLIC_API libvlc_time_t
261 libvlc_media_get_duration( libvlc_media_t * p_md,
262 libvlc_exception_t * p_e );
265 * Get preparsed status for media descriptor object.
267 * \param p_md media descriptor object
268 * \return true if media object has been preparsed otherwise it returns false
271 libvlc_media_is_preparsed( libvlc_media_t * p_md );
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
278 * \param p_md media descriptor object
279 * \param p_new_user_data pointer to user data
282 libvlc_media_set_user_data( libvlc_media_t * p_md,
283 void * p_new_user_data );
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
290 * \param p_md media descriptor object
292 VLC_PUBLIC_API void *
293 libvlc_media_get_user_data( libvlc_media_t * p_md );
297 #endif /* VLC_LIBVLC_MEDIA_H */