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

mediacodec: add a function that checks if codec is blacklisted

This also fixes a crash because of a missing __MIN(strlen()) for MTK MPEG4.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 8317c242
......@@ -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);
......
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