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 /** \defgroup libvlc_media LibVLC media
40 * @ref libvlc_media_t is an abstract representation of a playable media.
41 * It consists of a media location and various optional meta data.
45 typedef struct libvlc_media_t libvlc_media_t;
47 /** defgroup libvlc_meta LibVLC meta data
48 * \ingroup libvlc_media
52 /** Meta data types */
53 typedef enum libvlc_meta_t {
57 libvlc_meta_Copyright,
59 libvlc_meta_TrackNumber,
60 libvlc_meta_Description,
66 libvlc_meta_NowPlaying,
67 libvlc_meta_Publisher,
68 libvlc_meta_EncodedBy,
69 libvlc_meta_ArtworkURL,
71 /* Add new meta types HERE */
77 * Note the order of libvlc_state_t enum must match exactly the order of
78 * @see mediacontrol_PlayerStatus, @see input_state_e enums,
79 * and VideoLAN.LibVLC.State (at bindings/cil/src/media.cs).
81 * Expected states by web plugins are:
82 * IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, PAUSED=4,
83 * STOPPING=5, ENDED=6, ERROR=7
85 typedef enum libvlc_state_t
87 libvlc_NothingSpecial=0,
99 libvlc_media_option_trusted = 0x2,
100 libvlc_media_option_unique = 0x100
103 typedef enum libvlc_es_type_t
105 libvlc_es_unknown = -1,
111 /** defgroup libvlc_media_stats_t LibVLC media statistics
112 * \ingroup libvlc_media
115 typedef struct libvlc_media_stats_t
119 float f_input_bitrate;
122 int i_demux_read_bytes;
123 float f_demux_bitrate;
124 int i_demux_corrupted;
125 int i_demux_discontinuity;
132 int i_displayed_pictures;
136 int i_played_abuffers;
142 float f_send_bitrate;
143 } libvlc_media_stats_t;
146 typedef struct libvlc_media_es_t
151 libvlc_es_type_t i_type;
169 * Create a media with a certain given media resource location.
171 * \param p_instance the instance
172 * \param psz_mrl the MRL to read
173 * \return the newly created media or NULL on error
175 VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_location(
176 libvlc_instance_t *p_instance,
177 const char * psz_mrl );
180 * Create a media with a certain file path.
182 * \param p_instance the instance
183 * \param path local filesystem path
184 * \return the newly created media or NULL on error
186 VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_path(
187 libvlc_instance_t *p_instance,
191 * Create a media as an empty node with a given name.
193 * \param p_instance the instance
194 * \param psz_name the name of the node
195 * \return the new empty media or NULL on error
197 VLC_PUBLIC_API libvlc_media_t * libvlc_media_new_as_node(
198 libvlc_instance_t *p_instance,
199 const char * psz_name );
202 * Add an option to the media.
204 * This option will be used to determine how the media_player will
205 * read the media. This allows to use VLC's advanced
206 * reading/streaming options on a per-media basis.
208 * The options are detailed in vlc --long-help, for instance "--sout-all"
210 * \param p_md the media descriptor
211 * \param ppsz_options the options (as a string)
213 VLC_PUBLIC_API void libvlc_media_add_option(
214 libvlc_media_t * p_md,
215 const char * ppsz_options );
218 * Add an option to the media with configurable flags.
220 * This option will be used to determine how the media_player will
221 * read the media. This allows to use VLC's advanced
222 * reading/streaming options on a per-media basis.
224 * The options are detailed in vlc --long-help, for instance "--sout-all"
226 * \param p_md the media descriptor
227 * \param ppsz_options the options (as a string)
228 * \param i_flags the flags for this option
230 VLC_PUBLIC_API void libvlc_media_add_option_flag(
231 libvlc_media_t * p_md,
232 const char * ppsz_options,
237 * Retain a reference to a media descriptor object (libvlc_media_t). Use
238 * libvlc_media_release() to decrement the reference count of a
239 * media descriptor object.
241 * \param p_md the media descriptor
243 VLC_PUBLIC_API void libvlc_media_retain( libvlc_media_t *p_md );
246 * Decrement the reference count of a media descriptor object. If the
247 * reference count is 0, then libvlc_media_release() will release the
248 * media descriptor object. It will send out an libvlc_MediaFreed event
249 * to all listeners. If the media descriptor object has been released it
250 * should not be used again.
252 * \param p_md the media descriptor
254 VLC_PUBLIC_API void libvlc_media_release( libvlc_media_t *p_md );
258 * Get the media resource locator (mrl) from a media descriptor object
260 * \param p_md a media descriptor object
261 * \return string with mrl of media descriptor object
263 VLC_PUBLIC_API char * libvlc_media_get_mrl( libvlc_media_t * p_md );
266 * Duplicate a media descriptor object.
268 * \param p_md a media descriptor object.
270 VLC_PUBLIC_API libvlc_media_t * libvlc_media_duplicate( libvlc_media_t *p_md );
273 * Read the meta of the media.
275 * \param p_md the media descriptor
276 * \param e_meta the meta to read
277 * \return the media's meta
279 VLC_PUBLIC_API char * libvlc_media_get_meta( libvlc_media_t *p_md,
280 libvlc_meta_t e_meta );
283 * Set the meta of the media (this function will not save the meta, call
284 * libvlc_media_save_meta in order to save the meta)
286 * \param p_md the media descriptor
287 * \param e_meta the meta to write
288 * \param psz_value the media's meta
290 VLC_PUBLIC_API void libvlc_media_set_meta( libvlc_media_t *p_md,
291 libvlc_meta_t e_meta,
292 const char *psz_value );
296 * Save the meta previously set
298 * \param p_md the media desriptor
299 * \return true if the write operation was successfull
301 VLC_PUBLIC_API int libvlc_media_save_meta( libvlc_media_t *p_md );
305 * Get current state of media descriptor object. Possible media states
306 * are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
307 * libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
308 * libvlc_Stopped, libvlc_Ended,
311 * @see libvlc_state_t
312 * \param p_meta_desc a media descriptor object
313 * \return state of media descriptor object
315 VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state(
316 libvlc_media_t *p_meta_desc );
320 * get the current statistics about the media
321 * @param p_md: media descriptor object
322 * @param p_stats: structure that contain the statistics about the media
323 * (this structure must be allocated by the caller)
324 * @return true if the statistics are available, false otherwise
326 VLC_PUBLIC_API int libvlc_media_get_stats( libvlc_media_t *p_md,
327 libvlc_media_stats_t *p_stats );
330 * Get subitems of media descriptor object. This will increment
331 * the reference count of supplied media descriptor object. Use
332 * libvlc_media_list_release() to decrement the reference counting.
334 * \param p_md media descriptor object
335 * \return list of media descriptor subitems or NULL
338 /* This method uses libvlc_media_list_t, however, media_list usage is optionnal
339 * and this is here for convenience */
340 #define VLC_FORWARD_DECLARE_OBJECT(a) struct a
342 VLC_PUBLIC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *)
343 libvlc_media_subitems( libvlc_media_t *p_md );
346 * Get event manager from media descriptor object.
347 * NOTE: this function doesn't increment reference counting.
349 * \param p_md a media descriptor object
350 * \return event manager object
352 VLC_PUBLIC_API libvlc_event_manager_t *
353 libvlc_media_event_manager( libvlc_media_t * p_md );
356 * Get duration (in ms) of media descriptor object item.
358 * \param p_md media descriptor object
359 * \return duration of media item or -1 on error
361 VLC_PUBLIC_API libvlc_time_t
362 libvlc_media_get_duration( libvlc_media_t * p_md );
365 * Get preparsed status for media descriptor object.
367 * \param p_md media descriptor object
368 * \return true if media object has been preparsed otherwise it returns false
371 libvlc_media_is_preparsed( libvlc_media_t * p_md );
374 * Sets media descriptor's user_data. user_data is specialized data
375 * accessed by the host application, VLC.framework uses it as a pointer to
376 * an native object that references a libvlc_media_t pointer
378 * \param p_md media descriptor object
379 * \param p_new_user_data pointer to user data
382 libvlc_media_set_user_data( libvlc_media_t * p_md,
383 void * p_new_user_data );
386 * Get media descriptor's user_data. user_data is specialized data
387 * accessed by the host application, VLC.framework uses it as a pointer to
388 * an native object that references a libvlc_media_t pointer
390 * \param p_md media descriptor object
392 VLC_PUBLIC_API void *
393 libvlc_media_get_user_data( libvlc_media_t * p_md );
396 * Get media descriptor's elementary streams description
398 * Note, you need to play the media _one_ time with --sout="#description"
399 * Not doing this will result in an empty array, and doing it more than once
400 * will duplicate the entries in the array each time.
402 * \param p_md media descriptor object
403 * \param pp_es address to store an allocated array of Elementary Streams descriptions (must be freed by the caller)
405 * return the number of Elementary Streams
408 libvlc_media_get_es( libvlc_media_t * p_md, libvlc_media_es_t ** pp_es );
416 #endif /* VLC_LIBVLC_MEDIA_H */