Media

#include <NdkImage.h>
#include <NdkImageReader.h>
#include <NdkMediaCodec.h>
#include <NdkMediaCrypto.h>
#include <NdkMediaDrm.h>
#include <NdkMediaError.h>
#include <NdkMediaExtractor.h>
#include <NdkMediaFormat.h>
#include <NdkMediaMuxer.h>

Summary

Enumerations

Anonymous Enum 121{
  AMEDIACODEC_BUFFER_FLAG_CODEC_CONFIG = 2,
  AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM = 4,
  AMEDIACODEC_BUFFER_FLAG_PARTIAL_FRAME = 8,
  AMEDIACODEC_CONFIGURE_FLAG_ENCODE = 1,
  AMEDIACODEC_INFO_OUTPUT_BUFFERS_CHANGED = -3,
  AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED = -2,
  AMEDIACODEC_INFO_TRY_AGAIN_LATER = -1
}
enum
Anonymous Enum 122{
  AMEDIAEXTRACTOR_SAMPLE_FLAG_SYNC = 1,
  AMEDIAEXTRACTOR_SAMPLE_FLAG_ENCRYPTED = 2
}
enum
AIMAGE_FORMATS{
  AIMAGE_FORMAT_RGBA_8888 = 0x1,
  AIMAGE_FORMAT_RGBX_8888 = 0x2,
  AIMAGE_FORMAT_RGB_888 = 0x3,
  AIMAGE_FORMAT_RGB_565 = 0x4,
  AIMAGE_FORMAT_RGBA_FP16 = 0x16,
  AIMAGE_FORMAT_YUV_420_888 = 0x23,
  AIMAGE_FORMAT_JPEG = 0x100,
  AIMAGE_FORMAT_RAW16 = 0x20,
  AIMAGE_FORMAT_RAW_PRIVATE = 0x24,
  AIMAGE_FORMAT_RAW10 = 0x25,
  AIMAGE_FORMAT_RAW12 = 0x26,
  AIMAGE_FORMAT_DEPTH16 = 0x44363159,
  AIMAGE_FORMAT_DEPTH_POINT_CLOUD = 0x101,
  AIMAGE_FORMAT_PRIVATE = 0x22,
  AIMAGE_FORMAT_Y8 = 0x20203859,
  AIMAGE_FORMAT_HEIC = 0x48454946,
  AIMAGE_FORMAT_DEPTH_JPEG = 0x69656963
}
enum
AImage supported formats: AImageReader only guarantees the support for the formats listed here.
AMediaDrmEventType{
  EVENT_PROVISION_REQUIRED = 1,
  EVENT_KEY_REQUIRED = 2,
  EVENT_KEY_EXPIRED = 3,
  EVENT_VENDOR_DEFINED = 4,
  EVENT_SESSION_RECLAIMED = 5
}
enum
AMediaDrmKeyRequestType{
  KEY_REQUEST_TYPE_INITIAL,
  KEY_REQUEST_TYPE_RENEWAL,
  KEY_REQUEST_TYPE_RELEASE,
  KEY_REQUEST_TYPE_NONE,
  KEY_REQUEST_TYPE_UPDATE
}
enum
Introduced in API 33.
AMediaDrmKeyType{
  KEY_TYPE_STREAMING = 1,
  KEY_TYPE_OFFLINE = 2,
  KEY_TYPE_RELEASE = 3
}
enum
AMediaKeyStatusType{
  KEY_STATUS_TYPE_USABLE,
  KEY_STATUS_TYPE_EXPIRED,
  KEY_STATUS_TYPE_OUTPUTNOTALLOWED,
  KEY_STATUS_TYPE_STATUSPENDING,
  KEY_STATUS_TYPE_INTERNALERROR
}
enum
AppendMode{
  AMEDIAMUXER_APPEND_IGNORE_LAST_VIDEO_GOP = 0,
  AMEDIAMUXER_APPEND_TO_EXISTING_DATA = 1
}
enum
OutputFormat{
  AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4 = 0,
  AMEDIAMUXER_OUTPUT_FORMAT_WEBM = 1,
  AMEDIAMUXER_OUTPUT_FORMAT_THREE_GPP = 2
}
enum
SeekMode{
  AMEDIAEXTRACTOR_SEEK_PREVIOUS_SYNC,
  AMEDIAEXTRACTOR_SEEK_NEXT_SYNC,
  AMEDIAEXTRACTOR_SEEK_CLOSEST_SYNC
}
enum
cryptoinfo_mode_t{
  AMEDIACODECRYPTOINFO_MODE_CLEAR = 0,
  AMEDIACODECRYPTOINFO_MODE_AES_CTR = 1,
  AMEDIACODECRYPTOINFO_MODE_AES_WV = 2,
  AMEDIACODECRYPTOINFO_MODE_AES_CBC = 3
}
enum
media_status_t{
  AMEDIA_OK = 0,
  AMEDIACODEC_ERROR_INSUFFICIENT_RESOURCE = 1100,
  AMEDIACODEC_ERROR_RECLAIMED = 1101,
  AMEDIA_ERROR_BASE = -10000,
  AMEDIA_ERROR_UNKNOWN = AMEDIA_ERROR_BASE,
  AMEDIA_ERROR_MALFORMED = AMEDIA_ERROR_BASE - 1,
  AMEDIA_ERROR_UNSUPPORTED = AMEDIA_ERROR_BASE - 2,
  AMEDIA_ERROR_INVALID_OBJECT = AMEDIA_ERROR_BASE - 3,
  AMEDIA_ERROR_INVALID_PARAMETER = AMEDIA_ERROR_BASE - 4,
  AMEDIA_ERROR_INVALID_OPERATION = AMEDIA_ERROR_BASE - 5,
  AMEDIA_ERROR_END_OF_STREAM = AMEDIA_ERROR_BASE - 6,
  AMEDIA_ERROR_IO = AMEDIA_ERROR_BASE - 7,
  AMEDIA_ERROR_WOULD_BLOCK = AMEDIA_ERROR_BASE - 8,
  AMEDIA_DRM_ERROR_BASE = -20000,
  AMEDIA_DRM_NOT_PROVISIONED = AMEDIA_DRM_ERROR_BASE - 1,
  AMEDIA_DRM_RESOURCE_BUSY = AMEDIA_DRM_ERROR_BASE - 2,
  AMEDIA_DRM_DEVICE_REVOKED = AMEDIA_DRM_ERROR_BASE - 3,
  AMEDIA_DRM_SHORT_BUFFER = AMEDIA_DRM_ERROR_BASE - 4,
  AMEDIA_DRM_SESSION_NOT_OPENED = AMEDIA_DRM_ERROR_BASE - 5,
  AMEDIA_DRM_TAMPER_DETECTED = AMEDIA_DRM_ERROR_BASE - 6,
  AMEDIA_DRM_VERIFY_FAILED = AMEDIA_DRM_ERROR_BASE - 7,
  AMEDIA_DRM_NEED_KEY = AMEDIA_DRM_ERROR_BASE - 8,
  AMEDIA_DRM_LICENSE_EXPIRED = AMEDIA_DRM_ERROR_BASE - 9,
  AMEDIA_IMGREADER_ERROR_BASE = -30000,
  AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE = AMEDIA_IMGREADER_ERROR_BASE - 1,
  AMEDIA_IMGREADER_MAX_IMAGES_ACQUIRED = AMEDIA_IMGREADER_ERROR_BASE - 2,
  AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE = AMEDIA_IMGREADER_ERROR_BASE - 3,
  AMEDIA_IMGREADER_CANNOT_UNLOCK_IMAGE = AMEDIA_IMGREADER_ERROR_BASE - 4,
  AMEDIA_IMGREADER_IMAGE_NOT_LOCKED = AMEDIA_IMGREADER_ERROR_BASE - 5
}
enum
Media error message types returned from NDK media functions.

Typedefs

