00001 /***************************************************************************** 00002 * libvlc.h: libvlc external API 00003 ***************************************************************************** 00004 * Copyright (C) 1998-2009 the VideoLAN team 00005 * $Id: 1185bf464fb443e8e48158960974a31568fdf345 $ 00006 * 00007 * Authors: Clément Stenac <zorglub@videolan.org> 00008 * Jean-Paul Saman <jpsaman@videolan.org> 00009 * Pierre d'Herbemont <pdherbemont@videolan.org> 00010 * 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00024 *****************************************************************************/ 00025 00026 /** 00027 * \file 00028 * This file defines libvlc_media external API 00029 */ 00030 00031 #ifndef VLC_LIBVLC_MEDIA_H 00032 #define VLC_LIBVLC_MEDIA_H 1 00033 00034 # ifdef __cplusplus 00035 extern "C" { 00036 # endif 00037 00038 /** \defgroup libvlc_media LibVLC media 00039 * \ingroup libvlc 00040 * @ref libvlc_media_t is an abstract representation of a playable media. 00041 * It consists of a media location and various optional meta data. 00042 * @{ 00043 */ 00044 00045 typedef struct libvlc_media_t libvlc_media_t; 00046 00047 /** defgroup libvlc_meta LibVLC meta data 00048 * \ingroup libvlc_media 00049 * @{ 00050 */ 00051 00052 /** Meta data types */ 00053 typedef enum libvlc_meta_t { 00054 libvlc_meta_Title, 00055 libvlc_meta_Artist, 00056 libvlc_meta_Genre, 00057 libvlc_meta_Copyright, 00058 libvlc_meta_Album, 00059 libvlc_meta_TrackNumber, 00060 libvlc_meta_Description, 00061 libvlc_meta_Rating, 00062 libvlc_meta_Date, 00063 libvlc_meta_Setting, 00064 libvlc_meta_URL, 00065 libvlc_meta_Language, 00066 libvlc_meta_NowPlaying, 00067 libvlc_meta_Publisher, 00068 libvlc_meta_EncodedBy, 00069 libvlc_meta_ArtworkURL, 00070 libvlc_meta_TrackID, 00071 /* Add new meta types HERE */ 00072 } libvlc_meta_t; 00073 00074 /** @}*/ 00075 00076 /** 00077 * Note the order of libvlc_state_t enum must match exactly the order of 00078 * \see mediacontrol_PlayerStatus, \see input_state_e enums, 00079 * and VideoLAN.LibVLC.State (at bindings/cil/src/media.cs). 00080 * 00081 * Expected states by web plugins are: 00082 * IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, PAUSED=4, 00083 * STOPPING=5, ENDED=6, ERROR=7 00084 */ 00085 typedef enum libvlc_state_t 00086 { 00087 libvlc_NothingSpecial=0, 00088 libvlc_Opening, 00089 libvlc_Buffering, 00090 libvlc_Playing, 00091 libvlc_Paused, 00092 libvlc_Stopped, 00093 libvlc_Ended, 00094 libvlc_Error 00095 } libvlc_state_t; 00096 00097 enum 00098 { 00099 libvlc_media_option_trusted = 0x2, 00100 libvlc_media_option_unique = 0x100 00101 }; 00102 00103 typedef enum libvlc_track_type_t 00104 { 00105 libvlc_track_unknown = -1, 00106 libvlc_track_audio = 0, 00107 libvlc_track_video = 1, 00108 libvlc_track_text = 2, 00109 } libvlc_track_type_t; 00110 00111 /** defgroup libvlc_media_stats_t LibVLC media statistics 00112 * \ingroup libvlc_media 00113 * @{ 00114 */ 00115 typedef struct libvlc_media_stats_t 00116 { 00117 /* Input */ 00118 int i_read_bytes; 00119 float f_input_bitrate; 00120 00121 /* Demux */ 00122 int i_demux_read_bytes; 00123 float f_demux_bitrate; 00124 int i_demux_corrupted; 00125 int i_demux_discontinuity; 00126 00127 /* Decoders */ 00128 int i_decoded_video; 00129 int i_decoded_audio; 00130 00131 /* Video Output */ 00132 int i_displayed_pictures; 00133 int i_lost_pictures; 00134 00135 /* Audio output */ 00136 int i_played_abuffers; 00137 int i_lost_abuffers; 00138 00139 /* Stream output */ 00140 int i_sent_packets; 00141 int i_sent_bytes; 00142 float f_send_bitrate; 00143 } libvlc_media_stats_t; 00144 /** @}*/ 00145 00146 typedef struct libvlc_media_track_info_t 00147 { 00148 /* Codec fourcc */ 00149 uint32_t i_codec; 00150 int i_id; 00151 libvlc_track_type_t i_type; 00152 00153 /* Codec specific */ 00154 int i_profile; 00155 int i_level; 00156 00157 union { 00158 struct { 00159 /* Audio specific */ 00160 unsigned i_channels; 00161 unsigned i_rate; 00162 } audio; 00163 struct { 00164 /* Video specific */ 00165 unsigned i_height; 00166 unsigned i_width; 00167 } video; 00168 } u; 00169 00170 } libvlc_media_track_info_t; 00171 00172 00173 /** 00174 * Create a media with a certain given media resource location. 00175 * 00176 * \see libvlc_media_release 00177 * 00178 * \param p_instance the instance 00179 * \param psz_mrl the MRL to read 00180 * \return the newly created media or NULL on error 00181 */ 00182 VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_location( 00183 libvlc_instance_t *p_instance, 00184 const char * psz_mrl ); 00185 00186 /** 00187 * Create a media with a certain file path. 00188 * 00189 * \see libvlc_media_release 00190 * 00191 * \param p_instance the instance 00192 * \param path local filesystem path 00193 * \return the newly created media or NULL on error 00194 */ 00195 VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_path( 00196 libvlc_instance_t *p_instance, 00197 const char *path ); 00198 00199 /** 00200 * Create a media as an empty node with a given name. 00201 * 00202 * \see libvlc_media_release 00203 * 00204 * \param p_instance the instance 00205 * \param psz_name the name of the node 00206 * \return the new empty media or NULL on error 00207 */ 00208 VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_as_node( 00209 libvlc_instance_t *p_instance, 00210 const char * psz_name ); 00211 00212 /** 00213 * Add an option to the media. 00214 * 00215 * This option will be used to determine how the media_player will 00216 * read the media. This allows to use VLC's advanced 00217 * reading/streaming options on a per-media basis. 00218 * 00219 * The options are detailed in vlc --long-help, for instance "--sout-all" 00220 * 00221 * \param p_md the media descriptor 00222 * \param ppsz_options the options (as a string) 00223 */ 00224 VLC_PUBLIC_API void libvlc_media_add_option( 00225 libvlc_media_t *p_md, 00226 const char * ppsz_options ); 00227 00228 /** 00229 * Add an option to the media with configurable flags. 00230 * 00231 * This option will be used to determine how the media_player will 00232 * read the media. This allows to use VLC's advanced 00233 * reading/streaming options on a per-media basis. 00234 * 00235 * The options are detailed in vlc --long-help, for instance "--sout-all" 00236 * 00237 * \param p_md the media descriptor 00238 * \param ppsz_options the options (as a string) 00239 * \param i_flags the flags for this option 00240 */ 00241 VLC_PUBLIC_API void libvlc_media_add_option_flag( 00242 libvlc_media_t *p_md, 00243 const char * ppsz_options, 00244 unsigned i_flags ); 00245 00246 00247 /** 00248 * Retain a reference to a media descriptor object (libvlc_media_t). Use 00249 * libvlc_media_release() to decrement the reference count of a 00250 * media descriptor object. 00251 * 00252 * \param p_md the media descriptor 00253 */ 00254 VLC_PUBLIC_API void libvlc_media_retain( libvlc_media_t *p_md ); 00255 00256 /** 00257 * Decrement the reference count of a media descriptor object. If the 00258 * reference count is 0, then libvlc_media_release() will release the 00259 * media descriptor object. It will send out an libvlc_MediaFreed event 00260 * to all listeners. If the media descriptor object has been released it 00261 * should not be used again. 00262 * 00263 * \param p_md the media descriptor 00264 */ 00265 VLC_PUBLIC_API void libvlc_media_release( libvlc_media_t *p_md ); 00266 00267 00268 /** 00269 * Get the media resource locator (mrl) from a media descriptor object 00270 * 00271 * \param p_md a media descriptor object 00272 * \return string with mrl of media descriptor object 00273 */ 00274 VLC_PUBLIC_API char *libvlc_media_get_mrl( libvlc_media_t *p_md ); 00275 00276 /** 00277 * Duplicate a media descriptor object. 00278 * 00279 * \param p_md a media descriptor object. 00280 */ 00281 VLC_PUBLIC_API libvlc_media_t *libvlc_media_duplicate( libvlc_media_t *p_md ); 00282 00283 /** 00284 * Read the meta of the media. 00285 * 00286 * If the media has not yet been parsed this will return NULL. 00287 * 00288 * This methods automatically calls libvlc_media_parse_async(), so after calling 00289 * it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous 00290 * version ensure that you call libvlc_media_parse() before get_meta(). 00291 * 00292 * \see libvlc_media_parse 00293 * \see libvlc_media_parse_async 00294 * \see libvlc_MediaMetaChanged 00295 * 00296 * \param p_md the media descriptor 00297 * \param e_meta the meta to read 00298 * \return the media's meta 00299 */ 00300 VLC_PUBLIC_API char *libvlc_media_get_meta( libvlc_media_t *p_md, 00301 libvlc_meta_t e_meta ); 00302 00303 /** 00304 * Set the meta of the media (this function will not save the meta, call 00305 * libvlc_media_save_meta in order to save the meta) 00306 * 00307 * \param p_md the media descriptor 00308 * \param e_meta the meta to write 00309 * \param psz_value the media's meta 00310 */ 00311 VLC_PUBLIC_API void libvlc_media_set_meta( libvlc_media_t *p_md, 00312 libvlc_meta_t e_meta, 00313 const char *psz_value ); 00314 00315 00316 /** 00317 * Save the meta previously set 00318 * 00319 * \param p_md the media desriptor 00320 * \return true if the write operation was successfull 00321 */ 00322 VLC_PUBLIC_API int libvlc_media_save_meta( libvlc_media_t *p_md ); 00323 00324 00325 /** 00326 * Get current state of media descriptor object. Possible media states 00327 * are defined in libvlc_structures.c ( libvlc_NothingSpecial=0, 00328 * libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused, 00329 * libvlc_Stopped, libvlc_Ended, 00330 * libvlc_Error). 00331 * 00332 * \see libvlc_state_t 00333 * \param p_md a media descriptor object 00334 * \return state of media descriptor object 00335 */ 00336 VLC_PUBLIC_API libvlc_state_t libvlc_media_get_state( 00337 libvlc_media_t *p_md ); 00338 00339 00340 /** 00341 * Get the current statistics about the media 00342 * \param p_md: media descriptor object 00343 * \param p_stats: structure that contain the statistics about the media 00344 * (this structure must be allocated by the caller) 00345 * \return true if the statistics are available, false otherwise 00346 */ 00347 VLC_PUBLIC_API int libvlc_media_get_stats( libvlc_media_t *p_md, 00348 libvlc_media_stats_t *p_stats ); 00349 00350 /** 00351 * Get subitems of media descriptor object. This will increment 00352 * the reference count of supplied media descriptor object. Use 00353 * libvlc_media_list_release() to decrement the reference counting. 00354 * 00355 * \param p_md media descriptor object 00356 * \return list of media descriptor subitems or NULL 00357 */ 00358 00359 /* This method uses libvlc_media_list_t, however, media_list usage is optionnal 00360 * and this is here for convenience */ 00361 #define VLC_FORWARD_DECLARE_OBJECT(a) struct a 00362 00363 VLC_PUBLIC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *) 00364 libvlc_media_subitems( libvlc_media_t *p_md ); 00365 00366 /** 00367 * Get event manager from media descriptor object. 00368 * NOTE: this function doesn't increment reference counting. 00369 * 00370 * \param p_md a media descriptor object 00371 * \return event manager object 00372 */ 00373 VLC_PUBLIC_API libvlc_event_manager_t * 00374 libvlc_media_event_manager( libvlc_media_t *p_md ); 00375 00376 /** 00377 * Get duration (in ms) of media descriptor object item. 00378 * 00379 * \param p_md media descriptor object 00380 * \return duration of media item or -1 on error 00381 */ 00382 VLC_PUBLIC_API libvlc_time_t 00383 libvlc_media_get_duration( libvlc_media_t *p_md ); 00384 00385 /** 00386 * Parse a media. 00387 * 00388 * This fetches (local) meta data and tracks information. 00389 * The method is synchronous. 00390 * 00391 * \see libvlc_media_parse_async 00392 * \see libvlc_media_get_meta 00393 * \see libvlc_media_get_tracks_info 00394 * 00395 * \param p_md media descriptor object 00396 */ 00397 VLC_PUBLIC_API void 00398 libvlc_media_parse( libvlc_media_t *p_md ); 00399 00400 /** 00401 * Parse a media. 00402 * 00403 * This fetches (local) meta data and tracks information. 00404 * The method is the asynchronous of libvlc_media_parse(). 00405 * 00406 * To track when this is over you can listen to libvlc_MediaParsedChanged 00407 * event. However if the media was already parsed you will not receive this 00408 * event. 00409 * 00410 * \see libvlc_media_parse 00411 * \see libvlc_MediaParsedChanged 00412 * \see libvlc_media_get_meta 00413 * \see libvlc_media_get_tracks_info 00414 * 00415 * \param p_md media descriptor object 00416 */ 00417 VLC_PUBLIC_API void 00418 libvlc_media_parse_async( libvlc_media_t *p_md ); 00419 00420 /** 00421 * Get Parsed status for media descriptor object. 00422 * 00423 * \see libvlc_MediaParsedChanged 00424 * 00425 * \param p_md media descriptor object 00426 * \return true if media object has been parsed otherwise it returns false 00427 */ 00428 VLC_PUBLIC_API int 00429 libvlc_media_is_parsed( libvlc_media_t *p_md ); 00430 00431 /** 00432 * Sets media descriptor's user_data. user_data is specialized data 00433 * accessed by the host application, VLC.framework uses it as a pointer to 00434 * an native object that references a libvlc_media_t pointer 00435 * 00436 * \param p_md media descriptor object 00437 * \param p_new_user_data pointer to user data 00438 */ 00439 VLC_PUBLIC_API void 00440 libvlc_media_set_user_data( libvlc_media_t *p_md, void *p_new_user_data ); 00441 00442 /** 00443 * Get media descriptor's user_data. user_data is specialized data 00444 * accessed by the host application, VLC.framework uses it as a pointer to 00445 * an native object that references a libvlc_media_t pointer 00446 * 00447 * \param p_md media descriptor object 00448 */ 00449 VLC_PUBLIC_API void *libvlc_media_get_user_data( libvlc_media_t *p_md ); 00450 00451 /** 00452 * Get media descriptor's elementary streams description 00453 * 00454 * Note, you need to play the media _one_ time with --sout="#description" 00455 * Not doing this will result in an empty array, and doing it more than once 00456 * will duplicate the entries in the array each time. Something like this: 00457 * 00458 * @begincode 00459 * libvlc_media_player_t *player = libvlc_media_player_new_from_media(media); 00460 * libvlc_media_add_option_flag(media, "sout=\"#description\""); 00461 * libvlc_media_player_play(player); 00462 * // ... wait until playing 00463 * libvlc_media_player_release(player); 00464 * @endcode 00465 * 00466 * This is very likely to change in next release, and be done at the parsing 00467 * phase. 00468 * 00469 * \param p_md media descriptor object 00470 * \param tracks address to store an allocated array of Elementary Streams 00471 * descriptions (must be freed by the caller) 00472 * 00473 * return the number of Elementary Streams 00474 */ 00475 VLC_PUBLIC_API 00476 int libvlc_media_get_tracks_info( libvlc_media_t *p_md, 00477 libvlc_media_track_info_t **tracks ); 00478 00479 /** @}*/ 00480 00481 # ifdef __cplusplus 00482 } 00483 # endif 00484 00485 #endif /* VLC_LIBVLC_MEDIA_H */
1.5.6