# DecoderInputBuffer

Artifact: [androidx.media3:media3-decoder](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/decoder/DecoderInputBuffer.java+class:androidx.media3.decoder.DecoderInputBuffer)

*** ** * ** ***


```
@UnstableApi
class DecoderInputBuffer : Buffer
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.media3.decoder.Buffer](https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer) ||
|   | ↳ | [androidx.media3.decoder.DecoderInputBuffer](https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer) |

Known direct subclasses [MetadataInputBuffer](https://developer.android.com/reference/kotlin/androidx/media3/extractor/metadata/MetadataInputBuffer), [SubtitleInputBuffer](https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleInputBuffer)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/metadata/MetadataInputBuffer` | A `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer` for a `https://developer.android.com/reference/kotlin/androidx/media3/extractor/metadata/MetadataDecoder`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleInputBuffer` | A `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer` for a `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/SubtitleDecoder`. |

*** ** * ** ***

Holds input for a decoder.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.BufferReplacementMode` The buffer replacement mode. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.InsufficientCapacityException : https://developer.android.com/reference/java/lang/IllegalStateException.html` Thrown when an attempt is made to write into a `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer` whose `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#bufferReplacementMode()` is `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#BUFFER_REPLACEMENT_MODE_DISABLED()` and who `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#data()` capacity is smaller than required. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#BUFFER_REPLACEMENT_MODE_DIRECT() = 2` Allows buffer replacement using `https://developer.android.com/reference/java/nio/ByteBuffer.html#allocateDirect(int)`. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#BUFFER_REPLACEMENT_MODE_DISABLED() = 0` Disallows buffer replacement. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#BUFFER_REPLACEMENT_MODE_NORMAL() = 1` Allows buffer replacement using `https://developer.android.com/reference/java/nio/ByteBuffer.html#allocate(int)`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#DecoderInputBuffer(int)( @https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a new instance. |
| `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#DecoderInputBuffer(int,int)( @https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, paddingSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a new instance. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#clear()()` Clears the buffer. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/EnsuresNonNull.html(value = "data") https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#ensureSpaceForWrite(int)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Ensures that `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#data()` is large enough to accommodate a write of a given length at its current position. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#flip()()` Flips `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#data()` and `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#supplementalData()` in preparation for being queued to a decoder. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#isEncrypted()()` Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/C#BUFFER_FLAG_ENCRYPTED()` flag is set. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer!` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#newNoDataInstance()()` Returns a new instance that's not able to hold any data. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/EnsuresNonNull.html(value = "supplementalData") https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#resetSupplementalData(int)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Clears `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#supplementalData()` and ensures that it's large enough to accommodate ` length` bytes. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoInfo!` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#cryptoInfo()` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoInfo` for encrypted data. |
| `https://developer.android.com/reference/java/nio/ByteBuffer.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#data()` The buffer's data, or `null` if no data has been set. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Format?` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#format()` The `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. |
| `https://developer.android.com/reference/java/nio/ByteBuffer.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#supplementalData()` Supplemental data related to the buffer, if `https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#hasSupplementalData()` returns true. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#timeUs()` The time at which the sample should be presented. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#waitingForKeys()` 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](https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#addFlag(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/C.BufferFlags flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Adds the `flag` to this buffer's flags.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#clearFlag(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/C.BufferFlags flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Removes the `flag` from this buffer's flags, if it is set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#getFlag(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/C.BufferFlags flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Returns whether the specified flag has been set on this buffer.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#hasSupplementalData()()`

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/C#BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA()` flag is set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#isEndOfStream()()`

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/C#BUFFER_FLAG_END_OF_STREAM()` flag is set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#isFirstSample()()`

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/C#BUFFER_FLAG_FIRST_SAMPLE()` flag is set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#isKeyFrame()()`

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/C#BUFFER_FLAG_KEY_FRAME()` flag is set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#isLastSample()()`

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/C#BUFFER_FLAG_LAST_SAMPLE()` flag is set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#notDependedOn()()`

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/C#BUFFER_FLAG_NOT_DEPENDED_ON()` flag is set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#setFlags(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/C.BufferFlags flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Replaces this buffer's flags with `flags`.

## Constants

### BUFFER_REPLACEMENT_MODE_DIRECT

```
const val BUFFER_REPLACEMENT_MODE_DIRECT = 2: Int
```

Allows buffer replacement using `https://developer.android.com/reference/java/nio/ByteBuffer.html#allocateDirect(int)`.

### 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 `https://developer.android.com/reference/java/nio/ByteBuffer.html#allocate(int)`.

## Public constructors

### DecoderInputBuffer

```
DecoderInputBuffer(
    @DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: Int
)
```

Creates a new instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.BufferReplacementMode` replacement mode. |

### DecoderInputBuffer

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

Creates a new instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.BufferReplacementMode bufferReplacementMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.BufferReplacementMode` replacement mode. |
| `paddingSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | If non-zero, `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#ensureSpaceForWrite(int)` 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 `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#data()` is large enough to accommodate a write of a given length at its current position.

If the capacity of `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#data()` is sufficient this method does nothing. If the capacity is insufficient then an attempt is made to replace `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#data()` with a new `https://developer.android.com/reference/java/nio/ByteBuffer.html` whose capacity is sufficient. Data up to the current position is copied to the new buffer.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the write that must be accommodated, in bytes. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.InsufficientCapacityException` | If there is insufficient capacity to accommodate the write and `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#bufferReplacementMode()` is `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#BUFFER_REPLACEMENT_MODE_DISABLED()`. |

### flip

```
fun flip(): Unit
```

Flips `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#data()` and `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#supplementalData()` in preparation for being queued to a decoder.

| See also |
|---|---|
| `https://developer.android.com/reference/java/nio/Buffer.html#flip()` |   |

### isEncrypted

```
fun isEncrypted(): Boolean
```

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/C#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 `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#supplementalData()` and ensures that it's large enough to accommodate `
length` bytes.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the supplemental data that must be accommodated, in bytes. |

## Public properties

### cryptoInfo

```
val cryptoInfo: CryptoInfo!
```

`https://developer.android.com/reference/kotlin/androidx/media3/decoder/CryptoInfo` for encrypted data.

### data

```
val data: ByteBuffer?
```

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

### format

```
val format: Format?
```

The `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`.

### supplementalData

```
val supplementalData: ByteBuffer?
```

Supplemental data related to the buffer, if `https://developer.android.com/reference/kotlin/androidx/media3/decoder/Buffer#hasSupplementalData()` returns true. If present, the buffer is populated with supplemental data from position 0 to its limit.

### timeUs

```
val timeUs: Long
```

The time at which the sample should be presented.

### waitingForKeys

```
val waitingForKeys: 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.