AImage typedef
struct AImage
AImage is an opaque type that provides access to image generated by AImageReader.
AImageCropRect typedef
Data type describing an cropped rectangle returned by AImage_getCropRect.
AImageReader typedef
struct AImageReader
AImage is an opaque type that allows direct application access to image data rendered into a ANativeWindow.
AImageReader_BufferRemovedCallback)(void *context, AImageReader *reader, AHardwareBuffer *buffer) typedef
void(*
Signature of the callback which is called when AImageReader is about to remove a buffer.
AImageReader_BufferRemovedListener typedef
A listener to the AHardwareBuffer removal event, use AImageReader_setBufferRemovedListener to register the listener object to AImageReader.
AImageReader_ImageCallback)(void *context, AImageReader *reader) typedef
void(*
Signature of the callback which is called when a new image is available from AImageReader.
AImageReader_ImageListener typedef
AMediaCodec typedef
struct AMediaCodec
AMediaCodecBufferInfo typedef
AMediaCodecCryptoInfo typedef
struct AMediaCodecCryptoInfo
AMediaCodecOnAsyncError)(AMediaCodec *codec, void *userdata, media_status_t error, int32_t actionCode, const char *detail) typedef
void(*
Called when the MediaCodec encountered an error.
AMediaCodecOnAsyncFormatChanged)(AMediaCodec *codec, void *userdata, AMediaFormat *format) typedef
void(*
Called when the output format has changed.
AMediaCodecOnAsyncInputAvailable)(AMediaCodec *codec, void *userdata, int32_t index) typedef
void(*
Called when an input buffer becomes available.
AMediaCodecOnAsyncNotifyCallback typedef
AMediaCodecOnAsyncOutputAvailable)(AMediaCodec *codec, void *userdata, int32_t index, AMediaCodecBufferInfo *bufferInfo) typedef
void(*
Called when an output buffer becomes available.
AMediaCodecOnFrameRendered)(AMediaCodec *codec, void *userdata, int64_t mediaTimeUs, int64_t systemNano) typedef
void(*
Called when an output frame has rendered on the output surface.
AMediaCrypto typedef
struct AMediaCrypto
AMediaDrm typedef
struct AMediaDrm
AMediaDrmEventListener)(AMediaDrm *, const AMediaDrmSessionId *sessionId, AMediaDrmEventType eventType, int extra, const uint8_t *data, size_t dataSize) typedef
void(*
AMediaDrmEventType typedef
AMediaDrmExpirationUpdateListener)(AMediaDrm *, const AMediaDrmSessionId *sessionId, int64_t expiryTimeInMS) typedef
void(*
AMediaDrmKeyId typedef
AMediaDrmKeyRequestType typedef
Introduced in API 33.
AMediaDrmKeySetId typedef
AMediaDrmKeyStatus typedef
AMediaDrmKeyStatusType typedef
AMediaDrmKeyType typedef
AMediaDrmKeyValue typedef
Data type containing {key, value} pair.
AMediaDrmKeysChangeListener)(AMediaDrm *, const AMediaDrmSessionId *sessionId, const AMediaDrmKeyStatus *keyStatus, size_t numKeys, bool hasNewUsableKey) typedef
void(*
AMediaDrmScope typedef
AMediaDrmSecureStop typedef
AMediaDrmSessionId typedef
AMediaExtractor typedef
struct AMediaExtractor
AMediaFormat typedef
struct AMediaFormat
AMediaMuxer typedef
struct AMediaMuxer
AMediaUUID[16] typedef
uint8_t
ANativeWindow typedef
struct ANativeWindow
PsshEntry typedef
struct PsshEntry
mapping of crypto scheme uuid to the scheme specific data for that scheme
PsshInfo typedef
struct PsshInfo
list of crypto schemes and their data

Variables

AMEDIACODEC_KEY_HDR10_PLUS_INFO
const char *
AMEDIACODEC_KEY_LOW_LATENCY
const char *
AMEDIACODEC_KEY_OFFSET_TIME
const char *
AMEDIACODEC_KEY_REQUEST_SYNC_FRAME
const char *
AMEDIACODEC_KEY_SUSPEND
const char *
AMEDIACODEC_KEY_SUSPEND_TIME
const char *
AMEDIACODEC_KEY_VIDEO_BITRATE
const char *
AMEDIAFORMAT_KEY_AAC_DRC_ATTENUATION_FACTOR
const char *
AMEDIAFORMAT_KEY_AAC_DRC_BOOST_FACTOR
const char *
AMEDIAFORMAT_KEY_AAC_DRC_HEAVY_COMPRESSION
const char *
AMEDIAFORMAT_KEY_AAC_DRC_TARGET_REFERENCE_LEVEL
const char *
AMEDIAFORMAT_KEY_AAC_ENCODED_TARGET_LEVEL
const char *
AMEDIAFORMAT_KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT
const char *
AMEDIAFORMAT_KEY_AAC_PROFILE
const char *
AMEDIAFORMAT_KEY_AAC_SBR_MODE
const char *
AMEDIAFORMAT_KEY_ALBUM
const char *
AMEDIAFORMAT_KEY_ALBUMART
const char *
AMEDIAFORMAT_KEY_ALBUMARTIST
const char *
AMEDIAFORMAT_KEY_ARTIST
const char *
AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_INFO
const char *
AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_PRESENTATION_ID
const char *
AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_PROGRAM_ID
const char *
AMEDIAFORMAT_KEY_AUDIO_SESSION_ID
const char *
AMEDIAFORMAT_KEY_AUTHOR
const char *
AMEDIAFORMAT_KEY_BITRATE_MODE
const char *
AMEDIAFORMAT_KEY_BITS_PER_SAMPLE
const char *
AMEDIAFORMAT_KEY_BIT_RATE
const char *
AMEDIAFORMAT_KEY_CAPTURE_RATE
const char *
AMEDIAFORMAT_KEY_CDTRACKNUMBER
const char *
AMEDIAFORMAT_KEY_CHANNEL_COUNT
const char *
AMEDIAFORMAT_KEY_CHANNEL_MASK
const char *
AMEDIAFORMAT_KEY_COLOR_FORMAT
const char *
AMEDIAFORMAT_KEY_COLOR_RANGE
const char *
AMEDIAFORMAT_KEY_COLOR_STANDARD
const char *
AMEDIAFORMAT_KEY_COLOR_TRANSFER
const char *
AMEDIAFORMAT_KEY_COMPILATION
const char *
AMEDIAFORMAT_KEY_COMPLEXITY
const char *
AMEDIAFORMAT_KEY_COMPOSER
const char *
AMEDIAFORMAT_KEY_CREATE_INPUT_SURFACE_SUSPENDED
const char *
AMEDIAFORMAT_KEY_CRYPTO_DEFAULT_IV_SIZE
const char *
AMEDIAFORMAT_KEY_CRYPTO_ENCRYPTED_BYTE_BLOCK
const char *
AMEDIAFORMAT_KEY_CRYPTO_ENCRYPTED_SIZES
const char *
AMEDIAFORMAT_KEY_CRYPTO_IV
const char *
AMEDIAFORMAT_KEY_CRYPTO_KEY
const char *
AMEDIAFORMAT_KEY_CRYPTO_MODE
const char *
AMEDIAFORMAT_KEY_CRYPTO_PLAIN_SIZES
const char *
AMEDIAFORMAT_KEY_CRYPTO_SKIP_BYTE_BLOCK
const char *
AMEDIAFORMAT_KEY_CSD
const char *
AMEDIAFORMAT_KEY_CSD_0
const char *
AMEDIAFORMAT_KEY_CSD_1
const char *
AMEDIAFORMAT_KEY_CSD_2
const char *
AMEDIAFORMAT_KEY_CSD_AVC
const char *
AMEDIAFORMAT_KEY_CSD_HEVC
const char *
AMEDIAFORMAT_KEY_D263
const char *
AMEDIAFORMAT_KEY_DATE
const char *
AMEDIAFORMAT_KEY_DISCNUMBER
const char *
AMEDIAFORMAT_KEY_DISPLAY_CROP
const char *
AMEDIAFORMAT_KEY_DISPLAY_HEIGHT
const char *
AMEDIAFORMAT_KEY_DISPLAY_WIDTH
const char *
AMEDIAFORMAT_KEY_DURATION
const char *
AMEDIAFORMAT_KEY_ENCODER_DELAY
const char *
AMEDIAFORMAT_KEY_ENCODER_PADDING
const char *
AMEDIAFORMAT_KEY_ESDS
const char *
AMEDIAFORMAT_KEY_EXIF_OFFSET
const char *
AMEDIAFORMAT_KEY_EXIF_SIZE
const char *
AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL
const char *
AMEDIAFORMAT_KEY_FRAME_COUNT
const char *
AMEDIAFORMAT_KEY_FRAME_RATE
const char *
AMEDIAFORMAT_KEY_GENRE
const char *
AMEDIAFORMAT_KEY_GRID_COLUMNS
const char *
AMEDIAFORMAT_KEY_GRID_ROWS
const char *
AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT
const char *
AMEDIAFORMAT_KEY_HDR10_PLUS_INFO
const char *
AMEDIAFORMAT_KEY_HDR_STATIC_INFO
const char *
AMEDIAFORMAT_KEY_HEIGHT
const char *
AMEDIAFORMAT_KEY_ICC_PROFILE
const char *
AMEDIAFORMAT_KEY_INTRA_REFRESH_PERIOD
const char *
AMEDIAFORMAT_KEY_IS_ADTS
const char *
AMEDIAFORMAT_KEY_IS_AUTOSELECT
const char *
AMEDIAFORMAT_KEY_IS_DEFAULT
const char *
AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE
const char *
AMEDIAFORMAT_KEY_IS_SYNC_FRAME
const char *
AMEDIAFORMAT_KEY_I_FRAME_INTERVAL
const char *
AMEDIAFORMAT_KEY_LANGUAGE
const char *
AMEDIAFORMAT_KEY_LAST_SAMPLE_INDEX_IN_CHUNK
const char *
AMEDIAFORMAT_KEY_LATENCY
const char *
AMEDIAFORMAT_KEY_LEVEL
const char *
AMEDIAFORMAT_KEY_LOCATION
const char *
AMEDIAFORMAT_KEY_LOOP
const char *
AMEDIAFORMAT_KEY_LOW_LATENCY
const char *
An optional key describing the low latency decoding mode.
AMEDIAFORMAT_KEY_LYRICIST
const char *
AMEDIAFORMAT_KEY_MANUFACTURER
const char *
AMEDIAFORMAT_KEY_MAX_BIT_RATE
const char *
AMEDIAFORMAT_KEY_MAX_FPS_TO_ENCODER
const char *
AMEDIAFORMAT_KEY_MAX_HEIGHT
const char *
AMEDIAFORMAT_KEY_MAX_INPUT_SIZE
const char *
AMEDIAFORMAT_KEY_MAX_PTS_GAP_TO_ENCODER
const char *
AMEDIAFORMAT_KEY_MAX_WIDTH
const char *
AMEDIAFORMAT_KEY_MIME
const char *
AMEDIAFORMAT_KEY_MPEG2_STREAM_HEADER
const char *
AMEDIAFORMAT_KEY_MPEGH_COMPATIBLE_SETS
const char *
MPEG-H audio profile and level compatibility.
AMEDIAFORMAT_KEY_MPEGH_PROFILE_LEVEL_INDICATION
const char *
MPEG-H audio profile level indication.
AMEDIAFORMAT_KEY_MPEGH_REFERENCE_CHANNEL_LAYOUT
const char *
MPEG-H audio reference channel layout.
AMEDIAFORMAT_KEY_MPEG_USER_DATA
const char *
AMEDIAFORMAT_KEY_OPERATING_RATE
const char *
AMEDIAFORMAT_KEY_PCM_BIG_ENDIAN
const char *
AMEDIAFORMAT_KEY_PCM_ENCODING
const char *
AMEDIAFORMAT_KEY_PICTURE_TYPE
const char *
AMEDIAFORMAT_KEY_PRIORITY
const char *
AMEDIAFORMAT_KEY_PROFILE
const char *
AMEDIAFORMAT_KEY_PSSH
const char *
AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP
const char *
AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER
const char *
AMEDIAFORMAT_KEY_ROTATION
const char *
AMEDIAFORMAT_KEY_SAMPLE_FILE_OFFSET
const char *
AMEDIAFORMAT_KEY_SAMPLE_RATE
const char *
AMEDIAFORMAT_KEY_SAMPLE_TIME_BEFORE_APPEND
const char *
AMEDIAFORMAT_KEY_SAR_HEIGHT
const char *
AMEDIAFORMAT_KEY_SAR_WIDTH
const char *
AMEDIAFORMAT_KEY_SEI
const char *
AMEDIAFORMAT_KEY_SLICE_HEIGHT
const char *
AMEDIAFORMAT_KEY_SLOW_MOTION_MARKERS
const char *
AMEDIAFORMAT_KEY_STRIDE
const char *
AMEDIAFORMAT_KEY_TARGET_TIME
const char *
AMEDIAFORMAT_KEY_TEMPORAL_LAYERING
const char *
AMEDIAFORMAT_KEY_TEMPORAL_LAYER_COUNT
const char *
AMEDIAFORMAT_KEY_TEMPORAL_LAYER_ID
const char *
AMEDIAFORMAT_KEY_TEXT_FORMAT_DATA
const char *
AMEDIAFORMAT_KEY_THUMBNAIL_CSD_AV1C
const char *
AMEDIAFORMAT_KEY_THUMBNAIL_CSD_HEVC
const char *
AMEDIAFORMAT_KEY_THUMBNAIL_HEIGHT
const char *
AMEDIAFORMAT_KEY_THUMBNAIL_TIME
const char *
AMEDIAFORMAT_KEY_THUMBNAIL_WIDTH
const char *
AMEDIAFORMAT_KEY_TILE_HEIGHT
const char *
AMEDIAFORMAT_KEY_TILE_WIDTH
const char *
AMEDIAFORMAT_KEY_TIME_US
const char *
AMEDIAFORMAT_KEY_TITLE
const char *
AMEDIAFORMAT_KEY_TRACK_ID
const char *
AMEDIAFORMAT_KEY_TRACK_INDEX
const char *
AMEDIAFORMAT_KEY_VALID_SAMPLES
const char *
AMEDIAFORMAT_KEY_VIDEO_ENCODING_STATISTICS_LEVEL
const char *
AMEDIAFORMAT_KEY_VIDEO_QP_AVERAGE
const char *
AMEDIAFORMAT_KEY_WIDTH
const char *
AMEDIAFORMAT_KEY_XMP_OFFSET
const char *
AMEDIAFORMAT_KEY_XMP_SIZE
const char *
AMEDIAFORMAT_KEY_YEAR
const char *
AMEDIAFORMAT_VIDEO_QP_B_MAX
const char *
AMEDIAFORMAT_VIDEO_QP_B_MIN
const char *
AMEDIAFORMAT_VIDEO_QP_I_MAX
const char *
AMEDIAFORMAT_VIDEO_QP_I_MIN
const char *
AMEDIAFORMAT_VIDEO_QP_MAX
const char *
AMEDIAFORMAT_VIDEO_QP_MIN
const char *
AMEDIAFORMAT_VIDEO_QP_P_MAX
const char *
AMEDIAFORMAT_VIDEO_QP_P_MIN
const char *

Functions

AImageReader_acquireLatestImage(AImageReader *reader, AImage **image)
Acquire the latest AImage from the image reader's queue, dropping older images.
AImageReader_acquireLatestImageAsync(AImageReader *reader, AImage **image, int *acquireFenceFd)
Acquire the latest AImage from the image reader's queue asynchronously, dropping older images.
AImageReader_acquireNextImage(AImageReader *reader, AImage **image)
Acquire the next AImage from the image reader's queue.
AImageReader_acquireNextImageAsync(AImageReader *reader, AImage **image, int *acquireFenceFd)
Acquire the next AImage from the image reader's queue asynchronously.
AImageReader_delete(AImageReader *reader)
void
Delete an AImageReader and return all images generated by this reader to system.
AImageReader_getFormat(const AImageReader *reader, int32_t *format)
Query the format of the AImage generated by this reader.
AImageReader_getHeight(const AImageReader *reader, int32_t *height)
Query the default height of the AImage generated by this reader, in pixels.
AImageReader_getMaxImages(const AImageReader *reader, int32_t *maxImages)
Query the maximum number of concurrently acquired AImages of this reader.
AImageReader_getWidth(const AImageReader *reader, int32_t *width)
Query the default width of the AImage generated by this reader, in pixels.
AImageReader_getWindow(AImageReader *reader, ANativeWindow **window)
Get a ANativeWindow that can be used to produce AImage for this image reader.
AImageReader_new(int32_t width, int32_t height, int32_t format, int32_t maxImages, AImageReader **reader)
Create a new reader for images of the desired size and format.
AImageReader_newWithUsage(int32_t width, int32_t height, int32_t format, uint64_t usage, int32_t maxImages, AImageReader **reader)
AImageReader constructor similar to AImageReader_new that takes an additional parameter for the consumer usage.
AImageReader_setBufferRemovedListener(AImageReader *reader, AImageReader_BufferRemovedListener *listener)
Set the onBufferRemoved listener of this image reader.
AImageReader_setImageListener(AImageReader *reader, AImageReader_ImageListener *listener)
Set the onImageAvailable listener of this image reader.
AImage_delete(AImage *image)
void
Return the image back the the system and delete the AImage object from memory.
AImage_deleteAsync(AImage *image, int releaseFenceFd)
void
Return the image back the the system and delete the AImage object from memory asynchronously.
AImage_getCropRect(const AImage *image, AImageCropRect *rect)
Query the cropped rectangle of the input AImage.
AImage_getFormat(const AImage *image, int32_t *format)
Query the format of the input AImage.
AImage_getHardwareBuffer(const AImage *image, AHardwareBuffer **buffer)
Get the hardware buffer handle of the input image intended for GPU and/or hardware access.
AImage_getHeight(const AImage *image, int32_t *height)
Query the height of the input AImage.
AImage_getNumberOfPlanes(const AImage *image, int32_t *numPlanes)
Query the number of planes of the input AImage.
AImage_getPlaneData(const AImage *image, int planeIdx, uint8_t **data, int *dataLength)
Get the data pointer of the input image for direct application access.
AImage_getPlanePixelStride(const AImage *image, int planeIdx, int32_t *pixelStride)
Query the pixel stride of the input AImage.
AImage_getPlaneRowStride(const AImage *image, int planeIdx, int32_t *rowStride)
Query the row stride of the input AImage.
AImage_getTimestamp(const AImage *image, int64_t *timestampNs)
Query the timestamp of the input AImage.
AImage_getWidth(const AImage *image, int32_t *width)
Query the width of the input AImage.
AMediaCodecActionCode_isRecoverable(int32_t actionCode)
bool
Returns true if the codec cannot proceed further, but can be recovered by stopping, configuring, and starting again.
AMediaCodecActionCode_isTransient(int32_t actionCode)
bool
Returns true if the codec error is a transient issue, perhaps due to resource constraints, and that the method (or encoding/decoding) may be retried at a later time.
AMediaCodecCryptoInfo_delete(AMediaCodecCryptoInfo *)
Delete an AMediaCodecCryptoInfo created previously with AMediaCodecCryptoInfo_new, or obtained from AMediaExtractor.
AMediaCodecCryptoInfo_getClearBytes(AMediaCodecCryptoInfo *, size_t *dst)
The number of leading unencrypted bytes in each subsample.
AMediaCodecCryptoInfo_getEncryptedBytes(AMediaCodecCryptoInfo *, size_t *dst)
The number of trailing encrypted bytes in each subsample.
AMediaCodecCryptoInfo_getIV(AMediaCodecCryptoInfo *, uint8_t *dst)
A 16-byte initialization vector.
AMediaCodecCryptoInfo_getKey(AMediaCodecCryptoInfo *, uint8_t *dst)
A 16-byte opaque key.
AMediaCodecCryptoInfo_getMode(AMediaCodecCryptoInfo *)
cryptoinfo_mode_t
The type of encryption that has been applied, one of AMEDIACODECRYPTOINFO_MODE_CLEAR or AMEDIACODECRYPTOINFO_MODE_AES_CTR.
AMediaCodecCryptoInfo_getNumSubSamples(AMediaCodecCryptoInfo *)
size_t
The number of subsamples that make up the buffer's contents.
AMediaCodecCryptoInfo_new(int numsubsamples, uint8_t key[16], uint8_t iv[16], cryptoinfo_mode_t mode, size_t *clearbytes, size_t *encryptedbytes)
AMediaCodecCryptoInfo *
Create an AMediaCodecCryptoInfo from scratch.
AMediaCodecCryptoInfo_setPattern(AMediaCodecCryptoInfo *info, cryptoinfo_pattern_t *pattern)
void
Set the crypto pattern on an AMediaCryptoInfo object.
AMediaCodec_configure(AMediaCodec *, const AMediaFormat *format, ANativeWindow *surface, AMediaCrypto *crypto, uint32_t flags)
Configure the codec.
AMediaCodec_createCodecByName(const char *name)
AMediaCodec *
Create codec by name.
AMediaCodec_createDecoderByType(const char *mime_type)
AMediaCodec *
Create codec by mime type.
AMediaCodec_createEncoderByType(const char *mime_type)
AMediaCodec *
Create encoder by name.
AMediaCodec_createInputSurface(AMediaCodec *mData, ANativeWindow **surface)
Creates a Surface that can be used as the input to encoder, in place of input buffers.
AMediaCodec_createPersistentInputSurface(ANativeWindow **surface)
Creates a persistent Surface that can be used as the input to encoder.
AMediaCodec_delete(AMediaCodec *)
Delete the codec and free its resources.
AMediaCodec_dequeueInputBuffer(AMediaCodec *, int64_t timeoutUs)
ssize_t
Get the index of the next available input buffer.
AMediaCodec_dequeueOutputBuffer(AMediaCodec *, AMediaCodecBufferInfo *info, int64_t timeoutUs)
ssize_t
Get the index of the next available buffer of processed data.
AMediaCodec_flush(AMediaCodec *)
AMediaCodec_getBufferFormat(AMediaCodec *, size_t index)
AMediaFormat *
Get format of the buffer.
AMediaCodec_getInputBuffer(AMediaCodec *, size_t idx, size_t *out_size)
uint8_t *
Get an input buffer.
AMediaCodec_getInputFormat(AMediaCodec *)
AMediaFormat *
Call this after AMediaCodec_configure() returns successfully to get the input format accepted by the codec.
AMediaCodec_getName(AMediaCodec *, char **out_name)
Get the component name.
AMediaCodec_getOutputBuffer(AMediaCodec *, size_t idx, size_t *out_size)
uint8_t *
Get an output buffer.
AMediaCodec_getOutputFormat(AMediaCodec *)
AMediaFormat *
Returns the format of the codec's output.
AMediaCodec_queueInputBuffer(AMediaCodec *, size_t idx, _off_t_compat offset, size_t size, uint64_t time, uint32_t flags)
Send the specified buffer to the codec for processing.
AMediaCodec_queueSecureInputBuffer(AMediaCodec *, size_t idx, _off_t_compat offset, AMediaCodecCryptoInfo *, uint64_t time, uint32_t flags)
Send the specified buffer to the codec for processing.
AMediaCodec_releaseCrypto(AMediaCodec *)
Release the crypto if applicable.
AMediaCodec_releaseName(AMediaCodec *, char *name)
void
Free the memory pointed by name which is returned by AMediaCodec_getName.
AMediaCodec_releaseOutputBuffer(AMediaCodec *, size_t idx, bool render)
If you are done with a buffer, use this call to return the buffer to the codec.
AMediaCodec_releaseOutputBufferAtTime(AMediaCodec *mData, size_t idx, int64_t timestampNs)
If you are done with a buffer, use this call to update its surface timestamp and return it to the codec to render it on the output surface.
AMediaCodec_setAsyncNotifyCallback(AMediaCodec *, AMediaCodecOnAsyncNotifyCallback callback, void *userdata)
Set an asynchronous callback for actionable AMediaCodec events.
AMediaCodec_setInputSurface(AMediaCodec *mData, ANativeWindow *surface)
Set a persistent-surface that can be used as the input to encoder, in place of input buffers.
AMediaCodec_setOnFrameRenderedCallback(AMediaCodec *, AMediaCodecOnFrameRendered callback, void *userdata)
Registers a callback to be invoked when an output frame is rendered on the output surface.
AMediaCodec_setOutputSurface(AMediaCodec *, ANativeWindow *surface)
Dynamically sets the output surface of a codec.
AMediaCodec_setParameters(AMediaCodec *mData, const AMediaFormat *params)
Signal additional parameters to the codec instance.
AMediaCodec_signalEndOfInputStream(AMediaCodec *mData)
Signals end-of-stream on input.
AMediaCodec_start(AMediaCodec *)
Start the codec.
AMediaCodec_stop(AMediaCodec *)
Stop the codec.
AMediaCrypto_delete(AMediaCrypto *crypto)
void
Available since API level 21.
AMediaCrypto_isCryptoSchemeSupported(const AMediaUUID uuid)
bool
Available since API level 21.
AMediaCrypto_new(const AMediaUUID uuid, const void *initData, size_t initDataSize)
AMediaCrypto *
Available since API level 21.
AMediaCrypto_requiresSecureDecoderComponent(const char *mime)
bool
Available since API level 21.
AMediaDrm_closeSession(AMediaDrm *, const AMediaDrmSessionId *sessionId)
Close a session on the MediaDrm object that was previously opened with AMediaDrm_openSession.
AMediaDrm_createByUUID(const uint8_t *uuid)
AMediaDrm *
Create a MediaDrm instance from a UUID.
AMediaDrm_decrypt(AMediaDrm *, const AMediaDrmSessionId *sessionId, const char *cipherAlgorithm, uint8_t *keyId, uint8_t *iv, const uint8_t *input, uint8_t *output, size_t dataSize)
AMediaDrm_encrypt(AMediaDrm *, const AMediaDrmSessionId *sessionId, const char *cipherAlgorithm, uint8_t *keyId, uint8_t *iv, const uint8_t *input, uint8_t *output, size_t dataSize)
In addition to supporting decryption of DASH Common Encrypted Media, the MediaDrm APIs provide the ability to securely deliver session keys from an operator's session key server to a client device, based on the factory-installed root of trust, and then perform encrypt, decrypt, sign and verify operations with the session key on arbitrary user data.
AMediaDrm_getKeyRequest(AMediaDrm *, const AMediaDrmScope *scope, const uint8_t *init, size_t initSize, const char *mimeType, AMediaDrmKeyType keyType, const AMediaDrmKeyValue *optionalParameters, size_t numOptionalParameters, const uint8_t **keyRequest, size_t *keyRequestSize)
A key request/response exchange occurs between the app and a license server to obtain or release keys used to decrypt encrypted content.
AMediaDrm_getKeyRequestWithDefaultUrlAndType(AMediaDrm *, const AMediaDrmScope *scope, const uint8_t *init, size_t initSize, const char *mimeType, AMediaDrmKeyType keyType, const AMediaDrmKeyValue *optionalParameters, size_t numOptionalParameters, const uint8_t **keyRequest, size_t *keyRequestSize, const char **defaultUrl, AMediaDrmKeyRequestType *keyRequestType)
A key request/response exchange occurs between the app and a license server to obtain or release keys used to decrypt encrypted content.
AMediaDrm_getPropertyByteArray(AMediaDrm *, const char *propertyName, AMediaDrmByteArray *propertyValue)
Read a DRM engine plugin byte array property value, given the property name string.
AMediaDrm_getPropertyString(AMediaDrm *, const char *propertyName, const char **propertyValue)
Read a DRM engine plugin String property value, given the property name string.
AMediaDrm_getProvisionRequest(AMediaDrm *, const uint8_t **provisionRequest, size_t *provisionRequestSize, const char **serverUrl)
A provision request/response exchange occurs between the app and a provisioning server to retrieve a device certificate.
AMediaDrm_getSecureStops(AMediaDrm *, AMediaDrmSecureStop *secureStops, size_t *numSecureStops)
A means of enforcing limits on the number of concurrent streams per subscriber across devices is provided via SecureStop.
AMediaDrm_isCryptoSchemeSupported(const uint8_t *uuid, const char *mimeType)
bool
Query if the given scheme identified by its UUID is supported on this device, and whether the drm plugin is able to handle the media container format specified by mimeType.
AMediaDrm_openSession(AMediaDrm *, AMediaDrmSessionId *sessionId)
Open a new session with the MediaDrm object.
AMediaDrm_provideKeyResponse(AMediaDrm *, const AMediaDrmScope *scope, const uint8_t *response, size_t responseSize, AMediaDrmKeySetId *keySetId)
A key response is received from the license server by the app, then it is provided to the DRM engine plugin using provideKeyResponse.
AMediaDrm_provideProvisionResponse(AMediaDrm *, const uint8_t *response, size_t responseSize)
After a provision response is received by the app, it is provided to the DRM engine plugin using this method.
AMediaDrm_queryKeyStatus(AMediaDrm *, const AMediaDrmSessionId *sessionId, AMediaDrmKeyValue *keyValuePairs, size_t *numPairs)
Request an informative description of the key status for the session.
AMediaDrm_release(AMediaDrm *)
void
Release a MediaDrm object.
AMediaDrm_releaseSecureStops(AMediaDrm *, const AMediaDrmSecureStop *ssRelease)
Process the SecureStop server response message ssRelease.
AMediaDrm_removeKeys(AMediaDrm *, const AMediaDrmSessionId *keySetId)
Remove the current keys from a session.
AMediaDrm_restoreKeys(AMediaDrm *, const AMediaDrmSessionId *sessionId, const AMediaDrmKeySetId *keySetId)
Restore persisted offline keys into a new session.
AMediaDrm_setOnEventListener(AMediaDrm *, AMediaDrmEventListener listener)
Register a callback to be invoked when an event occurs.
AMediaDrm_setOnExpirationUpdateListener(AMediaDrm *, AMediaDrmExpirationUpdateListener listener)
Register a callback to be invoked when an expiration update event occurs.
AMediaDrm_setOnKeysChangeListener(AMediaDrm *, AMediaDrmKeysChangeListener listener)
Register a callback to be invoked when a key status change event occurs.
AMediaDrm_setPropertyByteArray(AMediaDrm *, const char *propertyName, const uint8_t *value, size_t valueSize)
Set a DRM engine plugin byte array property value.
AMediaDrm_setPropertyString(AMediaDrm *, const char *propertyName, const char *value)
Set a DRM engine plugin String property value.
AMediaDrm_sign(AMediaDrm *, const AMediaDrmSessionId *sessionId, const char *macAlgorithm, uint8_t *keyId, uint8_t *message, size_t messageSize, uint8_t *signature, size_t *signatureSize)
AMediaDrm_verify(AMediaDrm *, const AMediaDrmSessionId *sessionId, const char *macAlgorithm, uint8_t *keyId, const uint8_t *message, size_t messageSize, const uint8_t *signature, size_t signatureSize)
AMediaExtractor_advance(AMediaExtractor *)
bool
Advance to the next sample.
AMediaExtractor_delete(AMediaExtractor *)
Delete a previously created media extractor.
AMediaExtractor_getCachedDuration(AMediaExtractor *)
int64_t
Returns the duration of cached media samples downloaded from a network data source (AMediaExtractor_setDataSource with a "http(s)" URI) in microseconds.
AMediaExtractor_getFileFormat(AMediaExtractor *)
AMediaFormat *
Returns the format of the extractor.
AMediaExtractor_getPsshInfo(AMediaExtractor *)
Get the PSSH info if present.
AMediaExtractor_getSampleCryptoInfo(AMediaExtractor *)
AMediaCodecCryptoInfo *
Available since API level 21.
AMediaExtractor_getSampleFlags(AMediaExtractor *)
uint32_t
Read the current sample's flags.
AMediaExtractor_getSampleFormat(AMediaExtractor *ex, AMediaFormat *fmt)
Read the current sample's metadata format into |fmt|.
AMediaExtractor_getSampleSize(AMediaExtractor *)
ssize_t
Returns the size of the current sample in bytes, or -1 when no samples are available (end of stream).
AMediaExtractor_getSampleTime(AMediaExtractor *)
int64_t
Returns the current sample's presentation time in microseconds.
AMediaExtractor_getSampleTrackIndex(AMediaExtractor *)
int
Returns the track index the current sample originates from (or -1 if no more samples are available)
AMediaExtractor_getTrackCount(AMediaExtractor *)
size_t
Return the number of tracks in the previously specified media file.
AMediaExtractor_getTrackFormat(AMediaExtractor *, size_t idx)
AMediaFormat *
Return the format of the specified track.
AMediaExtractor_new()
AMediaExtractor *
Create new media extractor.
AMediaExtractor_readSampleData(AMediaExtractor *, uint8_t *buffer, size_t capacity)
ssize_t
Read the current sample.
AMediaExtractor_seekTo(AMediaExtractor *, int64_t seekPosUs, SeekMode mode)
Available since API level 21.
AMediaExtractor_selectTrack(AMediaExtractor *, size_t idx)
Select the specified track.
AMediaExtractor_setDataSource(AMediaExtractor *, const char *location)
Set the URI from which the extractor will read.
AMediaExtractor_setDataSourceCustom(AMediaExtractor *, AMediaDataSource *src)
Set the custom data source implementation from which the extractor will read.
AMediaExtractor_setDataSourceFd(AMediaExtractor *, int fd, off64_t offset, off64_t length)
Set the file descriptor from which the extractor will read.
AMediaExtractor_unselectTrack(AMediaExtractor *, size_t idx)
Unselect the specified track.
AMediaFormat_clear(AMediaFormat *)
void
Remove all key/value pairs from the given AMediaFormat.
AMediaFormat_copy(AMediaFormat *to, AMediaFormat *from)
Copy one AMediaFormat to another.
AMediaFormat_delete(AMediaFormat *)
Available since API level 21.
AMediaFormat_getBuffer(AMediaFormat *, const char *name, void **data, size_t *size)
bool
The returned data is owned by the format and remains valid as long as the named entry is part of the format.
AMediaFormat_getDouble(AMediaFormat *, const char *name, double *out)
bool
Available since API level 28.
AMediaFormat_getFloat(AMediaFormat *, const char *name, float *out)
bool
Available since API level 21.
AMediaFormat_getInt32(AMediaFormat *, const char *name, int32_t *out)
bool
Available since API level 21.
AMediaFormat_getInt64(AMediaFormat *, const char *name, int64_t *out)
bool
Available since API level 21.
AMediaFormat_getRect(AMediaFormat *, const char *name, int32_t *left, int32_t *top, int32_t *right, int32_t *bottom)
bool
Available since API level 28.
AMediaFormat_getSize(AMediaFormat *, const char *name, size_t *out)
bool
Available since API level 21.
AMediaFormat_getString(AMediaFormat *, const char *name, const char **out)
bool
The returned string is owned by the format, and remains valid until the next call to getString, or until the format is deleted.
AMediaFormat_new()
AMediaFormat *
Available since API level 21.
AMediaFormat_setBuffer(AMediaFormat *, const char *name, const void *data, size_t size)
void
The provided data is copied into the format.
AMediaFormat_setDouble(AMediaFormat *, const char *name, double value)
void
Available since API level 28.
AMediaFormat_setFloat(AMediaFormat *, const char *name, float value)
void
Available since API level 21.
AMediaFormat_setInt32(AMediaFormat *, const char *name, int32_t value)
void
Available since API level 21.
AMediaFormat_setInt64(AMediaFormat *, const char *name, int64_t value)
void
Available since API level 21.
AMediaFormat_setRect(AMediaFormat *, const char *name, int32_t left, int32_t top, int32_t right, int32_t bottom)
void
Available since API level 28.
AMediaFormat_setSize(AMediaFormat *, const char *name, size_t value)
void
Available since API level 28.
AMediaFormat_setString(AMediaFormat *, const char *name, const char *value)
void
The provided string is copied into the format.
AMediaFormat_toString(AMediaFormat *)
const char *
Human readable representation of the format.
AMediaMuxer_addTrack(AMediaMuxer *, const AMediaFormat *format)
ssize_t
Adds a track with the specified format.
AMediaMuxer_append(int fd, AppendMode mode)
AMediaMuxer *
Creates a new media muxer for appending data to an existing MPEG4 file.
AMediaMuxer_delete(AMediaMuxer *)
Delete a previously created media muxer.
AMediaMuxer_getTrackCount(AMediaMuxer *)
ssize_t
Returns the number of tracks added in the file passed to AMediaMuxer_new or the number of existing tracks in the file passed to AMediaMuxer_append.
AMediaMuxer_getTrackFormat(AMediaMuxer *muxer, size_t idx)
AMediaFormat *
Returns AMediaFormat of the added track with index idx in the file passed to AMediaMuxer_new or the AMediaFormat of the existing track with index idx in the file passed to AMediaMuxer_append.
AMediaMuxer_new(int fd, OutputFormat format)
AMediaMuxer *
Create new media muxer.
AMediaMuxer_setLocation(AMediaMuxer *, float latitude, float longitude)
Set and store the geodata (latitude and longitude) in the output file.
AMediaMuxer_setOrientationHint(AMediaMuxer *, int degrees)
Sets the orientation hint for output video playback.
AMediaMuxer_start(AMediaMuxer *)
Start the muxer.
AMediaMuxer_stop(AMediaMuxer *)
Stops the muxer.
AMediaMuxer_writeSampleData(AMediaMuxer *muxer, size_t trackIdx, const uint8_t *data, const AMediaCodecBufferInfo *info)
Writes an encoded sample into the muxer.

Structs

AImageCropRect

Data type describing an cropped rectangle returned by AImage_getCropRect.

AImageReader_BufferRemovedListener

A listener to the AHardwareBuffer removal event, use AImageReader_setBufferRemovedListener to register the listener object to AImageReader.

AImageReader_ImageListener
AMediaCodecBufferInfo
AMediaCodecOnAsyncNotifyCallback
AMediaDrmByteArray
AMediaDrmKeyStatus
AMediaDrmKeyValuePair

Data type containing {key, value} pair.

PsshEntry

mapping of crypto scheme uuid to the scheme specific data for that scheme

PsshInfo

list of crypto schemes and their data

cryptoinfo_pattern_t

Enumerations

Anonymous Enum 122

 Anonymous Enum 122

AIMAGE_FORMATS

 AIMAGE_FORMATS

AImage supported formats: AImageReader only guarantees the support for the formats listed here.

Properties
AIMAGE_FORMAT_DEPTH16

Android dense depth image format.

Each pixel is 16 bits, representing a depth ranging measurement from a depth camera or similar sensor. The 16-bit sample consists of a confidence value and the actual ranging measurement.

The confidence value is an estimate of correctness for this sample. It is encoded in the 3 most significant bits of the sample, with a value of 0 representing 100% confidence, a value of 1 representing 0% confidence, a value of 2 representing 1/7, a value of 3 representing 2/7, and so on.

As an example, the following sample extracts the range and confidence from the first pixel of a DEPTH16-format AImage, and converts the confidence to a floating-point value between 0 and 1.f inclusive, with 1.f representing maximum confidence:

   uint16_t* data;
   int dataLength;
   AImage_getPlaneData(image, 0, (uint8_t**)&data, &dataLength);
   uint16_t depthSample = data[0];
   uint16_t depthRange = (depthSample & 0x1FFF);
   uint16_t depthConfidence = ((depthSample >> 13) & 0x7);
   float depthPercentage = depthConfidence == 0 ? 1.f : (depthConfidence - 1) / 7.f;

This format assumes

  • an even width
  • an even height
  • a horizontal stride multiple of 16 pixels

 y_size = stride * height 

When produced by a camera, the units for the range are millimeters.

AIMAGE_FORMAT_DEPTH_JPEG

Depth augmented compressed JPEG format.

JPEG compressed main image along with XMP embedded depth metadata following ISO 16684-1:2011(E).

AIMAGE_FORMAT_DEPTH_POINT_CLOUD

Android sparse depth point cloud format.

A variable-length list of 3D points plus a confidence value, with each point represented by four floats; first the X, Y, Z position coordinates, and then the confidence value.

The number of points is ((size of the buffer in bytes) / 16).

The coordinate system and units of the position values depend on the source of the point cloud data. The confidence value is between 0.f and 1.f, inclusive, with 0 representing 0% confidence and 1.f representing 100% confidence in the measured position values.

As an example, the following code extracts the first depth point in a DEPTH_POINT_CLOUD format AImage:

   float* data;
   int dataLength;
   AImage_getPlaneData(image, 0, (uint8_t**)&data, &dataLength);
   float x = data[0];
   float y = data[1];
   float z = data[2];
   float confidence = data[3];

AIMAGE_FORMAT_HEIC

Compressed HEIC format.

This format defines the HEIC brand of High Efficiency Image File Format as described in ISO/IEC 23008-12.

AIMAGE_FORMAT_JPEG

Compressed JPEG format.

This format is always supported as an output format for the android Camera2 NDK API.

AIMAGE_FORMAT_PRIVATE

Android private opaque image format.

The choices of the actual format and pixel data layout are entirely up to the device-specific and framework internal implementations, and may vary depending on use cases even for the same device. Also note that the contents of these buffers are not directly accessible to the application.

When an AImage of this format is obtained from an AImageReader or AImage_getNumberOfPlanes() method will return zero.

AIMAGE_FORMAT_RAW10

Android 10-bit raw format.

This is a single-plane, 10-bit per pixel, densely packed (in each row), unprocessed format, usually representing raw Bayer-pattern images coming from an image sensor.

In an image buffer with this format, starting from the first pixel of each row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte contains the 2 least significant bits of the 4 pixels, the exact layout data for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth bit of the ith pixel):

bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
Byte 0: P0[9] P0[8] P0[7] P0[6] P0[5] P0[4] P0[3] P0[2]
Byte 1: P1[9] P1[8] P1[7] P1[6] P1[5] P1[4] P1[3] P1[2]
Byte 2: P2[9] P2[8] P2[7] P2[6] P2[5] P2[4] P2[3] P2[2]
Byte 3: P3[9] P3[8] P3[7] P3[6] P3[5] P3[4] P3[3] P3[2]
Byte 4: P3[1] P3[0] P2[1] P2[0] P1[1] P1[0] P0[1] P0[0]

This format assumes

  • a width multiple of 4 pixels
  • an even height

size = row stride * height
where the row stride is in bytes, not pixels.

Since this is a densely packed format, the pixel stride is always 0. The application must use the pixel data layout defined in above table to access each row data. When row stride is equal to (width * (10 / 8)), there will be no padding bytes at the end of each row, the entire image data is densely packed. When stride is larger than (width * (10 / 8)), padding bytes will be present at the end of each row.

For example, the AImage object can provide data in this format from a ACameraDevice (if supported) through a AImageReader object. The number of planes returned by AImage_getNumberOfPlanes will always be 1. The pixel stride is undefined (AImage_getPlanePixelStride will return AMEDIA_ERROR_UNSUPPORTED), and the AImage_getPlaneRowStride described the vertical neighboring pixel distance (in bytes) between adjacent rows.

See also: AImage See also: AImageReader See also: ACameraDevice

AIMAGE_FORMAT_RAW12

Android 12-bit raw format.

This is a single-plane, 12-bit per pixel, densely packed (in each row), unprocessed format, usually representing raw Bayer-pattern images coming from an image sensor.

In an image buffer with this format, starting from the first pixel of each row, each two consecutive pixels are packed into 3 bytes (24 bits). The first and second byte contains the top 8 bits of first and second pixel. The third byte contains the 4 least significant bits of the two pixels, the exact layout data for each two consecutive pixels is illustrated below (Pi[j] stands for the jth bit of the ith pixel):

bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
Byte 0: P0[11] P0[10] P0[ 9] P0[ 8] P0[ 7] P0[ 6] P0[ 5] P0[ 4]
Byte 1: P1[11] P1[10] P1[ 9] P1[ 8] P1[ 7] P1[ 6] P1[ 5] P1[ 4]
Byte 2: P1[ 3] P1[ 2] P1[ 1] P1[ 0] P0[ 3] P0[ 2] P0[ 1] P0[ 0]

This format assumes

  • a width multiple of 4 pixels
  • an even height

size = row stride * height
where the row stride is in bytes, not pixels.

Since this is a densely packed format, the pixel stride is always 0. The application must use the pixel data layout defined in above table to access each row data. When row stride is equal to (width * (12 / 8)), there will be no padding bytes at the end of each row, the entire image data is densely packed. When stride is larger than (width * (12 / 8)), padding bytes will be present at the end of each row.

For example, the AImage object can provide data in this format from a ACameraDevice (if supported) through a AImageReader object. The number of planes returned by AImage_getNumberOfPlanes will always be 1. The pixel stride is undefined (AImage_getPlanePixelStride will return AMEDIA_ERROR_UNSUPPORTED), and the AImage_getPlaneRowStride described the vertical neighboring pixel distance (in bytes) between adjacent rows.

See also: AImage See also: AImageReader See also: ACameraDevice

AIMAGE_FORMAT_RAW16

16 bits per pixel raw camera sensor image format, usually representing a single-channel Bayer-mosaic image.

The layout of the color mosaic, the maximum and minimum encoding values of the raw pixel data, the color space of the image, and all other needed information to interpret a raw sensor image must be queried from the ACameraDevice which produced the image.

AIMAGE_FORMAT_RAW_PRIVATE

Private raw camera sensor image format, a single channel image with implementation depedent pixel layout.

AIMAGE_FORMAT_RAW_PRIVATE is a format for unprocessed raw image buffers coming from an image sensor. The actual structure of buffers of this format is implementation-dependent.

AIMAGE_FORMAT_RGBA_8888

32 bits RGBA format, 8 bits for each of the four channels.

Corresponding formats:

  • AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM
  • Vulkan: VK_FORMAT_R8G8B8A8_UNORM
  • OpenGL ES: GL_RGBA8

See also: AImage See also: AImageReader See also: AHardwareBuffer

AIMAGE_FORMAT_RGBA_FP16

64 bits RGBA format, 16 bits for each of the four channels.

Corresponding formats:

  • AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT
  • Vulkan: VK_FORMAT_R16G16B16A16_SFLOAT
  • OpenGL ES: GL_RGBA16F

See also: AImage See also: AImageReader See also: AHardwareBuffer

AIMAGE_FORMAT_RGBX_8888

32 bits RGBX format, 8 bits for each of the four channels.

The values of the alpha channel bits are ignored (image is assumed to be opaque).

Corresponding formats:

  • AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM
  • Vulkan: VK_FORMAT_R8G8B8A8_UNORM
  • OpenGL ES: GL_RGB8

See also: AImage See also: AImageReader See also: AHardwareBuffer

AIMAGE_FORMAT_RGB_565

16 bits RGB format, 5 bits for Red channel, 6 bits for Green channel, and 5 bits for Blue channel.

Corresponding formats:

  • AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM
  • Vulkan: VK_FORMAT_R5G6B5_UNORM_PACK16
  • OpenGL ES: GL_RGB565

See also: AImage See also: AImageReader See also: AHardwareBuffer

AIMAGE_FORMAT_RGB_888

24 bits RGB format, 8 bits for each of the three channels.

Corresponding formats:

  • AHardwareBuffer: AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM
  • Vulkan: VK_FORMAT_R8G8B8_UNORM
  • OpenGL ES: GL_RGB8

See also: AImage See also: AImageReader See also: AHardwareBuffer

AIMAGE_FORMAT_Y8

Android Y8 format.

Y8 is a planar format comprised of a WxH Y plane only, with each pixel being represented by 8 bits.

This format assumes

  • an even width
  • an even height
  • a horizontal stride multiple of 16 pixels

 size = stride * height 

For example, the AImage object can provide data in this format from a ACameraDevice (if supported) through a AImageReader object. The number of planes returned by AImage_getNumberOfPlanes will always be 1. The pixel stride returned by AImage_getPlanePixelStride will always be 1, and the AImage_getPlaneRowStride described the vertical neighboring pixel distance (in bytes) between adjacent rows.

AIMAGE_FORMAT_YUV_420_888

Multi-plane Android YUV 420 format.

This format is a generic YCbCr format, capable of describing any 4:2:0 chroma-subsampled planar or semiplanar buffer (but not fully interleaved), with 8 bits per color sample.

Images in this format are always represented by three separate buffers of data, one for each color plane. Additional information always accompanies the buffers, describing the row stride and the pixel stride for each plane.

The order of planes is guaranteed such that plane #0 is always Y, plane #1 is always U (Cb), and plane #2 is always V (Cr).

The Y-plane is guaranteed not to be interleaved with the U/V planes (in particular, pixel stride is always 1 in AImage_getPlanePixelStride).

The U/V planes are guaranteed to have the same row stride and pixel stride, that is, the return value of AImage_getPlaneRowStride for the U/V plane are guaranteed to be the same, and the return value of AImage_getPlanePixelStride for the U/V plane are also guaranteed to be the same.

For example, the AImage object can provide data in this format from a ACameraDevice through an AImageReader object.

This format is always supported as an output format for the android Camera2 NDK API.

See also: AImage See also: AImageReader See also: ACameraDevice

AMediaDrmEventType

 AMediaDrmEventType
Properties
EVENT_KEY_EXPIRED

This event type indicates that the licensed usage duration for keys in a session has expired.

The keys are no longer valid.

EVENT_KEY_REQUIRED

This event type indicates that the app needs to request keys from a license server.

The request message data is obtained using AMediaDrm_getKeyRequest.

EVENT_PROVISION_REQUIRED

This event type indicates that the app needs to request a certificate from the provisioning server.

The request message data is obtained using AMediaDrm_getProvisionRequest.

EVENT_SESSION_RECLAIMED

