MediaCodec.QueueRequest  |  API reference  |  Android Developers


public final class MediaCodec.QueueRequest
extends Object



Builder-like class for queue requests. Use this class to prepare a queue request and send it.

Summary

Public methods

void queue()

Finish building a queue request and queue the buffers with tunings.

MediaCodec.QueueRequest setByteBufferParameter(String key, ByteBuffer value)

Add a ByteBuffer parameter.

MediaCodec.QueueRequest setEncryptedLinearBlock(MediaCodec.LinearBlock block, int offset, int size, MediaCodec.CryptoInfo cryptoInfo)

Set an encrypted linear block to this queue request.

MediaCodec.QueueRequest setFlags(int flags)

Set flags to this queue request.

MediaCodec.QueueRequest setFloatParameter(String key, float value)

Add a float parameter.

MediaCodec.QueueRequest setHardwareBuffer(HardwareBuffer buffer)

Set a hardware graphic buffer to this queue request.

MediaCodec.QueueRequest setIntegerParameter(String key, int value)

Add an integer parameter.

MediaCodec.QueueRequest setLinearBlock(MediaCodec.LinearBlock block, int offset, int size)

Set a linear block to this queue request.

MediaCodec.QueueRequest setLongParameter(String key, long value)

Add a long parameter.

MediaCodec.QueueRequest setMultiFrameEncryptedLinearBlock(MediaCodec.LinearBlock block, ArrayDeque<MediaCodec.BufferInfo> bufferInfos, ArrayDeque<MediaCodec.CryptoInfo> cryptoInfos)

Set an encrypted linear block to this queue request.

MediaCodec.QueueRequest setMultiFrameLinearBlock(MediaCodec.LinearBlock block, ArrayDeque<MediaCodec.BufferInfo> infos)

Set a linear block that contain multiple non-encrypted access unit to this queue request.

MediaCodec.QueueRequest setPresentationTimeUs(long presentationTimeUs)

Set timestamp to this queue request.

MediaCodec.QueueRequest setStringParameter(String key, String value)

Add a string parameter.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public methods

queue

public void queue ()

Finish building a queue request and queue the buffers with tunings.

setEncryptedLinearBlock

public MediaCodec.QueueRequest setEncryptedLinearBlock (MediaCodec.LinearBlock block, 
                int offset, 
                int size, 
                MediaCodec.CryptoInfo cryptoInfo)

Set an encrypted linear block to this queue request. Exactly one buffer must be set for a queue request before calling queue(). It is possible to use the same LinearBlock object for multiple queue requests. The behavior is undefined if the range of the buffer overlaps for multiple requests, or the application writes into the region being processed by the codec.

Parameters
block MediaCodec.LinearBlock: The linear block object.
This value cannot be null.
offset int: The byte offset into the input buffer at which the data starts.
size int: The number of bytes of valid input data.
cryptoInfo MediaCodec.CryptoInfo: Metadata describing the structure of the encrypted input sample.
This value cannot be null.
Returns
MediaCodec.QueueRequest this object.
This value cannot be null.
Throws
IllegalStateException if a buffer is already set

setFloatParameter

public MediaCodec.QueueRequest setFloatParameter (String key, 
                float value)

Add a float parameter. See MediaFormat for an exhaustive list of supported keys with values of type float, that can also be set with MediaFormat.setFloat. If there was MediaCodec.setParameters call with the same key which is not processed by the codec yet, the value set from this method will override the unprocessed value.

Parameters
key String: This value cannot be null.
value float
Returns
MediaCodec.QueueRequest this object.
This value cannot be null.

setIntegerParameter

public MediaCodec.QueueRequest setIntegerParameter (String key, 
                int value)

Add an integer parameter. See MediaFormat for an exhaustive list of supported keys with values of type int, that can also be set with MediaFormat.setInteger. If there was MediaCodec.setParameters call with the same key which is not processed by the codec yet, the value set from this method will override the unprocessed value.

Parameters
key String: This value cannot be null.
value int
Returns
MediaCodec.QueueRequest this object.
This value cannot be null.

setLinearBlock

public MediaCodec.QueueRequest setLinearBlock (MediaCodec.LinearBlock block, 
                int offset, 
                int size)

