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 75{
  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 76{
  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
}
enum
AMediaDrmEventType{
  EVENT_PROVISION_REQUIRED = 1,
  EVENT_KEY_REQUIRED = 2,
  EVENT_KEY_EXPIRED = 3,
  EVENT_VENDOR_DEFINED = 4
}
enum
AMediaDrmKeyType{
  KEY_TYPE_STREAMING = 1,
  KEY_TYPE_OFFLINE = 2,
  KEY_TYPE_RELEASE = 3
}
enum
OutputFormat{
  AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4 = 0,
  AMEDIAMUXER_OUTPUT_FORMAT_WEBM = 1
}
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_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

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
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.
AMediaCodecOnAsyncOutputAvailable)(AMediaCodec *codec, void *userdata, int32_t index, AMediaCodecBufferInfo *bufferInfo) typedef
void(*
Called when an output buffer becomes available.
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
AMediaDrmKeySetId typedef
AMediaDrmKeyType typedef
AMediaDrmKeyValue typedef
Data type containing {key, value} pair.
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

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 *
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_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
AMediaCrypto_isCryptoSchemeSupported(const AMediaUUID uuid)
bool
AMediaCrypto_new(const AMediaUUID uuid, const void *initData, size_t initDataSize)
AMediaCrypto *
AMediaCrypto_requiresSecureDecoderComponent(const char *mime)
bool
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 uuid identifies the universal unique ID of the crypto scheme.
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_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_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 *
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)
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_delete(AMediaFormat *)
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
AMediaFormat_getFloat(AMediaFormat *, const char *name, float *out)
bool
AMediaFormat_getInt32(AMediaFormat *, const char *name, int32_t *out)
bool
AMediaFormat_getInt64(AMediaFormat *, const char *name, int64_t *out)
bool
AMediaFormat_getRect(AMediaFormat *, const char *name, int32_t *left, int32_t *top, int32_t *right, int32_t *bottom)
bool
AMediaFormat_getSize(AMediaFormat *, const char *name, size_t *out)
bool
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 *
AMediaFormat_setBuffer(AMediaFormat *, const char *name, void *data, size_t size)
void
The provided data is copied into the format.
AMediaFormat_setDouble(AMediaFormat *, const char *name, double value)
void
AMediaFormat_setFloat(AMediaFormat *, const char *name, float value)
void
AMediaFormat_setInt32(AMediaFormat *, const char *name, int32_t value)
void
AMediaFormat_setInt64(AMediaFormat *, const char *name, int64_t value)
void
AMediaFormat_setRect(AMediaFormat *, const char *name, int32_t left, int32_t top, int32_t right, int32_t bottom)
void
AMediaFormat_setSize(AMediaFormat *, const char *name, size_t value)
void
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_delete(AMediaMuxer *)
Delete a previously created media muxer.
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.
__INTRODUCED_IN(28)
const char *AMEDIAFORMAT_KEY_AAC_DRC_ATTENUATION_FACTOR
XXX should these be ints/enums that we look up in a table as needed?
__INTRODUCED_IN(21)
const char *AMEDIAFORMAT_KEY_AAC_PROFILE

Structs

AImageCropRect

Data type describing an cropped rectangle returned by AImage_getCropRect.

AImageReader_BufferRemovedListener
AImageReader_ImageListener
AMediaCodecBufferInfo
AMediaCodecOnAsyncNotifyCallback
AMediaDrmByteArray
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 76

 Anonymous Enum 76

AIMAGE_FORMATS

 AIMAGE_FORMATS
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_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_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_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_VENDOR_DEFINED

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

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 species 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.

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

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.

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.

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

AMediaDrmKeySetId

AMediaDrmByteArray AMediaDrmKeySetId

AMediaDrmKeyType

enum AMediaDrmKeyType AMediaDrmKeyType

AMediaDrmKeyValue

struct AMediaDrmKeyValuePair AMediaDrmKeyValue

Data type containing {key, value} pair.

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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_READ_RARELY or AHARDWAREBUFFER_USAGE_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-PRIVATE formats defined in AImage.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
See also:AImageSee also:AImageReader_newSee also:AHardwareBuffer

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.
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.

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.

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.

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.

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.

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.

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.

See also: AImageReader_ImageCallback

Details
Parameters
image
the AImage of interest.
outBuffer
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.

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.

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.

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.

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.

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.

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.

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.

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.

AMediaCodecCryptoInfo_delete

