Commit f3cc5c9f authored by Thomas Guillem's avatar Thomas Guillem Committed by Jean-Baptiste Kempf

libvlc: add libvlc_media_get_type

Get the type of the media.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 4455e6d2
......@@ -105,6 +105,7 @@ libVLC:
* Add libvlc_media_parse_with_options that uses a flag to specify parse options
* Add libvlc_audio_output_device_get to get the currently selected audio output device
identifier (if there is one available)
* Add libvlc_media_get_type to get the type of the media
Logging
* Support for the SystemD Journal
......
......@@ -223,6 +223,27 @@ typedef struct libvlc_media_track_t
} 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()
*
......@@ -669,6 +690,20 @@ 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
......
......@@ -90,6 +90,7 @@ libvlc_media_get_meta
libvlc_media_get_mrl
libvlc_media_get_state
libvlc_media_get_stats
libvlc_media_get_type
libvlc_media_get_user_data
libvlc_media_get_tracks_info
libvlc_media_is_parsed
......
......@@ -999,3 +999,35 @@ void libvlc_media_tracks_release( libvlc_media_track_t **p_tracks, unsigned i_co
}
free( p_tracks );
}
/**************************************************************************
* Get the media type of the media descriptor object
**************************************************************************/
libvlc_media_type_t libvlc_media_get_type( libvlc_media_t *p_md )
{
assert( p_md );
int i_type;
input_item_t *p_input_item = p_md->p_input_item;
vlc_mutex_lock( &p_input_item->lock );
i_type = p_md->p_input_item->i_type;
vlc_mutex_unlock( &p_input_item->lock );
switch( i_type )
{
case ITEM_TYPE_FILE:
return libvlc_media_type_file;
case ITEM_TYPE_NODE:
case ITEM_TYPE_DIRECTORY:
return libvlc_media_type_directory;
case ITEM_TYPE_DISC:
return libvlc_media_type_disc;
case ITEM_TYPE_STREAM:
return libvlc_media_type_stream;
case ITEM_TYPE_PLAYLIST:
return libvlc_media_type_playlist;
default:
return libvlc_media_type_unknown;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment