libvlc: add libvlc_media_get_type
authorThomas Guillem <thomas@gllm.fr>
Tue, 24 Mar 2015 16:22:20 +0000 (16:22 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 25 Mar 2015 14:29:57 +0000 (15:29 +0100)
Get the type of the media.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
NEWS
include/vlc/libvlc_media.h
lib/libvlc.sym
lib/media.c

diff --git a/NEWS b/NEWS
index 3daee6e..b2e443b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index 7fc718a..18cb500 100644 (file)
@@ -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
index 4fd2378..1e241e7 100644 (file)
@@ -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
index 9ccfb25..1d01c11 100644 (file)
@@ -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;
+    }
+}