# ParsableNalUnitBitArray

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

*** ** * ** ***

<br />

```
@UnstableApi
class ParsableNalUnitBitArray
```

<br />

*** ** * ** ***

Wraps a byte array, providing methods that allow it to be read as a NAL unit bitstream.

Whenever the byte sequence \[0, 0, 3\] appears in the wrapped byte array, it is treated as \[0, 0\] for all reading/skipping operations, which makes the bitstream appear to be unescaped.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#ParsableNalUnitBitArray(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)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#byteAlign()()` Skips bits until at a byte alignment; if already byte aligned, then simply returns. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#canReadBits(int)(numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns whether it's possible to read `n` bits starting from the current offset. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#canReadExpGolombCodedNum()()` Returns whether it is possible to read an Exp-Golomb-coded integer starting from the current offset. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#readBit()()` Reads a single bit. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#readBits(int)(numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Reads up to 32 bits. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#readSignedExpGolombCodedInt()()` Reads an signed Exp-Golomb-coded format integer. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#readUnsignedExpGolombCodedInt()()` Reads an unsigned Exp-Golomb-coded format integer. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#reset(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)` Resets the wrapped data, limit and offset. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#skipBit()()` Skips a single bit. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/ParsableNalUnitBitArray#skipBits(int)(numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Skips bits and moves current reading position forward. |

## Public constructors

### ParsableNalUnitBitArray

```
ParsableNalUnitBitArray(data: ByteArray<Byte>!, offset: Int, limit: Int)
```

| 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>!` | The data to wrap. |
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The byte offset in `data` to start reading from. |
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The byte offset of the end of the bitstream in `data`. |

## Public functions

### byteAlign

```
fun byteAlign(): Unit
```

Skips bits until at a byte alignment; if already byte aligned, then simply returns.

### canReadBits

```
fun canReadBits(numBits: Int): Boolean
```

Returns whether it's possible to read `n` bits starting from the current offset. The offset is not modified.

| Parameters |
|---|---|
| `numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bits. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether it is possible to read `n` bits. |

### canReadExpGolombCodedNum

```
fun canReadExpGolombCodedNum(): Boolean
```

Returns whether it is possible to read an Exp-Golomb-coded integer starting from the current offset. The offset is not modified.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether it is possible to read an Exp-Golomb-coded integer. |

### readBit

```
fun readBit(): Boolean
```

Reads a single bit.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the bit is set. |

### readBits

```
fun readBits(numBits: Int): Int
```

Reads up to 32 bits.

| Parameters |
|---|---|
| `numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bits to read. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | An integer whose bottom n bits hold the read data. |

### readSignedExpGolombCodedInt

```
fun readSignedExpGolombCodedInt(): Int
```

Reads an signed Exp-Golomb-coded format integer.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The value of the parsed Exp-Golomb-coded integer. |

### readUnsignedExpGolombCodedInt

```
fun readUnsignedExpGolombCodedInt(): Int
```

Reads an unsigned Exp-Golomb-coded format integer.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The value of the parsed Exp-Golomb-coded integer. |

### reset

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

Resets the wrapped data, limit and offset.

| 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>!` | The data to wrap. |
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The byte offset in `data` to start reading from. |
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The byte offset of the end of the bitstream in `data`. |

### skipBit

```
fun skipBit(): Unit
```

Skips a single bit.

### skipBits

```
fun skipBits(numBits: Int): Unit
```

Skips bits and moves current reading position forward.

| Parameters |
|---|---|
| `numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bits to skip. |