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 | 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) format->sym = dlsym(format->libmedia, "AMediaFormat_" #sym); |
#define | GET_SYMBOL(sym) |
#define | GET_SYMBOL(sym, required) |
#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 JNI_GET_ENV_OR_RETURN | ( | env, | |
log_ctx, | |||
ret | |||
) |
Definition at line 289 of file mediacodec_wrapper.c.
#define JNI_GET_ENV_OR_RETURN_VOID | ( | env, | |
log_ctx | |||
) |
Definition at line 296 of file mediacodec_wrapper.c.
#define CREATE_CODEC_BY_NAME 0 |
Definition at line 1273 of file mediacodec_wrapper.c.
#define CREATE_DECODER_BY_TYPE 1 |
Definition at line 1274 of file mediacodec_wrapper.c.
#define CREATE_ENCODER_BY_TYPE 2 |
Definition at line 1275 of file mediacodec_wrapper.c.
#define DECLARE_FF_AMEDIACODEC_CREATE_FUNC | ( | name, | |
method | |||
) |
Definition at line 1377 of file mediacodec_wrapper.c.
#define GET_SYMBOL | ( | sym | ) |
#define GET_SYMBOL | ( | sym, | |
required | |||
) |
#define DECLARE_NDK_AMEDIACODEC_CREATE_FUNC | ( | name, | |
method | |||
) |
Definition at line 2273 of file mediacodec_wrapper.c.
#define MEDIACODEC_NDK_WRAPPER | ( | method | ) |
Definition at line 2363 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 303 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_init(), and mediacodec_init().
char* ff_AMediaCodecList_getCodecNameByType | ( | const char * | mime, |
int | profile, | ||
int | encoder, | ||
void * | log_ctx | ||
) |
Definition at line 463 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_init().
|
static |
Definition at line 705 of file mediacodec_wrapper.c.
|
static |
Definition at line 750 of file mediacodec_wrapper.c.
Referenced by mediacodec_jni_getOutputFormat().
|
static |
Definition at line 785 of file mediacodec_wrapper.c.
|
static |
Definition at line 807 of file mediacodec_wrapper.c.
|
static |
Definition at line 832 of file mediacodec_wrapper.c.
|
static |
Definition at line 871 of file mediacodec_wrapper.c.
|
static |
Definition at line 910 of file mediacodec_wrapper.c.
|
static |
Definition at line 949 of file mediacodec_wrapper.c.
|
static |
Definition at line 1007 of file mediacodec_wrapper.c.
|
static |
Definition at line 1057 of file mediacodec_wrapper.c.
|
static |
Definition at line 1083 of file mediacodec_wrapper.c.
|
static |
Definition at line 1109 of file mediacodec_wrapper.c.
|
static |
Definition at line 1135 of file mediacodec_wrapper.c.
|
static |
Definition at line 1171 of file mediacodec_wrapper.c.
|
static |
Definition at line 1219 of file mediacodec_wrapper.c.
Referenced by codec_create().
|
inlinestatic |
Definition at line 1277 of file mediacodec_wrapper.c.
|
static |
Definition at line 1387 of file mediacodec_wrapper.c.
|
static |
Definition at line 1423 of file mediacodec_wrapper.c.
|
static |
Definition at line 1447 of file mediacodec_wrapper.c.
|
static |
Definition at line 1490 of file mediacodec_wrapper.c.
|
static |
Definition at line 1508 of file mediacodec_wrapper.c.
|
static |
Definition at line 1526 of file mediacodec_wrapper.c.
|
static |
Definition at line 1544 of file mediacodec_wrapper.c.
|
static |
Definition at line 1562 of file mediacodec_wrapper.c.
|
static |
Definition at line 1580 of file mediacodec_wrapper.c.
|
static |
Definition at line 1598 of file mediacodec_wrapper.c.
|
static |
Definition at line 1616 of file mediacodec_wrapper.c.
|
static |
Definition at line 1652 of file mediacodec_wrapper.c.
|
static |
Definition at line 1700 of file mediacodec_wrapper.c.
|
static |
Definition at line 1748 of file mediacodec_wrapper.c.
|
static |
Definition at line 1772 of file mediacodec_wrapper.c.
|
static |
Definition at line 1778 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 1838 of file mediacodec_wrapper.c.
|
static |
Definition at line 2002 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_getOutputFormat(), and mediaformat_ndk_new().
|
static |
Definition at line 2062 of file mediacodec_wrapper.c.
|
static |
Definition at line 2067 of file mediacodec_wrapper.c.
|
static |
Definition at line 2085 of file mediacodec_wrapper.c.
|
static |
Definition at line 2092 of file mediacodec_wrapper.c.
|
static |
Definition at line 2098 of file mediacodec_wrapper.c.
|
static |
Definition at line 2104 of file mediacodec_wrapper.c.
|
static |
Definition at line 2110 of file mediacodec_wrapper.c.
|
static |
Definition at line 2116 of file mediacodec_wrapper.c.
|
static |
Definition at line 2127 of file mediacodec_wrapper.c.
|
static |
Definition at line 2136 of file mediacodec_wrapper.c.
|
static |
Definition at line 2142 of file mediacodec_wrapper.c.
|
static |
Definition at line 2148 of file mediacodec_wrapper.c.
|
static |
Definition at line 2154 of file mediacodec_wrapper.c.
|
static |
Definition at line 2160 of file mediacodec_wrapper.c.
|
static |
Definition at line 2166 of file mediacodec_wrapper.c.
|
static |
Definition at line 2177 of file mediacodec_wrapper.c.
|
inlinestatic |
Definition at line 2197 of file mediacodec_wrapper.c.
|
static |
Definition at line 2283 of file mediacodec_wrapper.c.
|
static |
Definition at line 2304 of file mediacodec_wrapper.c.
|
static |
Definition at line 2381 of file mediacodec_wrapper.c.
|
static |
Definition at line 2387 of file mediacodec_wrapper.c.
|
static |
Definition at line 2393 of file mediacodec_wrapper.c.
|
static |
Definition at line 2399 of file mediacodec_wrapper.c.
|
static |
Definition at line 2407 of file mediacodec_wrapper.c.
|
static |
Definition at line 2422 of file mediacodec_wrapper.c.
|
static |
Definition at line 2432 of file mediacodec_wrapper.c.
|
static |
Definition at line 2446 of file mediacodec_wrapper.c.
|
static |
Definition at line 2460 of file mediacodec_wrapper.c.
|
static |
Definition at line 2465 of file mediacodec_wrapper.c.
|
static |
Definition at line 2470 of file mediacodec_wrapper.c.
|
static |
Definition at line 2475 of file mediacodec_wrapper.c.
|
static |
Definition at line 2480 of file mediacodec_wrapper.c.
|
static |
Definition at line 2485 of file mediacodec_wrapper.c.
|
static |
Definition at line 2490 of file mediacodec_wrapper.c.
|
static |
Definition at line 2495 of file mediacodec_wrapper.c.
|
static |
Definition at line 2500 of file mediacodec_wrapper.c.
FFAMediaFormat* ff_AMediaFormat_new | ( | int | ndk | ) |
Definition at line 2583 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 2590 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_init(), and mediacodec_init().
FFAMediaCodec* ff_AMediaCodec_createDecoderByType | ( | const char * | mime_type, |
int | ndk | ||
) |
Definition at line 2597 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_init().
FFAMediaCodec* ff_AMediaCodec_createEncoderByType | ( | const char * | mime_type, |
int | ndk | ||
) |
Definition at line 2604 of file mediacodec_wrapper.c.
Referenced by mediacodec_init().
int ff_Build_SDK_INT | ( | AVCodecContext * | avctx | ) |
Definition at line 2611 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 2682 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_parse_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 2691 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 2699 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_parse_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 2708 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 2717 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_parse_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 2727 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_parse_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 2736 of file mediacodec_wrapper.c.
Referenced by mediacodec_init().
|
static |
Definition at line 63 of file mediacodec_wrapper.c.
Referenced by ff_AMediaCodecList_getCodecNameByType().
|
static |
Definition at line 113 of file mediacodec_wrapper.c.
Referenced by ff_AMediaCodecList_getCodecNameByType(), mediaformat_jni_delete(), mediaformat_jni_new(), and mediaformat_jni_newFromObject().
|
static |
Definition at line 137 of file mediacodec_wrapper.c.
|
static |
Definition at line 150 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormat_new(), mediaformat_jni_new(), and mediaformat_jni_newFromObject().
|
static |
Definition at line 205 of file mediacodec_wrapper.c.
Referenced by codec_create(), and mediacodec_jni_delete().
|
static |
Definition at line 257 of file mediacodec_wrapper.c.
|
static |
Definition at line 287 of file mediacodec_wrapper.c.
Referenced by codec_create(), ff_AMediaCodec_createCodecByName(), ff_AMediaCodec_createDecoderByType(), and ff_AMediaCodec_createEncoderByType().
|
static |
Definition at line 1987 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormat_new(), and mediaformat_ndk_create().
|
static |
Definition at line 1988 of file mediacodec_wrapper.c.
Referenced by ff_AMediaCodec_createCodecByName(), ff_AMediaCodec_createDecoderByType(), ff_AMediaCodec_createEncoderByType(), and ndk_codec_create().
|
static |
Definition at line 1990 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_configure(), and mediaformat_ndk_delete().
|
static |
Definition at line 1996 of file mediacodec_wrapper.c.
Referenced by mediacodec_ndk_delete().
enum FFAMediaFormatColorRange mf_range |
Definition at line 2645 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormatColorRange_to_AVColorRange().
enum AVColorRange range |
Definition at line 2646 of file mediacodec_wrapper.c.
Referenced by ac_normalize(), adpcm_compress_trellis(), 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(), compute_kernel(), config_input(), configure_video_device(), decode_audio_block(), decode_channel(), dirac_get_arith_bit(), draw_legend(), dshow_cycle_formats(), extend_code(), fade_gain(), 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(), filter_channels(), find_image_range(), floor_encode(), floor_fit(), format_init(), g722_encode_trellis(), get_cabac_bypass(), get_cabac_bypass_sign(), get_cv_pixel_format(), get_Fragment(), get_limits(), get_te0_golomb(), get_te_golomb(), mclms_update(), msmpeg4v2_encode_motion(), opus_rc_tell_frac(), output_gain(), parse_fmtp(), plot_channel_log(), process_callback(), put_rac(), range_map(), set_te_golomb(), step_collect_psy_metrics(), sws_printVec2(), vorbis_floor1_decode(), 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 2653 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormatColorStandard_to_AVColorPrimaries(), and ff_AMediaFormatColorStandard_to_AVColorSpace().
enum AVColorSpace space |
Definition at line 2654 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormatColorStandard_from_AVColorSpace().
struct { ... } color_space_map[] |
Referenced by ff_AMediaFormatColorStandard_from_AVColorSpace(), and ff_AMediaFormatColorStandard_to_AVColorSpace().
enum AVColorPrimaries primaries |
Definition at line 2664 of file mediacodec_wrapper.c.
Referenced by av_color_primaries_name(), 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 2673 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormatColorTransfer_to_AVColorTransfer().
enum AVColorTransferCharacteristic transfer |
Definition at line 2674 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().