media_status_t AMediaCodecCryptoInfo_delete(
  AMediaCodecCryptoInfo *
)

delete an AMediaCodecCryptoInfo created previously with AMediaCodecCryptoInfo_new, or obtained from AMediaExtractor

AMediaCodecCryptoInfo_getClearBytes

media_status_t AMediaCodecCryptoInfo_getClearBytes(
  AMediaCodecCryptoInfo *,
  size_t *dst
)

The number of leading unencrypted bytes in each subsample.

AMediaCodecCryptoInfo_getEncryptedBytes

media_status_t AMediaCodecCryptoInfo_getEncryptedBytes(
  AMediaCodecCryptoInfo *,
  size_t *dst
)

The number of trailing encrypted bytes in each subsample.

AMediaCodecCryptoInfo_getIV

media_status_t AMediaCodecCryptoInfo_getIV(
  AMediaCodecCryptoInfo *,
  uint8_t *dst
)

A 16-byte initialization vector.

AMediaCodecCryptoInfo_getKey

media_status_t AMediaCodecCryptoInfo_getKey(
  AMediaCodecCryptoInfo *,
  uint8_t *dst
)

A 16-byte opaque key.

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.

AMediaCodecCryptoInfo_getNumSubSamples

size_t AMediaCodecCryptoInfo_getNumSubSamples(
  AMediaCodecCryptoInfo *
)

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

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".

AMediaCodecCryptoInfo_setPattern

void AMediaCodecCryptoInfo_setPattern(
  AMediaCodecCryptoInfo *info,
  cryptoinfo_pattern_t *pattern
)

Set the crypto pattern on an AMediaCryptoInfo object.

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.

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.

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.

AMediaCodec_createEncoderByType

AMediaCodec * AMediaCodec_createEncoderByType(
  const char *mime_type
)

Create encoder by name.

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.

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.

AMediaCodec_delete

media_status_t AMediaCodec_delete(
  AMediaCodec *
)

delete the codec and free its resources

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.

AMediaCodec_dequeueOutputBuffer

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

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

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.

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.

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.

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.

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.

AMediaCodec_getOutputFormat

AMediaFormat * AMediaCodec_getOutputFormat(
  AMediaCodec *
)

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.

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.

AMediaCodec_releaseCrypto

media_status_t AMediaCodec_releaseCrypto(
  AMediaCodec *
)

Release the crypto if applicable.

AMediaCodec_releaseName

void AMediaCodec_releaseName(
  AMediaCodec *,
  char *name
)

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

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.

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.

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, the client should not call AMediaCodec_getInputBuffers(), AMediaCodec_getOutputBuffers(), AMediaCodec_dequeueInputBuffer() or AMediaCodec_dequeueOutputBuffer().

Also, AMediaCodec_flush() behaves differently in asynchronous mode. After calling AMediaCodec_flush(), you must call AMediaCodec_start() to "resume" receiving input buffers, even if an input surface was created.

Refer to the definition of AMediaCodecOnAsyncNotifyCallback on how each callback function is called and what are specified. The specified userdata is the pointer used when those callback functions are 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.

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.

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.

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.

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.

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.

AMediaCodec_stop

media_status_t AMediaCodec_stop(
  AMediaCodec *
)

Stop the codec.

AMediaCrypto_delete

void AMediaCrypto_delete(
  AMediaCrypto *crypto
)

AMediaCrypto_isCryptoSchemeSupported

bool AMediaCrypto_isCryptoSchemeSupported(
  const AMediaUUID uuid
)

AMediaCrypto_new

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

AMediaCrypto_requiresSecureDecoderComponent

bool AMediaCrypto_requiresSecureDecoderComponent(
  const char *mime
)

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.

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.

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.data.

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:

  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 until the MediaDrm object is released.
  2. keyRequestSize will be set to the size of the request

returns MEDIADRM_NOT_PROVISIONED_ERROR if reprovisioning is needed, due to a problem with the device certificate.

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.

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.

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.

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, MEDIADRM_SHORT_BUFFER will be returned and *numSecureStops will be set to the number required.

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.

AMediaDrm_openSession

media_status_t AMediaDrm_openSession(
  AMediaDrm *,
  AMediaDrmSessionId *sessionId
)

Open a new session with the MediaDrm object.

A session ID is returned.

returns MEDIADRM_NOT_PROVISIONED_ERROR if provisioning is needed returns MEDIADRM_RESOURCE_BUSY_ERROR if required resources are in use

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

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 MEDIADRM_DEVICE_REVOKED_ERROR if the response indicates that the server rejected the request

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, MEDIADRM_SHORT_BUFFER will be returned and numPairs will be set to the number of pairs available.

