DecoderInputBuffer


@UnstableApi
class DecoderInputBuffer : Buffer


Holds input for a decoder.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
annotation DecoderInputBuffer.BufferReplacementMode

The buffer replacement mode.

Thrown when an attempt is made to write into a DecoderInputBuffer whose bufferReplacementMode is BUFFER_REPLACEMENT_MODE_DISABLED and who data capacity is smaller than required.

Constants

const Int

Allows buffer replacement using allocateDirect.

const Int

Disallows buffer replacement.

const Int

Allows buffer replacement using allocate.

Public constructors

Creates a new instance.

DecoderInputBuffer(
    @DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: Int,
    paddingSize: Int
)

Creates a new instance.

Public functions

Unit

Clears the buffer.

Unit
@EnsuresNonNull(value = "data")
ensureSpaceForWrite(length: Int)

Ensures that data is large enough to accommodate a write of a given length at its current position.

Unit

Flips data and supplementalData in preparation for being queued to a decoder.

Boolean

Returns whether the BUFFER_FLAG_ENCRYPTED flag is set.

java-static DecoderInputBuffer!

Returns a new instance that's not able to hold any data.

Unit
@EnsuresNonNull(value = "supplementalData")
resetSupplementalData(length: Int)

Clears supplementalData and ensures that it's large enough to accommodate length bytes.

Public properties

CryptoInfo!

CryptoInfo for encrypted data.

ByteBuffer?

The buffer's data, or null if no data has been set.

Format?

The Format.

ByteBuffer?

Supplemental data related to the buffer, if hasSupplementalData returns true.

Long

The time at which the sample should be presented.

Boolean

Whether the last attempt to read a sample into this buffer failed due to not yet having the DRM keys associated with the next sample.

Inherited functions

From androidx.media3.decoder.Buffer
Unit

Adds the flag to this buffer's flags.

Unit

Removes the flag from this buffer's flags, if it is set.

Boolean

Returns whether the specified flag has been set on this buffer.

Boolean

Returns whether the BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA flag is set.

Boolean

This function is deprecated.

Check instead whether the buffer time is greater or equal to the desired start time.

Boolean

Returns whether the BUFFER_FLAG_END_OF_STREAM flag is set.

Boolean

Returns whether the BUFFER_FLAG_FIRST_SAMPLE flag is set.

Boolean

Returns whether the BUFFER_FLAG_KEY_FRAME flag is set.

Boolean

Returns whether the BUFFER_FLAG_LAST_SAMPLE flag is set.

Unit

Replaces this buffer's flags with flags.

Constants

BUFFER_REPLACEMENT_MODE_DIRECT

const val BUFFER_REPLACEMENT_MODE_DIRECT = 2: Int

Allows buffer replacement using allocateDirect.

BUFFER_REPLACEMENT_MODE_DISABLED

const val BUFFER_REPLACEMENT_MODE_DISABLED = 0: Int

Disallows buffer replacement.

BUFFER_REPLACEMENT_MODE_NORMAL

const val BUFFER_REPLACEMENT_MODE_NORMAL = 1: Int

Allows buffer replacement using allocate.

Public constructors

DecoderInputBuffer

DecoderInputBuffer(
    @DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: Int
)

Creates a new instance.

Parameters
@DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: Int

The BufferReplacementMode replacement mode.

DecoderInputBuffer

DecoderInputBuffer(
    @DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: Int,
    paddingSize: Int
)

Creates a new instance.

Parameters
@DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: Int

The BufferReplacementMode replacement mode.

paddingSize: Int

If non-zero, ensureSpaceForWrite will ensure that the buffer is this number of bytes larger than the requested length. This can be useful for decoders that consume data in fixed size blocks, for efficiency. Setting the padding size to the decoder's fixed read size is necessary to prevent such a decoder from trying to read beyond the end of the buffer.

Public functions

clear

fun clear(): Unit

Clears the buffer.

ensureSpaceForWrite

@EnsuresNonNull(value = "data")
fun ensureSpaceForWrite(length: Int): Unit

Ensures that data is large enough to accommodate a write of a given length at its current position.

If the capacity of data is sufficient this method does nothing. If the capacity is insufficient then an attempt is made to replace data with a new ByteBuffer whose capacity is sufficient. Data up to the current position is copied to the new buffer.

Parameters
length: Int

The length of the write that must be accommodated, in bytes.

flip

fun flip(): Unit

Flips data and supplementalData in preparation for being queued to a decoder.

See also
flip

isEncrypted

fun isEncrypted(): Boolean

Returns whether the BUFFER_FLAG_ENCRYPTED flag is set.

newNoDataInstance

java-static fun newNoDataInstance(): DecoderInputBuffer!

Returns a new instance that's not able to hold any data.

resetSupplementalData

@EnsuresNonNull(value = "supplementalData")
fun resetSupplementalData(length: Int): Unit

Clears supplementalData and ensures that it's large enough to accommodate length bytes.

Parameters
length: Int

The length of the supplemental data that must be accommodated, in bytes.

Public properties

cryptoInfo

val cryptoInfoCryptoInfo!

CryptoInfo for encrypted data.

data

val dataByteBuffer?

The buffer's data, or null if no data has been set.

format

val formatFormat?

The Format.

supplementalData

val supplementalDataByteBuffer?

Supplemental data related to the buffer, if hasSupplementalData returns true. If present, the buffer is populated with supplemental data from position 0 to its limit.

timeUs

val timeUsLong

The time at which the sample should be presented.

waitingForKeys

val waitingForKeysBoolean

Whether the last attempt to read a sample into this buffer failed due to not yet having the DRM keys associated with the next sample.