This event indicates that a session opened by the app has been reclaimed by the resource manager.

EVENT_VENDOR_DEFINED

This event may indicate some specific vendor-defined condition, see your DRM provider documentation for details.

AMediaDrmKeyRequestType

 AMediaDrmKeyRequestType

Introduced in API 33.

Properties
KEY_REQUEST_TYPE_INITIAL

Key request type is initial license request.

An initial license request is necessary to load keys.

KEY_REQUEST_TYPE_NONE

Keys are already loaded and are available for use.

No license request is necessary, and no key request data is returned.

KEY_REQUEST_TYPE_RELEASE

Key request type is license release.

A license release request indicates that keys are removed.

KEY_REQUEST_TYPE_RENEWAL

Key request type is license renewal.

A renewal license request is necessary to prevent the keys from expiring.

KEY_REQUEST_TYPE_UPDATE

Keys have been loaded but an additional license request is needed to update their values.

AMediaDrmKeyType

 AMediaDrmKeyType
Properties
KEY_TYPE_OFFLINE

This key request type specifies that the keys will be for offline use, they will be saved to the device for use when the device is not connected to a network.

KEY_TYPE_RELEASE

This key request type specifies that previously saved offline keys should be released.

KEY_TYPE_STREAMING

This key request type specifies that the keys will be for online use, they will not be saved to the device for subsequent use when the device is not connected to a network.

AMediaKeyStatusType

 AMediaKeyStatusType
Properties
KEY_STATUS_TYPE_EXPIRED

The key is no longer usable to decrypt media data because its expiration time has passed.

KEY_STATUS_TYPE_INTERNALERROR

The key is not currently usable to decrypt media data because of an internal error in processing unrelated to input parameters.

KEY_STATUS_TYPE_OUTPUTNOTALLOWED

The key is not currently usable to decrypt media data because its output requirements cannot currently be met.

KEY_STATUS_TYPE_STATUSPENDING

The status of the key is not yet known and is being determined.

KEY_STATUS_TYPE_USABLE

The key is currently usable to decrypt media data.

media_status_t

 media_status_t

Media error message types returned from NDK media functions.

Properties
AMEDIACODEC_ERROR_INSUFFICIENT_RESOURCE

This indicates required resource was not able to be allocated.

AMEDIACODEC_ERROR_RECLAIMED

This indicates the resource manager reclaimed the media resource used by the codec.

With this error, the codec must be released, as it has moved to terminal state.

AMEDIA_DRM_DEVICE_REVOKED
AMEDIA_DRM_ERROR_BASE
AMEDIA_DRM_LICENSE_EXPIRED
AMEDIA_DRM_NEED_KEY
AMEDIA_DRM_NOT_PROVISIONED
AMEDIA_DRM_RESOURCE_BUSY
AMEDIA_DRM_SESSION_NOT_OPENED
AMEDIA_DRM_SHORT_BUFFER
AMEDIA_DRM_TAMPER_DETECTED
AMEDIA_DRM_VERIFY_FAILED
AMEDIA_ERROR_BASE
AMEDIA_ERROR_END_OF_STREAM

Media stream ends while processing the requested operation.

AMEDIA_ERROR_INVALID_OBJECT

An invalid (or already closed) object is used in the function call.

AMEDIA_ERROR_INVALID_OPERATION

The media object is not in the right state for the required operation.

AMEDIA_ERROR_INVALID_PARAMETER

At least one of the invalid parameters is used.

AMEDIA_ERROR_IO

An Error occurred when the Media object is carrying IO operation.

AMEDIA_ERROR_MALFORMED

The input media data is corrupt or incomplete.

AMEDIA_ERROR_UNKNOWN

The called media function failed with an unknown error.

AMEDIA_ERROR_UNSUPPORTED

The required operation or media formats are not supported.

AMEDIA_ERROR_WOULD_BLOCK

The required operation would have to be blocked (on I/O or others), but blocking is not enabled.

AMEDIA_IMGREADER_CANNOT_LOCK_IMAGE

The required image buffer could not be locked to read.

AMEDIA_IMGREADER_CANNOT_UNLOCK_IMAGE

The media data or buffer could not be unlocked.

AMEDIA_IMGREADER_ERROR_BASE
AMEDIA_IMGREADER_IMAGE_NOT_LOCKED

The media/buffer needs to be locked to perform the required operation.

AMEDIA_IMGREADER_MAX_IMAGES_ACQUIRED

The AImage object has used up the allowed maximum image buffers.

AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE

There are no more image buffers to read/write image data.

AMEDIA_OK

The requested media operation completed successfully.

Typedefs

AImage

struct AImage AImage

AImage is an opaque type that provides access to image generated by AImageReader.

AImageCropRect

struct AImageCropRect AImageCropRect

Data type describing an cropped rectangle returned by AImage_getCropRect.

Note that the right and bottom coordinates are exclusive, so the width of the rectangle is (right - left) and the height of the rectangle is (bottom - top).

AImageReader

struct AImageReader AImageReader

AImage is an opaque type that allows direct application access to image data rendered into a ANativeWindow.

AImageReader_BufferRemovedCallback

void(* AImageReader_BufferRemovedCallback)(void *context, AImageReader *reader, AHardwareBuffer *buffer)

Signature of the callback which is called when AImageReader is about to remove a buffer.

Details
Parameters
context
The optional application context provided by user in AImageReader_setBufferRemovedListener.
reader
The AImageReader of interest.
buffer
The AHardwareBuffer that is being removed from this image reader.

AImageReader_BufferRemovedListener

struct AImageReader_BufferRemovedListener AImageReader_BufferRemovedListener

A listener to the AHardwareBuffer removal event, use AImageReader_setBufferRemovedListener to register the listener object to AImageReader.

AImageReader_ImageCallback

void(* AImageReader_ImageCallback)(void *context, AImageReader *reader)

Signature of the callback which is called when a new image is available from AImageReader.

Details
Parameters
context
The optional application context provided by user in AImageReader_setImageListener.
session
The camera capture session whose state is changing.

AImageReader_ImageListener

struct AImageReader_ImageListener AImageReader_ImageListener

AMediaCodec

struct AMediaCodec AMediaCodec

AMediaCodecBufferInfo

struct AMediaCodecBufferInfo AMediaCodecBufferInfo

AMediaCodecCryptoInfo

struct AMediaCodecCryptoInfo AMediaCodecCryptoInfo

AMediaCodecOnAsyncError

void(* AMediaCodecOnAsyncError)(AMediaCodec *codec, void *userdata, media_status_t error, int32_t actionCode, const char *detail)

Called when the MediaCodec encountered an error.

The specified actionCode indicates the possible actions that client can take, and it can be checked by calling AMediaCodecActionCode_isRecoverable or AMediaCodecActionCode_isTransient. If both AMediaCodecActionCode_isRecoverable() and AMediaCodecActionCode_isTransient() return false, then the codec error is fatal and the codec must be deleted. The specified detail may contain more detailed messages about this error.

AMediaCodecOnAsyncFormatChanged

void(* AMediaCodecOnAsyncFormatChanged)(AMediaCodec *codec, void *userdata, AMediaFormat *format)

Called when the output format has changed.

The specified format contains the new output format.

AMediaCodecOnAsyncInputAvailable

void(* AMediaCodecOnAsyncInputAvailable)(AMediaCodec *codec, void *userdata, int32_t index)

Called when an input buffer becomes available.

The specified index is the index of the available input buffer.

AMediaCodecOnAsyncNotifyCallback

struct AMediaCodecOnAsyncNotifyCallback AMediaCodecOnAsyncNotifyCallback

AMediaCodecOnAsyncOutputAvailable

void(* AMediaCodecOnAsyncOutputAvailable)(AMediaCodec *codec, void *userdata, int32_t index, AMediaCodecBufferInfo *bufferInfo)

Called when an output buffer becomes available.

The specified index is the index of the available output buffer. The specified bufferInfo contains information regarding the available output buffer.

AMediaCodecOnFrameRendered

void(* AMediaCodecOnFrameRendered)(AMediaCodec *codec, void *userdata, int64_t mediaTimeUs, int64_t systemNano)

Called when an output frame has rendered on the output surface.

Details
Parameters
codec
The codec object that generated this notification.
userdata
The user data set at AMediaCodec_setOnFrameRenderedCallback.
mediaTimeUs
The presentation time (media time) of the frame rendered. This is usually the same as specified in AMediaCodec_queueInputBuffer, but some codecs may alter the media time by applying some time-based transformation, such as frame rate conversion. In that case, presentation time corresponds to the actual output frame rendered.
systemNano
The system time when the frame was rendered.

AMediaCrypto

struct AMediaCrypto AMediaCrypto

AMediaDrm

struct AMediaDrm AMediaDrm

AMediaDrmEventListener

void(* AMediaDrmEventListener)(AMediaDrm *, const AMediaDrmSessionId *sessionId, AMediaDrmEventType eventType, int extra, const uint8_t *data, size_t dataSize)

AMediaDrmEventType

enum AMediaDrmEventType AMediaDrmEventType

AMediaDrmExpirationUpdateListener

void(* AMediaDrmExpirationUpdateListener)(AMediaDrm *, const AMediaDrmSessionId *sessionId, int64_t expiryTimeInMS)

AMediaDrmKeyId

AMediaDrmByteArray AMediaDrmKeyId

AMediaDrmKeyRequestType

enum AMediaDrmKeyRequestType AMediaDrmKeyRequestType

Introduced in API 33.

AMediaDrmKeySetId

AMediaDrmByteArray AMediaDrmKeySetId

AMediaDrmKeyStatus

struct AMediaDrmKeyStatus AMediaDrmKeyStatus

AMediaDrmKeyStatusType

enum AMediaKeyStatusType AMediaDrmKeyStatusType

AMediaDrmKeyType

enum AMediaDrmKeyType AMediaDrmKeyType

AMediaDrmKeyValue

struct AMediaDrmKeyValuePair AMediaDrmKeyValue

Data type containing {key, value} pair.

AMediaDrmKeysChangeListener

void(* AMediaDrmKeysChangeListener)(AMediaDrm *, const AMediaDrmSessionId *sessionId, const AMediaDrmKeyStatus *keyStatus, size_t numKeys, bool hasNewUsableKey)

AMediaDrmScope

AMediaDrmByteArray AMediaDrmScope

AMediaDrmSecureStop

AMediaDrmByteArray AMediaDrmSecureStop

AMediaDrmSessionId

AMediaDrmByteArray AMediaDrmSessionId

AMediaExtractor

struct AMediaExtractor AMediaExtractor

AMediaFormat

struct AMediaFormat AMediaFormat

AMediaMuxer

struct AMediaMuxer AMediaMuxer

AMediaUUID

uint8_t AMediaUUID[16]

ANativeWindow

struct ANativeWindow ANativeWindow

PsshEntry

struct PsshEntry PsshEntry

mapping of crypto scheme uuid to the scheme specific data for that scheme

PsshInfo

struct PsshInfo PsshInfo

list of crypto schemes and their data

Variables

AMEDIACODEC_KEY_HDR10_PLUS_INFO

const char * AMEDIACODEC_KEY_HDR10_PLUS_INFO

AMEDIACODEC_KEY_LOW_LATENCY

const char * AMEDIACODEC_KEY_LOW_LATENCY

AMEDIACODEC_KEY_OFFSET_TIME

const char * AMEDIACODEC_KEY_OFFSET_TIME

AMEDIACODEC_KEY_REQUEST_SYNC_FRAME

const char * AMEDIACODEC_KEY_REQUEST_SYNC_FRAME

AMEDIACODEC_KEY_SUSPEND

const char * AMEDIACODEC_KEY_SUSPEND

AMEDIACODEC_KEY_SUSPEND_TIME

const char * AMEDIACODEC_KEY_SUSPEND_TIME

AMEDIACODEC_KEY_VIDEO_BITRATE

const char * AMEDIACODEC_KEY_VIDEO_BITRATE

AMEDIAFORMAT_KEY_AAC_DRC_ATTENUATION_FACTOR

const char * AMEDIAFORMAT_KEY_AAC_DRC_ATTENUATION_FACTOR

AMEDIAFORMAT_KEY_AAC_DRC_BOOST_FACTOR

const char * AMEDIAFORMAT_KEY_AAC_DRC_BOOST_FACTOR

AMEDIAFORMAT_KEY_AAC_DRC_HEAVY_COMPRESSION

const char * AMEDIAFORMAT_KEY_AAC_DRC_HEAVY_COMPRESSION

AMEDIAFORMAT_KEY_AAC_DRC_TARGET_REFERENCE_LEVEL

const char * AMEDIAFORMAT_KEY_AAC_DRC_TARGET_REFERENCE_LEVEL

AMEDIAFORMAT_KEY_AAC_ENCODED_TARGET_LEVEL

const char * AMEDIAFORMAT_KEY_AAC_ENCODED_TARGET_LEVEL

AMEDIAFORMAT_KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT

const char * AMEDIAFORMAT_KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT

AMEDIAFORMAT_KEY_AAC_PROFILE

const char * AMEDIAFORMAT_KEY_AAC_PROFILE

AMEDIAFORMAT_KEY_AAC_SBR_MODE

const char * AMEDIAFORMAT_KEY_AAC_SBR_MODE

AMEDIAFORMAT_KEY_ALBUM

const char * AMEDIAFORMAT_KEY_ALBUM

AMEDIAFORMAT_KEY_ALBUMART

const char * AMEDIAFORMAT_KEY_ALBUMART

AMEDIAFORMAT_KEY_ALBUMARTIST

const char * AMEDIAFORMAT_KEY_ALBUMARTIST

AMEDIAFORMAT_KEY_ARTIST

const char * AMEDIAFORMAT_KEY_ARTIST

AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_INFO

const char * AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_INFO

AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_PRESENTATION_ID

const char * AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_PRESENTATION_ID

AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_PROGRAM_ID

const char * AMEDIAFORMAT_KEY_AUDIO_PRESENTATION_PROGRAM_ID

AMEDIAFORMAT_KEY_AUDIO_SESSION_ID

const char * AMEDIAFORMAT_KEY_AUDIO_SESSION_ID

AMEDIAFORMAT_KEY_AUTHOR

const char * AMEDIAFORMAT_KEY_AUTHOR

AMEDIAFORMAT_KEY_BITRATE_MODE

const char * AMEDIAFORMAT_KEY_BITRATE_MODE

AMEDIAFORMAT_KEY_BITS_PER_SAMPLE

const char * AMEDIAFORMAT_KEY_BITS_PER_SAMPLE

AMEDIAFORMAT_KEY_BIT_RATE

const char * AMEDIAFORMAT_KEY_BIT_RATE

AMEDIAFORMAT_KEY_CAPTURE_RATE

const char * AMEDIAFORMAT_KEY_CAPTURE_RATE

AMEDIAFORMAT_KEY_CDTRACKNUMBER

const char * AMEDIAFORMAT_KEY_CDTRACKNUMBER

AMEDIAFORMAT_KEY_CHANNEL_COUNT

const char * AMEDIAFORMAT_KEY_CHANNEL_COUNT

AMEDIAFORMAT_KEY_CHANNEL_MASK

const char * AMEDIAFORMAT_KEY_CHANNEL_MASK

AMEDIAFORMAT_KEY_COLOR_FORMAT

const char * AMEDIAFORMAT_KEY_COLOR_FORMAT

AMEDIAFORMAT_KEY_COLOR_RANGE

const char * AMEDIAFORMAT_KEY_COLOR_RANGE

AMEDIAFORMAT_KEY_COLOR_STANDARD

const char * AMEDIAFORMAT_KEY_COLOR_STANDARD

AMEDIAFORMAT_KEY_COLOR_TRANSFER

const char * AMEDIAFORMAT_KEY_COLOR_TRANSFER

AMEDIAFORMAT_KEY_COMPILATION

const char * AMEDIAFORMAT_KEY_COMPILATION

AMEDIAFORMAT_KEY_COMPLEXITY

const char * AMEDIAFORMAT_KEY_COMPLEXITY

AMEDIAFORMAT_KEY_COMPOSER

const char * AMEDIAFORMAT_KEY_COMPOSER

AMEDIAFORMAT_KEY_CREATE_INPUT_SURFACE_SUSPENDED

const char * AMEDIAFORMAT_KEY_CREATE_INPUT_SURFACE_SUSPENDED

AMEDIAFORMAT_KEY_CRYPTO_DEFAULT_IV_SIZE

const char * AMEDIAFORMAT_KEY_CRYPTO_DEFAULT_IV_SIZE

AMEDIAFORMAT_KEY_CRYPTO_ENCRYPTED_BYTE_BLOCK

const char * AMEDIAFORMAT_KEY_CRYPTO_ENCRYPTED_BYTE_BLOCK

AMEDIAFORMAT_KEY_CRYPTO_ENCRYPTED_SIZES

const char * AMEDIAFORMAT_KEY_CRYPTO_ENCRYPTED_SIZES

AMEDIAFORMAT_KEY_CRYPTO_IV

const char * AMEDIAFORMAT_KEY_CRYPTO_IV

AMEDIAFORMAT_KEY_CRYPTO_KEY

const char * AMEDIAFORMAT_KEY_CRYPTO_KEY

AMEDIAFORMAT_KEY_CRYPTO_MODE

const char * AMEDIAFORMAT_KEY_CRYPTO_MODE

AMEDIAFORMAT_KEY_CRYPTO_PLAIN_SIZES

const char * AMEDIAFORMAT_KEY_CRYPTO_PLAIN_SIZES

AMEDIAFORMAT_KEY_CRYPTO_SKIP_BYTE_BLOCK

const char * AMEDIAFORMAT_KEY_CRYPTO_SKIP_BYTE_BLOCK

AMEDIAFORMAT_KEY_CSD

const char * AMEDIAFORMAT_KEY_CSD

AMEDIAFORMAT_KEY_CSD_0

const char * AMEDIAFORMAT_KEY_CSD_0

AMEDIAFORMAT_KEY_CSD_1

const char * AMEDIAFORMAT_KEY_CSD_1

AMEDIAFORMAT_KEY_CSD_2

const char * AMEDIAFORMAT_KEY_CSD_2

AMEDIAFORMAT_KEY_CSD_AVC

const char * AMEDIAFORMAT_KEY_CSD_AVC

AMEDIAFORMAT_KEY_CSD_HEVC

const char * AMEDIAFORMAT_KEY_CSD_HEVC

AMEDIAFORMAT_KEY_D263

const char * AMEDIAFORMAT_KEY_D263

AMEDIAFORMAT_KEY_DATE

const char * AMEDIAFORMAT_KEY_DATE

AMEDIAFORMAT_KEY_DISCNUMBER

const char * AMEDIAFORMAT_KEY_DISCNUMBER

AMEDIAFORMAT_KEY_DISPLAY_CROP

const char * AMEDIAFORMAT_KEY_DISPLAY_CROP

AMEDIAFORMAT_KEY_DISPLAY_HEIGHT

const char * AMEDIAFORMAT_KEY_DISPLAY_HEIGHT

AMEDIAFORMAT_KEY_DISPLAY_WIDTH

const char * AMEDIAFORMAT_KEY_DISPLAY_WIDTH

AMEDIAFORMAT_KEY_DURATION

const char * AMEDIAFORMAT_KEY_DURATION

AMEDIAFORMAT_KEY_ENCODER_DELAY

