public interface MediaCodecAdapter
MediaCodec
operations.
MediaCodecAdapter
offers a common interface to interact with a MediaCodec
regardless of the MediaCodecRenderer.MediaCodecOperationMode
the MediaCodec
is operating in.
Modifier and Type | Method | Description |
---|---|---|
void |
configure(MediaFormat mediaFormat,
Surface surface,
MediaCrypto crypto,
int flags) |
Configures this adapter and the underlying
MediaCodec . |
int |
dequeueInputBufferIndex() |
Returns the next available input buffer index from the underlying
MediaCodec or MediaCodec.INFO_TRY_AGAIN_LATER if no such buffer exists. |
int |
dequeueOutputBufferIndex(MediaCodec.BufferInfo bufferInfo) |
Returns the next available output buffer index from the underlying
MediaCodec . |
void |
flush() |
Flushes both the adapter and the underlying
MediaCodec . |
MediaCodec |
getCodec() |
Returns the
MediaCodec instance of this adapter. |
MediaFormat |
getOutputFormat() |
Gets the
MediaFormat that was output from the MediaCodec . |
void |
queueInputBuffer(int index,
int offset,
int size,
long presentationTimeUs,
int flags) |
Submit an input buffer for decoding.
|
void |
queueSecureInputBuffer(int index,
int offset,
CryptoInfo info,
long presentationTimeUs,
int flags) |
Submit an input buffer that is potentially encrypted for decoding.
|
void |
shutdown() |
Shuts down the adapter.
|
void |
start() |
Starts this instance.
|
void configure(@Nullable MediaFormat mediaFormat, @Nullable Surface surface, @Nullable MediaCrypto crypto, int flags)
MediaCodec
. Needs to be called before start()
.void start()
configure(android.media.MediaFormat, android.view.Surface, android.media.MediaCrypto, int)
.MediaCodec.start()
int dequeueInputBufferIndex()
MediaCodec
or MediaCodec.INFO_TRY_AGAIN_LATER
if no such buffer exists.IllegalStateException
- If the underlying MediaCodec
raised an error.int dequeueOutputBufferIndex(MediaCodec.BufferInfo bufferInfo)
MediaCodec
. If the
next available output is a MediaFormat change, it will return MediaCodec.INFO_OUTPUT_FORMAT_CHANGED
and you should call getOutputFormat()
to get
the format. If there is no available output, this method will return MediaCodec.INFO_TRY_AGAIN_LATER
.IllegalStateException
- If the underlying MediaCodec
raised an error.MediaFormat getOutputFormat()
MediaFormat
that was output from the MediaCodec
.
Call this method if a previous call to dequeueOutputBufferIndex(android.media.MediaCodec.BufferInfo)
returned MediaCodec.INFO_OUTPUT_FORMAT_CHANGED
.
void queueInputBuffer(int index, int offset, int size, long presentationTimeUs, int flags)
The index
must be an input buffer index that has been obtained from a previous call
to dequeueInputBufferIndex()
.
void queueSecureInputBuffer(int index, int offset, CryptoInfo info, long presentationTimeUs, int flags)
The index
must be an input buffer index that has been obtained from a previous call
to dequeueInputBufferIndex()
.
This method behaves like MediaCodec.queueSecureInputBuffer(int, int, android.media.MediaCodec.CryptoInfo, long, int)
, with the difference that
info
is of type CryptoInfo
and not MediaCodec.CryptoInfo
.
void flush()
MediaCodec
.void shutdown()
This method does not stop or release the underlying MediaCodec
. It should be called
before stopping or releasing the MediaCodec
to avoid the possibility of the adapter
interacting with a stopped or released MediaCodec
.
MediaCodec getCodec()
MediaCodec
instance of this adapter.