# DtsUtil

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

*** ** * ** ***

<br />

```
@UnstableApi
class DtsUtil
```

<br />

*** ** * ** ***

Utility methods for parsing DTS frames.

## 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/StringDef(value = [https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes.AUDIO_DTS, https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes.AUDIO_DTS_EXPRESS, https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes.AUDIO_DTS_HD, https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes.AUDIO_DTS_UHD_P2]) annotation https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsAudioMimeType` The possible MIME types for DTS that can be used. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader` Information parsed from a DTS frame header. |
| `@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/extractor/DtsUtil.FrameType` Frame types for a DTS stream. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND() = 768000` Maximum bit-rate for a DTS Express audio stream, in bits per second. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#DTS_HD_MAX_RATE_BYTES_PER_SECOND() = 2250000` Maximum rate for a DTS-HD audio stream, in bytes per second. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#DTS_MAX_RATE_BYTES_PER_SECOND() = 192000` Maximum rate for a DTS audio stream, in bytes per second. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#FRAME_TYPE_CORE() = 1` Represents a DTS core frame. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#FRAME_TYPE_EXTENSION_SUBSTREAM() = 2` Represents a DTS extension substream frame. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#FRAME_TYPE_UHD_NON_SYNC() = 4` Represents a DTS UHD non-sync frame. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#FRAME_TYPE_UHD_SYNC() = 3` Represents a DTS UHD sync frame. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#FRAME_TYPE_UNKNOWN() = 0` Represents a DTS frame for which type is unknown. |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#getDtsFrameSize(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Returns the size in bytes of the given DTS Core frame. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.FrameType https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#getFrameType(int)(word: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.FrameType` if `word` is a DTS sync word, otherwise `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#FRAME_TYPE_UNKNOWN()`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#isDtsBaseAudioMimeType(java.lang.String)(mimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Returns whether `mimeType` is `https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes#AUDIO_DTS()` or `https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes#AUDIO_DTS_HD()`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#parseDtsAudioSampleCount(java.nio.ByteBuffer)(buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!)` Like `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#parseDtsAudioSampleCount(byte[])` but reads from a `https://developer.android.com/reference/java/nio/ByteBuffer.html`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#parseDtsAudioSampleCount(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Returns the number of audio samples represented by the given DTS Core frame. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#parseDtsFormat(byte[],java.lang.String,java.lang.String,int,java.lang.String,androidx.media3.common.DrmInitData)( frame: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, trackId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, language: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, @https://developer.android.com/reference/kotlin/androidx/media3/common/C.RoleFlags roleFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, containerMimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, drmInitData: https://developer.android.com/reference/kotlin/androidx/media3/common/DrmInitData? )` Returns the DTS format given `data` containing the DTS Core frame according to ETSI TS 102 114 V1.6.1 (2019-08) subsections 5.3/5.4. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#parseDtsHdHeader(byte[])(header: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Parses the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader` data from the extension substream header of a DTS-HD frame according to ETSI TS 102 114 V1.6.1 (2019-08), Section 7.5.2. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#parseDtsHdHeaderSize(byte[])(headerPrefix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Returns the size of the extension substream header in a DTS-HD frame according to ETSI TS 102 114 V1.6.1 (2019-08), Section 7.5.2. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#parseDtsUhdHeader(byte[],java.util.concurrent.atomic.AtomicInteger)( header: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, uhdAudioChunkId: https://developer.android.com/reference/java/util/concurrent/atomic/AtomicInteger.html! )` Parses the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader` data from the headers of a DTS-UHD(Profile 2) frame according to ETSI TS 103 491 V1.2.1 (2019-05), Section 6.4.3. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#parseDtsUhdHeaderSize(byte[])(headerPrefix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Returns the size of frame header in a DTS-UHD(Profile 2) frame according to ETSI TS 103 491 V1.2.1 (2019-05), Section 6.4.3. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#updateFormatWithDtsHdInfo(androidx.media3.extractor.ExtractorInput,int,androidx.media3.common.Format)( input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!, sampleSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format! )` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` with an adjusted MIME type if the sample data at the current `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput` is a DTS-HD sample with static fields, or the unmodified `format` if it is not. |

## Constants

### DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND

```
const val DTS_EXPRESS_MAX_RATE_BITS_PER_SECOND = 768000: Int
```

Maximum bit-rate for a DTS Express audio stream, in bits per second.

### DTS_HD_MAX_RATE_BYTES_PER_SECOND

```
const val DTS_HD_MAX_RATE_BYTES_PER_SECOND = 2250000: Int
```

Maximum rate for a DTS-HD audio stream, in bytes per second.

### DTS_MAX_RATE_BYTES_PER_SECOND

```
const val DTS_MAX_RATE_BYTES_PER_SECOND = 192000: Int
```

Maximum rate for a DTS audio stream, in bytes per second.

DTS allows an 'open' bitrate, but we assume the maximum listed value: 1536 kbit/s.

### FRAME_TYPE_CORE

```
const val FRAME_TYPE_CORE = 1: Int
```

Represents a DTS core frame.

### FRAME_TYPE_EXTENSION_SUBSTREAM

```
const val FRAME_TYPE_EXTENSION_SUBSTREAM = 2: Int
```

Represents a DTS extension substream frame.

### FRAME_TYPE_UHD_NON_SYNC

```
const val FRAME_TYPE_UHD_NON_SYNC = 4: Int
```

Represents a DTS UHD non-sync frame.

### FRAME_TYPE_UHD_SYNC

```
const val FRAME_TYPE_UHD_SYNC = 3: Int
```