const char * AMEDIAFORMAT_KEY_ENCODER_DELAY

AMEDIAFORMAT_KEY_ENCODER_PADDING

const char * AMEDIAFORMAT_KEY_ENCODER_PADDING

AMEDIAFORMAT_KEY_ESDS

const char * AMEDIAFORMAT_KEY_ESDS

AMEDIAFORMAT_KEY_EXIF_OFFSET

const char * AMEDIAFORMAT_KEY_EXIF_OFFSET

AMEDIAFORMAT_KEY_EXIF_SIZE

const char * AMEDIAFORMAT_KEY_EXIF_SIZE

AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL

const char * AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL

AMEDIAFORMAT_KEY_FRAME_COUNT

const char * AMEDIAFORMAT_KEY_FRAME_COUNT

AMEDIAFORMAT_KEY_FRAME_RATE

const char * AMEDIAFORMAT_KEY_FRAME_RATE

AMEDIAFORMAT_KEY_GENRE

const char * AMEDIAFORMAT_KEY_GENRE

AMEDIAFORMAT_KEY_GRID_COLUMNS

const char * AMEDIAFORMAT_KEY_GRID_COLUMNS

AMEDIAFORMAT_KEY_GRID_ROWS

const char * AMEDIAFORMAT_KEY_GRID_ROWS

AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT

const char * AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT

AMEDIAFORMAT_KEY_HDR10_PLUS_INFO

const char * AMEDIAFORMAT_KEY_HDR10_PLUS_INFO

AMEDIAFORMAT_KEY_HDR_STATIC_INFO

const char * AMEDIAFORMAT_KEY_HDR_STATIC_INFO

AMEDIAFORMAT_KEY_HEIGHT

const char * AMEDIAFORMAT_KEY_HEIGHT

AMEDIAFORMAT_KEY_ICC_PROFILE

const char * AMEDIAFORMAT_KEY_ICC_PROFILE

AMEDIAFORMAT_KEY_INTRA_REFRESH_PERIOD

const char * AMEDIAFORMAT_KEY_INTRA_REFRESH_PERIOD

AMEDIAFORMAT_KEY_IS_ADTS

const char * AMEDIAFORMAT_KEY_IS_ADTS

AMEDIAFORMAT_KEY_IS_AUTOSELECT

const char * AMEDIAFORMAT_KEY_IS_AUTOSELECT

AMEDIAFORMAT_KEY_IS_DEFAULT

const char * AMEDIAFORMAT_KEY_IS_DEFAULT

AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE

const char * AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE

AMEDIAFORMAT_KEY_IS_SYNC_FRAME

const char * AMEDIAFORMAT_KEY_IS_SYNC_FRAME

AMEDIAFORMAT_KEY_I_FRAME_INTERVAL

const char * AMEDIAFORMAT_KEY_I_FRAME_INTERVAL

AMEDIAFORMAT_KEY_LANGUAGE

const char * AMEDIAFORMAT_KEY_LANGUAGE

AMEDIAFORMAT_KEY_LAST_SAMPLE_INDEX_IN_CHUNK

const char * AMEDIAFORMAT_KEY_LAST_SAMPLE_INDEX_IN_CHUNK

AMEDIAFORMAT_KEY_LATENCY

const char * AMEDIAFORMAT_KEY_LATENCY

AMEDIAFORMAT_KEY_LEVEL

const char * AMEDIAFORMAT_KEY_LEVEL

AMEDIAFORMAT_KEY_LOCATION

const char * AMEDIAFORMAT_KEY_LOCATION

AMEDIAFORMAT_KEY_LOOP

const char * AMEDIAFORMAT_KEY_LOOP

AMEDIAFORMAT_KEY_LOW_LATENCY

const char * AMEDIAFORMAT_KEY_LOW_LATENCY

An optional key describing the low latency decoding mode.

This is an optional parameter that applies only to decoders. If enabled, the decoder doesn't hold input and output data more than required by the codec standards. The associated value is an integer (0 or 1): 1 when low-latency decoding is enabled, 0 otherwise. The default value is 0.

Available since API level 30.

AMEDIAFORMAT_KEY_LYRICIST

const char * AMEDIAFORMAT_KEY_LYRICIST

AMEDIAFORMAT_KEY_MANUFACTURER

const char * AMEDIAFORMAT_KEY_MANUFACTURER

AMEDIAFORMAT_KEY_MAX_BIT_RATE

const char * AMEDIAFORMAT_KEY_MAX_BIT_RATE

AMEDIAFORMAT_KEY_MAX_FPS_TO_ENCODER

const char * AMEDIAFORMAT_KEY_MAX_FPS_TO_ENCODER

AMEDIAFORMAT_KEY_MAX_HEIGHT

const char * AMEDIAFORMAT_KEY_MAX_HEIGHT

AMEDIAFORMAT_KEY_MAX_INPUT_SIZE

const char * AMEDIAFORMAT_KEY_MAX_INPUT_SIZE

AMEDIAFORMAT_KEY_MAX_PTS_GAP_TO_ENCODER

const char * AMEDIAFORMAT_KEY_MAX_PTS_GAP_TO_ENCODER

AMEDIAFORMAT_KEY_MAX_WIDTH

const char * AMEDIAFORMAT_KEY_MAX_WIDTH

AMEDIAFORMAT_KEY_MIME

const char * AMEDIAFORMAT_KEY_MIME

AMEDIAFORMAT_KEY_MPEG2_STREAM_HEADER

const char * AMEDIAFORMAT_KEY_MPEG2_STREAM_HEADER

AMEDIAFORMAT_KEY_MPEGH_COMPATIBLE_SETS

const char * AMEDIAFORMAT_KEY_MPEGH_COMPATIBLE_SETS

MPEG-H audio profile and level compatibility.

See FDAmd_2 of ISO_IEC_23008-3;2019 MHAProfileAndLevelCompatibilitySetBox.

Available since API level 32.

AMEDIAFORMAT_KEY_MPEGH_PROFILE_LEVEL_INDICATION

const char * AMEDIAFORMAT_KEY_MPEGH_PROFILE_LEVEL_INDICATION

MPEG-H audio profile level indication.

See ISO_IEC_23008-3;2019 MHADecoderConfigurationRecord mpegh3daProfileLevelIndication.

Available since API level 32.

AMEDIAFORMAT_KEY_MPEGH_REFERENCE_CHANNEL_LAYOUT

const char * AMEDIAFORMAT_KEY_MPEGH_REFERENCE_CHANNEL_LAYOUT

MPEG-H audio reference channel layout.

See ISO_IEC_23008-3;2019 MHADecoderConfigurationRecord referenceChannelLayout and ISO_IEC_23001‐8 ChannelConfiguration value.

Available since API level 32.

AMEDIAFORMAT_KEY_MPEG_USER_DATA

const char * AMEDIAFORMAT_KEY_MPEG_USER_DATA

AMEDIAFORMAT_KEY_OPERATING_RATE

const char * AMEDIAFORMAT_KEY_OPERATING_RATE

AMEDIAFORMAT_KEY_PCM_BIG_ENDIAN

const char * AMEDIAFORMAT_KEY_PCM_BIG_ENDIAN

AMEDIAFORMAT_KEY_PCM_ENCODING

const char * AMEDIAFORMAT_KEY_PCM_ENCODING

AMEDIAFORMAT_KEY_PICTURE_TYPE

const char * AMEDIAFORMAT_KEY_PICTURE_TYPE

AMEDIAFORMAT_KEY_PRIORITY

const char * AMEDIAFORMAT_KEY_PRIORITY

AMEDIAFORMAT_KEY_PROFILE

const char * AMEDIAFORMAT_KEY_PROFILE

AMEDIAFORMAT_KEY_PSSH

const char * AMEDIAFORMAT_KEY_PSSH

AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP

const char * AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP

AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER

const char * AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER

AMEDIAFORMAT_KEY_ROTATION

const char * AMEDIAFORMAT_KEY_ROTATION

AMEDIAFORMAT_KEY_SAMPLE_FILE_OFFSET

const char * AMEDIAFORMAT_KEY_SAMPLE_FILE_OFFSET

AMEDIAFORMAT_KEY_SAMPLE_RATE

const char * AMEDIAFORMAT_KEY_SAMPLE_RATE

AMEDIAFORMAT_KEY_SAMPLE_TIME_BEFORE_APPEND

const char * AMEDIAFORMAT_KEY_SAMPLE_TIME_BEFORE_APPEND

AMEDIAFORMAT_KEY_SAR_HEIGHT

const char * AMEDIAFORMAT_KEY_SAR_HEIGHT

AMEDIAFORMAT_KEY_SAR_WIDTH

const char * AMEDIAFORMAT_KEY_SAR_WIDTH

AMEDIAFORMAT_KEY_SEI

const char * AMEDIAFORMAT_KEY_SEI

AMEDIAFORMAT_KEY_SLICE_HEIGHT

const char * AMEDIAFORMAT_KEY_SLICE_HEIGHT

AMEDIAFORMAT_KEY_SLOW_MOTION_MARKERS

const char * AMEDIAFORMAT_KEY_SLOW_MOTION_MARKERS

AMEDIAFORMAT_KEY_STRIDE

const char * AMEDIAFORMAT_KEY_STRIDE

AMEDIAFORMAT_KEY_TARGET_TIME

const char * AMEDIAFORMAT_KEY_TARGET_TIME

AMEDIAFORMAT_KEY_TEMPORAL_LAYERING

const char * AMEDIAFORMAT_KEY_TEMPORAL_LAYERING

AMEDIAFORMAT_KEY_TEMPORAL_LAYER_COUNT

const char * AMEDIAFORMAT_KEY_TEMPORAL_LAYER_COUNT

AMEDIAFORMAT_KEY_TEMPORAL_LAYER_ID

const char * AMEDIAFORMAT_KEY_TEMPORAL_LAYER_ID

AMEDIAFORMAT_KEY_TEXT_FORMAT_DATA

const char * AMEDIAFORMAT_KEY_TEXT_FORMAT_DATA

AMEDIAFORMAT_KEY_THUMBNAIL_CSD_AV1C

const char * AMEDIAFORMAT_KEY_THUMBNAIL_CSD_AV1C

AMEDIAFORMAT_KEY_THUMBNAIL_CSD_HEVC

const char * AMEDIAFORMAT_KEY_THUMBNAIL_CSD_HEVC

AMEDIAFORMAT_KEY_THUMBNAIL_HEIGHT

const char * AMEDIAFORMAT_KEY_THUMBNAIL_HEIGHT

AMEDIAFORMAT_KEY_THUMBNAIL_TIME

const char * AMEDIAFORMAT_KEY_THUMBNAIL_TIME

AMEDIAFORMAT_KEY_THUMBNAIL_WIDTH

const char * AMEDIAFORMAT_KEY_THUMBNAIL_WIDTH

AMEDIAFORMAT_KEY_TILE_HEIGHT

const char * AMEDIAFORMAT_KEY_TILE_HEIGHT

AMEDIAFORMAT_KEY_TILE_WIDTH

const char * AMEDIAFORMAT_KEY_TILE_WIDTH

AMEDIAFORMAT_KEY_TIME_US

const char * AMEDIAFORMAT_KEY_TIME_US

AMEDIAFORMAT_KEY_TITLE

const char * AMEDIAFORMAT_KEY_TITLE

AMEDIAFORMAT_KEY_TRACK_ID

const char * AMEDIAFORMAT_KEY_TRACK_ID

AMEDIAFORMAT_KEY_TRACK_INDEX

const char * AMEDIAFORMAT_KEY_TRACK_INDEX

AMEDIAFORMAT_KEY_VALID_SAMPLES

const char * AMEDIAFORMAT_KEY_VALID_SAMPLES

AMEDIAFORMAT_KEY_VIDEO_ENCODING_STATISTICS_LEVEL

const char * AMEDIAFORMAT_KEY_VIDEO_ENCODING_STATISTICS_LEVEL

AMEDIAFORMAT_KEY_VIDEO_QP_AVERAGE

const char * AMEDIAFORMAT_KEY_VIDEO_QP_AVERAGE

AMEDIAFORMAT_KEY_WIDTH

const char * AMEDIAFORMAT_KEY_WIDTH

AMEDIAFORMAT_KEY_XMP_OFFSET

const char * AMEDIAFORMAT_KEY_XMP_OFFSET

AMEDIAFORMAT_KEY_XMP_SIZE

const char * AMEDIAFORMAT_KEY_XMP_SIZE

AMEDIAFORMAT_KEY_YEAR

const char * AMEDIAFORMAT_KEY_YEAR

AMEDIAFORMAT_VIDEO_QP_B_MAX

const char * AMEDIAFORMAT_VIDEO_QP_B_MAX

AMEDIAFORMAT_VIDEO_QP_B_MIN

const char * AMEDIAFORMAT_VIDEO_QP_B_MIN

AMEDIAFORMAT_VIDEO_QP_I_MAX

const char * AMEDIAFORMAT_VIDEO_QP_I_MAX

AMEDIAFORMAT_VIDEO_QP_I_MIN

const char * AMEDIAFORMAT_VIDEO_QP_I_MIN

AMEDIAFORMAT_VIDEO_QP_MAX

const char * AMEDIAFORMAT_VIDEO_QP_MAX

AMEDIAFORMAT_VIDEO_QP_MIN

const char * AMEDIAFORMAT_VIDEO_QP_MIN

AMEDIAFORMAT_VIDEO_QP_P_MAX

const char * AMEDIAFORMAT_VIDEO_QP_P_MAX

AMEDIAFORMAT_VIDEO_QP_P_MIN

const char * AMEDIAFORMAT_VIDEO_QP_P_MIN

Functions

AImageReader_acquireLatestImage

media_status_t AImageReader_acquireLatestImage(
  AImageReader *reader,
  AImage **image
)

Acquire the latest AImage from the image reader's queue, dropping older images.

This operation will acquire all the images possible from the image reader, but AImage_delete all images that aren't the latest. This function is recommended to use over AImageReader_acquireNextImage for most use-cases, as it's more suited for real-time processing.

Note that maxImages should be at least 2 for AImageReader_acquireLatestImage to be any different than AImageReader_acquireNextImage - discarding all-but-the-newest AImage requires temporarily acquiring two AImages at once. Or more generally, calling AImageReader_acquireLatestImage with less than two images of margin, that is (maxImages - currentAcquiredImages < 2) will not discard as expected.

This method will fail if maxImages have been acquired with AImageReader_acquireNextImage or AImageReader_acquireLatestImage. In particular a sequence of AImageReader_acquireNextImage or AImageReader_acquireLatestImage calls greater than maxImages without calling AImage_delete in-between will exhaust the underlying queue. At such a time, AMEDIA_IMGREADER_MAX_IMAGES_ACQUIRED will be returned until more images are released with AImage_delete.

Available since API level 24.

See also: AImageReader_acquireNextImage

Details
Parameters
reader
The image reader of interest.
image
the acquired AImage will be filled here if the method call succeeeds.
Returns

AImageReader_acquireLatestImageAsync

media_status_t AImageReader_acquireLatestImageAsync(
  AImageReader *reader,
  AImage **image,
  int *acquireFenceFd
)

Acquire the latest AImage from the image reader's queue asynchronously, dropping older images.

AImageReader acquire method similar to AImageReader_acquireLatestImage that takes an additional parameter for the sync fence. All other parameters and the return values are identical to those passed to AImageReader_acquireLatestImage.

Available since API level 26.

See also:sync.hSee also:sync_get_fence_info

Details
Parameters
acquireFenceFd
A sync fence fd defined in sync.h, which is used to signal when the buffer is ready to consume. When synchronization fence is not needed, fence will be set to -1 and the AImage returned is ready for use immediately. Otherwise, user shall use syscalls such as poll(), epoll(), select() to wait for the fence fd to change status before attempting to access the AImage returned.

AImageReader_acquireNextImage

media_status_t AImageReader_acquireNextImage(
  AImageReader *reader,
  AImage **image
)

Acquire the next AImage from the image reader's queue.

Warning: Consider using AImageReader_acquireLatestImage instead, as it will automatically release older images, and allow slower-running processing routines to catch up to the newest frame. Usage of AImageReader_acquireNextImage is recommended for batch/background processing. Incorrectly using this method can cause images to appear with an ever-increasing delay, followed by a complete stall where no new images seem to appear.

This method will fail if maxImages have been acquired with AImageReader_acquireNextImage or AImageReader_acquireLatestImage. In particular a sequence of AImageReader_acquireNextImage or AImageReader_acquireLatestImage calls greater than maxImages without calling AImage_delete in-between will exhaust the underlying queue. At such a time, AMEDIA_IMGREADER_MAX_IMAGES_ACQUIRED will be returned until more images are released with AImage_delete.

Available since API level 24.

See also: AImageReader_acquireLatestImage

Details
Parameters
reader
The image reader of interest.
image
the acquired AImage will be filled here if the method call succeeeds.
Returns

AImageReader_acquireNextImageAsync

media_status_t AImageReader_acquireNextImageAsync(
  AImageReader *reader,
  AImage **image,
  int *acquireFenceFd
)

Acquire the next AImage from the image reader's queue asynchronously.

AImageReader acquire method similar to AImageReader_acquireNextImage that takes an additional parameter for the sync fence. All other parameters and the return values are identical to those passed to AImageReader_acquireNextImage.

Available since API level 26.

See also:sync.hSee also:sync_get_fence_info

Details
Parameters
acquireFenceFd
A sync fence fd defined in sync.h, which is used to signal when the buffer is ready to consume. When synchronization fence is not needed, fence will be set to -1 and the AImage returned is ready for use immediately. Otherwise, user shall use syscalls such as poll(), epoll(), select() to wait for the fence fd to change status before attempting to access the AImage returned.

AImageReader_delete

void AImageReader_delete(
  AImageReader *reader
)

Delete an AImageReader and return all images generated by this reader to system.

This method will return all AImage objects acquired by this reader (via AImageReader_acquireNextImage or AImageReader_acquireLatestImage) to system, making any of data pointers obtained from AImage_getPlaneData invalid. Do NOT access the reader object or any of those data pointers after this method returns.

Available since API level 24.

Details
Parameters
reader
The image reader to be deleted.

AImageReader_getFormat

media_status_t AImageReader_getFormat(
  const AImageReader *reader,
  int32_t *format
)

Query the format of the AImage generated by this reader.

Available since API level 24.

Details
Parameters
reader
The image reader of interest.
format
the fromat of the reader will be filled here if the method call succeeeds. The value will be one of the AIMAGE_FORMAT_* enum value defiend in NdkImage.h.
Returns

AImageReader_getHeight

media_status_t AImageReader_getHeight(
  const AImageReader *reader,
  int32_t *height
)

Query the default height of the AImage generated by this reader, in pixels.

The height may be overridden by the producer sending buffers to this reader's ANativeWindow. If so, the actual height of the images can be found using AImage_getHeight.

Available since API level 24.

Details
Parameters
reader
The image reader of interest.
height
the default height of the reader will be filled here if the method call succeeeds.
Returns

AImageReader_getMaxImages

media_status_t AImageReader_getMaxImages(
  const AImageReader *reader,
  int32_t *maxImages
)

Query the maximum number of concurrently acquired AImages of this reader.

Available since API level 24.

