char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int width, int height, void *log_ctx)

{

    int ret;

    char *name = NULL;

    char *supported_type = NULL;



    int attached = 0;

    JNIEnv *env = NULL;

    struct JNIAMediaCodecListFields jfields = { 0 };



    jobject format = NULL;

    jobject codec = NULL;

    jstring tmp = NULL;



    jobject info = NULL;

    jobject type = NULL;

    jobjectArray types = NULL;



    JNI_ATTACH_ENV_OR_RETURN(env, &attached, log_ctx, NULL);



    if ((ret = ff_jni_init_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, log_ctx)) < 0) {

        goto done;

    }



    if (jfields.init_id && jfields.find_decoder_for_format_id) {

        tmp = ff_jni_utf_chars_to_jstring(env, mime, log_ctx);

        if (!tmp) {

            goto done;

        }



        format = (*env)->CallStaticObjectMethod(env, jfields.mediaformat_class, jfields.create_video_format_id, tmp, width, height);

        if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

            goto done;

        }

        (*env)->DeleteLocalRef(env, tmp);

        tmp = NULL;



        codec = (*env)->NewObject(env, jfields.mediacodec_list_class, jfields.init_id, 0);

        if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

            goto done;

        }



        tmp = (*env)->CallObjectMethod(env, codec, jfields.find_decoder_for_format_id, format);

        if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

            goto done;

        }

        if (!tmp) {

            av_log(NULL, AV_LOG_ERROR, "Could not find decoder in media codec list "

                                       "for format { mime=%s width=%d height=%d }\n", mime, width, height);

            goto done;

        }



        name = ff_jni_jstring_to_utf_chars(env, tmp, log_ctx);

        if (!name) {

            goto done;

        }



    } else {

        int i;

        int codec_count;



        codec_count = (*env)->CallStaticIntMethod(env, jfields.mediacodec_list_class, jfields.get_codec_count_id);

        if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

            goto done;

        }



        for(i = 0; i < codec_count; i++) {

            int j;

            int type_count;

            int is_encoder;



            info = (*env)->CallStaticObjectMethod(env, jfields.mediacodec_list_class, jfields.get_codec_info_at_id, i);

            if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                goto done;

            }



            types = (*env)->CallObjectMethod(env, info, jfields.get_supported_types_id);

            if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                goto done;

            }



            is_encoder = (*env)->CallBooleanMethod(env, info, jfields.is_encoder_id);

            if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                goto done;

            }



            if (is_encoder) {

                continue;

            }



            type_count = (*env)->GetArrayLength(env, types);

            for (j = 0; j < type_count; j++) {



                type = (*env)->GetObjectArrayElement(env, types, j);

                if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                    goto done;

                }



                supported_type = ff_jni_jstring_to_utf_chars(env, type, log_ctx);

                if (!supported_type) {

                    goto done;

                }



                if (!av_strcasecmp(supported_type, mime)) {

                    jobject codec_name;



                    codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id);

                    if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                        goto done;

                    }



                    name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx);

                    if (!name) {

                        goto done;

                    }



                    if (strstr(name, "OMX.google")) {

                        av_freep(&name);

                        continue;

                    }

                }



                av_freep(&supported_type);

            }



            (*env)->DeleteLocalRef(env, info);

            info = NULL;



            (*env)->DeleteLocalRef(env, types);

            types = NULL;



            if (name)

                break;

        }

    }



done:

    if (format) {

        (*env)->DeleteLocalRef(env, format);

    }



    if (codec) {

        (*env)->DeleteLocalRef(env, codec);

    }



    if (tmp) {

        (*env)->DeleteLocalRef(env, tmp);

    }



    if (info) {

        (*env)->DeleteLocalRef(env, info);

    }



    if (type) {

        (*env)->DeleteLocalRef(env, type);

    }



    if (types) {

        (*env)->DeleteLocalRef(env, types);

    }



    av_freep(&supported_type);



    ff_jni_reset_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, log_ctx);



    JNI_DETACH_ENV(attached, log_ctx);



    return name;

}

char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int width, int height, void *log_ctx)

