]> git.sesse.net Git - vlc/commitdiff
mediacodec: add a function that checks if codec is blacklisted
authorThomas Guillem <thomas@gllm.fr>
Mon, 16 Mar 2015 08:29:54 +0000 (08:29 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 16 Mar 2015 09:33:05 +0000 (10:33 +0100)
This also fixes a crash because of a missing __MIN(strlen()) for MTK MPEG4.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/codec/omxil/android_mediacodec.c

index 2840494c379041219480f2b914f2d97c5493e682..7ccffb22c440d9a98a3ccd4a4bcb893022b389b8 100644 (file)
@@ -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);