Details
Parameters
reader
The image reader of interest.
maxImages
the maximum number of concurrently acquired images of the reader will be filled here if the method call succeeeds.
Returns

AImageReader_getWidth

media_status_t AImageReader_getWidth(
  const AImageReader *reader,
  int32_t *width
)

Query the default width of the AImage generated by this reader, in pixels.

The width may be overridden by the producer sending buffers to this reader's ANativeWindow. If so, the actual width of the images can be found using AImage_getWidth.

Available since API level 24.

Details
Parameters
reader
The image reader of interest.
width
the default width of the reader will be filled here if the method call succeeeds.
Returns

AImageReader_getWindow

media_status_t AImageReader_getWindow(
  AImageReader *reader,
  ANativeWindow **window
)

Get a ANativeWindow that can be used to produce AImage for this image reader.

Available since API level 24.

Details
Parameters
reader
The image reader of interest.
window
The output ANativeWindow will be filled here if the method call succeeds. The ANativeWindow is managed by this image reader. Do NOT call ANativeWindow_release on it. Instead, use AImageReader_delete.
Returns

AImageReader_new

media_status_t AImageReader_new(
  int32_t width,
  int32_t height,
  int32_t format,
  int32_t maxImages,
  AImageReader **reader
)

Create a new reader for images of the desired size and format.

The maxImages parameter determines the maximum number of AImage objects that can be acquired from the AImageReader simultaneously. Requesting more buffers will use up more memory, so it is important to use only the minimum number necessary for the use case.

The valid sizes and formats depend on the source of the image data.

Available since API level 24.

See also: AImage

Details
Parameters
width
The default width in pixels of the Images that this reader will produce.
height
The default height in pixels of the Images that this reader will produce.
format
The format of the Image that this reader will produce. This must be one of the AIMAGE_FORMAT_* enum value defined in AIMAGE_FORMATS. Note that not all formats are supported. One example is AIMAGE_FORMAT_PRIVATE, as it is not intended to be read by applications directly. That format is supported by AImageReader_newWithUsage introduced in API 26.
maxImages
The maximum number of images the user will want to access simultaneously. This should be as small as possible to limit memory use. Once maxImages Images are obtained by the user, one of them has to be released before a new AImage will become available for access through AImageReader_acquireLatestImage or AImageReader_acquireNextImage. Must be greater than 0.
reader
The created image reader will be filled here if the method call succeeeds.
Returns

AImageReader_newWithUsage

media_status_t AImageReader_newWithUsage(
  int32_t width,
  int32_t height,
  int32_t format,
  uint64_t usage,
  int32_t maxImages,
  AImageReader **reader
)

AImageReader constructor similar to AImageReader_new that takes an additional parameter for the consumer usage.

All other parameters and the return values are identical to those passed to AImageReader_new.

If the format is AIMAGE_FORMAT_PRIVATE, the created AImageReader will produce images whose contents are not directly accessible by the application. The application can still acquire images from this AImageReader and access AHardwareBuffer via AImage_getHardwareBuffer(). The AHardwareBuffer gained this way can then be passed back to hardware (such as GPU or hardware encoder if supported) for future processing. For example, you can obtain an EGLClientBuffer from the AHardwareBuffer by using eglGetNativeClientBufferANDROID extension and pass that EGLClientBuffer to eglCreateImageKHR to create an EGLImage resource type, which may then be bound to a texture via glEGLImageTargetTexture2DOES on supported devices. This can be useful for transporting textures that may be shared cross-process.

In general, when software access to image data is not necessary, an AImageReader created with AIMAGE_FORMAT_PRIVATE format is more efficient, compared with AImageReaders using other format such as AIMAGE_FORMAT_YUV_420_888.

Note that not all format and usage flag combination is supported by the AImageReader, especially if format is AIMAGE_FORMAT_PRIVATE, usage must not include either AHARDWAREBUFFER_USAGE_CPU_READ_RARELY or AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN

Note that not all format and usage flag combination is supported by the AImageReader. Below are the combinations supported by the AImageReader.

Format Compatible usage flags
non-AIMAGE_FORMAT_PRIVATE formats defined in NdkImage.h AHARDWAREBUFFER_USAGE_CPU_READ_RARELY or AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN
AIMAGE_FORMAT_RGBA_8888 AHARDWAREBUFFER_USAGE_VIDEO_ENCODE or AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE, or combined

Details
Parameters
width
The default width in pixels of the Images that this reader will produce.
height
The default height in pixels of the Images that this reader will produce.
format
The format of the Image that this reader will produce. This must be one of the AIMAGE_FORMAT_* enum value defined in AIMAGE_FORMATS.
usage
specifies how the consumer will access the AImage, using combination of the AHARDWAREBUFFER_USAGE flags described in hardware_buffer.h. Passing AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN is equivalent to calling AImageReader_new with the same parameters.

Available since API level 26.

See also: AImage See also: AImageReader_new See also: AHardwareBuffer

Details
Returns

AImageReader_setBufferRemovedListener

media_status_t AImageReader_setBufferRemovedListener(
  AImageReader *reader,
  AImageReader_BufferRemovedListener *listener
)

Set the onBufferRemoved listener of this image reader.

Note that calling this method will replace previously registered listeners.

Available since API level 26.

See also: AImage_getHardwareBuffer

Details
Parameters
reader
The image reader of interest.
listener
the AImageReader_BufferRemovedListener to be registered. Set this to NULL if application no longer needs to listen to buffer removed events.
Returns

AImageReader_setImageListener

media_status_t AImageReader_setImageListener(
  AImageReader *reader,
  AImageReader_ImageListener *listener
)

Set the onImageAvailable listener of this image reader.

Calling this method will replace previously registered listeners.

Available since API level 24.

Details
Parameters
reader
The image reader of interest.
listener
The AImageReader_ImageListener to be registered. Set this to NULL if the application no longer needs to listen to new images.
Returns

AImage_delete

void AImage_delete(
  AImage *image
)

Return the image back the the system and delete the AImage object from memory.

Do NOT use the image pointer after this method returns. Note that if the parent AImageReader is closed, all the AImage objects acquired from the parent reader will be returned to system. All AImage_* methods except this method will return AMEDIA_ERROR_INVALID_OBJECT. Application still needs to call this method on those AImage objects to fully delete the AImage object from memory.

Available since API level 24.

Details
Parameters
image
The AImage to be deleted.

AImage_deleteAsync

void AImage_deleteAsync(
  AImage *image,
  int releaseFenceFd
)

Return the image back the the system and delete the AImage object from memory asynchronously.

Similar to AImage_delete, do NOT use the image pointer after this method returns. However, the caller can still hold on to the AHardwareBuffer returned from this image and signal the release of the hardware buffer back to the AImageReader's queue using releaseFenceFd.

Available since API level 26.

See also: sync.h

Details
Parameters
image
The AImage to be deleted.
releaseFenceFd
A sync fence fd defined in sync.h, which signals the release of underlying AHardwareBuffer.

AImage_getCropRect

media_status_t AImage_getCropRect(
  const AImage *image,
  AImageCropRect *rect
)

Query the cropped rectangle of the input AImage.

The crop rectangle specifies the region of valid pixels in the image, using coordinates in the largest-resolution plane.

Available since API level 24.

Details
Parameters
image
the AImage of interest.
rect
the cropped rectangle of the image will be filled here if the method call succeeeds.
Returns

AImage_getFormat

media_status_t AImage_getFormat(
  const AImage *image,
  int32_t *format
)

Query the format of the input AImage.

The format value will be one of AIMAGE_FORMAT_* enum value.

Available since API level 24.

Details
Parameters
image
the AImage of interest.
format
the format of the image will be filled here if the method call succeeeds.
Returns

AImage_getHardwareBuffer

media_status_t AImage_getHardwareBuffer(
  const AImage *image,
  AHardwareBuffer **buffer
)

Get the hardware buffer handle of the input image intended for GPU and/or hardware access.

Note that no reference on the returned AHardwareBuffer handle is acquired automatically. Once the AImage or the parent AImageReader is deleted, the AHardwareBuffer handle from previous AImage_getHardwareBuffer becomes invalid.

If the caller ever needs to hold on a reference to the AHardwareBuffer handle after the AImage or the parent AImageReader is deleted, it must call AHardwareBuffer_acquire to acquire an extra reference, and call AHardwareBuffer_release once it has finished using it in order to properly deallocate the underlying memory managed by AHardwareBuffer. If the caller has acquired extra reference on an AHardwareBuffer returned from this function, it must also register a listener using the function AImageReader_setBufferRemovedListener to be notified when the buffer is no longer used by AImageReader.

Available since API level 26.

See also: AImageReader_ImageCallback

Details
Parameters
image
the AImage of interest.
buffer
The memory area pointed to by buffer will contain the acquired AHardwareBuffer handle.
Returns

AImage_getHeight

media_status_t AImage_getHeight(
  const AImage *image,
  int32_t *height
)

Query the height of the input AImage.

Available since API level 24.

Details
Parameters
image
the AImage of interest.
height
the height of the image will be filled here if the method call succeeeds.
Returns

AImage_getNumberOfPlanes

media_status_t AImage_getNumberOfPlanes(
  const AImage *image,
  int32_t *numPlanes
)

Query the number of planes of the input AImage.

The number of plane of an AImage is determined by its format, which can be queried by AImage_getFormat method.

Available since API level 24.

Details
Parameters
image
the AImage of interest.
numPlanes
the number of planes of the image will be filled here if the method call succeeeds.
Returns

AImage_getPlaneData

media_status_t AImage_getPlaneData(
  const AImage *image,
  int planeIdx,
  uint8_t **data,
  int *dataLength
)

Get the data pointer of the input image for direct application access.

Note that once the AImage or the parent AImageReader is deleted, the data pointer from previous AImage_getPlaneData call becomes invalid. Do NOT use it after the AImage or the parent AImageReader is deleted.

Available since API level 24.

Details
Parameters
image
the AImage of interest.
planeIdx
the index of the plane. Must be less than the number of planes of input image.
data
the data pointer of the image will be filled here if the method call succeeeds.
dataLength
the valid length of data will be filled here if the method call succeeeds.
Returns

AImage_getPlanePixelStride

media_status_t AImage_getPlanePixelStride(
  const AImage *image,
  int planeIdx,
  int32_t *pixelStride
)

Query the pixel stride of the input AImage.

This is the distance between two consecutive pixel values in a row of pixels. It may be larger than the size of a single pixel to account for interleaved image data or padded formats. Note that pixel stride is undefined for some formats such as AIMAGE_FORMAT_RAW_PRIVATE, and calling this method on images of these formats will cause AMEDIA_ERROR_UNSUPPORTED being returned. For formats where pixel stride is well defined, the pixel stride is always greater than 0.

Available since API level 24.

Details
Parameters
image
the AImage of interest.
planeIdx
the index of the plane. Must be less than the number of planes of input image.
pixelStride
the pixel stride of the image will be filled here if the method call succeeeds.
Returns

AImage_getPlaneRowStride

media_status_t AImage_getPlaneRowStride(
  const AImage *image,
  int planeIdx,
  int32_t *rowStride
)

Query the row stride of the input AImage.

This is the distance between the start of two consecutive rows of pixels in the image. Note that row stried is undefined for some formats such as AIMAGE_FORMAT_RAW_PRIVATE, and calling this method on images of these formats will cause AMEDIA_ERROR_UNSUPPORTED being returned. For formats where row stride is well defined, the row stride is always greater than 0.

Available since API level 24.

Details
Parameters
image
the AImage of interest.
planeIdx
the index of the plane. Must be less than the number of planes of input image.
rowStride
the row stride of the image will be filled here if the method call succeeeds.
Returns

AImage_getTimestamp

media_status_t AImage_getTimestamp(
  const AImage *image,
  int64_t *timestampNs
)

Query the timestamp of the input AImage.

The timestamp is measured in nanoseconds, and is normally monotonically increasing. The timestamps for the images from different sources may have different timebases therefore may not be comparable. The specific meaning and timebase of the timestamp depend on the source providing images. For images generated by camera, the timestamp value will match ACAMERA_SENSOR_TIMESTAMP of the ACameraMetadata in ACameraCaptureSession_captureCallbacks#onCaptureStarted and ACameraCaptureSession_captureCallbacks#onCaptureCompleted callback.

Available since API level 24.

Details
Parameters
image
the AImage of interest.
timestampNs
the timestamp of the image will be filled here if the method call succeeeds.
Returns

AImage_getWidth

media_status_t AImage_getWidth(
  const AImage *image,
  int32_t *width
)

Query the width of the input AImage.

Available since API level 24.

Details
Parameters
image
the AImage of interest.
width
the width of the image will be filled here if the method call succeeeds.
Returns

AMediaCodecActionCode_isRecoverable

bool AMediaCodecActionCode_isRecoverable(
  int32_t actionCode
)

Returns true if the codec cannot proceed further, but can be recovered by stopping, configuring, and starting again.

Available since API level 28.

AMediaCodecActionCode_isTransient

bool AMediaCodecActionCode_isTransient(
  int32_t actionCode
)

Returns true if the codec error is a transient issue, perhaps due to resource constraints, and that the method (or encoding/decoding) may be retried at a later time.

Available since API level 28.

AMediaCodecCryptoInfo_delete

media_status_t AMediaCodecCryptoInfo_delete(
  AMediaCodecCryptoInfo *
)

Delete an AMediaCodecCryptoInfo created previously with AMediaCodecCryptoInfo_new, or obtained from AMediaExtractor.

Available since API level 21.

AMediaCodecCryptoInfo_getClearBytes

media_status_t AMediaCodecCryptoInfo_getClearBytes(
  AMediaCodecCryptoInfo *,
  size_t *dst
)

The number of leading unencrypted bytes in each subsample.

Available since API level 21.

AMediaCodecCryptoInfo_getEncryptedBytes

media_status_t AMediaCodecCryptoInfo_getEncryptedBytes(
  AMediaCodecCryptoInfo *,
  size_t *dst
)

The number of trailing encrypted bytes in each subsample.

Available since API level 21.

AMediaCodecCryptoInfo_getIV

media_status_t AMediaCodecCryptoInfo_getIV(
  AMediaCodecCryptoInfo *,
  uint8_t *dst
)

A 16-byte initialization vector.

Available since API level 21.

AMediaCodecCryptoInfo_getKey

media_status_t AMediaCodecCryptoInfo_getKey(
  AMediaCodecCryptoInfo *,
  uint8_t *dst
)

A 16-byte opaque key.

Available since API level 21.

AMediaCodecCryptoInfo_getMode

cryptoinfo_mode_t AMediaCodecCryptoInfo_getMode(
  AMediaCodecCryptoInfo *
)

The type of encryption that has been applied, one of AMEDIACODECRYPTOINFO_MODE_CLEAR or AMEDIACODECRYPTOINFO_MODE_AES_CTR.

Available since API level 21.

AMediaCodecCryptoInfo_getNumSubSamples

size_t AMediaCodecCryptoInfo_getNumSubSamples(
  AMediaCodecCryptoInfo *
)

The number of subsamples that make up the buffer's contents.

Available since API level 21.

AMediaCodecCryptoInfo_new

AMediaCodecCryptoInfo * AMediaCodecCryptoInfo_new(
  int numsubsamples,
  uint8_t key[16],
  uint8_t iv[16],
  cryptoinfo_mode_t mode,
  size_t *clearbytes,
  size_t *encryptedbytes
)

Create an AMediaCodecCryptoInfo from scratch.

Use this if you need to use custom crypto info, rather than one obtained from AMediaExtractor.

AMediaCodecCryptoInfo describes the structure of an (at least partially) encrypted input sample. A buffer's data is considered to be partitioned into "subsamples", each subsample starts with a (potentially empty) run of plain, unencrypted bytes followed by a (also potentially empty) run of encrypted bytes. numBytesOfClearData can be null to indicate that all data is encrypted. This information encapsulates per-sample metadata as outlined in ISO/IEC FDIS 23001-7:2011 "Common encryption in ISO base media file format files".

Available since API level 21.

AMediaCodecCryptoInfo_setPattern

void AMediaCodecCryptoInfo_setPattern(
  AMediaCodecCryptoInfo *info,
  cryptoinfo_pattern_t *pattern
)

Set the crypto pattern on an AMediaCryptoInfo object.

Available since API level 21.

AMediaCodec_configure

media_status_t AMediaCodec_configure(
  AMediaCodec *,
  const AMediaFormat *format,
  ANativeWindow *surface,
  AMediaCrypto *crypto,
  uint32_t flags
)

Configure the codec.

For decoding you would typically get the format from an extractor.

Available since API level 21.

AMediaCodec_createCodecByName

AMediaCodec * AMediaCodec_createCodecByName(
  const char *name
)

Create codec by name.

Use this if you know the exact codec you want to use. When configuring, you will need to specify whether to use the codec as an encoder or decoder.

Available since API level 21.

AMediaCodec_createDecoderByType

AMediaCodec * AMediaCodec_createDecoderByType(
  const char *mime_type
)

Create codec by mime type.

Most applications will use this, specifying a mime type obtained from media extractor.

Available since API level 21.

AMediaCodec_createEncoderByType

AMediaCodec * AMediaCodec_createEncoderByType(
  const char *mime_type
)

Create encoder by name.

Available since API level 21.

AMediaCodec_createInputSurface

media_status_t AMediaCodec_createInputSurface(
  AMediaCodec *mData,
  ANativeWindow **surface
)

Creates a Surface that can be used as the input to encoder, in place of input buffers.

This can only be called after the codec has been configured via AMediaCodec_configure(..); and before AMediaCodec_start() has been called.

The application is responsible for releasing the surface by calling ANativeWindow_release() when done.

For more details, see the Java documentation for MediaCodec.createInputSurface.

Available since API level 26.

AMediaCodec_createPersistentInputSurface

media_status_t AMediaCodec_createPersistentInputSurface(
  ANativeWindow **surface
)

Creates a persistent Surface that can be used as the input to encoder.

Persistent surface can be reused by MediaCodec instances and can be set on a new instance via AMediaCodec_setInputSurface(). A persistent surface can be connected to at most one instance of MediaCodec at any point in time.

The application is responsible for releasing the surface by calling ANativeWindow_release() when done.

For more details, see the Java documentation for MediaCodec.createPersistentInputSurface.

Available since API level 26.

AMediaCodec_delete

media_status_t AMediaCodec_delete(
  AMediaCodec *
)

Delete the codec and free its resources.

Available since API level 21.

AMediaCodec_dequeueInputBuffer

ssize_t AMediaCodec_dequeueInputBuffer(
  AMediaCodec *,
  int64_t timeoutUs
)

Get the index of the next available input buffer.

An app will typically use this with getInputBuffer() to get a pointer to the buffer, then copy the data to be encoded or decoded into the buffer before passing it to the codec.

Available since API level 21.

AMediaCodec_dequeueOutputBuffer

ssize_t AMediaCodec_dequeueOutputBuffer(
  AMediaCodec *,
  AMediaCodecBufferInfo *info,
  int64_t timeoutUs
)

Get the index of the next available buffer of processed data.

Available since API level 21.

AMediaCodec_flush

media_status_t AMediaCodec_flush(
  AMediaCodec *
)

AMediaCodec_getBufferFormat

AMediaFormat * AMediaCodec_getBufferFormat(
  AMediaCodec *,
  size_t index
)

