X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=include%2Fvlc%2Flibvlc_media.h;h=18cb5006248fef48ca10a8137f140ef702ced9af;hb=f3cc5c9f0f1512eb0a69ec4a080bebc609b3645c;hp=f8b267d7f43e2456af3e761fb1c1999d1b96ad88;hpb=269bc558110cc3497f3346c3ca5991f0e6f04513;p=vlc diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h index f8b267d7f4..18cb500624 100644 --- a/include/vlc/libvlc_media.h +++ b/include/vlc/libvlc_media.h @@ -67,7 +67,15 @@ typedef enum libvlc_meta_t { libvlc_meta_Publisher, libvlc_meta_EncodedBy, libvlc_meta_ArtworkURL, - libvlc_meta_TrackID + libvlc_meta_TrackID, + libvlc_meta_TrackTotal, + libvlc_meta_Director, + libvlc_meta_Season, + libvlc_meta_Episode, + libvlc_meta_ShowName, + libvlc_meta_Actors, + libvlc_meta_AlbumArtist, + libvlc_meta_DiscNumber /* Add new meta types HERE */ } libvlc_meta_t; @@ -170,6 +178,97 @@ typedef struct libvlc_media_track_info_t } libvlc_media_track_info_t; +typedef struct libvlc_audio_track_t +{ + unsigned i_channels; + unsigned i_rate; +} libvlc_audio_track_t; + +typedef struct libvlc_video_track_t +{ + unsigned i_height; + unsigned i_width; + unsigned i_sar_num; + unsigned i_sar_den; + unsigned i_frame_rate_num; + unsigned i_frame_rate_den; +} libvlc_video_track_t; + +typedef struct libvlc_subtitle_track_t +{ + char *psz_encoding; +} libvlc_subtitle_track_t; + +typedef struct libvlc_media_track_t +{ + /* Codec fourcc */ + uint32_t i_codec; + uint32_t i_original_fourcc; + int i_id; + libvlc_track_type_t i_type; + + /* Codec specific */ + int i_profile; + int i_level; + + union { + libvlc_audio_track_t *audio; + libvlc_video_track_t *video; + libvlc_subtitle_track_t *subtitle; + }; + + unsigned int i_bitrate; + char *psz_language; + char *psz_description; + +} libvlc_media_track_t; + +/** defgroup libvlc_media_type LibVLC media type + * \ingroup libvlc_media + * @{ + */ + +/** + * Media type + * + * \see libvlc_media_get_type + */ +typedef enum libvlc_media_type_t { + libvlc_media_type_unknown, + libvlc_media_type_file, + libvlc_media_type_directory, + libvlc_media_type_disc, + libvlc_media_type_stream, + libvlc_media_type_playlist, +} libvlc_media_type_t; + +/** @}*/ + +/** + * Parse flags used by libvlc_media_parse_with_options() + * + * \see libvlc_media_parse_with_options + */ +typedef enum libvlc_media_parse_flag_t +{ + /** + * Parse media if it's a local file + */ + libvlc_media_parse_local = 0x00, + /** + * Parse media even if it's a network file + */ + libvlc_media_parse_network = 0x01, + /** + * Fetch meta and covert art using local resources + */ + libvlc_media_fetch_local = 0x02, + /** + * Fetch meta and covert art using network resources + */ + libvlc_media_fetch_network = 0x04, +} libvlc_media_parse_flag_t; + /** * Create a media with a certain given media resource location, * for instance a valid URL. @@ -251,18 +350,20 @@ LIBVLC_API libvlc_media_t *libvlc_media_new_as_node( * read the media. This allows to use VLC's advanced * reading/streaming options on a per-media basis. * - * The options are detailed in vlc --long-help, for instance - * "--sout-all". Note that all options are not usable on medias: - * specifically, due to architectural issues, video-related options - * such as text renderer options cannot be set on a single media. They - * must be set on the whole libvlc instance instead. + * \note The options are listed in 'vlc --long-help' from the command line, + * e.g. "-sout-all". Keep in mind that available options and their semantics + * vary across LibVLC versions and builds. + * \warning Not all options affects libvlc_media_t objects: + * Specifically, due to architectural issues most audio and video options, + * such as text renderer options, have no effects on an individual media. + * These options must be set through libvlc_new() instead. * * \param p_md the media descriptor - * \param ppsz_options the options (as a string) + * \param psz_options the options (as a string) */ LIBVLC_API void libvlc_media_add_option( libvlc_media_t *p_md, - const char * ppsz_options ); + const char * psz_options ); /** * Add an option to the media with configurable flags. @@ -278,12 +379,12 @@ LIBVLC_API void libvlc_media_add_option( * must be set on the whole libvlc instance instead. * * \param p_md the media descriptor - * \param ppsz_options the options (as a string) + * \param psz_options the options (as a string) * \param i_flags the flags for this option */ LIBVLC_API void libvlc_media_add_option_flag( libvlc_media_t *p_md, - const char * ppsz_options, + const char * psz_options, unsigned i_flags ); @@ -392,6 +493,10 @@ LIBVLC_API libvlc_state_t libvlc_media_get_state( LIBVLC_API int libvlc_media_get_stats( libvlc_media_t *p_md, libvlc_media_stats_t *p_stats ); +/* The following method uses libvlc_media_list_t, however, media_list usage is optionnal + * and this is here for convenience */ +#define VLC_FORWARD_DECLARE_OBJECT(a) struct a + /** * Get subitems of media descriptor object. This will increment * the reference count of supplied media descriptor object. Use @@ -400,11 +505,6 @@ LIBVLC_API int libvlc_media_get_stats( libvlc_media_t *p_md, * \param p_md media descriptor object * \return list of media descriptor subitems or NULL */ - -/* This method uses libvlc_media_list_t, however, media_list usage is optionnal - * and this is here for convenience */ -#define VLC_FORWARD_DECLARE_OBJECT(a) struct a - LIBVLC_API VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t *) libvlc_media_subitems( libvlc_media_t *p_md ); @@ -430,7 +530,7 @@ LIBVLC_API libvlc_time_t /** * Parse a media. * - * This fetches (local) meta data and tracks information. + * This fetches (local) art, meta data and tracks information. * The method is synchronous. * * \see libvlc_media_parse_async @@ -445,7 +545,7 @@ libvlc_media_parse( libvlc_media_t *p_md ); /** * Parse a media. * - * This fetches (local) meta data and tracks information. + * This fetches (local) art, meta data and tracks information. * The method is the asynchronous of libvlc_media_parse(). * * To track when this is over you can listen to libvlc_MediaParsedChanged @@ -462,6 +562,34 @@ libvlc_media_parse( libvlc_media_t *p_md ); LIBVLC_API void libvlc_media_parse_async( libvlc_media_t *p_md ); +/** + * Parse the media asynchronously with options. + * + * This fetches (local or network) art, meta data and/or tracks information. + * This method is the extended version of libvlc_media_parse_async(). + * + * To track when this is over you can listen to libvlc_MediaParsedChanged + * event. However if this functions returns an error, you will not receive this + * event. + * + * It uses a flag to specify parse options (see libvlc_media_parse_flag_t). All + * these flags can be combined. By default, media is parsed if it's a local + * file. + * + * \see libvlc_MediaParsedChanged + * \see libvlc_media_get_meta + * \see libvlc_media_tracks_get + * \see libvlc_media_parse_flag_t + * + * \param p_md media descriptor object + * \param parse_flag parse options: + * \return -1 in case of error, 0 otherwise + * \version LibVLC 3.0.0 or later + */ +LIBVLC_API int +libvlc_media_parse_with_options( libvlc_media_t *p_md, + libvlc_media_parse_flag_t parse_flag ); + /** * Get Parsed status for media descriptor object. * @@ -502,16 +630,80 @@ LIBVLC_API void *libvlc_media_get_user_data( libvlc_media_t *p_md ); * before calling this function. * Not doing this will result in an empty array. * + * \deprecated Use libvlc_media_tracks_get instead + * * \param p_md media descriptor object * \param tracks address to store an allocated array of Elementary Streams * descriptions (must be freed by the caller) [OUT] * * \return the number of Elementary Streams */ -LIBVLC_API +LIBVLC_DEPRECATED LIBVLC_API int libvlc_media_get_tracks_info( libvlc_media_t *p_md, libvlc_media_track_info_t **tracks ); +/** + * Get media descriptor's elementary streams description + * + * Note, you need to call libvlc_media_parse() or play the media at least once + * before calling this function. + * Not doing this will result in an empty array. + * + * \version LibVLC 2.1.0 and later. + * + * \param p_md media descriptor object + * \param tracks address to store an allocated array of Elementary Streams + * descriptions (must be freed with libvlc_media_tracks_release + by the caller) [OUT] + * + * \return the number of Elementary Streams (zero on error) + */ +LIBVLC_API +unsigned libvlc_media_tracks_get( libvlc_media_t *p_md, + libvlc_media_track_t ***tracks ); + +/** + * Get codec description from media elementary stream + * + * \version LibVLC 3.0.0 and later. + * + * \see libvlc_media_track_t + * + * \param i_type i_type from libvlc_media_track_t + * \param i_codec i_codec or i_original_fourcc from libvlc_media_track_t + * + * \return codec description + */ +LIBVLC_API +const char *libvlc_media_get_codec_description( libvlc_track_type_t i_type, + uint32_t i_codec ); + +/** + * Release media descriptor's elementary streams description array + * + * \version LibVLC 2.1.0 and later. + * + * \param p_tracks tracks info array to release + * \param i_count number of elements in the array + */ +LIBVLC_API +void libvlc_media_tracks_release( libvlc_media_track_t **p_tracks, + unsigned i_count ); + +/** + * Get the media type of the media descriptor object + * + * \version LibVLC 3.0.0 and later. + * + * \see libvlc_media_type_t + * + * \param p_md media descriptor object + * + * \return media type + */ +LIBVLC_API +libvlc_media_type_t libvlc_media_get_type( libvlc_media_t *p_md ); + /** @}*/ # ifdef __cplusplus