Callback
abstract class Callback
kotlin.Any | |
↳ | android.media.MediaCodec.Callback |
MediaCodec callback interface. Used to notify the user asynchronously of various MediaCodec events.
Summary
Public constructors | |
---|---|
Callback() |
Public methods | |
---|---|
open Unit |
onCryptoError(codec: MediaCodec, e: MediaCodec.CryptoException) Called only when MediaCodec encountered a crypto(decryption) error when using a decoder configured with CONFIGURE_FLAG_USE_CRYPTO_ASYNC flag along with crypto or descrambler object. |
abstract Unit |
onError(codec: MediaCodec, e: MediaCodec.CodecException) Called when the MediaCodec encountered an error |
abstract Unit |
onInputBufferAvailable(codec: MediaCodec, index: Int) Called when an input buffer becomes available. |
open Unit |
onMetricsFlushed(codec: MediaCodec, metrics: PersistableBundle) Called when the metrics for this codec have been flushed "mid-stream" due to the start of a new subsession during execution. |
abstract Unit |
onOutputBufferAvailable(codec: MediaCodec, index: Int, info: MediaCodec.BufferInfo) Called when an output buffer becomes available. |
open Unit |
onOutputBuffersAvailable(codec: MediaCodec, index: Int, infos: ArrayDeque<MediaCodec.BufferInfo!>) Called when multiple access-units are available in the output. |
abstract Unit |
onOutputFormatChanged(codec: MediaCodec, format: MediaFormat) Called when the output format has changed |
Public constructors
Callback
Callback()
Public methods
onCryptoError
open fun onCryptoError(
codec: MediaCodec,
e: MediaCodec.CryptoException
): Unit
Called only when MediaCodec encountered a crypto(decryption) error when using a decoder configured with CONFIGURE_FLAG_USE_CRYPTO_ASYNC flag along with crypto or descrambler object.
Parameters | |
---|---|
codec |
MediaCodec: The MediaCodec object This value cannot be null . |
e |
MediaCodec.CryptoException: The MediaCodec.CryptoException object with error details. This value cannot be null . |
onError
abstract fun onError(
codec: MediaCodec,
e: MediaCodec.CodecException
): Unit
Called when the MediaCodec encountered an error
Parameters | |
---|---|
codec |
MediaCodec: The MediaCodec object. This value cannot be null . |
e |
MediaCodec.CodecException: The MediaCodec.CodecException object describing the error. This value cannot be null . |
onInputBufferAvailable
abstract fun onInputBufferAvailable(
codec: MediaCodec,
index: Int
): Unit
Called when an input buffer becomes available.
Parameters | |
---|---|
codec |
MediaCodec: The MediaCodec object. This value cannot be null . |
index |
Int: The index of the available input buffer. |
onMetricsFlushed
open fun onMetricsFlushed(
codec: MediaCodec,
metrics: PersistableBundle
): Unit
Called when the metrics for this codec have been flushed "mid-stream" due to the start of a new subsession during execution.
A new codec subsession normally starts when the codec is reconfigured after stop(), but it can also happen mid-stream e.g. if the video size changes. When this happens, the metrics for the previous subsession are flushed, and MediaCodec.getMetrics
will return the metrics for the new subsession.
For subsessions that begin due to a reconfiguration, the metrics for the prior subsession can be retrieved via MediaCodec.getMetrics
prior to calling #configure.
When a new subsession begins "mid-stream", the metrics for the prior subsession are flushed just before the Callback.onOutputFormatChanged
event, so this optional callback is provided to be able to capture the final metrics for the previous subsession.
Parameters | |
---|---|
codec |
MediaCodec: The MediaCodec object. This value cannot be null . |
metrics |
PersistableBundle: The flushed metrics for this codec. This is a PersistableBundle containing the set of attributes and values available for the media being handled by this instance of MediaCodec. The attributes are described in MetricsConstants . Additional vendor-specific fields may also be present. This value cannot be null . |
onOutputBufferAvailable
abstract fun onOutputBufferAvailable(
codec: MediaCodec,
index: Int,
info: MediaCodec.BufferInfo
): Unit
Called when an output buffer becomes available.
Parameters | |
---|---|
codec |
MediaCodec: The MediaCodec object. This value cannot be null . |
index |
Int: The index of the available output buffer. |
info |
MediaCodec.BufferInfo: Info regarding the available output buffer MediaCodec.BufferInfo . This value cannot be null . |
onOutputBuffersAvailable
open fun onOutputBuffersAvailable(
codec: MediaCodec,
index: Int,
infos: ArrayDeque<MediaCodec.BufferInfo!>
): Unit
Called when multiple access-units are available in the output.
Parameters | |
---|---|
codec |
MediaCodec: The MediaCodec object. This value cannot be null . |
index |
Int: The index of the available output buffer. |
infos |
ArrayDeque<MediaCodec.BufferInfo!>: Infos describing the available output buffer MediaCodec.BufferInfo . Access units present in the output buffer are laid out contiguously without gaps and in order. This value cannot be null . |
onOutputFormatChanged
abstract fun onOutputFormatChanged(
codec: MediaCodec,
format: MediaFormat
): Unit
Called when the output format has changed
Parameters | |
---|---|
codec |
MediaCodec: The MediaCodec object. This value cannot be null . |
format |
MediaFormat: The new output format. This value cannot be null . |