Get format of the buffer.

The specified buffer index must have been previously obtained from dequeueOutputBuffer. The caller must free the returned format.

Available since API level 28.

AMediaCodec_getInputBuffer

uint8_t * AMediaCodec_getInputBuffer(
  AMediaCodec *,
  size_t idx,
  size_t *out_size
)

Get an input buffer.

The specified buffer index must have been previously obtained from dequeueInputBuffer, and not yet queued.

Available since API level 21.

AMediaCodec_getInputFormat

AMediaFormat * AMediaCodec_getInputFormat(
  AMediaCodec *
)

Call this after AMediaCodec_configure() returns successfully to get the input format accepted by the codec.

Do this to determine what optional configuration parameters were supported by the codec. The caller must free the returned format.

Available since API level 28.

AMediaCodec_getName

media_status_t AMediaCodec_getName(
  AMediaCodec *,
  char **out_name
)

Get the component name.

If the codec was created by createDecoderByType or createEncoderByType, what component is chosen is not known beforehand. Caller shall call AMediaCodec_releaseName to free the returned pointer.

Available since API level 28.

AMediaCodec_getOutputBuffer

uint8_t * AMediaCodec_getOutputBuffer(
  AMediaCodec *,
  size_t idx,
  size_t *out_size
)

Get an output buffer.

The specified buffer index must have been previously obtained from dequeueOutputBuffer, and not yet queued.

Available since API level 21.

AMediaCodec_getOutputFormat

AMediaFormat * AMediaCodec_getOutputFormat(
  AMediaCodec *
)

Returns the format of the codec's output.

The caller must free the returned format.

Available since API level 21.

AMediaCodec_queueInputBuffer

media_status_t AMediaCodec_queueInputBuffer(
  AMediaCodec *,
  size_t idx,
  _off_t_compat offset,
  size_t size,
  uint64_t time,
  uint32_t flags
)

Send the specified buffer to the codec for processing.

Available since API level 21.

AMediaCodec_queueSecureInputBuffer

media_status_t AMediaCodec_queueSecureInputBuffer(
  AMediaCodec *,
  size_t idx,
  _off_t_compat offset,
  AMediaCodecCryptoInfo *,
  uint64_t time,
  uint32_t flags
)

Send the specified buffer to the codec for processing.

Available since API level 21.

AMediaCodec_releaseCrypto

media_status_t AMediaCodec_releaseCrypto(
  AMediaCodec *
)

Release the crypto if applicable.

Available since API level 28.

AMediaCodec_releaseName

void AMediaCodec_releaseName(
  AMediaCodec *,
  char *name
)

Free the memory pointed by name which is returned by AMediaCodec_getName.

Available since API level 28.

AMediaCodec_releaseOutputBuffer

media_status_t AMediaCodec_releaseOutputBuffer(
  AMediaCodec *,
  size_t idx,
  bool render
)

If you are done with a buffer, use this call to return the buffer to the codec.

If you previously specified a surface when configuring this video decoder you can optionally render the buffer.

Available since API level 21.

AMediaCodec_releaseOutputBufferAtTime

media_status_t AMediaCodec_releaseOutputBufferAtTime(
  AMediaCodec *mData,
  size_t idx,
  int64_t timestampNs
)

If you are done with a buffer, use this call to update its surface timestamp and return it to the codec to render it on the output surface.

If you have not specified an output surface when configuring this video codec, this call will simply return the buffer to the codec.

For more details, see the Java documentation for MediaCodec.releaseOutputBuffer.

Available since API level 21.

AMediaCodec_setAsyncNotifyCallback

media_status_t AMediaCodec_setAsyncNotifyCallback(
  AMediaCodec *,
  AMediaCodecOnAsyncNotifyCallback callback,
  void *userdata
)

Set an asynchronous callback for actionable AMediaCodec events.

When asynchronous callback is enabled, it is an error for the client to call AMediaCodec_getInputBuffers(), AMediaCodec_getOutputBuffers(), AMediaCodec_dequeueInputBuffer() or AMediaCodec_dequeueOutputBuffer().

AMediaCodec_flush() behaves differently in asynchronous mode. After calling AMediaCodec_flush(), the client must call AMediaCodec_start() to "resume" receiving input buffers. Even if the client does not receive AMediaCodecOnAsyncInputAvailable callbacks from video encoders configured with an input surface, the client still needs to call AMediaCodec_start() to resume the input surface to send buffers to the encoders.

When called with null callback, this method unregisters any previously set callback.

Refer to the definition of AMediaCodecOnAsyncNotifyCallback on how each callback function is called and what are specified. The specified userdata is opaque data which will be passed along when the callback functions are called. MediaCodec does not look at or alter the value of userdata. Often it is a pointer to a client-owned object, and client manages the lifecycle of the object in that case.

Once the callback is unregistered or the codec is reset / released, the previously registered callback will not be called.

All callbacks are fired on one NDK internal thread. AMediaCodec_setAsyncNotifyCallback should not be called on the callback thread. No heavy duty task should be performed on callback thread.

Available since API level 28.

AMediaCodec_setInputSurface

media_status_t AMediaCodec_setInputSurface(
  AMediaCodec *mData,
  ANativeWindow *surface
)

Set a persistent-surface that can be used as the input to encoder, in place of input buffers.

The surface provided must be a persistent surface created via AMediaCodec_createPersistentInputSurface() This can only be called after the codec has been configured by calling AMediaCodec_configure(..); and before AMediaCodec_start() has been called.

For more details, see the Java documentation for MediaCodec.setInputSurface.

Available since API level 26.

AMediaCodec_setOnFrameRenderedCallback

media_status_t AMediaCodec_setOnFrameRenderedCallback(
  AMediaCodec *,
  AMediaCodecOnFrameRendered callback,
  void *userdata
)

Registers a callback to be invoked when an output frame is rendered on the output surface.

This method can be called in any codec state, but will only have an effect in the Executing state for codecs that render buffers to the output surface.

This callback is for informational purposes only: to get precise render timing samples, and can be significantly delayed and batched. Some frames may have been rendered even if there was no callback generated.

When called with null callback, this method unregisters any previously set callback.

Refer to the definition of AMediaCodecOnFrameRendered on how each callback function is called and what are specified. The specified userdata is opaque data which will be passed along when the callback functions are called. MediaCodec does not look at or alter the value of userdata. Often it is a pointer to a client-owned object, and client manages the lifecycle of the object in that case.

Once the callback is unregistered or the codec is reset / released, the previously registered callback will not be called.

All callbacks are fired on one NDK internal thread. AMediaCodec_setOnFrameRenderedCallback should not be called on the callback thread. No heavy duty task should be performed on callback thread.

Available since Android T.

AMediaCodec_setOutputSurface

media_status_t AMediaCodec_setOutputSurface(
  AMediaCodec *,
  ANativeWindow *surface
)

Dynamically sets the output surface of a codec.

This can only be used if the codec was configured with an output surface. The new output surface should have a compatible usage type to the original output surface. E.g. codecs may not support switching from a SurfaceTexture (GPU readable) output to ImageReader (software readable) output.

For more details, see the Java documentation for MediaCodec.setOutputSurface.

Available since API level 21.

AMediaCodec_setParameters

media_status_t AMediaCodec_setParameters(
  AMediaCodec *mData,
  const AMediaFormat *params
)

Signal additional parameters to the codec instance.

Parameters can be communicated only when the codec is running, i.e after AMediaCodec_start() has been called.

NOTE: Some of these parameter changes may silently fail to apply.

Available since API level 26.

AMediaCodec_signalEndOfInputStream

media_status_t AMediaCodec_signalEndOfInputStream(
  AMediaCodec *mData
)

Signals end-of-stream on input.

Equivalent to submitting an empty buffer with AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM set.

Returns AMEDIA_ERROR_INVALID_OPERATION when used with an encoder not in executing state or not receiving input from a Surface created by AMediaCodec_createInputSurface or AMediaCodec_createPersistentInputSurface.

Returns the previous codec error if one exists.

Returns AMEDIA_OK when completed succesfully.

For more details, see the Java documentation for MediaCodec.signalEndOfInputStream.

Available since API level 26.

AMediaCodec_start

media_status_t AMediaCodec_start(
  AMediaCodec *
)

Start the codec.

A codec must be configured before it can be started, and must be started before buffers can be sent to it.

Available since API level 21.

AMediaCodec_stop

media_status_t AMediaCodec_stop(
  AMediaCodec *
)

Stop the codec.

Available since API level 21.

AMediaCrypto_delete

void AMediaCrypto_delete(
  AMediaCrypto *crypto
)

Available since API level 21.

AMediaCrypto_isCryptoSchemeSupported

bool AMediaCrypto_isCryptoSchemeSupported(
  const AMediaUUID uuid
)

Available since API level 21.

AMediaCrypto_new

AMediaCrypto * AMediaCrypto_new(
  const AMediaUUID uuid,
  const void *initData,
  size_t initDataSize
)

Available since API level 21.

AMediaCrypto_requiresSecureDecoderComponent

bool AMediaCrypto_requiresSecureDecoderComponent(
  const char *mime
)

Available since API level 21.

AMediaDrm_closeSession

media_status_t AMediaDrm_closeSession(
  AMediaDrm *,
  const AMediaDrmSessionId *sessionId
)

Close a session on the MediaDrm object that was previously opened with AMediaDrm_openSession.

Available since API level 21.

AMediaDrm_createByUUID

AMediaDrm * AMediaDrm_createByUUID(
  const uint8_t *uuid
)

Create a MediaDrm instance from a UUID.

uuid identifies the universal unique ID of the crypto scheme. uuid must be 16 bytes.

Available since API level 21.

AMediaDrm_decrypt

media_status_t AMediaDrm_decrypt(
  AMediaDrm *,
  const AMediaDrmSessionId *sessionId,
  const char *cipherAlgorithm,
  uint8_t *keyId,
  uint8_t *iv,
  const uint8_t *input,
  uint8_t *output,
  size_t dataSize
)

AMediaDrm_encrypt

media_status_t AMediaDrm_encrypt(
  AMediaDrm *,
  const AMediaDrmSessionId *sessionId,
  const char *cipherAlgorithm,
  uint8_t *keyId,
  uint8_t *iv,
  const uint8_t *input,
  uint8_t *output,
  size_t dataSize
)

In addition to supporting decryption of DASH Common Encrypted Media, the MediaDrm APIs provide the ability to securely deliver session keys from an operator's session key server to a client device, based on the factory-installed root of trust, and then perform encrypt, decrypt, sign and verify operations with the session key on arbitrary user data.

Operators create session key servers that receive session key requests and provide encrypted session keys which can be used for general purpose crypto operations.

Generic encrypt/decrypt/sign/verify methods are based on the established session keys. These keys are exchanged using the getKeyRequest/provideKeyResponse methods.

Applications of this capability include securing various types of purchased or private content, such as applications, books and other media, photos or media delivery protocols.

AMediaDrm_getKeyRequest

media_status_t AMediaDrm_getKeyRequest(
  AMediaDrm *,
  const AMediaDrmScope *scope,
  const uint8_t *init,
  size_t initSize,
  const char *mimeType,
  AMediaDrmKeyType keyType,
  const AMediaDrmKeyValue *optionalParameters,
  size_t numOptionalParameters,
  const uint8_t **keyRequest,
  size_t *keyRequestSize
)

A key request/response exchange occurs between the app and a license server to obtain or release keys used to decrypt encrypted content.

AMediaDrm_getKeyRequest is used to obtain an opaque key request byte array that is delivered to the license server. The opaque key request byte array is returned in *keyRequest and the number of bytes in the request is returned in *keyRequestSize. This API has same functionality as AMediaDrm_getKeyRequestWithDefaultUrlAndType() when defaultUrl and keyRequestType are passed in as NULL.

After the app has received the key request response from the server, it should deliver to the response to the DRM engine plugin using the method AMediaDrm_provideKeyResponse.

scope may be a sessionId or a keySetId, depending on the specified keyType. When the keyType is KEY_TYPE_STREAMING or KEY_TYPE_OFFLINE, scope should be set to the sessionId the keys will be provided to. When the keyType is KEY_TYPE_RELEASE, scope should be set to the keySetId of the keys being released. Releasing keys from a device invalidates them for all sessions.

init container-specific data, its meaning is interpreted based on the mime type provided in the mimeType parameter. It could contain, for example, the content ID, key ID or other data obtained from the content metadata that is required in generating the key request. init may be null when keyType is KEY_TYPE_RELEASE.

initSize is the number of bytes of initData

mimeType identifies the mime type of the content.

keyType specifes the type of the request. The request may be to acquire keys for streaming or offline content, or to release previously acquired keys, which are identified by a keySetId.

optionalParameters are included in the key request message to allow a client application to provide additional message parameters to the server.

numOptionalParameters indicates the number of optional parameters provided by the caller

On exit: If this returns AMEDIA_OK,

  1. The keyRequest pointer will reference the opaque key request data. It will reside in memory owned by the AMediaDrm object, and will remain accessible until the next call to AMediaDrm_getKeyRequest or AMediaDrm_getKeyRequestWithDefaultUrlAndType or until the MediaDrm object is released.
  2. keyRequestSize will be set to the size of the request If this does not return AMEDIA_OK, value of these parameters should not be used.

Returns AMEDIA_DRM_NOT_PROVISIONED if reprovisioning is needed, due to a problem with the device certificate.

Available since API level 21.

AMediaDrm_getKeyRequestWithDefaultUrlAndType

media_status_t AMediaDrm_getKeyRequestWithDefaultUrlAndType(
  AMediaDrm *,
  const AMediaDrmScope *scope,
  const uint8_t *init,
  size_t initSize,
  const char *mimeType,
  AMediaDrmKeyType keyType,
  const AMediaDrmKeyValue *optionalParameters,
  size_t numOptionalParameters,
  const uint8_t **keyRequest,
  size_t *keyRequestSize,
  const char **defaultUrl,
  AMediaDrmKeyRequestType *keyRequestType
)

A key request/response exchange occurs between the app and a license server to obtain or release keys used to decrypt encrypted content.

AMediaDrm_getKeyRequest is used to obtain an opaque key request byte array that is delivered to the license server. The opaque key request byte array is returned in *keyRequest and the number of bytes in the request is returned in *keyRequestSize.

After the app has received the key request response from the server, it should deliver to the response to the DRM engine plugin using the method AMediaDrm_provideKeyResponse.

scope may be a sessionId or a keySetId, depending on the specified keyType. When the keyType is KEY_TYPE_STREAMING or KEY_TYPE_OFFLINE, scope should be set to the sessionId the keys will be provided to. When the keyType is KEY_TYPE_RELEASE, scope should be set to the keySetId of the keys being released. Releasing keys from a device invalidates them for all sessions.

init container-specific data, its meaning is interpreted based on the mime type provided in the mimeType parameter. It could contain, for example, the content ID, key ID or other data obtained from the content metadata that is required in generating the key request. init may be null when keyType is KEY_TYPE_RELEASE.

initSize is the number of bytes of initData

mimeType identifies the mime type of the content.

keyType specifes the type of the request. The request may be to acquire keys for streaming or offline content, or to release previously acquired keys, which are identified by a keySetId.

optionalParameters are included in the key request message to allow a client application to provide additional message parameters to the server.

numOptionalParameters indicates the number of optional parameters provided by the caller

On exit: If this returns AMEDIA_OK,

  1. The keyRequest pointer will reference the opaque key request data. It will reside in memory owned by the AMediaDrm object, and will remain accessible until the next call to either AMediaDrm_getKeyRequest or AMediaDrm_getKeyRequestWithDefaultUrlAndType or until the MediaDrm object is released.
  2. keyRequestSize will be set to the size of the request.
  3. defaultUrl will be set to the recommended URL to deliver the key request. The defaultUrl pointer will reference a NULL terminated URL string. It will be UTF-8 encoded and have same lifetime with the key request data KeyRequest pointer references to. Passing in NULL means you don't need it to be reported.
  4. keyRequestType will be set to the key request type. Passing in NULL means you don't need it to be reported.

Returns AMEDIA_DRM_NOT_PROVISIONED if reprovisioning is needed, due to a problem with the device certificate.

Available since API level 33.

AMediaDrm_getPropertyByteArray

media_status_t AMediaDrm_getPropertyByteArray(
  AMediaDrm *,
  const char *propertyName,
  AMediaDrmByteArray *propertyValue
)

Read a DRM engine plugin byte array property value, given the property name string.

On return, *propertyValue will be set to point to the property value. The memory that the value resides in is owned by the NDK MediaDrm API and will remain valid until the next call to AMediaDrm_getPropertyByteArray.

Available since API level 21.

AMediaDrm_getPropertyString

media_status_t AMediaDrm_getPropertyString(
  AMediaDrm *,
  const char *propertyName,
  const char **propertyValue
)

Read a DRM engine plugin String property value, given the property name string.

propertyName identifies the property to query On return, propertyValue will be set to point to the property value. The memory that the value resides in is owned by the NDK MediaDrm API and will remain valid until the next call to AMediaDrm_getPropertyString.

Available since API level 21.

AMediaDrm_getProvisionRequest

media_status_t AMediaDrm_getProvisionRequest(
  AMediaDrm *,
  const uint8_t **provisionRequest,
  size_t *provisionRequestSize,
  const char **serverUrl
)

A provision request/response exchange occurs between the app and a provisioning server to retrieve a device certificate.

If provisionining is required, the EVENT_PROVISION_REQUIRED event will be sent to the event handler. getProvisionRequest is used to obtain the opaque provision request byte array that should be delivered to the provisioning server. On exit:

  1. The provision request data will be referenced by provisionRequest, in memory owned by the AMediaDrm object. It will remain accessible until the next call to getProvisionRequest.
  2. provisionRequestSize will be set to the size of the request data.
  3. serverUrl will reference a NULL terminated string containing the URL the provisioning request should be sent to. It will remain accessible until the next call to getProvisionRequest.

Available since API level 21.

AMediaDrm_getSecureStops

media_status_t AMediaDrm_getSecureStops(
  AMediaDrm *,
  AMediaDrmSecureStop *secureStops,
  size_t *numSecureStops
)

A means of enforcing limits on the number of concurrent streams per subscriber across devices is provided via SecureStop.

This is achieved by securely monitoring the lifetime of sessions.

Information from the server related to the current playback session is written to persistent storage on the device when each MediaCrypto object is created.

In the normal case, playback will be completed, the session destroyed and the Secure Stops will be queried. The app queries secure stops and forwards the secure stop message to the server which verifies the signature and notifies the server side database that the session destruction has been confirmed. The persisted record on the client is only removed after positive confirmation that the server received the message using releaseSecureStops().

numSecureStops is set by the caller to the maximum number of secure stops to return. On exit, *numSecureStops will be set to the number actually returned. If *numSecureStops is too small for the number of secure stops available, AMEDIA_DRM_SHORT_BUFFER will be returned and *numSecureStops will be set to the number required.

Available since API level 21.

AMediaDrm_isCryptoSchemeSupported

bool AMediaDrm_isCryptoSchemeSupported(
  const uint8_t *uuid,
  const char *mimeType
)

Query if the given scheme identified by its UUID is supported on this device, and whether the drm plugin is able to handle the media container format specified by mimeType.