{

    int ret;

    char *name = NULL;

    char *supported_type = NULL;



    int attached = 0;

    JNIEnv *env = NULL;

    struct JNIAMediaCodecListFields jfields = { 0 };



    jobject format = NULL;

    jobject codec = NULL;

    jstring tmp = NULL;



    jobject info = NULL;

    jobject type = NULL;

    jobjectArray types = NULL;



    JNI_ATTACH_ENV_OR_RETURN(env, &attached, log_ctx, NULL);



    if ((ret = ff_jni_init_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, log_ctx)) < 0) {

        goto done;

    }



    if (jfields.init_id && jfields.find_decoder_for_format_id) {

        tmp = ff_jni_utf_chars_to_jstring(env, mime, log_ctx);

        if (!tmp) {

            goto done;

        }



        format = (*env)->CallStaticObjectMethod(env, jfields.mediaformat_class, jfields.create_video_format_id, tmp, width, height);

        if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

            goto done;

        }

        (*env)->DeleteLocalRef(env, tmp);

        tmp = NULL;



        codec = (*env)->NewObject(env, jfields.mediacodec_list_class, jfields.init_id, 0);

        if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

            goto done;

        }



        tmp = (*env)->CallObjectMethod(env, codec, jfields.find_decoder_for_format_id, format);

        if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

            goto done;

        }

        if (!tmp) {

            av_log(NULL, AV_LOG_ERROR, "Could not find decoder in media codec list "

                                       "for format { mime=%s width=%d height=%d }\n", mime, width, height);

            goto done;

        }



        name = ff_jni_jstring_to_utf_chars(env, tmp, log_ctx);

        if (!name) {

            goto done;

        }



    } else {

        int i;

        int codec_count;



        codec_count = (*env)->CallStaticIntMethod(env, jfields.mediacodec_list_class, jfields.get_codec_count_id);

        if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

            goto done;

        }



        for(i = 0; i < codec_count; i++) {

            int j;

            int type_count;

            int is_encoder;



            info = (*env)->CallStaticObjectMethod(env, jfields.mediacodec_list_class, jfields.get_codec_info_at_id, i);

            if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                goto done;

            }



            types = (*env)->CallObjectMethod(env, info, jfields.get_supported_types_id);

            if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                goto done;

            }



            is_encoder = (*env)->CallBooleanMethod(env, info, jfields.is_encoder_id);

            if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                goto done;

            }



            if (is_encoder) {

                continue;

            }



            type_count = (*env)->GetArrayLength(env, types);

            for (j = 0; j < type_count; j++) {



                type = (*env)->GetObjectArrayElement(env, types, j);

                if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                    goto done;

                }



                supported_type = ff_jni_jstring_to_utf_chars(env, type, log_ctx);

                if (!supported_type) {

                    goto done;

                }



                if (!av_strcasecmp(supported_type, mime)) {

                    jobject codec_name;



                    codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id);

                    if (ff_jni_exception_check(env, 1, log_ctx) < 0) {

                        goto done;

                    }



                    name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx);

                    if (!name) {

                        goto done;

                    }



                    if (strstr(name, "OMX.google")) {

                        av_freep(&name);

                        continue;

                    }

                }



                av_freep(&supported_type);

            }



            (*env)->DeleteLocalRef(env, info);

            info = NULL;



            (*env)->DeleteLocalRef(env, types);

            types = NULL;



            if (name)

                break;

        }

    }



done:

    if (format) {

        (*env)->DeleteLocalRef(env, format);

    }



    if (codec) {

        (*env)->DeleteLocalRef(env, codec);

    }



    if (tmp) {

        (*env)->DeleteLocalRef(env, tmp);

    }



    if (info) {

        (*env)->DeleteLocalRef(env, info);

    }



    if (type) {

        (*env)->DeleteLocalRef(env, type);

    }



    if (types) {

        (*env)->DeleteLocalRef(env, types);

    }



    av_freep(&supported_type);



    ff_jni_reset_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, log_ctx);



    JNI_DETACH_ENV(attached, log_ctx);



    return name;

}

char *FUNC_0(const char *VAR_0, int VAR_1, int VAR_2, void *VAR_3)