AMediaDrm_release

void AMediaDrm_release(
  AMediaDrm *
)

Release a MediaDrm object.

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

AMediaDrm_removeKeys

media_status_t AMediaDrm_removeKeys(
  AMediaDrm *,
  const AMediaDrmSessionId *keySetId
)

Remove the current keys from a session.

keySetId identifies keys to remove

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

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

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.

AMediaDrm_setPropertyString

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

Set a DRM engine plugin String property value.

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).

AMediaExtractor_delete

media_status_t AMediaExtractor_delete(
  AMediaExtractor *
)

Delete a previously created media extractor.

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).

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.

AMediaExtractor_getPsshInfo

PsshInfo * AMediaExtractor_getPsshInfo(
  AMediaExtractor *
)

Get the PSSH info if present.

AMediaExtractor_getSampleCryptoInfo

AMediaCodecCryptoInfo * AMediaExtractor_getSampleCryptoInfo(
  AMediaExtractor *
)

AMediaExtractor_getSampleFlags

uint32_t AMediaExtractor_getSampleFlags(
  AMediaExtractor *
)

Read the current sample's flags.

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_*.

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);

AMediaExtractor_getSampleTime

int64_t AMediaExtractor_getSampleTime(
  AMediaExtractor *
)

Returns the current sample's presentation time in microseconds.

or -1 if no more samples are available.

AMediaExtractor_getSampleTrackIndex

int AMediaExtractor_getSampleTrackIndex(
  AMediaExtractor *
)

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

AMediaExtractor_getTrackCount

size_t AMediaExtractor_getTrackCount(
  AMediaExtractor *
)

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

AMediaExtractor_getTrackFormat

AMediaFormat * AMediaExtractor_getTrackFormat(
  AMediaExtractor *,
  size_t idx
)

Return the format of the specified track.

The caller must free the returned format

AMediaExtractor_new

AMediaExtractor * AMediaExtractor_new()

Create new media extractor.

AMediaExtractor_readSampleData

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

Read the current sample.

AMediaExtractor_seekTo

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

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.

AMediaExtractor_setDataSource

media_status_t AMediaExtractor_setDataSource(
  AMediaExtractor *,
  const char *location
)

Set the URI from which the extractor will read.

AMediaExtractor_setDataSourceCustom

media_status_t AMediaExtractor_setDataSourceCustom(
  AMediaExtractor *,
  AMediaDataSource *src
)

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

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.

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..

AMediaFormat_delete

media_status_t AMediaFormat_delete(
  AMediaFormat *
)

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.

AMediaFormat_getDouble

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

AMediaFormat_getFloat

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

AMediaFormat_getInt32

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

AMediaFormat_getInt64

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

AMediaFormat_getRect

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

AMediaFormat_getSize

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

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.

AMediaFormat_new

AMediaFormat * AMediaFormat_new()

AMediaFormat_setBuffer

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

The provided data is copied into the format.

AMediaFormat_setDouble

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

AMediaFormat_setFloat

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

AMediaFormat_setInt32

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

AMediaFormat_setInt64

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

AMediaFormat_setRect

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

AMediaFormat_setSize

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

AMediaFormat_setString

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

The provided string is copied into the format.

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.

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.

AMediaMuxer_delete

media_status_t AMediaMuxer_delete(
  AMediaMuxer *
)

Delete a previously created media muxer.

AMediaMuxer_new

AMediaMuxer * AMediaMuxer_new(
  int fd,
  OutputFormat format
)

Create new media muxer.

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].

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.

AMediaMuxer_start

media_status_t AMediaMuxer_start(
  AMediaMuxer *
)

Start the muxer.

Should be called after AMediaMuxer_addTrack and before AMediaMuxer_writeSampleData.

AMediaMuxer_stop

media_status_t AMediaMuxer_stop(
  AMediaMuxer *
)

Stops the muxer.

Once the muxer stops, it can not be restarted.

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.)

__INTRODUCED_IN

const char *AMEDIAFORMAT_KEY_AAC_DRC_ATTENUATION_FACTOR __INTRODUCED_IN(
  28
)

XXX should these be ints/enums that we look up in a table as needed?

__INTRODUCED_IN

const char *AMEDIAFORMAT_KEY_AAC_PROFILE __INTRODUCED_IN(
  21
)