|
FFmpeg
|
#include <dlfcn.h>#include <jni.h>#include <stdbool.h>#include <media/NdkMediaFormat.h>#include <media/NdkMediaCodec.h>#include <android/native_window_jni.h>#include "libavutil/avassert.h"#include "libavutil/mem.h"#include "libavutil/avstring.h"#include "avcodec.h"#include "ffjni.h"#include "mediacodec_wrapper.h"Go to the source code of this file.
Data Structures | |
| struct | JNIAMediaCodecListFields |
| struct | JNIAMediaFormatFields |
| struct | FFAMediaFormatJni |
| struct | JNIAMediaCodecFields |
| struct | FFAMediaCodecJni |
| struct | FFAMediaFormatNdk |
| struct | FFAMediaCodecNdk |
Macros | |
| #define | OFFSET(x) |
| #define | OFFSET(x) |
| #define | OFFSET(x) |
| #define | JNI_GET_ENV_OR_RETURN(env, log_ctx, ret) |
| #define | JNI_GET_ENV_OR_RETURN_VOID(env, log_ctx) |
| #define | CREATE_CODEC_BY_NAME 0 |
| #define | CREATE_DECODER_BY_TYPE 1 |
| #define | CREATE_ENCODER_BY_TYPE 2 |
| #define | DECLARE_FF_AMEDIACODEC_CREATE_FUNC(name, method) |
| #define | GET_OPTIONAL_SYMBOL(sym) |
| #define | GET_SYMBOL(sym) |
| #define | DECLARE_NDK_AMEDIACODEC_CREATE_FUNC(name, method) |
| #define | MEDIACODEC_NDK_WRAPPER(method) |
Variables | ||
| static const struct FFJniField | jni_amediacodeclist_mapping [] | |
| static const struct FFJniField | jni_amediaformat_mapping [] | |
| static const AVClass | amediaformat_class | |
| static const FFAMediaFormat | media_format_jni | |
| static const struct FFJniField | jni_amediacodec_mapping [] | |
| static const AVClass | amediacodec_class | |
| static const FFAMediaCodec | media_codec_jni | |
| static const FFAMediaFormat | media_format_ndk | |
| static const FFAMediaCodec | media_codec_ndk | |
| static const AVClass | amediaformat_ndk_class | |
| static const AVClass | amediacodec_ndk_class | |
| struct { | ||
| enum FFAMediaFormatColorRange mf_range | ||
| enum AVColorRange range | ||
| } | color_range_map [] | |
| struct { | ||
| enum FFAMediaFormatColorStandard mf_standard | ||
| enum AVColorSpace space | ||
| } | color_space_map [] | |
| struct { | ||
| enum FFAMediaFormatColorStandard mf_standard | ||
| enum AVColorPrimaries primaries | ||
| } | color_primaries_map [] | |
| struct { | ||
| enum FFAMediaFormatColorTransfer mf_transfer | ||
| enum AVColorTransferCharacteristic transfer | ||
| } | color_transfer_map [] | |
| #define OFFSET | ( | x | ) |
Definition at line 63 of file mediacodec_wrapper.c.
| #define OFFSET | ( | x | ) |
Definition at line 63 of file mediacodec_wrapper.c.
| #define OFFSET | ( | x | ) |
Definition at line 63 of file mediacodec_wrapper.c.
| #define JNI_GET_ENV_OR_RETURN | ( | env, | |
| log_ctx, | |||
| ret ) |
Definition at line 309 of file mediacodec_wrapper.c.
Referenced by codec_init_static_fields(), ff_AMediaCodecList_getCodecNameByType(), ff_Build_SDK_INT(), mediacodec_jni_configure(), mediacodec_jni_delete(), mediacodec_jni_dequeueInputBuffer(), mediacodec_jni_dequeueOutputBuffer(), mediacodec_jni_flush(), mediacodec_jni_getInputBuffer(), mediacodec_jni_getName(), mediacodec_jni_getOutputBuffer(), mediacodec_jni_getOutputFormat(), mediacodec_jni_queueInputBuffer(), mediacodec_jni_releaseOutputBuffer(), mediacodec_jni_releaseOutputBufferAtTime(), mediacodec_jni_signalEndOfInputStream(), mediacodec_jni_start(), mediacodec_jni_stop(), mediacodec_ndk_configure(), mediaformat_jni_delete(), mediaformat_jni_getBuffer(), mediaformat_jni_getFloat(), mediaformat_jni_getInt32(), mediaformat_jni_getInt64(), mediaformat_jni_getString(), and mediaformat_jni_toString().
| #define JNI_GET_ENV_OR_RETURN_VOID | ( | env, | |
| log_ctx ) |
Definition at line 316 of file mediacodec_wrapper.c.
Referenced by mediaformat_jni_setBuffer(), mediaformat_jni_setFloat(), mediaformat_jni_setInt32(), mediaformat_jni_setInt64(), and mediaformat_jni_setString().
| #define CREATE_CODEC_BY_NAME 0 |
Definition at line 1310 of file mediacodec_wrapper.c.
Referenced by codec_create(), and ndk_codec_create().
| #define CREATE_DECODER_BY_TYPE 1 |
Definition at line 1311 of file mediacodec_wrapper.c.
Referenced by codec_create(), and ndk_codec_create().
| #define CREATE_ENCODER_BY_TYPE 2 |
Definition at line 1312 of file mediacodec_wrapper.c.
Referenced by codec_create(), and ndk_codec_create().
| #define DECLARE_FF_AMEDIACODEC_CREATE_FUNC | ( | name, | |
| method ) |
Definition at line 1401 of file mediacodec_wrapper.c.
| #define GET_OPTIONAL_SYMBOL | ( | sym | ) |
Referenced by mediaformat_ndk_create().
| #define GET_SYMBOL | ( | sym | ) |
Referenced by ndk_codec_create().
| #define DECLARE_NDK_AMEDIACODEC_CREATE_FUNC | ( | name, | |
| method ) |
Definition at line 2232 of file mediacodec_wrapper.c.
| #define MEDIACODEC_NDK_WRAPPER | ( | method | ) |
Definition at line 2322 of file mediacodec_wrapper.c.
| int ff_AMediaCodecProfile_getProfileFromAVCodecContext | ( | AVCodecContext * | avctx | ) |
The following API around MediaCodec and MediaFormat is based on the NDK one provided by Google since Android 5.0.
Differences from the NDK API:
Buffers returned by ff_AMediaFormat_toString and ff_AMediaFormat_getString are newly allocated buffer and must be freed by the user after use.
The MediaCrypto API is not implemented.
ff_AMediaCodec_infoTryAgainLater, ff_AMediaCodec_infoOutputBuffersChanged, ff_AMediaCodec_infoOutputFormatChanged, ff_AMediaCodec_cleanOutputBuffers ff_AMediaCodec_getName and ff_AMediaCodec_getBufferFlagEndOfStream are not part of the original NDK API and are convenience functions to hide JNI implementation.
The API around MediaCodecList is not part of the NDK (and is lacking as we still need to retrieve the codec name to work around faulty decoders and encoders).
For documentation, please refers to NdkMediaCodec.h NdkMediaFormat.h and http://developer.android.com/reference/android/media/MediaCodec.html.
Definition at line 323 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_get_video_codec(), and mediacodec_init().
| char * ff_AMediaCodecList_getCodecNameByType | ( | const char * | mime, |
| int | profile, | ||
| int | encoder, | ||
| void * | log_ctx ) |
Definition at line 484 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_get_video_codec().
|
static |
Definition at line 692 of file mediacodec_wrapper.c.
|
static |
Definition at line 735 of file mediacodec_wrapper.c.
Referenced by mediacodec_jni_getOutputFormat().
|
static |
Definition at line 770 of file mediacodec_wrapper.c.
|
static |
Definition at line 792 of file mediacodec_wrapper.c.
|
static |
Definition at line 815 of file mediacodec_wrapper.c.
|
static |
Definition at line 852 of file mediacodec_wrapper.c.
|
static |
Definition at line 889 of file mediacodec_wrapper.c.
|
static |
Definition at line 926 of file mediacodec_wrapper.c.
|
static |
Definition at line 1060 of file mediacodec_wrapper.c.
|
static |
Definition at line 1105 of file mediacodec_wrapper.c.
|
static |
Definition at line 1129 of file mediacodec_wrapper.c.
|
static |
Definition at line 1153 of file mediacodec_wrapper.c.
|
static |
Definition at line 1177 of file mediacodec_wrapper.c.
|
static |
Definition at line 1208 of file mediacodec_wrapper.c.
|
static |
Definition at line 1256 of file mediacodec_wrapper.c.
Referenced by codec_create().
|
inlinestatic |
Definition at line 1314 of file mediacodec_wrapper.c.
|
static |
Definition at line 1411 of file mediacodec_wrapper.c.
Referenced by mediacodec_jni_delete().
|
static |
Definition at line 1447 of file mediacodec_wrapper.c.
|
static |
Definition at line 1471 of file mediacodec_wrapper.c.
|
static |
Definition at line 1514 of file mediacodec_wrapper.c.
|
static |
Definition at line 1532 of file mediacodec_wrapper.c.
|
static |
Definition at line 1550 of file mediacodec_wrapper.c.
|
static |
Definition at line 1568 of file mediacodec_wrapper.c.
|
static |
Definition at line 1586 of file mediacodec_wrapper.c.
|
static |
Definition at line 1604 of file mediacodec_wrapper.c.
|
static |
Definition at line 1622 of file mediacodec_wrapper.c.
|
static |
Definition at line 1640 of file mediacodec_wrapper.c.
|
static |
Definition at line 1676 of file mediacodec_wrapper.c.
|
static |
Definition at line 1719 of file mediacodec_wrapper.c.
|
static |
Definition at line 1762 of file mediacodec_wrapper.c.
|
static |
Definition at line 1784 of file mediacodec_wrapper.c.
|
static |
Definition at line 1790 of file mediacodec_wrapper.c.
|
static |
Definition at line 1796 of file mediacodec_wrapper.c.
|
static |
Definition at line 1802 of file mediacodec_wrapper.c.
|
static |
Definition at line 1808 of file mediacodec_wrapper.c.
|
static |
Definition at line 1814 of file mediacodec_wrapper.c.
|
static |
Definition at line 1820 of file mediacodec_wrapper.c.
|
static |
Definition at line 1826 of file mediacodec_wrapper.c.
|
static |
Definition at line 1850 of file mediacodec_wrapper.c.
|
static |
Definition at line 1865 of file mediacodec_wrapper.c.
|
static |
Definition at line 1983 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_onError().
|
static |
Definition at line 2009 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_getOutputFormat(), mediacodec_ndk_onFormatChanged(), and mediaformat_ndk_new().
|
static |
Definition at line 2046 of file mediacodec_wrapper.c.
|
static |
Definition at line 2051 of file mediacodec_wrapper.c.
|
static |
Definition at line 2069 of file mediacodec_wrapper.c.
|
static |
Definition at line 2076 of file mediacodec_wrapper.c.
|
static |
Definition at line 2082 of file mediacodec_wrapper.c.
|
static |
Definition at line 2088 of file mediacodec_wrapper.c.
|
static |
Definition at line 2094 of file mediacodec_wrapper.c.
|
static |
Definition at line 2100 of file mediacodec_wrapper.c.
|
static |
Definition at line 2111 of file mediacodec_wrapper.c.
|
static |
Definition at line 2120 of file mediacodec_wrapper.c.
|
static |
Definition at line 2126 of file mediacodec_wrapper.c.
|
static |
Definition at line 2132 of file mediacodec_wrapper.c.
|
static |
Definition at line 2138 of file mediacodec_wrapper.c.
|
static |
Definition at line 2144 of file mediacodec_wrapper.c.
|
static |
Definition at line 2150 of file mediacodec_wrapper.c.
|
static |
Definition at line 2161 of file mediacodec_wrapper.c.
|
inlinestatic |
Definition at line 2181 of file mediacodec_wrapper.c.
|
static |
Definition at line 2242 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_delete().
|
static |
Definition at line 2263 of file mediacodec_wrapper.c.
|
static |
Definition at line 2340 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_getInputBuffer().
|
static |
Definition at line 2346 of file mediacodec_wrapper.c.
|
static |
Definition at line 2352 of file mediacodec_wrapper.c.
|
static |
Definition at line 2358 of file mediacodec_wrapper.c.
|
static |
Definition at line 2366 of file mediacodec_wrapper.c.
|
static |
Definition at line 2381 of file mediacodec_wrapper.c.
|
static |
Definition at line 2391 of file mediacodec_wrapper.c.
|
static |
Definition at line 2405 of file mediacodec_wrapper.c.
|
static |
Definition at line 2419 of file mediacodec_wrapper.c.
|
static |
Definition at line 2424 of file mediacodec_wrapper.c.
|
static |
Definition at line 2429 of file mediacodec_wrapper.c.
|
static |
Definition at line 2434 of file mediacodec_wrapper.c.
|
static |
Definition at line 2439 of file mediacodec_wrapper.c.
|
static |
Definition at line 2444 of file mediacodec_wrapper.c.
|
static |
Definition at line 2449 of file mediacodec_wrapper.c.
|
static |
Definition at line 2454 of file mediacodec_wrapper.c.
|
static |
Definition at line 2459 of file mediacodec_wrapper.c.
|
static |
Definition at line 2479 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_setAsyncNotifyCallback().
|
static |
Definition at line 2487 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_setAsyncNotifyCallback().
|
static |
Definition at line 2504 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_setAsyncNotifyCallback().
|
static |
Definition at line 2517 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_setAsyncNotifyCallback().
|
static |
Definition at line 2529 of file mediacodec_wrapper.c.
| FFAMediaFormat * ff_AMediaFormat_new | ( | int | ndk | ) |
Definition at line 2631 of file mediacodec_wrapper.c.
Referenced by mediacodec_decode_init(), and mediacodec_init().
| FFAMediaCodec * ff_AMediaCodec_createCodecByName | ( | const char * | name, |
| int | ndk ) |
Definition at line 2638 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_get_video_codec(), and mediacodec_init().
| FFAMediaCodec * ff_AMediaCodec_createDecoderByType | ( | const char * | mime_type, |
| int | ndk ) |
Definition at line 2645 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_get_audio_codec(), and mediacodec_dec_get_video_codec().
| FFAMediaCodec * ff_AMediaCodec_createEncoderByType | ( | const char * | mime_type, |
| int | ndk ) |
Definition at line 2652 of file mediacodec_wrapper.c.
Referenced by mediacodec_init().
| int ff_Build_SDK_INT | ( | AVCodecContext * | avctx | ) |
Definition at line 2659 of file mediacodec_wrapper.c.
Referenced by mediacodec_decode_init().
| enum AVColorRange ff_AMediaFormatColorRange_to_AVColorRange | ( | int | color_range | ) |
Map MediaFormat color range to AVColorRange.
return AVCOL_RANGE_UNSPECIFIED when failed.
Definition at line 2730 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_parse_video_format().
| int ff_AMediaFormatColorRange_from_AVColorRange | ( | enum AVColorRange | color_range | ) |
Map AVColorRange to MediaFormat color range.
return COLOR_RANGE_UNSPECIFIED when failed.
Definition at line 2739 of file mediacodec_wrapper.c.
Referenced by mediacodec_init().
| enum AVColorSpace ff_AMediaFormatColorStandard_to_AVColorSpace | ( | int | color_standard | ) |
Map MediaFormat color standard to AVColorSpace.
return AVCOL_SPC_UNSPECIFIED when failed.
Definition at line 2747 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_parse_video_format().
| int ff_AMediaFormatColorStandard_from_AVColorSpace | ( | enum AVColorSpace | color_space | ) |
Map AVColorSpace to MediaFormat color standard.
return COLOR_STANDARD_UNSPECIFIED when failed.
Definition at line 2756 of file mediacodec_wrapper.c.
Referenced by mediacodec_init().
| enum AVColorPrimaries ff_AMediaFormatColorStandard_to_AVColorPrimaries | ( | int | color_standard | ) |
Map MediaFormat color standard to AVColorPrimaries.
return AVCOL_PRI_UNSPECIFIED when failed.
Definition at line 2765 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_parse_video_format().
| enum AVColorTransferCharacteristic ff_AMediaFormatColorTransfer_to_AVColorTransfer | ( | int | color_transfer | ) |
Map MediaFormat color transfer to AVColorTransferCharacteristic.
return AVCOL_TRC_UNSPECIFIED when failed.
Definition at line 2775 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_parse_video_format().
| int ff_AMediaFormatColorTransfer_from_AVColorTransfer | ( | enum AVColorTransferCharacteristic | color_transfer | ) |
Map AVColorTransferCharacteristic to MediaFormat color transfer.
return COLOR_TRANSFER_UNSPECIFIED when failed.
Definition at line 2784 of file mediacodec_wrapper.c.
Referenced by mediacodec_init().
|
static |
Definition at line 64 of file mediacodec_wrapper.c.
Referenced by ff_AMediaCodecList_getCodecNameByType().
|
static |
Definition at line 123 of file mediacodec_wrapper.c.
Referenced by ff_AMediaCodecList_getCodecNameByType(), mediaformat_jni_delete(), mediaformat_jni_new(), and mediaformat_jni_newFromObject().
|
static |
Definition at line 155 of file mediacodec_wrapper.c.
|
static |
Definition at line 168 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormat_new(), mediaformat_jni_new(), and mediaformat_jni_newFromObject().
|
static |
Definition at line 224 of file mediacodec_wrapper.c.
Referenced by codec_create(), and mediacodec_jni_delete().
|
static |
Definition at line 277 of file mediacodec_wrapper.c.
|
static |
Definition at line 307 of file mediacodec_wrapper.c.
Referenced by codec_create(), ff_AMediaCodec_createCodecByName(), ff_AMediaCodec_createDecoderByType(), and ff_AMediaCodec_createEncoderByType().
|
static |
Definition at line 1968 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormat_new(), and mediaformat_ndk_create().
|
static |
Definition at line 1969 of file mediacodec_wrapper.c.
Referenced by ff_AMediaCodec_createCodecByName(), ff_AMediaCodec_createDecoderByType(), ff_AMediaCodec_createEncoderByType(), and ndk_codec_create().
|
static |
Definition at line 1971 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_configure(), and mediaformat_ndk_delete().
|
static |
Definition at line 1977 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_delete().
| enum FFAMediaFormatColorRange mf_range |
Definition at line 2693 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormatColorRange_to_AVColorRange().
| enum AVColorRange range |
Definition at line 2694 of file mediacodec_wrapper.c.
Referenced by ac_normalize(), adpcm_compress_trellis(), amf_read_surface_color(), amf_to_av_range(), aptx_process_subband(), arith2_get_number(), arith2_get_prob(), arith2_get_scaled_value(), arith2_rescale_interval(), arith_get_bits(), arith_get_number(), arith_get_prob(), av_color_range_name(), av_image_fill_black(), av_opt_freep_ranges(), av_opt_query_ranges_default(), aw_pulse_set2(), block_matching_multi(), calc_input_response(), calculate_mask_curve(), check_alpha_detect(), check_cast(), check_image_fill_black(), check_scale(), check_unpack(), check_write(), checkasm_randomize_range(), checkasm_randomize_rangef(), compute_kernel(), config_input(), config_input(), configure_video_device(), decode_audio_block(), decode_channel(), dirac_get_arith_bit(), draw_legend(), dshow_cycle_formats(), encode_q_branch(), extend_code(), fade_gain(), ff_all_color_ranges(), ff_AMediaFormatColorRange_from_AVColorRange(), ff_bgmc_decode(), ff_draw_init2(), ff_fix_long_mvs(), ff_fix_long_p_mvs(), ff_get_best_fcode(), ff_h263_encode_motion(), ffat_init_encoder(), fill16(), fill32(), fill32f(), fill8(), filter_channels(), find_image_range(), floor_encode(), floor_fit(), format_init(), g722_encode_trellis(), generate_scaling(), get_cabac_bypass(), get_cabac_bypass_sign(), get_cv_pixel_format(), get_fragment(), get_limits(), get_te0_golomb(), get_te_golomb(), map_av_range(), map_range(), mclms_update(), msmpeg4v2_encode_motion(), opus_rc_tell_frac(), output_gain(), parse_content_range(), parse_fmtp(), plot_channel_log(), process_callback(), put_rac(), range_map(), set_te_golomb(), start_request(), step_collect_psy_metrics(), sws_printVec2(), test_range(), update_input_arguments(), vorbis_floor1_decode(), vt_format_from_pixfmt(), x8_setup_spatial_compensation(), and x8_setup_spatial_predictor().
| struct { ... } color_range_map[] |
Referenced by ff_AMediaFormatColorRange_from_AVColorRange(), and ff_AMediaFormatColorRange_to_AVColorRange().
| enum FFAMediaFormatColorStandard mf_standard |
Definition at line 2701 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormatColorStandard_to_AVColorPrimaries(), and ff_AMediaFormatColorStandard_to_AVColorSpace().
| enum AVColorSpace space |
Definition at line 2702 of file mediacodec_wrapper.c.
Referenced by av_color_space_name(), av_map_videotoolbox_color_matrix_from_av(), dshow_cycle_formats(), ff_AMediaFormatColorStandard_from_AVColorSpace(), output_packet(), parse_answer(), qoi_decode_frame(), read_packet(), and write_callback().
| struct { ... } color_space_map[] |
Referenced by ff_AMediaFormatColorStandard_from_AVColorSpace(), and ff_AMediaFormatColorStandard_to_AVColorSpace().
| enum AVColorPrimaries primaries |
Definition at line 2712 of file mediacodec_wrapper.c.
Referenced by amf_read_surface_color(), av_color_primaries_name(), ff_fmt_from_frame(), ff_jpegxl_parse_codestream_header(), and format_init().
| struct { ... } color_primaries_map[] |
Referenced by ff_AMediaFormatColorStandard_to_AVColorPrimaries().
| enum FFAMediaFormatColorTransfer mf_transfer |
Definition at line 2721 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormatColorTransfer_to_AVColorTransfer().
| enum AVColorTransferCharacteristic transfer |
Definition at line 2722 of file mediacodec_wrapper.c.
Referenced by av_color_transfer_name(), ff_AMediaFormatColorTransfer_from_AVColorTransfer(), and format_init().
| struct { ... } color_transfer_map[] |
Referenced by ff_AMediaFormatColorTransfer_from_AVColorTransfer(), and ff_AMediaFormatColorTransfer_to_AVColorTransfer().