Represents a DTS UHD sync frame.

### FRAME_TYPE_UNKNOWN

```
const val FRAME_TYPE_UNKNOWN = 0: Int
```

Represents a DTS frame for which type is unknown.

## Public functions

### getDtsFrameSize

```
java-static fun getDtsFrameSize(data: ByteArray<Byte>!): Int
```

Returns the size in bytes of the given DTS Core frame.

| 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 frame to parse. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The frame's size in bytes. |

### getFrameType

```
@DtsUtil.FrameType
java-static fun getFrameType(word: Int): Int
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.FrameType` if `word` is a DTS sync word, otherwise `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#FRAME_TYPE_UNKNOWN()`.

### isDtsBaseAudioMimeType

```
java-static fun isDtsBaseAudioMimeType(mimeType: String?): Boolean
```

Returns whether `mimeType` is `https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes#AUDIO_DTS()` or `https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes#AUDIO_DTS_HD()`.

### parseDtsAudioSampleCount

```
java-static fun parseDtsAudioSampleCount(buffer: ByteBuffer!): Int
```

Like `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil#parseDtsAudioSampleCount(byte[])` but reads from a `https://developer.android.com/reference/java/nio/ByteBuffer.html`. The buffer's position is not modified.

| Parameters |
|---|---|
| `buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!` | The `https://developer.android.com/reference/java/nio/ByteBuffer.html` from which to read. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of audio samples represented by the syncframe. |

### parseDtsAudioSampleCount

```
java-static fun parseDtsAudioSampleCount(data: ByteArray<Byte>!): Int
```

Returns the number of audio samples represented by the given DTS Core frame.

| 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 frame to parse. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of audio samples represented by the frame. |

### parseDtsFormat

```
java-static fun parseDtsFormat(
    frame: ByteArray<Byte>!,
    trackId: String?,
    language: String?,
    @C.RoleFlags roleFlags: Int,
    containerMimeType: String!,
    drmInitData: DrmInitData?
): Format!
```

Returns the DTS format given `data` containing the DTS Core frame according to ETSI TS 102 114 V1.6.1 (2019-08) subsections 5.3/5.4.

| Parameters |
|---|---|
| `frame: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The DTS Core frame to parse. |
| `trackId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The track identifier to set on the format. |
| `language: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The language to set on the format. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.RoleFlags roleFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The role flags to set on the format. |
| `containerMimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The MIME type of the container to set on the format. |
| `drmInitData: https://developer.android.com/reference/kotlin/androidx/media3/common/DrmInitData?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/DrmInitData` to be included in the format. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The DTS format parsed from data in the header. |

### parseDtsHdHeader

```
java-static fun parseDtsHdHeader(header: ByteArray<Byte>!): DtsUtil.DtsHeader!
```

Parses the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader` data from the extension substream header of a DTS-HD frame according to ETSI TS 102 114 V1.6.1 (2019-08), Section 7.5.2.

| Parameters |
|---|---|
| `header: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The DTS-HD extension substream header to parse. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader!` | The `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader` data extracted from the header. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/ParserException` |   |

### parseDtsHdHeaderSize

```
java-static fun parseDtsHdHeaderSize(headerPrefix: ByteArray<Byte>!): Int
```

Returns the size of the extension substream header in a DTS-HD frame according to ETSI TS 102 114 V1.6.1 (2019-08), Section 7.5.2.

| Parameters |
|---|---|
| `headerPrefix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | A byte array containing at least the first 55 bits of a DTS-HD frame. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Size of the DTS-HD frame header in bytes. |

### parseDtsUhdHeader

```
java-static fun parseDtsUhdHeader(
    header: ByteArray<Byte>!,
    uhdAudioChunkId: AtomicInteger!
): DtsUtil.DtsHeader!
```

Parses the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader` data from the headers of a DTS-UHD(Profile 2) frame according to ETSI TS 103 491 V1.2.1 (2019-05), Section 6.4.3.

| Parameters |
|---|---|
| `header: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The DTS-UHD header to parse. |
| `uhdAudioChunkId: https://developer.android.com/reference/java/util/concurrent/atomic/AtomicInteger.html!` | An `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicInteger.html` containing the last read UHD audio chunk ID from a synchronized frame, or zero if unset. This parameter is both an input and output parameter. In synchronized frames, the input value is not used; instead, the parameter is set to the current UHD audio chunk ID, which becomes the output value. For non-synchronized frames, it is used without any modification. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader!` | The `https://developer.android.com/reference/kotlin/androidx/media3/extractor/DtsUtil.DtsHeader` data extracted from the header. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/ParserException` |   |

### parseDtsUhdHeaderSize

```
java-static fun parseDtsUhdHeaderSize(headerPrefix: ByteArray<Byte>!): Int
```

Returns the size of frame header in a DTS-UHD(Profile 2) frame according to ETSI TS 103 491 V1.2.1 (2019-05), Section 6.4.3.

| Parameters |
|---|---|
| `headerPrefix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | A byte array containing at least the first 47 bits of a DTS-UHD frame. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Size of the DTS-UHD frame header in bytes. |

### updateFormatWithDtsHdInfo

```
java-static fun updateFormatWithDtsHdInfo(
    input: ExtractorInput!,
    sampleSize: Int,
    format: Format!
): Format!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` with an adjusted MIME type if the sample data at the current `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput` is a DTS-HD sample with static fields, or the unmodified `format` if it is not.

| Parameters |
|---|---|
| `input: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!` | The `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput` to read from. |
| `sampleSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The size of the sample data. |
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` to build upon. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The updated `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs reading from the input. |