Lines Matching +full:- +full:- +full:env
4 * Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
301 #define JNI_GET_ENV_OR_RETURN(env, log_ctx, ret) do { \ argument
302 (env) = ff_jni_get_env(log_ctx); \
303 if (!(env)) { \
308 #define JNI_GET_ENV_OR_RETURN_VOID(env, log_ctx) do { \ argument
309 (env) = ff_jni_get_env(log_ctx); \
310 if (!(env)) { \
317 int ret = -1; in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
319 JNIEnv *env = NULL; in ff_AMediaCodecProfile_getProfileFromAVCodecContext() local
323 JNI_GET_ENV_OR_RETURN(env, avctx, -1); in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
325 if (ff_jni_init_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, avctx) < 0) { in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
329 if (avctx->codec_id == AV_CODEC_ID_H264) { in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
330 switch(avctx->profile) { in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
358 } else if (avctx->codec_id == AV_CODEC_ID_HEVC) { in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
359 switch (avctx->profile) { in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
371 ret = (*env)->GetStaticIntField(env, jfields.codec_profile_level_class, field_id); in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
372 if (ff_jni_exception_check(env, 1, avctx) < 0) { in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
373 ret = -1; in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
379 ff_jni_reset_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, avctx); in ff_AMediaCodecProfile_getProfileFromAVCodecContext()
393 JNIEnv *env = NULL; in ff_AMediaCodecList_getCodecNameByType() local
407 JNI_GET_ENV_OR_RETURN(env, log_ctx, NULL); in ff_AMediaCodecList_getCodecNameByType()
409 if ((ret = ff_jni_init_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, log_ctx)) < 0) { in ff_AMediaCodecList_getCodecNameByType()
413 …if ((ret = ff_jni_init_jfields(env, &mediaformat_jfields, jni_amediaformat_mapping, 0, log_ctx)) <… in ff_AMediaCodecList_getCodecNameByType()
417 …codec_count = (*env)->CallStaticIntMethod(env, jfields.mediacodec_list_class, jfields.get_codec_co… in ff_AMediaCodecList_getCodecNameByType()
418 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
427 …info = (*env)->CallStaticObjectMethod(env, jfields.mediacodec_list_class, jfields.get_codec_info_a… in ff_AMediaCodecList_getCodecNameByType()
428 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
432 types = (*env)->CallObjectMethod(env, info, jfields.get_supported_types_id); in ff_AMediaCodecList_getCodecNameByType()
433 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
437 is_encoder = (*env)->CallBooleanMethod(env, info, jfields.is_encoder_id); in ff_AMediaCodecList_getCodecNameByType()
438 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
447 … int is_software_only = (*env)->CallBooleanMethod(env, info, jfields.is_software_only_id); in ff_AMediaCodecList_getCodecNameByType()
448 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
457 codec_name = (*env)->CallObjectMethod(env, info, jfields.get_name_id); in ff_AMediaCodecList_getCodecNameByType()
458 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
462 name = ff_jni_jstring_to_utf_chars(env, codec_name, log_ctx); in ff_AMediaCodecList_getCodecNameByType()
468 (*env)->DeleteLocalRef(env, codec_name); in ff_AMediaCodecList_getCodecNameByType()
481 type_count = (*env)->GetArrayLength(env, types); in ff_AMediaCodecList_getCodecNameByType()
486 type = (*env)->GetObjectArrayElement(env, types, j); in ff_AMediaCodecList_getCodecNameByType()
487 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
491 supported_type = ff_jni_jstring_to_utf_chars(env, type, log_ctx); in ff_AMediaCodecList_getCodecNameByType()
500 … capabilities = (*env)->CallObjectMethod(env, info, jfields.get_codec_capabilities_id, type); in ff_AMediaCodecList_getCodecNameByType()
501 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
505 profile_levels = (*env)->GetObjectField(env, capabilities, jfields.profile_levels_id); in ff_AMediaCodecList_getCodecNameByType()
506 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
510 profile_count = (*env)->GetArrayLength(env, profile_levels); in ff_AMediaCodecList_getCodecNameByType()
522 profile_level = (*env)->GetObjectArrayElement(env, profile_levels, k); in ff_AMediaCodecList_getCodecNameByType()
523 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
527 supported_profile = (*env)->GetIntField(env, profile_level, jfields.profile_id); in ff_AMediaCodecList_getCodecNameByType()
528 if (ff_jni_exception_check(env, 1, log_ctx) < 0) { in ff_AMediaCodecList_getCodecNameByType()
535 (*env)->DeleteLocalRef(env, profile_level); in ff_AMediaCodecList_getCodecNameByType()
546 (*env)->DeleteLocalRef(env, profile_levels); in ff_AMediaCodecList_getCodecNameByType()
551 (*env)->DeleteLocalRef(env, capabilities); in ff_AMediaCodecList_getCodecNameByType()
556 (*env)->DeleteLocalRef(env, type); in ff_AMediaCodecList_getCodecNameByType()
569 (*env)->DeleteLocalRef(env, info); in ff_AMediaCodecList_getCodecNameByType()
574 (*env)->DeleteLocalRef(env, types); in ff_AMediaCodecList_getCodecNameByType()
587 (*env)->DeleteLocalRef(env, codec_name); in ff_AMediaCodecList_getCodecNameByType()
591 (*env)->DeleteLocalRef(env, info); in ff_AMediaCodecList_getCodecNameByType()
595 (*env)->DeleteLocalRef(env, type); in ff_AMediaCodecList_getCodecNameByType()
599 (*env)->DeleteLocalRef(env, types); in ff_AMediaCodecList_getCodecNameByType()
603 (*env)->DeleteLocalRef(env, capabilities); in ff_AMediaCodecList_getCodecNameByType()
607 (*env)->DeleteLocalRef(env, profile_level); in ff_AMediaCodecList_getCodecNameByType()
611 (*env)->DeleteLocalRef(env, profile_levels); in ff_AMediaCodecList_getCodecNameByType()
616 ff_jni_reset_jfields(env, &jfields, jni_amediacodeclist_mapping, 0, log_ctx); in ff_AMediaCodecList_getCodecNameByType()
617 ff_jni_reset_jfields(env, &mediaformat_jfields, jni_amediaformat_mapping, 0, log_ctx); in ff_AMediaCodecList_getCodecNameByType()
628 JNIEnv *env = NULL; in ff_AMediaFormat_new() local
636 format->class = &amediaformat_class; in ff_AMediaFormat_new()
638 env = ff_jni_get_env(format); in ff_AMediaFormat_new()
639 if (!env) { in ff_AMediaFormat_new()
644 if (ff_jni_init_jfields(env, &format->jfields, jni_amediaformat_mapping, 1, format) < 0) { in ff_AMediaFormat_new()
648 object = (*env)->NewObject(env, format->jfields.mediaformat_class, format->jfields.init_id); in ff_AMediaFormat_new()
653 format->object = (*env)->NewGlobalRef(env, object); in ff_AMediaFormat_new()
654 if (!format->object) { in ff_AMediaFormat_new()
660 (*env)->DeleteLocalRef(env, object); in ff_AMediaFormat_new()
663 if (!format->object) { in ff_AMediaFormat_new()
664 ff_jni_reset_jfields(env, &format->jfields, jni_amediaformat_mapping, 1, format); in ff_AMediaFormat_new()
673 JNIEnv *env = NULL; in ff_AMediaFormat_newFromObject() local
680 format->class = &amediaformat_class; in ff_AMediaFormat_newFromObject()
682 env = ff_jni_get_env(format); in ff_AMediaFormat_newFromObject()
683 if (!env) { in ff_AMediaFormat_newFromObject()
688 if (ff_jni_init_jfields(env, &format->jfields, jni_amediaformat_mapping, 1, format) < 0) { in ff_AMediaFormat_newFromObject()
692 format->object = (*env)->NewGlobalRef(env, object); in ff_AMediaFormat_newFromObject()
693 if (!format->object) { in ff_AMediaFormat_newFromObject()
699 ff_jni_reset_jfields(env, &format->jfields, jni_amediaformat_mapping, 1, format); in ff_AMediaFormat_newFromObject()
710 JNIEnv *env = NULL; in ff_AMediaFormat_delete() local
716 JNI_GET_ENV_OR_RETURN(env, format, AVERROR_EXTERNAL); in ff_AMediaFormat_delete()
718 (*env)->DeleteGlobalRef(env, format->object); in ff_AMediaFormat_delete()
719 format->object = NULL; in ff_AMediaFormat_delete()
721 ff_jni_reset_jfields(env, &format->jfields, jni_amediaformat_mapping, 1, format); in ff_AMediaFormat_delete()
732 JNIEnv *env = NULL; in ff_AMediaFormat_toString() local
737 JNI_GET_ENV_OR_RETURN(env, format, NULL); in ff_AMediaFormat_toString()
739 description = (*env)->CallObjectMethod(env, format->object, format->jfields.to_string_id); in ff_AMediaFormat_toString()
740 if (ff_jni_exception_check(env, 1, NULL) < 0) { in ff_AMediaFormat_toString()
744 ret = ff_jni_jstring_to_utf_chars(env, description, format); in ff_AMediaFormat_toString()
747 (*env)->DeleteLocalRef(env, description); in ff_AMediaFormat_toString()
757 JNIEnv *env = NULL; in ff_AMediaFormat_getInt32() local
763 JNI_GET_ENV_OR_RETURN(env, format, 0); in ff_AMediaFormat_getInt32()
765 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_getInt32()
771 …contains_key = (*env)->CallBooleanMethod(env, format->object, format->jfields.contains_key_id, key… in ff_AMediaFormat_getInt32()
772 if (!contains_key || (ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getInt32()
777 *out = (*env)->CallIntMethod(env, format->object, format->jfields.get_integer_id, key); in ff_AMediaFormat_getInt32()
778 if ((ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getInt32()
786 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_getInt32()
796 JNIEnv *env = NULL; in ff_AMediaFormat_getInt64() local
802 JNI_GET_ENV_OR_RETURN(env, format, 0); in ff_AMediaFormat_getInt64()
804 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_getInt64()
810 …contains_key = (*env)->CallBooleanMethod(env, format->object, format->jfields.contains_key_id, key… in ff_AMediaFormat_getInt64()
811 if (!contains_key || (ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getInt64()
816 *out = (*env)->CallLongMethod(env, format->object, format->jfields.get_long_id, key); in ff_AMediaFormat_getInt64()
817 if ((ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getInt64()
825 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_getInt64()
835 JNIEnv *env = NULL; in ff_AMediaFormat_getFloat() local
841 JNI_GET_ENV_OR_RETURN(env, format, 0); in ff_AMediaFormat_getFloat()
843 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_getFloat()
849 …contains_key = (*env)->CallBooleanMethod(env, format->object, format->jfields.contains_key_id, key… in ff_AMediaFormat_getFloat()
850 if (!contains_key || (ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getFloat()
855 *out = (*env)->CallFloatMethod(env, format->object, format->jfields.get_float_id, key); in ff_AMediaFormat_getFloat()
856 if ((ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getFloat()
864 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_getFloat()
874 JNIEnv *env = NULL; in ff_AMediaFormat_getBuffer() local
881 JNI_GET_ENV_OR_RETURN(env, format, 0); in ff_AMediaFormat_getBuffer()
883 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_getBuffer()
889 …contains_key = (*env)->CallBooleanMethod(env, format->object, format->jfields.contains_key_id, key… in ff_AMediaFormat_getBuffer()
890 if (!contains_key || (ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getBuffer()
895 result = (*env)->CallObjectMethod(env, format->object, format->jfields.get_bytebuffer_id, key); in ff_AMediaFormat_getBuffer()
896 if ((ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getBuffer()
901 *data = (*env)->GetDirectBufferAddress(env, result); in ff_AMediaFormat_getBuffer()
902 *size = (*env)->GetDirectBufferCapacity(env, result); in ff_AMediaFormat_getBuffer()
918 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_getBuffer()
922 (*env)->DeleteLocalRef(env, result); in ff_AMediaFormat_getBuffer()
932 JNIEnv *env = NULL; in ff_AMediaFormat_getString() local
939 JNI_GET_ENV_OR_RETURN(env, format, 0); in ff_AMediaFormat_getString()
941 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_getString()
947 …contains_key = (*env)->CallBooleanMethod(env, format->object, format->jfields.contains_key_id, key… in ff_AMediaFormat_getString()
948 if (!contains_key || (ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getString()
953 result = (*env)->CallObjectMethod(env, format->object, format->jfields.get_string_id, key); in ff_AMediaFormat_getString()
954 if ((ret = ff_jni_exception_check(env, 1, format)) < 0) { in ff_AMediaFormat_getString()
959 *out = ff_jni_jstring_to_utf_chars(env, result, format); in ff_AMediaFormat_getString()
968 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_getString()
972 (*env)->DeleteLocalRef(env, result); in ff_AMediaFormat_getString()
980 JNIEnv *env = NULL; in ff_AMediaFormat_setInt32() local
985 JNI_GET_ENV_OR_RETURN_VOID(env, format); in ff_AMediaFormat_setInt32()
987 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_setInt32()
992 (*env)->CallVoidMethod(env, format->object, format->jfields.set_integer_id, key, value); in ff_AMediaFormat_setInt32()
993 if (ff_jni_exception_check(env, 1, format) < 0) { in ff_AMediaFormat_setInt32()
999 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_setInt32()
1005 JNIEnv *env = NULL; in ff_AMediaFormat_setInt64() local
1010 JNI_GET_ENV_OR_RETURN_VOID(env, format); in ff_AMediaFormat_setInt64()
1012 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_setInt64()
1017 (*env)->CallVoidMethod(env, format->object, format->jfields.set_long_id, key, value); in ff_AMediaFormat_setInt64()
1018 if (ff_jni_exception_check(env, 1, format) < 0) { in ff_AMediaFormat_setInt64()
1024 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_setInt64()
1030 JNIEnv *env = NULL; in ff_AMediaFormat_setFloat() local
1035 JNI_GET_ENV_OR_RETURN_VOID(env, format); in ff_AMediaFormat_setFloat()
1037 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_setFloat()
1042 (*env)->CallVoidMethod(env, format->object, format->jfields.set_float_id, key, value); in ff_AMediaFormat_setFloat()
1043 if (ff_jni_exception_check(env, 1, format) < 0) { in ff_AMediaFormat_setFloat()
1049 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_setFloat()
1055 JNIEnv *env = NULL; in ff_AMediaFormat_setString() local
1061 JNI_GET_ENV_OR_RETURN_VOID(env, format); in ff_AMediaFormat_setString()
1063 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_setString()
1068 string = ff_jni_utf_chars_to_jstring(env, value, format); in ff_AMediaFormat_setString()
1073 (*env)->CallVoidMethod(env, format->object, format->jfields.set_string_id, key, string); in ff_AMediaFormat_setString()
1074 if (ff_jni_exception_check(env, 1, format) < 0) { in ff_AMediaFormat_setString()
1080 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_setString()
1084 (*env)->DeleteLocalRef(env, string); in ff_AMediaFormat_setString()
1090 JNIEnv *env = NULL; in ff_AMediaFormat_setBuffer() local
1097 JNI_GET_ENV_OR_RETURN_VOID(env, format); in ff_AMediaFormat_setBuffer()
1099 key = ff_jni_utf_chars_to_jstring(env, name, format); in ff_AMediaFormat_setBuffer()
1115 buffer = (*env)->NewDirectByteBuffer(env, buffer_data, size); in ff_AMediaFormat_setBuffer()
1120 (*env)->CallVoidMethod(env, format->object, format->jfields.set_bytebuffer_id, key, buffer); in ff_AMediaFormat_setBuffer()
1121 if (ff_jni_exception_check(env, 1, format) < 0) { in ff_AMediaFormat_setBuffer()
1127 (*env)->DeleteLocalRef(env, key); in ff_AMediaFormat_setBuffer()
1131 (*env)->DeleteLocalRef(env, buffer); in ff_AMediaFormat_setBuffer()
1138 JNIEnv *env = NULL; in codec_init_static_fields() local
1140 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in codec_init_static_fields()
1142 …codec->INFO_TRY_AGAIN_LATER = (*env)->GetStaticIntField(env, codec->jfields.mediacodec_class, code… in codec_init_static_fields()
1143 if ((ret = ff_jni_exception_check(env, 1, codec)) < 0) { in codec_init_static_fields()
1147 …codec->BUFFER_FLAG_CODEC_CONFIG = (*env)->GetStaticIntField(env, codec->jfields.mediacodec_class, … in codec_init_static_fields()
1148 if ((ret = ff_jni_exception_check(env, 1, codec)) < 0) { in codec_init_static_fields()
1152 …codec->BUFFER_FLAG_END_OF_STREAM = (*env)->GetStaticIntField(env, codec->jfields.mediacodec_class,… in codec_init_static_fields()
1153 if ((ret = ff_jni_exception_check(env, 1, codec)) < 0) { in codec_init_static_fields()
1157 if (codec->jfields.buffer_flag_key_frame_id) { in codec_init_static_fields()
1158 …codec->BUFFER_FLAG_KEY_FRAME = (*env)->GetStaticIntField(env, codec->jfields.mediacodec_class, cod… in codec_init_static_fields()
1159 if ((ret = ff_jni_exception_check(env, 1, codec)) < 0) { in codec_init_static_fields()
1164 …codec->CONFIGURE_FLAG_ENCODE = (*env)->GetStaticIntField(env, codec->jfields.mediacodec_class, cod… in codec_init_static_fields()
1165 if ((ret = ff_jni_exception_check(env, 1, codec)) < 0) { in codec_init_static_fields()
1169 …codec->INFO_TRY_AGAIN_LATER = (*env)->GetStaticIntField(env, codec->jfields.mediacodec_class, code… in codec_init_static_fields()
1170 if ((ret = ff_jni_exception_check(env, 1, codec)) < 0) { in codec_init_static_fields()
1174 …codec->INFO_OUTPUT_BUFFERS_CHANGED = (*env)->GetStaticIntField(env, codec->jfields.mediacodec_clas… in codec_init_static_fields()
1175 if ((ret = ff_jni_exception_check(env, 1, codec)) < 0) { in codec_init_static_fields()
1179 …codec->INFO_OUTPUT_FORMAT_CHANGED = (*env)->GetStaticIntField(env, codec->jfields.mediacodec_class… in codec_init_static_fields()
1180 if ((ret = ff_jni_exception_check(env, 1, codec)) < 0) { in codec_init_static_fields()
1195 int ret = -1; in codec_create()
1196 JNIEnv *env = NULL; in codec_create() local
1207 codec->class = &amediacodec_class; in codec_create()
1209 env = ff_jni_get_env(codec); in codec_create()
1210 if (!env) { in codec_create()
1215 if (ff_jni_init_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec) < 0) { in codec_create()
1219 jarg = ff_jni_utf_chars_to_jstring(env, arg, codec); in codec_create()
1225 case CREATE_CODEC_BY_NAME: create_id = codec->jfields.create_by_codec_name_id; break; in codec_create()
1226 case CREATE_DECODER_BY_TYPE: create_id = codec->jfields.create_decoder_by_type_id; break; in codec_create()
1227 case CREATE_ENCODER_BY_TYPE: create_id = codec->jfields.create_encoder_by_type_id; break; in codec_create()
1232 object = (*env)->CallStaticObjectMethod(env, in codec_create()
1233 codec->jfields.mediacodec_class, in codec_create()
1236 if (ff_jni_exception_check(env, 1, codec) < 0) { in codec_create()
1240 codec->object = (*env)->NewGlobalRef(env, object); in codec_create()
1241 if (!codec->object) { in codec_create()
1249 if (codec->jfields.get_input_buffer_id && codec->jfields.get_output_buffer_id) { in codec_create()
1250 codec->has_get_i_o_buffer = 1; in codec_create()
1253 buffer_info = (*env)->NewObject(env, codec->jfields.mediainfo_class, codec->jfields.init_id); in codec_create()
1254 if (ff_jni_exception_check(env, 1, codec) < 0) { in codec_create()
1258 codec->buffer_info = (*env)->NewGlobalRef(env, buffer_info); in codec_create()
1259 if (!codec->buffer_info) { in codec_create()
1266 (*env)->DeleteLocalRef(env, jarg); in codec_create()
1270 (*env)->DeleteLocalRef(env, object); in codec_create()
1274 (*env)->DeleteLocalRef(env, buffer_info); in codec_create()
1278 if (codec->object) { in codec_create()
1279 (*env)->DeleteGlobalRef(env, codec->object); in codec_create()
1282 if (codec->buffer_info) { in codec_create()
1283 (*env)->DeleteGlobalRef(env, codec->buffer_info); in codec_create()
1286 ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec); in codec_create()
1307 JNIEnv *env = NULL; in DECLARE_FF_AMEDIACODEC_CREATE_FUNC() local
1313 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1315 (*env)->CallVoidMethod(env, codec->object, codec->jfields.release_id); in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1316 if (ff_jni_exception_check(env, 1, codec) < 0) { in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1320 (*env)->DeleteGlobalRef(env, codec->input_buffers); in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1321 codec->input_buffers = NULL; in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1323 (*env)->DeleteGlobalRef(env, codec->output_buffers); in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1324 codec->output_buffers = NULL; in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1326 (*env)->DeleteGlobalRef(env, codec->object); in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1327 codec->object = NULL; in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1329 (*env)->DeleteGlobalRef(env, codec->buffer_info); in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1330 codec->buffer_info = NULL; in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1332 ff_jni_reset_jfields(env, &codec->jfields, jni_amediacodec_mapping, 1, codec); in DECLARE_FF_AMEDIACODEC_CREATE_FUNC()
1342 JNIEnv *env = NULL; in ff_AMediaCodec_getName() local
1345 JNI_GET_ENV_OR_RETURN(env, codec, NULL); in ff_AMediaCodec_getName()
1347 name = (*env)->CallObjectMethod(env, codec->object, codec->jfields.get_name_id); in ff_AMediaCodec_getName()
1348 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getName()
1352 ret = ff_jni_jstring_to_utf_chars(env, name, codec); in ff_AMediaCodec_getName()
1356 (*env)->DeleteLocalRef(env, name); in ff_AMediaCodec_getName()
1365 JNIEnv *env = NULL; in ff_AMediaCodec_configure() local
1367 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in ff_AMediaCodec_configure()
1369 …(*env)->CallVoidMethod(env, codec->object, codec->jfields.configure_id, format->object, surface, N… in ff_AMediaCodec_configure()
1370 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_configure()
1382 JNIEnv *env = NULL; in ff_AMediaCodec_start() local
1384 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in ff_AMediaCodec_start()
1386 (*env)->CallVoidMethod(env, codec->object, codec->jfields.start_id); in ff_AMediaCodec_start()
1387 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_start()
1399 JNIEnv *env = NULL; in ff_AMediaCodec_stop() local
1401 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in ff_AMediaCodec_stop()
1403 (*env)->CallVoidMethod(env, codec->object, codec->jfields.stop_id); in ff_AMediaCodec_stop()
1404 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_stop()
1416 JNIEnv *env = NULL; in ff_AMediaCodec_flush() local
1418 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in ff_AMediaCodec_flush()
1420 (*env)->CallVoidMethod(env, codec->object, codec->jfields.flush_id); in ff_AMediaCodec_flush()
1421 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_flush()
1433 JNIEnv *env = NULL; in ff_AMediaCodec_releaseOutputBuffer() local
1435 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in ff_AMediaCodec_releaseOutputBuffer()
1437 …(*env)->CallVoidMethod(env, codec->object, codec->jfields.release_output_buffer_id, (jint)idx, (jb… in ff_AMediaCodec_releaseOutputBuffer()
1438 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_releaseOutputBuffer()
1450 JNIEnv *env = NULL; in ff_AMediaCodec_releaseOutputBufferAtTime() local
1452 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in ff_AMediaCodec_releaseOutputBufferAtTime()
1454 …(*env)->CallVoidMethod(env, codec->object, codec->jfields.release_output_buffer_at_time_id, (jint)… in ff_AMediaCodec_releaseOutputBufferAtTime()
1455 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_releaseOutputBufferAtTime()
1467 JNIEnv *env = NULL; in ff_AMediaCodec_dequeueInputBuffer() local
1469 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in ff_AMediaCodec_dequeueInputBuffer()
1471 …ret = (*env)->CallIntMethod(env, codec->object, codec->jfields.dequeue_input_buffer_id, timeoutUs); in ff_AMediaCodec_dequeueInputBuffer()
1472 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_dequeueInputBuffer()
1484 JNIEnv *env = NULL; in ff_AMediaCodec_queueInputBuffer() local
1486 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in ff_AMediaCodec_queueInputBuffer()
1488 …(*env)->CallVoidMethod(env, codec->object, codec->jfields.queue_input_buffer_id, (jint)idx, (jint)… in ff_AMediaCodec_queueInputBuffer()
1489 if ((ret = ff_jni_exception_check(env, 1, codec)) < 0) { in ff_AMediaCodec_queueInputBuffer()
1501 JNIEnv *env = NULL; in ff_AMediaCodec_dequeueOutputBuffer() local
1503 JNI_GET_ENV_OR_RETURN(env, codec, AVERROR_EXTERNAL); in ff_AMediaCodec_dequeueOutputBuffer()
1505 …ret = (*env)->CallIntMethod(env, codec->object, codec->jfields.dequeue_output_buffer_id, codec->bu… in ff_AMediaCodec_dequeueOutputBuffer()
1506 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_dequeueOutputBuffer()
1510 info->flags = (*env)->GetIntField(env, codec->buffer_info, codec->jfields.flags_id); in ff_AMediaCodec_dequeueOutputBuffer()
1511 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_dequeueOutputBuffer()
1515 info->offset = (*env)->GetIntField(env, codec->buffer_info, codec->jfields.offset_id); in ff_AMediaCodec_dequeueOutputBuffer()
1516 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_dequeueOutputBuffer()
1520 …info->presentationTimeUs = (*env)->GetLongField(env, codec->buffer_info, codec->jfields.presentati… in ff_AMediaCodec_dequeueOutputBuffer()
1521 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_dequeueOutputBuffer()
1525 info->size = (*env)->GetIntField(env, codec->buffer_info, codec->jfields.size_id); in ff_AMediaCodec_dequeueOutputBuffer()
1526 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_dequeueOutputBuffer()
1536 JNIEnv *env = NULL; in ff_AMediaCodec_getInputBuffer() local
1541 JNI_GET_ENV_OR_RETURN(env, codec, NULL); in ff_AMediaCodec_getInputBuffer()
1543 if (codec->has_get_i_o_buffer) { in ff_AMediaCodec_getInputBuffer()
1544 …buffer = (*env)->CallObjectMethod(env, codec->object, codec->jfields.get_input_buffer_id, (jint)id… in ff_AMediaCodec_getInputBuffer()
1545 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getInputBuffer()
1549 if (!codec->input_buffers) { in ff_AMediaCodec_getInputBuffer()
1550 … input_buffers = (*env)->CallObjectMethod(env, codec->object, codec->jfields.get_input_buffers_id); in ff_AMediaCodec_getInputBuffer()
1551 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getInputBuffer()
1555 codec->input_buffers = (*env)->NewGlobalRef(env, input_buffers); in ff_AMediaCodec_getInputBuffer()
1556 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getInputBuffer()
1561 buffer = (*env)->GetObjectArrayElement(env, codec->input_buffers, idx); in ff_AMediaCodec_getInputBuffer()
1562 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getInputBuffer()
1567 ret = (*env)->GetDirectBufferAddress(env, buffer); in ff_AMediaCodec_getInputBuffer()
1568 *out_size = (*env)->GetDirectBufferCapacity(env, buffer); in ff_AMediaCodec_getInputBuffer()
1571 (*env)->DeleteLocalRef(env, buffer); in ff_AMediaCodec_getInputBuffer()
1575 (*env)->DeleteLocalRef(env, input_buffers); in ff_AMediaCodec_getInputBuffer()
1584 JNIEnv *env = NULL; in ff_AMediaCodec_getOutputBuffer() local
1589 JNI_GET_ENV_OR_RETURN(env, codec, NULL); in ff_AMediaCodec_getOutputBuffer()
1591 if (codec->has_get_i_o_buffer) { in ff_AMediaCodec_getOutputBuffer()
1592 …buffer = (*env)->CallObjectMethod(env, codec->object, codec->jfields.get_output_buffer_id, (jint)i… in ff_AMediaCodec_getOutputBuffer()
1593 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getOutputBuffer()
1597 if (!codec->output_buffers) { in ff_AMediaCodec_getOutputBuffer()
1598 …output_buffers = (*env)->CallObjectMethod(env, codec->object, codec->jfields.get_output_buffers_id… in ff_AMediaCodec_getOutputBuffer()
1599 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getOutputBuffer()
1603 codec->output_buffers = (*env)->NewGlobalRef(env, output_buffers); in ff_AMediaCodec_getOutputBuffer()
1604 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getOutputBuffer()
1609 buffer = (*env)->GetObjectArrayElement(env, codec->output_buffers, idx); in ff_AMediaCodec_getOutputBuffer()
1610 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getOutputBuffer()
1615 ret = (*env)->GetDirectBufferAddress(env, buffer); in ff_AMediaCodec_getOutputBuffer()
1616 *out_size = (*env)->GetDirectBufferCapacity(env, buffer); in ff_AMediaCodec_getOutputBuffer()
1619 (*env)->DeleteLocalRef(env, buffer); in ff_AMediaCodec_getOutputBuffer()
1623 (*env)->DeleteLocalRef(env, output_buffers); in ff_AMediaCodec_getOutputBuffer()
1632 JNIEnv *env = NULL; in ff_AMediaCodec_getOutputFormat() local
1636 JNI_GET_ENV_OR_RETURN(env, codec, NULL); in ff_AMediaCodec_getOutputFormat()
1638 mediaformat = (*env)->CallObjectMethod(env, codec->object, codec->jfields.get_output_format_id); in ff_AMediaCodec_getOutputFormat()
1639 if (ff_jni_exception_check(env, 1, codec) < 0) { in ff_AMediaCodec_getOutputFormat()
1646 (*env)->DeleteLocalRef(env, mediaformat); in ff_AMediaCodec_getOutputFormat()
1654 return idx == codec->INFO_TRY_AGAIN_LATER; in ff_AMediaCodec_infoTryAgainLater()
1659 return idx == codec->INFO_OUTPUT_BUFFERS_CHANGED; in ff_AMediaCodec_infoOutputBuffersChanged()
1664 return idx == codec->INFO_OUTPUT_FORMAT_CHANGED; in ff_AMediaCodec_infoOutputFormatChanged()
1669 return codec->BUFFER_FLAG_CODEC_CONFIG; in ff_AMediaCodec_getBufferFlagCodecConfig()
1674 return codec->BUFFER_FLAG_END_OF_STREAM; in ff_AMediaCodec_getBufferFlagEndOfStream()
1679 return codec->BUFFER_FLAG_KEY_FRAME; in ff_AMediaCodec_getBufferFlagKeyFrame()
1684 return codec->CONFIGURE_FLAG_ENCODE; in ff_AMediaCodec_getConfigureFlagEncode()
1691 if (!codec->has_get_i_o_buffer) { in ff_AMediaCodec_cleanOutputBuffers()
1692 if (codec->output_buffers) { in ff_AMediaCodec_cleanOutputBuffers()
1693 JNIEnv *env = NULL; in ff_AMediaCodec_cleanOutputBuffers() local
1695 env = ff_jni_get_env(codec); in ff_AMediaCodec_cleanOutputBuffers()
1696 if (!env) { in ff_AMediaCodec_cleanOutputBuffers()
1701 (*env)->DeleteGlobalRef(env, codec->output_buffers); in ff_AMediaCodec_cleanOutputBuffers()
1702 codec->output_buffers = NULL; in ff_AMediaCodec_cleanOutputBuffers()
1712 int ret = -1; in ff_Build_SDK_INT()
1713 JNIEnv *env = NULL; in ff_Build_SDK_INT() local
1716 JNI_GET_ENV_OR_RETURN(env, avctx, -1); in ff_Build_SDK_INT()
1718 versionClass = (*env)->FindClass(env, "android/os/Build$VERSION"); in ff_Build_SDK_INT()
1719 sdkIntFieldID = (*env)->GetStaticFieldID(env, versionClass, "SDK_INT", "I"); in ff_Build_SDK_INT()
1720 ret = (*env)->GetStaticIntField(env, versionClass, sdkIntFieldID); in ff_Build_SDK_INT()
1721 (*env)->DeleteLocalRef(env, versionClass); in ff_Build_SDK_INT()