Added in API level 30

QueueRequest


class QueueRequest
kotlin.Any
   ↳ android.media.MediaCodec.QueueRequest

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

Summary

Public methods
Unit

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

MediaCodec.QueueRequest

Add a ByteBuffer parameter.

MediaCodec.QueueRequest

Set an encrypted linear block to this queue request.

MediaCodec.QueueRequest
setFlags(flags: Int)

Set flags to this queue request.

MediaCodec.QueueRequest

Add a float parameter.

MediaCodec.QueueRequest

Set a hardware graphic buffer to this queue request.

MediaCodec.QueueRequest

Add an integer parameter.

MediaCodec.QueueRequest
setLinearBlock(block: MediaCodec.LinearBlock, offset: Int, size: Int)

Set a linear block to this queue request.

MediaCodec.QueueRequest
setLongParameter(key: String, value: Long)

Add a long parameter.

MediaCodec.QueueRequest

Set an encrypted linear block to this queue request.

MediaCodec.QueueRequest

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

MediaCodec.QueueRequest
setPresentationTimeUs(presentationTimeUs: Long)

Set timestamp to this queue request.

MediaCodec.QueueRequest

Add a string parameter.

Public methods

queue

Added in API level 30
fun queue(): Unit

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

setByteBufferParameter

Added in API level 30
fun setByteBufferParameter(
    key: String,
    value: ByteBuffer
): MediaCodec.QueueRequest

Add a ByteBuffer parameter. See MediaFormat for an exhaustive list of supported keys with values of byte buffer, that can also be set with MediaFormat#setByteBuffer. 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 ByteBuffer: This value cannot be null.
Return
MediaCodec.QueueRequest this object This value cannot be null.

setEncryptedLinearBlock

Added in API level 30
fun setEncryptedLinearBlock(
    block: MediaCodec.LinearBlock,
    offset: Int,
    size: Int,
    cryptoInfo: MediaCodec.CryptoInfo
): MediaCodec.QueueRequest

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.
Return
MediaCodec.QueueRequest this object This value cannot be null.
Exceptions
java.lang.IllegalStateException if a buffer is already set

setFlags

Added in API level 30
fun setFlags(flags: Int): MediaCodec.QueueRequest

Set flags to this queue request.

Parameters
flags Int: A bitmask of flags BUFFER_FLAG_CODEC_CONFIG and BUFFER_FLAG_END_OF_STREAM. While not prohibited, most codecs do not use the BUFFER_FLAG_KEY_FRAME flag for input buffers. Value is either 0 or a combination of android.media.MediaCodec#BUFFER_FLAG_SYNC_FRAME, android.media.MediaCodec#BUFFER_FLAG_KEY_FRAME, android.media.MediaCodec#BUFFER_FLAG_CODEC_CONFIG, android.media.MediaCodec#BUFFER_FLAG_END_OF_STREAM, android.media.MediaCodec#BUFFER_FLAG_PARTIAL_FRAME, android.media.MediaCodec.BUFFER_FLAG_MUXER_DATA, and android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY
Return
MediaCodec.QueueRequest this object This value cannot be null.

setFloatParameter

Added in API level 30
fun setFloatParameter(
    key: String,
    value: Float
): MediaCodec.QueueRequest

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.
Return
MediaCodec.QueueRequest this object This value cannot be null.

setHardwareBuffer

Added in API level 30
fun setHardwareBuffer(buffer: HardwareBuffer): MediaCodec.QueueRequest

Set a hardware graphic buffer to this queue request. Exactly one buffer must be set for a queue request before calling queue.

Note: buffers should have format HardwareBuffer#YCBCR_420_888, a single layer, and an appropriate usage (HardwareBuffer#USAGE_CPU_READ_OFTEN for software codecs and HardwareBuffer#USAGE_VIDEO_ENCODE for hardware) for codecs to recognize. Format ImageFormat#PRIVATE together with usage HardwareBuffer#USAGE_VIDEO_ENCODE will also work for hardware codecs. Codecs may throw exception if the buffer is not recognizable.

Parameters
buffer HardwareBuffer: The hardware graphic buffer object This value cannot be null.
Return
MediaCodec.QueueRequest this object This value cannot be null.
Exceptions
java.lang.IllegalStateException if a buffer is already set

setIntegerParameter

Added in API level 30
fun setIntegerParameter(
    key: String,
    value: Int
): MediaCodec.QueueRequest

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.
Return
MediaCodec.QueueRequest this object This value cannot be null.

setLinearBlock

Added in API level 30
fun setLinearBlock(
    block: MediaCodec.LinearBlock,
    offset: Int,
    size: Int
): MediaCodec.QueueRequest

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.
Return
MediaCodec.QueueRequest this object This value cannot be null.
Exceptions
java.lang.IllegalStateException if a buffer is already set

setLongParameter

Added in API level 30
fun setLongParameter(
    key: String,
    value: Long
): MediaCodec.QueueRequest

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.
Return
MediaCodec.QueueRequest this object This value cannot be null.

setMultiFrameEncryptedLinearBlock

Added in API level 35
fun setMultiFrameEncryptedLinearBlock(
    block: MediaCodec.LinearBlock,
    bufferInfos: ArrayDeque<MediaCodec.BufferInfo!>,
    cryptoInfos: ArrayDeque<MediaCodec.CryptoInfo!>
): MediaCodec.QueueRequest

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<MediaCodec.BufferInfo!>: 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<MediaCodec.CryptoInfo!>: 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.
Return
MediaCodec.QueueRequest this object This value cannot be null.
Exceptions
java.lang.IllegalStateException if a buffer is already set
java.lang.IllegalArgumentException upon if bufferInfos is empty, contains null, or if the access units are not contiguous.

setMultiFrameLinearBlock

Added in API level 35
fun setMultiFrameLinearBlock(
    block: MediaCodec.LinearBlock,
    infos: ArrayDeque<MediaCodec.BufferInfo!>
): MediaCodec.QueueRequest

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<MediaCodec.BufferInfo!>: Represents MediaCodec.BufferInfo objects to mark individual access-unit boundaries and the timestamps associated with it. This value cannot be null.
Return
MediaCodec.QueueRequest this object This value cannot be null.
Exceptions
java.lang.IllegalStateException if a buffer is already set

setPresentationTimeUs

Added in API level 30
fun setPresentationTimeUs(presentationTimeUs: Long): MediaCodec.QueueRequest

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).
Return
MediaCodec.QueueRequest this object This value cannot be null.

setStringParameter

Added in API level 30
fun setStringParameter(
    key: String,
    value: String
): MediaCodec.QueueRequest

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.
Return
MediaCodec.QueueRequest this object This value cannot be null.