Set a linear block to this queue request. Exactly one buffer must be set for a queue request before calling queue(). It is possible to use the same LinearBlock object for multiple queue requests. The behavior is undefined if the range of the buffer overlaps for multiple requests, or the application writes into the region being processed by the codec.

Parameters
block MediaCodec.LinearBlock: The linear block object.
This value cannot be null.
offset int: The byte offset into the input buffer at which the data starts.
size int: The number of bytes of valid input data.
Returns
MediaCodec.QueueRequest this object.
This value cannot be null.
Throws
IllegalStateException if a buffer is already set

setLongParameter

public MediaCodec.QueueRequest setLongParameter (String key, 
                long value)

Add a long parameter. See MediaFormat for an exhaustive list of supported keys with values of type long, that can also be set with MediaFormat.setLong. If there was MediaCodec.setParameters call with the same key which is not processed by the codec yet, the value set from this method will override the unprocessed value.

Parameters
key String: This value cannot be null.
value long
Returns
MediaCodec.QueueRequest this object.
This value cannot be null.

setMultiFrameEncryptedLinearBlock

public MediaCodec.QueueRequest setMultiFrameEncryptedLinearBlock (MediaCodec.LinearBlock block, 
                ArrayDeque<MediaCodec.BufferInfo> bufferInfos, 
                ArrayDeque<MediaCodec.CryptoInfo> cryptoInfos)

Set an encrypted linear block to this queue request. Exactly one buffer must be set for a queue request before calling queue(). The block can contain multiple access units and if present should be laid out contiguously and without gaps.

Parameters
block MediaCodec.LinearBlock: The linear block object.
This value cannot be null.
bufferInfos ArrayDeque: ArrayDeque of MediaCodec.BufferInfo that describes the contents in the buffer. The ArrayDeque and the BufferInfo objects provided can be recycled by the caller for re-use.
This value cannot be null.
cryptoInfos ArrayDeque: ArrayDeque of MediaCodec.CryptoInfo that describes the structure of the encrypted input samples. The ArrayDeque and the BufferInfo objects provided can be recycled by the caller for re-use.
This value cannot be null.
Returns
MediaCodec.QueueRequest this object.
This value cannot be null.
Throws
IllegalArgumentException upon if bufferInfos is empty, contains null, or if the access units are not contiguous.
IllegalStateException if a buffer is already set

setMultiFrameLinearBlock

public MediaCodec.QueueRequest setMultiFrameLinearBlock (MediaCodec.LinearBlock block, 
                ArrayDeque<MediaCodec.BufferInfo> infos)

Set a linear block that contain multiple non-encrypted access unit to this queue request. Exactly one buffer must be set for a queue request before calling queue(). Multiple access units if present must be laid out contiguously and without gaps and in order. An IllegalArgumentException will be thrown during queue() if access units are not laid out contiguously.

Parameters
block MediaCodec.LinearBlock: The linear block object.
This value cannot be null.
infos ArrayDeque: Represents MediaCodec.BufferInfo objects to mark individual access-unit boundaries and the timestamps associated with it.
This value cannot be null.
Returns
MediaCodec.QueueRequest this object.
This value cannot be null.
Throws
IllegalStateException if a buffer is already set

setPresentationTimeUs

public MediaCodec.QueueRequest setPresentationTimeUs (long presentationTimeUs)

Set timestamp to this queue request.

Parameters
presentationTimeUs long: The presentation timestamp in microseconds for this buffer. This is normally the media time at which this buffer should be presented (rendered). When using an output surface, this will be propagated as the timestamp for the frame (after conversion to nanoseconds).
Returns
MediaCodec.QueueRequest this object.
This value cannot be null.

setStringParameter

public MediaCodec.QueueRequest setStringParameter (String key, 
                String value)

Add a string parameter. See MediaFormat for an exhaustive list of supported keys with values of type string, that can also be set with MediaFormat.setString. If there was MediaCodec.setParameters call with the same key which is not processed by the codec yet, the value set from this method will override the unprocessed value.

Parameters
key String: This value cannot be null.
value String: This value cannot be null.
Returns
MediaCodec.QueueRequest this object.
This value cannot be null.