Partager via


MediaCodec.ReleaseOutputBuffer Method

Definition

Overloads

ReleaseOutputBuffer(Int32, Boolean)

If you are done with a buffer, use this call to return the buffer to the codec or to render it on the output surface.

ReleaseOutputBuffer(Int32, Int64)

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.

ReleaseOutputBuffer(Int32, Boolean)

If you are done with a buffer, use this call to return the buffer to the codec or to render it on the output surface.

[Android.Runtime.Register("releaseOutputBuffer", "(IZ)V", "")]
public void ReleaseOutputBuffer (int index, bool render);
[<Android.Runtime.Register("releaseOutputBuffer", "(IZ)V", "")>]
member this.ReleaseOutputBuffer : int * bool -> unit

Parameters

index
Int32

The index of a client-owned output buffer previously returned from a call to #dequeueOutputBuffer.

render
Boolean

If a valid surface was specified when configuring the codec, passing true renders this output buffer to the surface.

Attributes

Exceptions

if not in the Executing state.

upon codec error.

Remarks

If you are done with a buffer, use this call to return the buffer to the codec or to render it on the output surface. If you configured the codec with an output surface, setting render to true will first send the buffer to that output surface. The surface will release the buffer back to the codec once it is no longer used/displayed.

Once an output buffer is released to the codec, it MUST NOT be used until it is later retrieved by #getOutputBuffer in response to a #dequeueOutputBuffer return value or a Callback#onOutputBufferAvailable callback.

Java documentation for android.media.MediaCodec.releaseOutputBuffer(int, boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

ReleaseOutputBuffer(Int32, Int64)

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.

[Android.Runtime.Register("releaseOutputBuffer", "(IJ)V", "")]
public void ReleaseOutputBuffer (int index, long renderTimestampNs);
[<Android.Runtime.Register("releaseOutputBuffer", "(IJ)V", "")>]
member this.ReleaseOutputBuffer : int * int64 -> unit

Parameters

index
Int32

The index of a client-owned output buffer previously returned from a call to #dequeueOutputBuffer.

renderTimestampNs
Int64

The timestamp to associate with this buffer when it is sent to the Surface.

Attributes

Exceptions

if not in the Executing state.

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

<table> <tr><th>SurfaceView specifics</th></tr> <tr><td> If you render your buffer on a android.view.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 System#nanoTime. Currently, this is set as within one (1) second. A few notes:

<ul> <li>the buffer will not be returned to the codec until the timestamp has passed and the buffer is no longer used by the android.view.Surface. <li>buffers are processed sequentially, so you may block subsequent buffers to be displayed on the android.view.Surface. This is important if you want to react to user action, e.g. stop the video or seek. <li>if multiple buffers are sent to the android.view.Surface to be rendered at the same VSYNC, the last one will be shown, and the other ones will be dropped. <li>if the timestamp is <em>not</em> "reasonably close" to the current system time, the android.view.Surface will ignore the timestamp, and display the buffer at the earliest feasible time. In this mode it will not drop frames. <li>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. </ul> </td></tr> </table>

Once an output buffer is released to the codec, it MUST NOT be used until it is later retrieved by #getOutputBuffer in response to a #dequeueOutputBuffer return value or a Callback#onOutputBufferAvailable callback.

Java documentation for android.media.MediaCodec.releaseOutputBuffer(int, long).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to