# NalUnitTargetBuffer

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

*** ** * ** ***

<br />

```
@UnstableApi
class NalUnitTargetBuffer
```

<br />

*** ** * ** ***

A buffer that fills itself with data corresponding to a specific NAL unit, as it is encountered in the stream.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ts/NalUnitTargetBuffer#NalUnitTargetBuffer(int,int)(targetType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, initialCapacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates the buffer. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ts/NalUnitTargetBuffer#appendToNalUnit(byte[],int,int)(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Called to pass stream data. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ts/NalUnitTargetBuffer#endNalUnit(int)(discardPadding: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Called to indicate that a NAL unit has ended. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ts/NalUnitTargetBuffer#reset()()` Resets the buffer, clearing any data that it holds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ts/NalUnitTargetBuffer#startNalUnit(int)(type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Called to indicate that a NAL unit has started. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ts/NalUnitTargetBuffer#isCompleted()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ts/NalUnitTargetBuffer#nalData()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ts/NalUnitTargetBuffer#nalLength()` |

## Public constructors

### NalUnitTargetBuffer

```
NalUnitTargetBuffer(targetType: Int, initialCapacity: Int)
```

Creates the buffer.

| Parameters |
|---|---|
| `targetType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The type of the NAL unit. |
| `initialCapacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The initial capacity of the buffer in bytes. |

## Public functions

### appendToNalUnit

```
fun appendToNalUnit(data: ByteArray<Byte>!, offset: Int, limit: Int): Unit
```

Called to pass stream data. The data passed should not include the 3 byte start code.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | Holds the data being passed. |
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The offset of the data in `data`. |
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit (exclusive) of the data in `data`. |

### endNalUnit

```
fun endNalUnit(discardPadding: Int): Boolean
```

Called to indicate that a NAL unit has ended.

| Parameters |
|---|---|
| `discardPadding: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of excess bytes that were passed to `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ts/NalUnitTargetBuffer#appendToNalUnit(byte[],int,int)`, which should be discarded. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the ended NAL unit is of the target type. |

### reset

```
fun reset(): Unit
```

Resets the buffer, clearing any data that it holds.

### startNalUnit

```
fun startNalUnit(type: Int): Unit
```

Called to indicate that a NAL unit has started.

| Parameters |
|---|---|
| `type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The type of the NAL unit. |

## Public properties

### isCompleted

```
val isCompleted: Boolean
```

### nalData

```
val nalData: Array<Byte>!
```

### nalLength

```
val nalLength: Int
```