uuid identifies the universal unique ID of the crypto scheme. uuid must be 16 bytes. mimeType is the MIME type of the media container, e.g. "video/mp4". If mimeType is not known or required, it can be provided as NULL.

Available since API level 21.

AMediaDrm_openSession

media_status_t AMediaDrm_openSession(
  AMediaDrm *,
  AMediaDrmSessionId *sessionId
)

Open a new session with the MediaDrm object.

A session ID is returned.

Returns AMEDIA_DRM_NOT_PROVISIONED if provisioning is needed. Returns AMEDIA_DRM_RESOURCE_BUSY if required resources are in use.

Available since API level 21.

AMediaDrm_provideKeyResponse

media_status_t AMediaDrm_provideKeyResponse(
  AMediaDrm *,
  const AMediaDrmScope *scope,
  const uint8_t *response,
  size_t responseSize,
  AMediaDrmKeySetId *keySetId
)

A key response is received from the license server by the app, then it is provided to the DRM engine plugin using provideKeyResponse.

When the response is for an offline key request, a keySetId is returned that can be used to later restore the keys to a new session with AMediaDrm_restoreKeys. When the response is for a streaming or release request, a null keySetId is returned.

scope may be a sessionId or keySetId depending on the type of the response. Scope should be set to the sessionId when the response is for either streaming or offline key requests. Scope should be set to the keySetId when the response is for a release request.

response points to the opaque response from the server responseSize should be set to the size of the response in bytes

Available since API level 21.

AMediaDrm_provideProvisionResponse

media_status_t AMediaDrm_provideProvisionResponse(
  AMediaDrm *,
  const uint8_t *response,
  size_t responseSize
)

After a provision response is received by the app, it is provided to the DRM engine plugin using this method.

response is the opaque provisioning response byte array to provide to the DRM engine plugin. responseSize is the length of the provisioning response in bytes.

Returns AMEDIA_DRM_DEVICE_REVOKED if the response indicates that the server rejected the request

Available since API level 21.

AMediaDrm_queryKeyStatus

media_status_t AMediaDrm_queryKeyStatus(
  AMediaDrm *,
  const AMediaDrmSessionId *sessionId,
  AMediaDrmKeyValue *keyValuePairs,
  size_t *numPairs
)

Request an informative description of the key status for the session.

The status is in the form of {key, value} pairs. Since DRM license policies vary by vendor, the specific status field names are determined by each DRM vendor. Refer to your DRM provider documentation for definitions of the field names for a particular DRM engine plugin.

On entry, numPairs should be set by the caller to the maximum number of pairs that can be returned (the size of the array). On exit, numPairs will be set to the number of entries written to the array. If the number of {key, value} pairs to be returned is greater than *numPairs, AMEDIA_DRM_SHORT_BUFFER will be returned and numPairs will be set to the number of pairs available.

Available since API level 21.

AMediaDrm_release

void AMediaDrm_release(
  AMediaDrm *
)

Release a MediaDrm object.

Available since API level 21.

AMediaDrm_releaseSecureStops

media_status_t AMediaDrm_releaseSecureStops(
  AMediaDrm *,
  const AMediaDrmSecureStop *ssRelease
)

Process the SecureStop server response message ssRelease.

After authenticating the message, remove the SecureStops identified in the response.

ssRelease is the server response indicating which secure stops to release

Available since API level 21.

AMediaDrm_removeKeys

media_status_t AMediaDrm_removeKeys(
  AMediaDrm *,
  const AMediaDrmSessionId *keySetId
)

Remove the current keys from a session.

keySetId identifies keys to remove.

Available since API level 21.

AMediaDrm_restoreKeys

media_status_t AMediaDrm_restoreKeys(
  AMediaDrm *,
  const AMediaDrmSessionId *sessionId,
  const AMediaDrmKeySetId *keySetId
)

Restore persisted offline keys into a new session.

keySetId identifies the keys to load, obtained from a prior call to AMediaDrm_provideKeyResponse.

sessionId is the session ID for the DRM session. keySetId identifies the saved key set to restore.

Available since API level 21.

AMediaDrm_setOnEventListener

media_status_t AMediaDrm_setOnEventListener(
  AMediaDrm *,
  AMediaDrmEventListener listener
)

Register a callback to be invoked when an event occurs.

listener is the callback that will be invoked on event.

Available since API level 21.

AMediaDrm_setOnExpirationUpdateListener

media_status_t AMediaDrm_setOnExpirationUpdateListener(
  AMediaDrm *,
  AMediaDrmExpirationUpdateListener listener
)

Register a callback to be invoked when an expiration update event occurs.

listener is the callback that will be invoked on event.

Available since API level 29.

AMediaDrm_setOnKeysChangeListener

media_status_t AMediaDrm_setOnKeysChangeListener(
  AMediaDrm *,
  AMediaDrmKeysChangeListener listener
)

Register a callback to be invoked when a key status change event occurs.

listener is the callback that will be invoked on event.

Available since API level 29.

AMediaDrm_setPropertyByteArray

media_status_t AMediaDrm_setPropertyByteArray(
  AMediaDrm *,
  const char *propertyName,
  const uint8_t *value,
  size_t valueSize
)

Set a DRM engine plugin byte array property value.

Available since API level 21.

AMediaDrm_setPropertyString

media_status_t AMediaDrm_setPropertyString(
  AMediaDrm *,
  const char *propertyName,
  const char *value
)

Set a DRM engine plugin String property value.

Available since API level 21.

AMediaDrm_sign

media_status_t AMediaDrm_sign(
  AMediaDrm *,
  const AMediaDrmSessionId *sessionId,
  const char *macAlgorithm,
  uint8_t *keyId,
  uint8_t *message,
  size_t messageSize,
  uint8_t *signature,
  size_t *signatureSize
)

AMediaDrm_verify

media_status_t AMediaDrm_verify(
  AMediaDrm *,
  const AMediaDrmSessionId *sessionId,
  const char *macAlgorithm,
  uint8_t *keyId,
  const uint8_t *message,
  size_t messageSize,
  const uint8_t *signature,
  size_t signatureSize
)

AMediaExtractor_advance

bool AMediaExtractor_advance(
  AMediaExtractor *
)

Advance to the next sample.

Returns false if no more sample data is available (end of stream).

Available since API level 21.

AMediaExtractor_delete

media_status_t AMediaExtractor_delete(
  AMediaExtractor *
)

Delete a previously created media extractor.

Available since API level 21.

AMediaExtractor_getCachedDuration

int64_t AMediaExtractor_getCachedDuration(
  AMediaExtractor *
)

Returns the duration of cached media samples downloaded from a network data source (AMediaExtractor_setDataSource with a "http(s)" URI) in microseconds.

This information is calculated using total bitrate; if total bitrate is not in the media container it is calculated using total duration and file size.

Returns -1 when the extractor is not reading from a network data source, or when the cached duration cannot be calculated (bitrate, duration, and file size information not available).

Available since API level 28.

AMediaExtractor_getFileFormat

AMediaFormat * AMediaExtractor_getFileFormat(
  AMediaExtractor *
)

Returns the format of the extractor.

The caller must free the returned format using AMediaFormat_delete(format).

This function will always return a format; however, the format could be empty (no key-value pairs) if the media container does not provide format information.

Available since API level 28.

AMediaExtractor_getPsshInfo

PsshInfo * AMediaExtractor_getPsshInfo(
  AMediaExtractor *
)

Get the PSSH info if present.

Available since API level 21.

AMediaExtractor_getSampleCryptoInfo

AMediaCodecCryptoInfo * AMediaExtractor_getSampleCryptoInfo(
  AMediaExtractor *
)

Available since API level 21.

AMediaExtractor_getSampleFlags

uint32_t AMediaExtractor_getSampleFlags(
  AMediaExtractor *
)

Read the current sample's flags.

Available since API level 21.

AMediaExtractor_getSampleFormat

media_status_t AMediaExtractor_getSampleFormat(
  AMediaExtractor *ex,
  AMediaFormat *fmt
)

Read the current sample's metadata format into |fmt|.

Examples of sample metadata are SEI (supplemental enhancement information) and MPEG user data, both of which can embed closed-caption data.

Returns AMEDIA_OK on success or AMEDIA_ERROR_* to indicate failure reason. Existing key-value pairs in |fmt| would be removed if this API returns AMEDIA_OK. The contents of |fmt| is undefined if this API returns AMEDIA_ERROR_*.

Available since API level 28.

AMediaExtractor_getSampleSize

ssize_t AMediaExtractor_getSampleSize(
  AMediaExtractor *
)

Returns the size of the current sample in bytes, or -1 when no samples are available (end of stream).

This API can be used in in conjunction with AMediaExtractor_readSampleData:

ssize_t sampleSize = AMediaExtractor_getSampleSize(ex); uint8_t *buf = new uint8_t[sampleSize]; AMediaExtractor_readSampleData(ex, buf, sampleSize);

Available since API level 28.

AMediaExtractor_getSampleTime

int64_t AMediaExtractor_getSampleTime(
  AMediaExtractor *
)

Returns the current sample's presentation time in microseconds.

or -1 if no more samples are available.

Available since API level 21.

AMediaExtractor_getSampleTrackIndex

int AMediaExtractor_getSampleTrackIndex(
  AMediaExtractor *
)

Returns the track index the current sample originates from (or -1 if no more samples are available)

Available since API level 21.

AMediaExtractor_getTrackCount

size_t AMediaExtractor_getTrackCount(
  AMediaExtractor *
)

Return the number of tracks in the previously specified media file.

Available since API level 21.

AMediaExtractor_getTrackFormat

AMediaFormat * AMediaExtractor_getTrackFormat(
  AMediaExtractor *,
  size_t idx
)

Return the format of the specified track.

The caller must free the returned format

Available since API level 21.

AMediaExtractor_new

AMediaExtractor * AMediaExtractor_new()

Create new media extractor.

Available since API level 21.

AMediaExtractor_readSampleData

ssize_t AMediaExtractor_readSampleData(
  AMediaExtractor *,
  uint8_t *buffer,
  size_t capacity
)

Read the current sample.

Available since API level 21.

AMediaExtractor_seekTo

media_status_t AMediaExtractor_seekTo(
  AMediaExtractor *,
  int64_t seekPosUs,
  SeekMode mode
)

Available since API level 21.

AMediaExtractor_selectTrack

media_status_t AMediaExtractor_selectTrack(
  AMediaExtractor *,
  size_t idx
)

Select the specified track.

Subsequent calls to readSampleData, getSampleTrackIndex and getSampleTime only retrieve information for the subset of tracks selected. Selecting the same track multiple times has no effect, the track is only selected once.

Available since API level 21.

AMediaExtractor_setDataSource

media_status_t AMediaExtractor_setDataSource(
  AMediaExtractor *,
  const char *location
)

Set the URI from which the extractor will read.

Available since API level 21.

AMediaExtractor_setDataSourceCustom

media_status_t AMediaExtractor_setDataSourceCustom(
  AMediaExtractor *,
  AMediaDataSource *src
)

Set the custom data source implementation from which the extractor will read.

Available since API level 28.

AMediaExtractor_setDataSourceFd

media_status_t AMediaExtractor_setDataSourceFd(
  AMediaExtractor *,
  int fd,
  off64_t offset,
  off64_t length
)

Set the file descriptor from which the extractor will read.

Available since API level 21.

AMediaExtractor_unselectTrack

media_status_t AMediaExtractor_unselectTrack(
  AMediaExtractor *,
  size_t idx
)

Unselect the specified track.

Subsequent calls to readSampleData, getSampleTrackIndex and getSampleTime only retrieve information for the subset of tracks selected.

Available since API level 21.

AMediaFormat_clear

void AMediaFormat_clear(
  AMediaFormat *
)

Remove all key/value pairs from the given AMediaFormat.

Available since API level 29.

AMediaFormat_copy

media_status_t AMediaFormat_copy(
  AMediaFormat *to,
  AMediaFormat *from
)

Copy one AMediaFormat to another.

Available since API level 29.

AMediaFormat_delete

media_status_t AMediaFormat_delete(
  AMediaFormat *
)

Available since API level 21.

AMediaFormat_getBuffer

bool AMediaFormat_getBuffer(
  AMediaFormat *,
  const char *name,
  void **data,
  size_t *size
)

The returned data is owned by the format and remains valid as long as the named entry is part of the format.

Available since API level 21.

AMediaFormat_getDouble

bool AMediaFormat_getDouble(
  AMediaFormat *,
  const char *name,
  double *out
)

Available since API level 28.

AMediaFormat_getFloat

bool AMediaFormat_getFloat(
  AMediaFormat *,
  const char *name,
  float *out
)

Available since API level 21.

AMediaFormat_getInt32

bool AMediaFormat_getInt32(
  AMediaFormat *,
  const char *name,
  int32_t *out
)

Available since API level 21.

AMediaFormat_getInt64

bool AMediaFormat_getInt64(
  AMediaFormat *,
  const char *name,
  int64_t *out
)

Available since API level 21.

AMediaFormat_getRect

bool AMediaFormat_getRect(
  AMediaFormat *,
  const char *name,
  int32_t *left,
  int32_t *top,
  int32_t *right,
  int32_t *bottom
)

Available since API level 28.

AMediaFormat_getSize

bool AMediaFormat_getSize(
  AMediaFormat *,
  const char *name,
  size_t *out
)

Available since API level 21.

AMediaFormat_getString

bool AMediaFormat_getString(
  AMediaFormat *,
  const char *name,
  const char **out
)

The returned string is owned by the format, and remains valid until the next call to getString, or until the format is deleted.

Available since API level 21.

AMediaFormat_new

AMediaFormat * AMediaFormat_new()

Available since API level 21.

AMediaFormat_setBuffer

void AMediaFormat_setBuffer(
  AMediaFormat *,
  const char *name,
  const void *data,
  size_t size
)

The provided data is copied into the format.

Available since API level 21.

AMediaFormat_setDouble

void AMediaFormat_setDouble(
  AMediaFormat *,
  const char *name,
  double value
)

Available since API level 28.

AMediaFormat_setFloat

void AMediaFormat_setFloat(
  AMediaFormat *,
  const char *name,
  float value
)

Available since API level 21.

AMediaFormat_setInt32

void AMediaFormat_setInt32(
  AMediaFormat *,
  const char *name,
  int32_t value
)

Available since API level 21.

AMediaFormat_setInt64

void AMediaFormat_setInt64(
  AMediaFormat *,
  const char *name,
  int64_t value
)

Available since API level 21.

AMediaFormat_setRect

void AMediaFormat_setRect(
  AMediaFormat *,
  const char *name,
  int32_t left,
  int32_t top,
  int32_t right,
  int32_t bottom
)

Available since API level 28.

AMediaFormat_setSize

void AMediaFormat_setSize(
  AMediaFormat *,
  const char *name,
  size_t value
)

Available since API level 28.

AMediaFormat_setString

void AMediaFormat_setString(
  AMediaFormat *,
  const char *name,
  const char *value
)

The provided string is copied into the format.

Available since API level 21.

AMediaFormat_toString

const char * AMediaFormat_toString(
  AMediaFormat *
)

Human readable representation of the format.

The returned string is owned by the format, and remains valid until the next call to toString, or until the format is deleted.

Available since API level 21.

AMediaMuxer_addTrack

ssize_t AMediaMuxer_addTrack(
  AMediaMuxer *,
  const AMediaFormat *format
)

Adds a track with the specified format.

Returns the index of the new track or a negative value in case of failure, which can be interpreted as a media_status_t.

Available since API level 21.

AMediaMuxer_append

AMediaMuxer * AMediaMuxer_append(
  int fd,
  AppendMode mode
)

Creates a new media muxer for appending data to an existing MPEG4 file.

This is a synchronous API call and could take a while to return if the existing file is large. Only works for MPEG4 files matching one of the following characteristics:

  • a single audio track.
  • a single video track.
  • a single audio and a single video track.
Available since API level 31.

Details
Parameters
fd
Must be opened with read and write permission. Does not take ownership of this fd i.e., caller is responsible for closing fd.
mode
Specifies how data will be appended; the AppendMode enum describes the possible methods for appending..
Returns
Pointer to AMediaMuxer if the file(fd) has tracks already, otherwise, nullptr. AMediaMuxer_delete should be used to free the returned pointer.

AMediaMuxer_delete

media_status_t AMediaMuxer_delete(
  AMediaMuxer *
)

Delete a previously created media muxer.

Available since API level 21.

AMediaMuxer_getTrackCount

ssize_t AMediaMuxer_getTrackCount(
  AMediaMuxer *
)

Returns the number of tracks added in the file passed to AMediaMuxer_new or the number of existing tracks in the file passed to AMediaMuxer_append.

Should be called in INITIALIZED or STARTED state, otherwise returns -1.

Available since API level 31.

AMediaMuxer_getTrackFormat

AMediaFormat * AMediaMuxer_getTrackFormat(
  AMediaMuxer *muxer,
  size_t idx
)

Returns AMediaFormat of the added track with index idx in the file passed to AMediaMuxer_new or the AMediaFormat of the existing track with index idx in the file passed to AMediaMuxer_append.

Should be called in INITIALIZED or STARTED state, otherwise returns nullptr. AMediaFormat_delete should be used to free the returned pointer.

Available since API level 31.

AMediaMuxer_new

AMediaMuxer * AMediaMuxer_new(
  int fd,
  OutputFormat format
)

Create new media muxer.

Available since API level 21.

AMediaMuxer_setLocation

media_status_t AMediaMuxer_setLocation(
  AMediaMuxer *,
  float latitude,
  float longitude
)

Set and store the geodata (latitude and longitude) in the output file.

This method should be called before AMediaMuxer_start. The geodata is stored in udta box if the output format is AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4, and is ignored for other output formats. The geodata is stored according to ISO-6709 standard.

Both values are specified in degrees. Latitude must be in the range [-90, 90]. Longitude must be in the range [-180, 180].

Available since API level 21.

AMediaMuxer_setOrientationHint

media_status_t AMediaMuxer_setOrientationHint(
  AMediaMuxer *,
  int degrees
)

Sets the orientation hint for output video playback.

This method should be called before AMediaMuxer_start. Calling this method will not rotate the video frame when muxer is generating the file, but add a composition matrix containing the rotation angle in the output video if the output format is AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4, so that a video player can choose the proper orientation for playback. Note that some video players may choose to ignore the composition matrix during playback. The angle is specified in degrees, clockwise. The supported angles are 0, 90, 180, and 270 degrees.

Available since API level 21.

AMediaMuxer_start

media_status_t AMediaMuxer_start(
  AMediaMuxer *
)

Start the muxer.

Should be called after AMediaMuxer_addTrack and before AMediaMuxer_writeSampleData.

Available since API level 21.

AMediaMuxer_stop

media_status_t AMediaMuxer_stop(
  AMediaMuxer *
)

Stops the muxer.

Once the muxer stops, it can not be restarted.

Available since API level 21.

AMediaMuxer_writeSampleData

media_status_t AMediaMuxer_writeSampleData(
  AMediaMuxer *muxer,
  size_t trackIdx,
  const uint8_t *data,
  const AMediaCodecBufferInfo *info
)

Writes an encoded sample into the muxer.

The application needs to make sure that the samples are written into the right tracks. Also, it needs to make sure the samples for each track are written in chronological order (e.g. in the order they are provided by the encoder.)

Available since API level 21.