MediaCodec.Callback
  public
  static
  
  abstract
  class
  MediaCodec.Callback
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.media.MediaCodec.Callback | 
MediaCodec callback interface. Used to notify the user asynchronously of various MediaCodec events.
Summary
| Public constructors | |
|---|---|
| 
      Callback()
       | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        void | 
      onCryptoError(MediaCodec codec, MediaCodec.CryptoException e)
      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
        
        
        
        
        void | 
      onError(MediaCodec codec, MediaCodec.CodecException e)
      Called when the MediaCodec encountered an error | 
| 
        abstract
        
        
        
        
        void | 
      onInputBufferAvailable(MediaCodec codec, int index)
      Called when an input buffer becomes available. | 
| 
        
        
        
        
        
        void | 
      onMetricsFlushed(MediaCodec codec, PersistableBundle metrics)
      Called when the metrics for this codec have been flushed "mid-stream" due to the start of a new subsession during execution. | 
| 
        abstract
        
        
        
        
        void | 
      onOutputBufferAvailable(MediaCodec codec, int index, MediaCodec.BufferInfo info)
      Called when an output buffer becomes available. | 
| 
        
        
        
        
        
        void | 
      onOutputBuffersAvailable(MediaCodec codec, int index, ArrayDeque<MediaCodec.BufferInfo> infos)
      Called when multiple access-units are available in the output. | 
| 
        abstract
        
        
        
        
        void | 
      onOutputFormatChanged(MediaCodec codec, MediaFormat format)
      Called when the output format has changed | 
| Inherited methods | |
|---|---|
Public constructors
Callback
public Callback ()
Public methods
onCryptoError
public void onCryptoError (MediaCodec codec, MediaCodec.CryptoException e)
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 benull. | 
| e | MediaCodec.CryptoException: TheMediaCodec.CryptoExceptionobject with error details.
 This value cannot benull. | 
onError
public abstract void onError (MediaCodec codec, MediaCodec.CodecException e)
Called when the MediaCodec encountered an error
| Parameters | |
|---|---|
| codec | MediaCodec: The MediaCodec object.
 This value cannot benull. | 
| e | MediaCodec.CodecException: TheMediaCodec.CodecExceptionobject describing the error.
 This value cannot benull. | 
onInputBufferAvailable
public abstract void onInputBufferAvailable (MediaCodec codec, int index)
Called when an input buffer becomes available.
| Parameters | |
|---|---|
| codec | MediaCodec: The MediaCodec object.
 This value cannot benull. | 
| index | int: The index of the available input buffer. | 
onMetricsFlushed
public void onMetricsFlushed (MediaCodec codec, PersistableBundle metrics)
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 MediaCodec.configure(MediaFormat, Surface, MediaCrypto, int).
 
 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 benull. | 
| metrics | PersistableBundle: The flushed metrics for this codec. This is aPersistableBundlecontaining the set of
                attributes and values available for the media being
                handled by this instance of MediaCodec. The attributes
                are described inMetricsConstants. Additional
                vendor-specific fields may also be present.
 This value cannot benull. | 
onOutputBufferAvailable
public abstract void onOutputBufferAvailable (MediaCodec codec, int index, MediaCodec.BufferInfo info)
Called when an output buffer becomes available.
| Parameters | |
|---|---|
| codec | MediaCodec: The MediaCodec object.
 This value cannot benull. | 
| index | int: The index of the available output buffer. | 
| info | MediaCodec.BufferInfo: Info regarding the available output bufferMediaCodec.BufferInfo.
 This value cannot benull. | 
onOutputBuffersAvailable
public void onOutputBuffersAvailable (MediaCodec codec, int index, ArrayDeque<MediaCodec.BufferInfo> infos)
Called when multiple access-units are available in the output.
| Parameters | |
|---|---|
| codec | MediaCodec: The MediaCodec object.
 This value cannot benull. | 
| index | int: The index of the available output buffer. | 
| infos | ArrayDeque: Infos describing the available output bufferMediaCodec.BufferInfo.
              Access units present in the output buffer are laid out contiguously
              without gaps and in order.
 This value cannot benull. | 
onOutputFormatChanged
public abstract void onOutputFormatChanged (MediaCodec codec, MediaFormat format)
Called when the output format has changed
| Parameters | |
|---|---|
| codec | MediaCodec: The MediaCodec object.
 This value cannot benull. | 
| format | MediaFormat: The new output format.
 This value cannot benull. | 
