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,
102 libvlc_media_option_trusted = 0x2,
103 libvlc_media_option_unique = 0x100
106 typedef enum libvlc_es_type_t
108 libvlc_es_unknown = -1,
114 /** defgroup libvlc_media_stats_t libvlc_media_stats_t
115 * \ingroup libvlc_media
116 * LibVLC Media statistics
119 typedef struct libvlc_media_stats_t
123 float f_input_bitrate;
126 int i_demux_read_bytes;
127 float f_demux_bitrate;
128 int i_demux_corrupted;
129 int i_demux_discontinuity;
136 int i_displayed_pictures;
140 int i_played_abuffers;
146 float f_send_bitrate;
147 } libvlc_media_stats_t;
150 typedef struct libvlc_media_es_t
155 libvlc_es_type_t i_type;
173 * Create a media with the given MRL.
175 * \param p_instance the instance
176 * \param psz_mrl the MRL to read
177 * \return the newly created media or NULL on error
179 VLC_PUBLIC_API libvlc_media_t * libvlc_media_new(
180 libvlc_instance_t *p_instance,
181 const char * psz_mrl );
184 * Create a media as an empty node with a given name.
186 * \param p_instance the instance
187 * \param psz_name the name of the node
188 * \return the new empty media or NULL on error
190 VLC_PUBLIC_API libvlc_media_t * libvlc_media_new_as_node(
191 libvlc_instance_t *p_instance,
192 const char * psz_name );
195 * Add an option to the media.
197 * This option will be used to determine how the media_player will
198 * read the media. This allows to use VLC's advanced
199 * reading/streaming options on a per-media basis.
201 * The options are detailed in vlc --long-help, for instance "--sout-all"
203 * \param p_md the media descriptor
204 * \param ppsz_options the options (as a string)
206 VLC_PUBLIC_API void libvlc_media_add_option(
207 libvlc_media_t * p_md,
208 const char * ppsz_options );
211 * Add an option to the media with configurable flags.
213 * This option will be used to determine how the media_player will
214 * read the media. This allows to use VLC's advanced
215 * reading/streaming options on a per-media basis.
217 * The options are detailed in vlc --long-help, for instance "--sout-all"
219 * \param p_md the media descriptor
220 * \param ppsz_options the options (as a string)
221 * \param i_flags the flags for this option
223 VLC_PUBLIC_API void libvlc_media_add_option_flag(
224 libvlc_media_t * p_md,
225 const char * ppsz_options,
230 * Retain a reference to a media descriptor object (libvlc_media_t). Use
231 * libvlc_media_release() to decrement the reference count of a
232 * media descriptor object.
234 * \param p_md the media descriptor
236 VLC_PUBLIC_API void libvlc_media_retain( libvlc_media_t *p_md );
239 * Decrement the reference count of a media descriptor object. If the
240 * reference count is 0, then libvlc_media_release() will release the
241 * media descriptor object. It will send out an libvlc_MediaFreed event
242 * to all listeners. If the media descriptor object has been released it
243 * should not be used again.
245 * \param p_md the media descriptor
247 VLC_PUBLIC_API void libvlc_media_release( libvlc_media_t *p_md );
251 * Get the media resource locator (mrl) from a media descriptor object
253 * \param p_md a media descriptor object
254 * \return string with mrl of media descriptor object
256 VLC_PUBLIC_API char * libvlc_media_get_mrl( libvlc_media_t * p_md );
259 * Duplicate a media descriptor object.
261 * \param p_md a media descriptor object.
263 VLC_PUBLIC_API libvlc_media_t * libvlc_media_duplicate( libvlc_media_t *p_md );
266 * Read the meta of the media.
268 * \param p_md the media descriptor
269 * \param e_meta the meta to read
270 * \return the media's meta
272 VLC_PUBLIC_API char * libvlc_media_get_meta( libvlc_media_t *p_md,
273 libvlc_meta_t e_meta );
276 * Set the meta of the media (this function will not save the meta, call
277 * libvlc_media_save_meta in order to save the meta)
279 * \param p_md the media descriptor
280 * \param e_meta the meta to write
281 * \param psz_value the media's meta
283 VLC_PUBLIC_API void libvlc_media_set_meta( libvlc_media_t *p_md,
284 libvlc_meta_t e_meta,
285 const char *psz_value );
289 * Save the meta previously set
291 * \param p_md the media desriptor
292 * \return true if the write operation was successfull
294 VLC_PUBLIC_API int libvlc_media_save_meta( libvlc_media_t *p_md );
298 * Get current state of media descriptor object. Possible media states
299 * are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
300 * libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
301 * libvlc_Stopped, libvlc_Ended,
304 * @see libvlc_state_t
305 * \param p_meta_desc a media descriptor object
306 * \return state of media descriptor object
308 VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state(
309 libvlc_media_t *p_meta_desc );
313 * get the current statistics about the media
314 * @param p_md: media descriptor object
315 * @param p_stats: structure that contain the statistics about the media
316 * (this structure must be allocated by the caller)
317 * @return true if the statistics are available, false otherwise
319 VLC_PUBLIC_API int libvlc_media_get_stats( libvlc_media_t *p_md,
320 libvlc_media_stats_t *p_stats );
323 * Get subitems of media descriptor object. This will increment
324 * the reference count of supplied media descriptor object. Use
325 * libvlc_media_list_release() to decrement the reference counting.
327 * \param p_md media descriptor object
328 * \return list of media descriptor subitems or NULL
331 /* This method uses libvlc_media_list_t, however, media_list usage is optionnal
332 * and this is here for convenience */
333 #define VLC_FORWARD_DECLARE_OBJECT(a) struct a
335 VLC_PUBLIC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *)
336 libvlc_media_subitems( libvlc_media_t *p_md );
339 * Get event manager from media descriptor object.
340 * NOTE: this function doesn't increment reference counting.
342 * \param p_md a media descriptor object
343 * \return event manager object
345 VLC_PUBLIC_API libvlc_event_manager_t *
346 libvlc_media_event_manager( libvlc_media_t * p_md );
349 * Get duration (in ms) of media descriptor object item.
351 * \param p_md media descriptor object
352 * \return duration of media item or -1 on error
354 VLC_PUBLIC_API libvlc_time_t
355 libvlc_media_get_duration( libvlc_media_t * p_md );
358 * Get preparsed status for media descriptor object.
360 * \param p_md media descriptor object
361 * \return true if media object has been preparsed otherwise it returns false
364 libvlc_media_is_preparsed( libvlc_media_t * p_md );
367 * Sets media descriptor's user_data. user_data is specialized data
368 * accessed by the host application, VLC.framework uses it as a pointer to
369 * an native object that references a libvlc_media_t pointer
371 * \param p_md media descriptor object
372 * \param p_new_user_data pointer to user data
375 libvlc_media_set_user_data( libvlc_media_t * p_md,
376 void * p_new_user_data );
379 * Get media descriptor's user_data. user_data is specialized data
380 * accessed by the host application, VLC.framework uses it as a pointer to
381 * an native object that references a libvlc_media_t pointer
383 * \param p_md media descriptor object
385 VLC_PUBLIC_API void *
386 libvlc_media_get_user_data( libvlc_media_t * p_md );
389 * Get media descriptor's elementary streams description
391 * Note, you need to play the media _one_ time with --sout="#description"
392 * Not doing this will result in an empty array, and doing it more than once
393 * will duplicate the entries in the array each time.
395 * \param p_md media descriptor object
396 * \param pp_es address to store an allocated array of Elementary Streams descriptions (must be freed by the caller)
398 * return the number of Elementary Streams
401 libvlc_media_get_es( libvlc_media_t * p_md, libvlc_media_es_t ** pp_es );
409 #endif /* VLC_LIBVLC_MEDIA_H */