{

    int VAR_4;

    char *VAR_5 = NULL;

    char *VAR_6 = NULL;



    int VAR_7 = 0;

    JNIEnv *env = NULL;

    struct JNIAMediaCodecListFields VAR_8 = { 0 };



    jobject format = NULL;

    jobject codec = NULL;

    jstring tmp = NULL;



    jobject info = NULL;

    jobject type = NULL;

    jobjectArray types = NULL;



    JNI_ATTACH_ENV_OR_RETURN(env, &VAR_7, VAR_3, NULL);



    if ((VAR_4 = ff_jni_init_jfields(env, &VAR_8, jni_amediacodeclist_mapping, 0, VAR_3)) < 0) {

        goto done;

    }



    if (VAR_8.init_id && VAR_8.find_decoder_for_format_id) {

        tmp = ff_jni_utf_chars_to_jstring(env, VAR_0, VAR_3);

        if (!tmp) {

            goto done;

        }



        format = (*env)->CallStaticObjectMethod(env, VAR_8.mediaformat_class, VAR_8.create_video_format_id, tmp, VAR_1, VAR_2);

        if (ff_jni_exception_check(env, 1, VAR_3) < 0) {

            goto done;

        }

        (*env)->DeleteLocalRef(env, tmp);

        tmp = NULL;



        codec = (*env)->NewObject(env, VAR_8.mediacodec_list_class, VAR_8.init_id, 0);

        if (ff_jni_exception_check(env, 1, VAR_3) < 0) {

            goto done;

        }



        tmp = (*env)->CallObjectMethod(env, codec, VAR_8.find_decoder_for_format_id, format);

        if (ff_jni_exception_check(env, 1, VAR_3) < 0) {

            goto done;

        }

        if (!tmp) {

            av_log(NULL, AV_LOG_ERROR, "Could not find decoder in media codec list "

                                       "for format { VAR_0=%s VAR_1=%d VAR_2=%d }\n", VAR_0, VAR_1, VAR_2);

            goto done;

        }



        VAR_5 = ff_jni_jstring_to_utf_chars(env, tmp, VAR_3);

        if (!VAR_5) {

            goto done;

        }



    } else {

        int VAR_9;

        int VAR_10;



        VAR_10 = (*env)->CallStaticIntMethod(env, VAR_8.mediacodec_list_class, VAR_8.get_codec_count_id);

        if (ff_jni_exception_check(env, 1, VAR_3) < 0) {

            goto done;

        }



        for(VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) {

            int VAR_11;

            int VAR_12;

            int VAR_13;



            info = (*env)->CallStaticObjectMethod(env, VAR_8.mediacodec_list_class, VAR_8.get_codec_info_at_id, VAR_9);

            if (ff_jni_exception_check(env, 1, VAR_3) < 0) {

                goto done;

            }



            types = (*env)->CallObjectMethod(env, info, VAR_8.get_supported_types_id);

            if (ff_jni_exception_check(env, 1, VAR_3) < 0) {

                goto done;

            }



            VAR_13 = (*env)->CallBooleanMethod(env, info, VAR_8.is_encoder_id);

            if (ff_jni_exception_check(env, 1, VAR_3) < 0) {

                goto done;

            }



            if (VAR_13) {

                continue;

            }



            VAR_12 = (*env)->GetArrayLength(env, types);

            for (VAR_11 = 0; VAR_11 < VAR_12; VAR_11++) {



                type = (*env)->GetObjectArrayElement(env, types, VAR_11);

                if (ff_jni_exception_check(env, 1, VAR_3) < 0) {

                    goto done;

                }



                VAR_6 = ff_jni_jstring_to_utf_chars(env, type, VAR_3);

                if (!VAR_6) {

                    goto done;

                }



                if (!av_strcasecmp(VAR_6, VAR_0)) {

                    jobject codec_name;



                    codec_name = (*env)->CallObjectMethod(env, info, VAR_8.get_name_id);

                    if (ff_jni_exception_check(env, 1, VAR_3) < 0) {

                        goto done;

                    }



                    VAR_5 = ff_jni_jstring_to_utf_chars(env, codec_name, VAR_3);

                    if (!VAR_5) {

                        goto done;

                    }



                    if (strstr(VAR_5, "OMX.google")) {

                        av_freep(&VAR_5);

                        continue;

                    }

                }



                av_freep(&VAR_6);

            }



            (*env)->DeleteLocalRef(env, info);

            info = NULL;



            (*env)->DeleteLocalRef(env, types);

            types = NULL;



            if (VAR_5)

                break;

        }

    }



done:

    if (format) {

        (*env)->DeleteLocalRef(env, format);

    }



    if (codec) {

        (*env)->DeleteLocalRef(env, codec);

    }



    if (tmp) {

        (*env)->DeleteLocalRef(env, tmp);

    }



    if (info) {

        (*env)->DeleteLocalRef(env, info);

    }



    if (type) {

        (*env)->DeleteLocalRef(env, type);

    }



    if (types) {

        (*env)->DeleteLocalRef(env, types);

    }



    av_freep(&VAR_6);



    ff_jni_reset_jfields(env, &VAR_8, jni_amediacodeclist_mapping, 0, VAR_3);



    JNI_DETACH_ENV(VAR_7, VAR_3);



    return VAR_5;

}

