FFmpeg
|
#include <jni.h>
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/avstring.h"
#include "avcodec.h"
#include "ffjni.h"
#include "version.h"
#include "mediacodec_wrapper.h"
Go to the source code of this file.
Data Structures | |
struct | JNIAMediaCodecListFields |
struct | JNIAMediaFormatFields |
struct | FFAMediaFormat |
struct | JNIAMediaCodecFields |
struct | FFAMediaCodec |
Macros | |
#define | JNI_ATTACH_ENV_OR_RETURN(env, attached, log_ctx, ret) |
#define | JNI_ATTACH_ENV_OR_RETURN_VOID(env, attached, log_ctx) |
#define | JNI_DETACH_ENV(attached, log_ctx) |
Variables | |
struct JNIAMediaCodecListFields | JNIAMediaCodecListFields |
static const struct FFJniField | jni_amediacodeclist_mapping [] |
struct JNIAMediaFormatFields | JNIAMediaFormatFields |
static const struct FFJniField | jni_amediaformat_mapping [] |
static const AVClass | amediaformat_class |
struct JNIAMediaCodecFields | JNIAMediaCodecFields |
static const struct FFJniField | jni_amediacodec_mapping [] |
static const AVClass | amediacodec_class |
#define JNI_ATTACH_ENV_OR_RETURN | ( | env, | |
attached, | |||
log_ctx, | |||
ret | |||
) |
Definition at line 286 of file mediacodec_wrapper.c.
Referenced by codec_init_static_fields(), ff_AMediaCodec_configure(), ff_AMediaCodec_delete(), ff_AMediaCodec_dequeueInputBuffer(), ff_AMediaCodec_dequeueOutputBuffer(), ff_AMediaCodec_flush(), ff_AMediaCodec_getInputBuffer(), ff_AMediaCodec_getName(), ff_AMediaCodec_getOutputBuffer(), ff_AMediaCodec_getOutputFormat(), ff_AMediaCodec_queueInputBuffer(), ff_AMediaCodec_releaseOutputBuffer(), ff_AMediaCodec_releaseOutputBufferAtTime(), ff_AMediaCodec_start(), ff_AMediaCodec_stop(), ff_AMediaCodecList_getCodecNameByType(), ff_AMediaCodecProfile_getProfileFromAVCodecContext(), ff_AMediaFormat_delete(), ff_AMediaFormat_getBuffer(), ff_AMediaFormat_getFloat(), ff_AMediaFormat_getInt32(), ff_AMediaFormat_getInt64(), ff_AMediaFormat_getString(), and ff_AMediaFormat_toString().
#define JNI_ATTACH_ENV_OR_RETURN_VOID | ( | env, | |
attached, | |||
log_ctx | |||
) |
Definition at line 293 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormat_setBuffer(), ff_AMediaFormat_setFloat(), ff_AMediaFormat_setInt32(), ff_AMediaFormat_setInt64(), and ff_AMediaFormat_setString().
#define JNI_DETACH_ENV | ( | attached, | |
log_ctx | |||
) |
Definition at line 300 of file mediacodec_wrapper.c.
Referenced by codec_init_static_fields(), ff_AMediaCodec_cleanOutputBuffers(), ff_AMediaCodec_configure(), ff_AMediaCodec_createCodecByName(), ff_AMediaCodec_createDecoderByType(), ff_AMediaCodec_createEncoderByType(), ff_AMediaCodec_delete(), ff_AMediaCodec_dequeueInputBuffer(), ff_AMediaCodec_dequeueOutputBuffer(), ff_AMediaCodec_flush(), ff_AMediaCodec_getInputBuffer(), ff_AMediaCodec_getName(), ff_AMediaCodec_getOutputBuffer(), ff_AMediaCodec_getOutputFormat(), ff_AMediaCodec_queueInputBuffer(), ff_AMediaCodec_releaseOutputBuffer(), ff_AMediaCodec_releaseOutputBufferAtTime(), ff_AMediaCodec_start(), ff_AMediaCodec_stop(), ff_AMediaCodecList_getCodecNameByType(), ff_AMediaCodecProfile_getProfileFromAVCodecContext(), ff_AMediaFormat_delete(), ff_AMediaFormat_getBuffer(), ff_AMediaFormat_getFloat(), ff_AMediaFormat_getInt32(), ff_AMediaFormat_getInt64(), ff_AMediaFormat_getString(), ff_AMediaFormat_new(), ff_AMediaFormat_newFromObject(), ff_AMediaFormat_setBuffer(), ff_AMediaFormat_setFloat(), ff_AMediaFormat_setInt32(), ff_AMediaFormat_setInt64(), ff_AMediaFormat_setString(), and ff_AMediaFormat_toString().
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 retreive 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 307 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_init().
char* ff_AMediaCodecList_getCodecNameByType | ( | const char * | mime, |
int | profile, | ||
int | encoder, | ||
void * | log_ctx | ||
) |
Definition at line 370 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_init().
FFAMediaFormat* ff_AMediaFormat_new | ( | void | ) |
Definition at line 600 of file mediacodec_wrapper.c.
Referenced by mediacodec_decode_init().
|
static |
Definition at line 645 of file mediacodec_wrapper.c.
Referenced by ff_AMediaCodec_getOutputFormat().
int ff_AMediaFormat_delete | ( | FFAMediaFormat * | format | ) |
Definition at line 685 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_close(), ff_mediacodec_dec_decode(), and mediacodec_decode_init().
char* ff_AMediaFormat_toString | ( | FFAMediaFormat * | format | ) |
Definition at line 710 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode(), ff_mediacodec_dec_init(), and mediacodec_dec_parse_format().
int ff_AMediaFormat_getInt32 | ( | FFAMediaFormat * | format, |
const char * | name, | ||
int32_t * | out | ||
) |
Definition at line 739 of file mediacodec_wrapper.c.
Referenced by mediacodec_dec_parse_format().
int ff_AMediaFormat_getInt64 | ( | FFAMediaFormat * | format, |
const char * | name, | ||
int64_t * | out | ||
) |
Definition at line 774 of file mediacodec_wrapper.c.
int ff_AMediaFormat_getFloat | ( | FFAMediaFormat * | format, |
const char * | name, | ||
float * | out | ||
) |
Definition at line 809 of file mediacodec_wrapper.c.
int ff_AMediaFormat_getBuffer | ( | FFAMediaFormat * | format, |
const char * | name, | ||
void ** | data, | ||
size_t * | size | ||
) |
Definition at line 844 of file mediacodec_wrapper.c.
int ff_AMediaFormat_getString | ( | FFAMediaFormat * | format, |
const char * | name, | ||
const char ** | out | ||
) |
Definition at line 898 of file mediacodec_wrapper.c.
void ff_AMediaFormat_setInt32 | ( | FFAMediaFormat * | format, |
const char * | name, | ||
int32_t | value | ||
) |
Definition at line 944 of file mediacodec_wrapper.c.
Referenced by mediacodec_decode_init().
void ff_AMediaFormat_setInt64 | ( | FFAMediaFormat * | format, |
const char * | name, | ||
int64_t | value | ||
) |
Definition at line 972 of file mediacodec_wrapper.c.
void ff_AMediaFormat_setFloat | ( | FFAMediaFormat * | format, |
const char * | name, | ||
float | value | ||
) |
Definition at line 1000 of file mediacodec_wrapper.c.
void ff_AMediaFormat_setString | ( | FFAMediaFormat * | format, |
const char * | name, | ||
const char * | value | ||
) |
Definition at line 1028 of file mediacodec_wrapper.c.
Referenced by mediacodec_decode_init().
void ff_AMediaFormat_setBuffer | ( | FFAMediaFormat * | format, |
const char * | name, | ||
void * | data, | ||
size_t | size | ||
) |
Definition at line 1066 of file mediacodec_wrapper.c.
Referenced by mediacodec_decode_init().
|
static |
Definition at line 1116 of file mediacodec_wrapper.c.
Referenced by ff_AMediaCodec_createCodecByName(), ff_AMediaCodec_createDecoderByType(), and ff_AMediaCodec_createEncoderByType().
FFAMediaCodec* ff_AMediaCodec_createCodecByName | ( | const char * | name | ) |
Definition at line 1172 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_init().
FFAMediaCodec* ff_AMediaCodec_createDecoderByType | ( | const char * | mime | ) |
Definition at line 1235 of file mediacodec_wrapper.c.
FFAMediaCodec* ff_AMediaCodec_createEncoderByType | ( | const char * | mime | ) |
Definition at line 1298 of file mediacodec_wrapper.c.
int ff_AMediaCodec_delete | ( | FFAMediaCodec * | codec | ) |
Definition at line 1361 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_close().
char* ff_AMediaCodec_getName | ( | FFAMediaCodec * | codec | ) |
Definition at line 1391 of file mediacodec_wrapper.c.
int ff_AMediaCodec_configure | ( | FFAMediaCodec * | codec, |
const FFAMediaFormat * | format, | ||
void * | surface, | ||
void * | crypto, | ||
uint32_t | flags | ||
) |
Definition at line 1413 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_init().
int ff_AMediaCodec_start | ( | FFAMediaCodec * | codec | ) |
Definition at line 1436 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_init().
int ff_AMediaCodec_stop | ( | FFAMediaCodec * | codec | ) |
Definition at line 1456 of file mediacodec_wrapper.c.
int ff_AMediaCodec_flush | ( | FFAMediaCodec * | codec | ) |
Definition at line 1476 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_flush().
int ff_AMediaCodec_releaseOutputBuffer | ( | FFAMediaCodec * | codec, |
size_t | idx, | ||
int | render | ||
) |
Definition at line 1496 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode(), and mediacodec_wrap_buffer().
int ff_AMediaCodec_releaseOutputBufferAtTime | ( | FFAMediaCodec * | codec, |
size_t | idx, | ||
int64_t | timestampNs | ||
) |
Definition at line 1516 of file mediacodec_wrapper.c.
ssize_t ff_AMediaCodec_dequeueInputBuffer | ( | FFAMediaCodec * | codec, |
int64_t | timeoutUs | ||
) |
Definition at line 1536 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
int ff_AMediaCodec_queueInputBuffer | ( | FFAMediaCodec * | codec, |
size_t | idx, | ||
off_t | offset, | ||
size_t | size, | ||
uint64_t | time, | ||
uint32_t | flags | ||
) |
Definition at line 1556 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
ssize_t ff_AMediaCodec_dequeueOutputBuffer | ( | FFAMediaCodec * | codec, |
FFAMediaCodecBufferInfo * | info, | ||
int64_t | timeoutUs | ||
) |
Definition at line 1576 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
uint8_t* ff_AMediaCodec_getInputBuffer | ( | FFAMediaCodec * | codec, |
size_t | idx, | ||
size_t * | out_size | ||
) |
Definition at line 1631 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
uint8_t* ff_AMediaCodec_getOutputBuffer | ( | FFAMediaCodec * | codec, |
size_t | idx, | ||
size_t * | out_size | ||
) |
Definition at line 1677 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
FFAMediaFormat* ff_AMediaCodec_getOutputFormat | ( | FFAMediaCodec * | codec | ) |
Definition at line 1723 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode(), and ff_mediacodec_dec_init().
int ff_AMediaCodec_infoTryAgainLater | ( | FFAMediaCodec * | codec, |
ssize_t | idx | ||
) |
Definition at line 1749 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
int ff_AMediaCodec_infoOutputBuffersChanged | ( | FFAMediaCodec * | codec, |
ssize_t | idx | ||
) |
Definition at line 1754 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
int ff_AMediaCodec_infoOutputFormatChanged | ( | FFAMediaCodec * | codec, |
ssize_t | idx | ||
) |
Definition at line 1759 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
int ff_AMediaCodec_getBufferFlagCodecConfig | ( | FFAMediaCodec * | codec | ) |
Definition at line 1764 of file mediacodec_wrapper.c.
int ff_AMediaCodec_getBufferFlagEndOfStream | ( | FFAMediaCodec * | codec | ) |
Definition at line 1769 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
int ff_AMediaCodec_getBufferFlagKeyFrame | ( | FFAMediaCodec * | codec | ) |
Definition at line 1774 of file mediacodec_wrapper.c.
int ff_AMediaCodec_getConfigureFlagEncode | ( | FFAMediaCodec * | codec | ) |
Definition at line 1779 of file mediacodec_wrapper.c.
int ff_AMediaCodec_cleanOutputBuffers | ( | FFAMediaCodec * | codec | ) |
Definition at line 1784 of file mediacodec_wrapper.c.
Referenced by ff_mediacodec_dec_decode().
|
static |
Definition at line 67 of file mediacodec_wrapper.c.
|
static |
Definition at line 122 of file mediacodec_wrapper.c.
|
static |
Definition at line 144 of file mediacodec_wrapper.c.
Referenced by ff_AMediaFormat_new(), and ff_AMediaFormat_newFromObject().
|
static |
Definition at line 207 of file mediacodec_wrapper.c.
|
static |
Definition at line 256 of file mediacodec_wrapper.c.
Referenced by ff_AMediaCodec_createCodecByName(), ff_AMediaCodec_createDecoderByType(), and ff_AMediaCodec_createEncoderByType().