[vlc-devel] [PATCH] mediacodec: add a function that checks if codec is blacklisted

Thomas Guillem thomas at gllm.fr
Mon Mar 16 10:29:54 CET 2015


This also fixes a crash because of a missing __MIN(strlen()) for MTK MPEG4.
---
 modules/codec/omxil/android_mediacodec.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index 2840494..7ccffb2 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -308,6 +308,26 @@ static inline bool check_exception( JNIEnv *env )
 }
 #define CHECK_EXCEPTION() check_exception( env )
 
+static bool codec_is_blacklisted( const char *p_name, int i_name_len )
+{
+     static const char *blacklisted_codecs[] = {
+        /* software decoders */
+        "OMX.google.",
+        /* crashes mediaserver */
+        "OMX.MTK.VIDEO.DECODER.MPEG4",
+        NULL,
+     };
+
+     for( const char **pp_bl_codecs = blacklisted_codecs; *pp_bl_codecs != NULL;
+          pp_bl_codecs++ )
+     {
+        if( !strncmp( p_name, *pp_bl_codecs,
+            __MIN( strlen(*pp_bl_codecs), i_name_len ) ) )
+            return true;
+     }
+     return false;
+}
+
 /*****************************************************************************
  * OpenDecoder: Create the decoder instance
  *****************************************************************************/
@@ -442,9 +462,7 @@ static int OpenDecoder(vlc_object_t *p_this)
         name_ptr = (*env)->GetStringUTFChars(env, name, NULL);
         found = false;
 
-        if (!strncmp(name_ptr, "OMX.google.", __MIN(11, name_len)))
-            goto loopclean;
-        if (!strncmp(name_ptr, "OMX.MTK.VIDEO.DECODER.MPEG4", name_len))
+        if (codec_is_blacklisted( name_ptr, name_len))
             goto loopclean;
         for (int j = 0; j < num_types && !found; j++) {
             jobject type = (*env)->GetObjectArrayElement(env, types, j);
-- 
2.1.3




More information about the vlc-devel mailing list