char *FUNC_0(const char *VAR_0, int VAR_1, int VAR_2, void *VAR_3)
{ int VAR_4; char *VAR_5 = NULL; char *VAR_6 = NULL; int VAR_7 = 0; JNIEnv *env = NULL; struct JNIAMediaCodecListFields VAR_8 = { 0 }; jobject format = NULL; jobject codec = NULL; jstring tmp = NULL; jobject info = NULL; jobject type = NULL; jobjectArray types = NULL; JNI_ATTACH_ENV_OR_RETURN(env, &VAR_7, VAR_3, NULL); if ((VAR_4 = ff_jni_init_jfields(env, &VAR_8, jni_amediacodeclist_mapping, 0, VAR_3)) < 0) { goto done; } if (VAR_8.init_id && VAR_8.find_decoder_for_format_id) { tmp = ff_jni_utf_chars_to_jstring(env, VAR_0, VAR_3); if (!tmp) { goto done; } format = (*env)->CallStaticObjectMethod(env, VAR_8.mediaformat_class, VAR_8.create_video_format_id, tmp, VAR_1, VAR_2); if (ff_jni_exception_check(env, 1, VAR_3) < 0) { goto done; } (*env)->DeleteLocalRef(env, tmp); tmp = NULL; codec = (*env)->NewObject(env, VAR_8.mediacodec_list_class, VAR_8.init_id, 0); if (ff_jni_exception_check(env, 1, VAR_3) < 0) { goto done; } tmp = (*env)->CallObjectMethod(env, codec, VAR_8.find_decoder_for_format_id, format); if (ff_jni_exception_check(env, 1, VAR_3) < 0) { goto done; } if (!tmp) { av_log(NULL, AV_LOG_ERROR, "Could not find decoder in media codec list "
"for format { VAR_0=%s VAR_1=%d VAR_2=%d }\n", VAR_0, VAR_1, VAR_2); goto done; } VAR_5 = ff_jni_jstring_to_utf_chars(env, tmp, VAR_3); if (!VAR_5) { goto done; } } else { int VAR_9; int VAR_10; VAR_10 = (*env)->CallStaticIntMethod(env, VAR_8.mediacodec_list_class, VAR_8.get_codec_count_id); if (ff_jni_exception_check(env, 1, VAR_3) < 0) { goto done; } for(VAR_9 = 0; VAR_9 < VAR_10; VAR_9++) { int VAR_11; int VAR_12; int VAR_13; info = (*env)->CallStaticObjectMethod(env, VAR_8.mediacodec_list_class, VAR_8.get_codec_info_at_id, VAR_9); if (ff_jni_exception_check(env, 1, VAR_3) < 0) { goto done; } types = (*env)->CallObjectMethod(env, info, VAR_8.get_supported_types_id); if (ff_jni_exception_check(env, 1, VAR_3) < 0) { goto done; } VAR_13 = (*env)->CallBooleanMethod(env, info, VAR_8.is_encoder_id); if (ff_jni_exception_check(env, 1, VAR_3) < 0) { goto done; } if (VAR_13) { continue; } VAR_12 = (*env)->GetArrayLength(env, types); for (VAR_11 = 0; VAR_11 < VAR_12; VAR_11++) { type = (*env)->GetObjectArrayElement(env, types, VAR_11); if (ff_jni_exception_check(env, 1, VAR_3) < 0) { goto done; } VAR_6 = ff_jni_jstring_to_utf_chars(env, type, VAR_3); if (!VAR_6) { goto done; } if (!av_strcasecmp(VAR_6, VAR_0)) { jobject codec_name; codec_name = (*env)->CallObjectMethod(env, info, VAR_8.get_name_id); if (ff_jni_exception_check(env, 1, VAR_3) < 0) { goto done; } VAR_5 = ff_jni_jstring_to_utf_chars(env, codec_name, VAR_3); if (!VAR_5) { goto done; } if (strstr(VAR_5, "OMX.google")) { av_freep(&VAR_5); continue; } } av_freep(&VAR_6); } (*env)->DeleteLocalRef(env, info); info = NULL; (*env)->DeleteLocalRef(env, types); types = NULL; if (VAR_5)
break; } } done:
if (format) { (*env)->DeleteLocalRef(env, format); } if (codec) { (*env)->DeleteLocalRef(env, codec); } if (tmp) { (*env)->DeleteLocalRef(env, tmp); } if (info) { (*env)->DeleteLocalRef(env, info); } if (type) { (*env)->DeleteLocalRef(env, type); } if (types) { (*env)->DeleteLocalRef(env, types); } av_freep(&VAR_6); ff_jni_reset_jfields(env, &VAR_8, jni_amediacodeclist_mapping, 0, VAR_3); JNI_DETACH_ENV(VAR_7, VAR_3); return VAR_5; }