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 /** defgroup libvlc_media_stats_t libvlc_media_stats_t
104 * \ingroup libvlc_media
105 * LibVLC Media statistics
108 typedef struct libvlc_media_stats_t
112 float f_input_bitrate;
115 int i_demux_read_bytes;
116 float f_demux_bitrate;
117 int i_demux_corrupted;
118 int i_demux_discontinuity;
125 int i_displayed_pictures;
129 int i_played_abuffers;
135 float f_send_bitrate;
136 } libvlc_media_stats_t;
141 * Create a media with the given MRL.
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
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 );
154 * Create a media as an empty node with the passed name.
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
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 );
167 * Add an option to the media.
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.
173 * The options are detailed in vlc --long-help, for instance "--sout-all"
175 * \param p_md the media descriptor
176 * \param ppsz_options the options (as a string)
178 VLC_PUBLIC_API void libvlc_media_add_option(
179 libvlc_media_t * p_md,
180 const char * ppsz_options );
183 * Add an option to the media with configurable flags.
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.
189 * The options are detailed in vlc --long-help, for instance "--sout-all"
191 * \param p_md the media descriptor
192 * \param ppsz_options the options (as a string)
193 * \param i_flags the flags for this option
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 );
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.
206 * \param p_md the media descriptor
208 VLC_PUBLIC_API void libvlc_media_retain( libvlc_media_t *p_md );
211 * Decrement the reference count of a media descriptor object. If the
212 * reference count is 0, then libvlc_media_release() will release the
213 * media descriptor object. It will send out an libvlc_MediaFreed event
214 * to all listeners. If the media descriptor object has been released it
215 * should not be used again.
217 * \param p_md the media descriptor
219 VLC_PUBLIC_API void libvlc_media_release( libvlc_media_t *p_md );
223 * Get the media resource locator (mrl) from a media descriptor object
225 * \param p_md a media descriptor object
226 * \return string with mrl of media descriptor object
228 VLC_PUBLIC_API char * libvlc_media_get_mrl( libvlc_media_t * p_md );
231 * Duplicate a media descriptor object.
233 * \param p_meta_desc a media descriptor object.
235 VLC_PUBLIC_API libvlc_media_t * libvlc_media_duplicate( libvlc_media_t *p_md );
238 * Read the meta of the media.
240 * \param p_md the media descriptor
241 * \param e_meta the meta to read
242 * \return the media's meta
244 VLC_PUBLIC_API char * libvlc_media_get_meta( libvlc_media_t *p_md,
245 libvlc_meta_t e_meta );
248 * Set the meta of the media (this function will not save the meta, call
249 * libvlc_media_save_meta in order to save the meta)
251 * \param p_md the media descriptor
252 * \param e_meta the meta to read
253 * \param the media's meta
255 VLC_PUBLIC_API void libvlc_media_set_meta( libvlc_media_t *p_md,
256 libvlc_meta_t e_meta,
257 const char *psz_value );
261 * Save the meta previously set
263 * \param p_md the media desriptor
264 * \return true if the werite was successfull
266 VLC_PUBLIC_API int libvlc_media_save_meta( libvlc_media_t *p_md );
270 * Get current state of media descriptor object. Possible media states
271 * are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
272 * libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
273 * libvlc_Stopped, libvlc_Ended,
276 * @see libvlc_state_t
277 * \param p_meta_desc a media descriptor object
278 * \return state of media descriptor object
280 VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state(
281 libvlc_media_t *p_meta_desc );
285 * get the current statistics about the media
286 * @param p_md: media descriptor object
287 * @param p_stats: structure that contain the statistics about the media
288 * (this structure must be allocated by the caller)
289 * @return true if the statistics are available, false otherwise
291 VLC_PUBLIC_API int libvlc_media_get_stats( libvlc_media_t *p_md,
292 libvlc_media_stats_t *p_stats );
295 * Get subitems of media descriptor object. This will increment
296 * the reference count of supplied media descriptor object. Use
297 * libvlc_media_list_release() to decrement the reference counting.
299 * \param p_md media descriptor object
300 * \return list of media descriptor subitems or NULL
303 /* This method uses libvlc_media_list_t, however, media_list usage is optionnal
304 * and this is here for convenience */
305 #define VLC_FORWARD_DECLARE_OBJECT(a) struct a
307 VLC_PUBLIC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *)
308 libvlc_media_subitems( libvlc_media_t *p_md );
311 * Get event manager from media descriptor object.
312 * NOTE: this function doesn't increment reference counting.
314 * \param p_md a media descriptor object
315 * \return event manager object
317 VLC_PUBLIC_API libvlc_event_manager_t *
318 libvlc_media_event_manager( libvlc_media_t * p_md );
321 * Get duration (in ms) of media descriptor object item.
323 * \param p_md media descriptor object
324 * \param p_e an initialized exception object
325 * \return duration of media item
327 VLC_PUBLIC_API libvlc_time_t
328 libvlc_media_get_duration( libvlc_media_t * p_md,
329 libvlc_exception_t * p_e );
332 * Get preparsed status for media descriptor object.
334 * \param p_md media descriptor object
335 * \return true if media object has been preparsed otherwise it returns false
338 libvlc_media_is_preparsed( libvlc_media_t * p_md );
341 * Sets media descriptor's user_data. user_data is specialized data
342 * accessed by the host application, VLC.framework uses it as a pointer to
343 * an native object that references a libvlc_media_t pointer
345 * \param p_md media descriptor object
346 * \param p_new_user_data pointer to user data
349 libvlc_media_set_user_data( libvlc_media_t * p_md,
350 void * p_new_user_data );
353 * Get media descriptor's user_data. user_data is specialized data
354 * accessed by the host application, VLC.framework uses it as a pointer to
355 * an native object that references a libvlc_media_t pointer
357 * \param p_md media descriptor object
359 VLC_PUBLIC_API void *
360 libvlc_media_get_user_data( libvlc_media_t * p_md );
364 #endif /* VLC_LIBVLC_MEDIA_H */