# Buffer

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/Buffer.java+class:androidx.media3.decoder.Buffer)

*** ** * ** ***


```
@UnstableApi
public abstract class Buffer
```

<br />

Known direct subclasses [DecoderInputBuffer](https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer), [DecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer)

|---|---|
| `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer` | Holds input for a decoder. |
| `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer` | Output buffer decoded by a `https://developer.android.com/reference/androidx/media3/decoder/Decoder`. |

Known indirect subclasses [ImageOutputBuffer](https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageOutputBuffer), [MetadataInputBuffer](https://developer.android.com/reference/androidx/media3/extractor/metadata/MetadataInputBuffer), [SimpleDecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoderOutputBuffer), [SubtitleInputBuffer](https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleInputBuffer), [SubtitleOutputBuffer](https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer), [VideoDecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageOutputBuffer` | Output buffer for `https://developer.android.com/reference/androidx/media3/exoplayer/image/ImageDecoder` instances. |
| `https://developer.android.com/reference/androidx/media3/extractor/metadata/MetadataInputBuffer` | A `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer` for a `https://developer.android.com/reference/androidx/media3/extractor/metadata/MetadataDecoder`. |
| `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoderOutputBuffer` | Buffer for `https://developer.android.com/reference/androidx/media3/decoder/SimpleDecoder` output. |
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleInputBuffer` | A `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer` for a `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleDecoder`. |
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer` | Base class for `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleDecoder` output buffers. |
| `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer` | Video decoder output buffer containing video frame data. |

*** ** * ** ***

Base class for buffers with flags.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/decoder/Buffer#Buffer()()` |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/media3/decoder/Buffer#addFlag(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag)` Adds the `flag` to this buffer's flags. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/media3/decoder/Buffer#clear()()` Clears the buffer. |
| `final void` | `https://developer.android.com/reference/androidx/media3/decoder/Buffer#clearFlag(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag)` Removes the `flag` from this buffer's flags, if it is set. |
| `final boolean` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/decoder/Buffer#hasSupplementalData()()` Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA()` flag is set. |
| `final boolean` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/decoder/Buffer#isEndOfStream()()` Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_END_OF_STREAM()` flag is set. |
| `final boolean` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/decoder/Buffer#isFirstSample()()` Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_FIRST_SAMPLE()` flag is set. |
| `final boolean` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/decoder/Buffer#isKeyFrame()()` Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_KEY_FRAME()` flag is set. |
| `final boolean` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/decoder/Buffer#isLastSample()()` Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_LAST_SAMPLE()` flag is set. |
| `final boolean` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/decoder/Buffer#notDependedOn()()` Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_NOT_DEPENDED_ON()` flag is set. |
| `final void` | `https://developer.android.com/reference/androidx/media3/decoder/Buffer#setFlags(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flags)` Replaces this buffer's flags with `flags`. |

| ### Protected methods |
|---|---|
| `final boolean` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/decoder/Buffer#getFlag(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag)` Returns whether the specified flag has been set on this buffer. |

## Public constructors

### Buffer

```
public Buffer()
```

## Public methods

### addFlag

```
public final void addFlag(@C.BufferFlags int flag)
```

Adds the `flag` to this buffer's flags.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag` | The flag to add to this buffer's flags, which should be one of the ` C.BUFFER_FLAG_*` constants. |

### clear

```
@CallSuper
public void clear()
```

Clears the buffer.

### clearFlag

```
public final void clearFlag(@C.BufferFlags int flag)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag` | The flag to remove. |

### hasSupplementalData

```
@Pure
public final boolean hasSupplementalData()
```

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA()` flag is set.

### isEndOfStream

```
@Pure
public final boolean isEndOfStream()
```

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_END_OF_STREAM()` flag is set.

If this is set, all other attributes of the buffer should be ignored.

### isFirstSample

```
@Pure
public final boolean isFirstSample()
```

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_FIRST_SAMPLE()` flag is set.

### isKeyFrame

```
@Pure
public final boolean isKeyFrame()
```

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_KEY_FRAME()` flag is set.

### isLastSample

```
@Pure
public final boolean isLastSample()
```

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_LAST_SAMPLE()` flag is set.

### notDependedOn

```
@Pure
public final boolean notDependedOn()
```

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_NOT_DEPENDED_ON()` flag is set.

### setFlags

```
public final void setFlags(@C.BufferFlags int flags)
```

Replaces this buffer's flags with `flags`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flags` | The flags to set, which should be a combination of the `C.BUFFER_FLAG_*` constants. |

## Protected methods

### getFlag

```
@Pure
protected final boolean getFlag(@C.BufferFlags int flag)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag` | The flag to check. |

| Returns |
|---|---|
| `boolean` | Whether the flag is set. |