[vlc-devel] [RFC PATCH 1/6] lib: media: factorize track type conversion

Thomas Guillem thomas at gllm.fr
Tue Jun 2 22:02:05 CEST 2020


---
 lib/media.c          | 14 ++------------
 lib/media_internal.h | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/lib/media.c b/lib/media.c
index 15df528161..fbf37f3fac 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -960,18 +960,8 @@ const char *
 libvlc_media_get_codec_description( libvlc_track_type_t i_type,
                                     uint32_t i_codec )
 {
-    switch( i_type )
-    {
-        case libvlc_track_audio:
-            return vlc_fourcc_GetDescription( AUDIO_ES, i_codec );
-        case libvlc_track_video:
-            return vlc_fourcc_GetDescription( VIDEO_ES, i_codec );
-        case libvlc_track_text:
-            return vlc_fourcc_GetDescription( SPU_ES, i_codec );
-        case libvlc_track_unknown:
-        default:
-            return vlc_fourcc_GetDescription( UNKNOWN_ES, i_codec );
-    }
+    return vlc_fourcc_GetDescription( libvlc_track_type_to_escat( i_type),
+                                      i_codec );
 }
 
 // Release media descriptor's elementary streams description array
diff --git a/lib/media_internal.h b/lib/media_internal.h
index aefc731c68..89adfd73ff 100644
--- a/lib/media_internal.h
+++ b/lib/media_internal.h
@@ -56,4 +56,21 @@ libvlc_media_t * libvlc_media_new_from_input_item(
 void libvlc_media_set_state( libvlc_media_t *, libvlc_state_t );
 void libvlc_media_add_subtree(libvlc_media_t *, input_item_node_t *);
 
+static inline enum es_format_category_e
+libvlc_track_type_to_escat( libvlc_track_type_t i_type )
+{
+    switch( i_type )
+    {
+        case libvlc_track_audio:
+            return AUDIO_ES;
+        case libvlc_track_video:
+            return VIDEO_ES;
+        case libvlc_track_text:
+            return SPU_ES;
+        case libvlc_track_unknown:
+        default:
+            return UNKNOWN_ES;
+    }
+}
+
 #endif
-- 
2.20.1



More information about the vlc-devel mailing list