Android.Media.MediaCodec.ReleaseOutputBuffer Method
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.

Syntax

[Android.Runtime.Register("releaseOutputBuffer", "(IJ)V", "")]
public void ReleaseOutputBuffer (int index, long renderTimestampNs)

Parameters

index
The index of a client-owned output buffer previously returned from a call to MediaCodec.DequeueOutputBuffer(.BufferInfo, System.Int64).
renderTimestampNs
The timestamp to associate with this buffer when it is sent to the Surface.

Exceptions

TypeReason
Java.Lang.IllegalStateExceptionif not in the Executing state.
!:NoType:android/media/MediaCodec$CodecException;Href=../../../reference/android/media/MediaCodec.CodecException.htmlupon codec error.

Remarks

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.

The timestamp may have special meaning depending on the destination surface.
SurfaceView specifics
If you render your buffer on a Android.Views.SurfaceView, you can use the timestamp to render the buffer at a specific time (at the VSYNC at or after the buffer timestamp). For this to work, the timestamp needs to be reasonably close to the current Java.Lang.JavaSystem.NanoTime. Currently, this is set as within one (1) second. A few notes:
  • the buffer will not be returned to the codec until the timestamp has passed and the buffer is no longer used by the Android.Views.Surface.
  • buffers are processed sequentially, so you may block subsequent buffers to be displayed on the Android.Views.Surface. This is important if you want to react to user action, e.g. stop the video or seek.
  • if multiple buffers are sent to the Android.Views.Surface to be rendered at the same VSYNC, the last one will be shown, and the other ones will be dropped.
  • if the timestamp is not "reasonably close" to the current system time, the Android.Views.Surface will ignore the timestamp, and display the buffer at the earliest feasible time. In this mode it will not drop frames.
  • for best performance and quality, call this method when you are about two VSYNCs' time before the desired render time. For 60Hz displays, this is about 33 msec.
Once an output buffer is released to the codec, it MUST NOT be used until it is later retrieved by MediaCodec.GetOutputBuffer(int) in response to a MediaCodec.DequeueOutputBuffer(.BufferInfo, System.Int64) return value or a NoType:android/media/MediaCodec$Callback;Href=../../../reference/android/media/MediaCodec.Callback.html#onOutputBufferAvailable(android.media.MediaCodec, int, android.media.MediaCodec.BufferInfo) callback.

[Android Documentation]

Requirements

Namespace: Android.Media
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 16