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
38 /*****************************************************************************
40 *****************************************************************************/
41 /** \defgroup libvlc_media libvlc_media
47 typedef struct libvlc_media_t libvlc_media_t;
50 /** defgroup libvlc_meta libvlc_meta
51 * \ingroup libvlc_media
56 typedef enum libvlc_meta_t {
60 libvlc_meta_Copyright,
62 libvlc_meta_TrackNumber,
63 libvlc_meta_Description,
69 libvlc_meta_NowPlaying,
70 libvlc_meta_Publisher,
71 libvlc_meta_EncodedBy,
72 libvlc_meta_ArtworkURL,
74 /* Add new meta types HERE */
80 * Note the order of libvlc_state_t enum must match exactly the order of
81 * @see mediacontrol_PlayerStatus, @see input_state_e enums,
82 * and VideoLAN.LibVLC.State (at bindings/cil/src/media.cs).
84 * Expected states by web plugins are:
85 * IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, PAUSED=4,
86 * STOPPING=5, ENDED=6, ERROR=7
88 typedef enum libvlc_state_t
90 libvlc_NothingSpecial=0,
100 typedef enum libvlc_media_option_t
102 libvlc_media_option_trusted = 0x2,
103 libvlc_media_option_unique = 0x100
104 } libvlc_media_option_t;
107 /** defgroup libvlc_media_stats_t libvlc_media_stats_t
108 * \ingroup libvlc_media
109 * LibVLC Media statistics
112 typedef struct libvlc_media_stats_t
116 float f_input_bitrate;
119 int i_demux_read_bytes;
120 float f_demux_bitrate;
121 int i_demux_corrupted;
122 int i_demux_discontinuity;
129 int i_displayed_pictures;
133 int i_played_abuffers;
139 float f_send_bitrate;
140 } libvlc_media_stats_t;
145 * Create a media with the given MRL.
147 * \param p_instance the instance
148 * \param psz_mrl the MRL to read
149 * \param p_e an initialized exception pointer
150 * \return the newly created media
152 VLC_PUBLIC_API libvlc_media_t * libvlc_media_new(
153 libvlc_instance_t *p_instance,
154 const char * psz_mrl,
155 libvlc_exception_t *p_e );
158 * Create a media as an empty node with the passed name.
160 * \param p_instance the instance
161 * \param psz_name the name of the node
162 * \param p_e an initialized exception pointer
163 * \return the new empty media
165 VLC_PUBLIC_API libvlc_media_t * libvlc_media_new_as_node(
166 libvlc_instance_t *p_instance,
167 const char * psz_name,
168 libvlc_exception_t *p_e );
171 * Add an option to the media.
173 * This option will be used to determine how the media_player will
174 * read the media. This allows to use VLC's advanced
175 * reading/streaming options on a per-media basis.
177 * The options are detailed in vlc --long-help, for instance "--sout-all"
179 * \param p_md the media descriptor
180 * \param ppsz_options the options (as a string)
182 VLC_PUBLIC_API void libvlc_media_add_option(
183 libvlc_media_t * p_md,
184 const char * ppsz_options );
187 * Add an option to the media with configurable flags.
189 * This option will be used to determine how the media_player will
190 * read the media. This allows to use VLC's advanced
191 * reading/streaming options on a per-media basis.
193 * The options are detailed in vlc --long-help, for instance "--sout-all"
195 * \param p_md the media descriptor
196 * \param ppsz_options the options (as a string)
197 * \param i_flags the flags for this option
199 VLC_PUBLIC_API void libvlc_media_add_option_flag(
200 libvlc_media_t * p_md,
201 const char * ppsz_options,
202 libvlc_media_option_t i_flags );
206 * Retain a reference to a media descriptor object (libvlc_media_t). Use
207 * libvlc_media_release() to decrement the reference count of a
208 * media descriptor object.
210 * \param p_md the media descriptor
212 VLC_PUBLIC_API void libvlc_media_retain( libvlc_media_t *p_md );
215 * Decrement the reference count of a media descriptor object. If the
216 * reference count is 0, then libvlc_media_release() will release the
217 * media descriptor object. It will send out an libvlc_MediaFreed event
218 * to all listeners. If the media descriptor object has been released it
219 * should not be used again.
221 * \param p_md the media descriptor
223 VLC_PUBLIC_API void libvlc_media_release( libvlc_media_t *p_md );
227 * Get the media resource locator (mrl) from a media descriptor object
229 * \param p_md a media descriptor object
230 * \return string with mrl of media descriptor object
232 VLC_PUBLIC_API char * libvlc_media_get_mrl( libvlc_media_t * p_md );
235 * Duplicate a media descriptor object.
237 * \param p_meta_desc a media descriptor object.
239 VLC_PUBLIC_API libvlc_media_t * libvlc_media_duplicate( libvlc_media_t *p_md );
242 * Read the meta of the media.
244 * \param p_md the media descriptor
245 * \param e_meta the meta to read
246 * \return the media's meta
248 VLC_PUBLIC_API char * libvlc_media_get_meta( libvlc_media_t *p_md,
249 libvlc_meta_t e_meta );
252 * Set the meta of the media (this function will not save the meta, call
253 * libvlc_media_save_meta in order to save the meta)
255 * \param p_md the media descriptor
256 * \param e_meta the meta to write
257 * \param the media's meta
259 VLC_PUBLIC_API void libvlc_media_set_meta( libvlc_media_t *p_md,
260 libvlc_meta_t e_meta,
261 const char *psz_value );
265 * Save the meta previously set
267 * \param p_md the media desriptor
268 * \return true if the write operation was successfull
270 VLC_PUBLIC_API int libvlc_media_save_meta( libvlc_media_t *p_md );
274 * Get current state of media descriptor object. Possible media states
275 * are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
276 * libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
277 * libvlc_Stopped, libvlc_Ended,
280 * @see libvlc_state_t
281 * \param p_meta_desc a media descriptor object
282 * \return state of media descriptor object
284 VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state(
285 libvlc_media_t *p_meta_desc );
289 * get the current statistics about the media
290 * @param p_md: media descriptor object
291 * @param p_stats: structure that contain the statistics about the media
292 * (this structure must be allocated by the caller)
293 * @return true if the statistics are available, false otherwise
295 VLC_PUBLIC_API int libvlc_media_get_stats( libvlc_media_t *p_md,
296 libvlc_media_stats_t *p_stats );
299 * Get subitems of media descriptor object. This will increment
300 * the reference count of supplied media descriptor object. Use
301 * libvlc_media_list_release() to decrement the reference counting.
303 * \param p_md media descriptor object
304 * \return list of media descriptor subitems or NULL
307 /* This method uses libvlc_media_list_t, however, media_list usage is optionnal
308 * and this is here for convenience */
309 #define VLC_FORWARD_DECLARE_OBJECT(a) struct a
311 VLC_PUBLIC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *)
312 libvlc_media_subitems( libvlc_media_t *p_md );
315 * Get event manager from media descriptor object.
316 * NOTE: this function doesn't increment reference counting.
318 * \param p_md a media descriptor object
319 * \return event manager object
321 VLC_PUBLIC_API libvlc_event_manager_t *
322 libvlc_media_event_manager( libvlc_media_t * p_md );
325 * Get duration (in ms) of media descriptor object item.
327 * \param p_md media descriptor object
328 * \param p_e an initialized exception object
329 * \return duration of media item
331 VLC_PUBLIC_API libvlc_time_t
332 libvlc_media_get_duration( libvlc_media_t * p_md,
333 libvlc_exception_t * p_e );
336 * Get preparsed status for media descriptor object.
338 * \param p_md media descriptor object
339 * \return true if media object has been preparsed otherwise it returns false
342 libvlc_media_is_preparsed( libvlc_media_t * p_md );
345 * Sets media descriptor's user_data. user_data is specialized data
346 * accessed by the host application, VLC.framework uses it as a pointer to
347 * an native object that references a libvlc_media_t pointer
349 * \param p_md media descriptor object
350 * \param p_new_user_data pointer to user data
353 libvlc_media_set_user_data( libvlc_media_t * p_md,
354 void * p_new_user_data );
357 * Get media descriptor's user_data. user_data is specialized data
358 * accessed by the host application, VLC.framework uses it as a pointer to
359 * an native object that references a libvlc_media_t pointer
361 * \param p_md media descriptor object
363 VLC_PUBLIC_API void *
364 libvlc_media_get_user_data( libvlc_media_t * p_md );
372 #endif /* VLC_LIBVLC_MEDIA_H */