@UnstableApi
class DtsUtil


Utility methods for parsing DTS frames.

Summary

Nested types

@Documented
@Retention(value = SOURCE)
@Target(value = TYPE_USE)
@StringDef(value = [MimeTypes.AUDIO_DTS, MimeTypes.AUDIO_DTS_EXPRESS, MimeTypes.AUDIO_DTS_X])
annotation DtsUtil.DtsAudioMimeType

The possible MIME types for DTS that can be used.

Information parsed from a DTS frame header.

@Documented
@Retention(value = SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
annotation DtsUtil.FrameType

Frame types for a DTS stream.

Constants

const Int

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

const Int

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

const Int

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

const Int

Represents a DTS core frame.

const Int

Represents a DTS extension substream frame.

const Int

Represents a DTS UHD non-sync frame.

const Int

Represents a DTS UHD sync frame.

const Int

Represents a DTS frame for which type is unknown.

Public functions

java-static Int

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

java-static Int

Returns the FrameType if word is a DTS sync word, otherwise FRAME_TYPE_UNKNOWN.

java-static Int

Like parseDtsAudioSampleCount but reads from a ByteBuffer.

java-static Int

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

java-static Format!
parseDtsFormat(
    frame: ByteArray!,
    trackId: String?,
    language: String?,
    @C.RoleFlags roleFlags: Int,
    drmInitData: 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 DtsUtil.DtsHeader!

Parses the 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 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.

java-static DtsUtil.DtsHeader!
parseDtsUhdHeader(header: ByteArray!, uhdAudioChunkId: AtomicInteger!)

Parses the 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 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.

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!): Int

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

Parameters
data: ByteArray!

The frame to parse.

Returns
Int

The frame's size in bytes.

getFrameType

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

Returns the FrameType if word is a DTS sync word, otherwise FRAME_TYPE_UNKNOWN.

parseDtsAudioSampleCount

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

Like parseDtsAudioSampleCount but reads from a ByteBuffer. The buffer's position is not modified.

Parameters
buffer: ByteBuffer!

The ByteBuffer from which to read.

Returns
Int

The number of audio samples represented by the syncframe.

parseDtsAudioSampleCount

java-static fun parseDtsAudioSampleCount(data: ByteArray!): Int

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

Parameters
data: ByteArray!

The frame to parse.

Returns
Int

The number of audio samples represented by the frame.

parseDtsFormat

java-static fun parseDtsFormat(
    frame: ByteArray!,
    trackId: String?,
    language: String?,
    @C.RoleFlags roleFlags: Int,
    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: ByteArray!

The DTS Core frame to parse.

trackId: String?

The track identifier to set on the format.

language: String?

The language to set on the format.

@C.RoleFlags roleFlags: Int

The role flags to set on the format.

drmInitData: DrmInitData?

DrmInitData to be included in the format.

Returns
Format!

The DTS format parsed from data in the header.

parseDtsHdHeader

java-static fun parseDtsHdHeader(header: ByteArray!): DtsUtil.DtsHeader!

Parses the 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: ByteArray!

The DTS-HD extension substream header to parse.

Returns
DtsUtil.DtsHeader!

The DtsHeader data extracted from the header.

parseDtsHdHeaderSize

java-static fun parseDtsHdHeaderSize(headerPrefix: ByteArray!): 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: ByteArray!

A byte array containing at least the first 55 bits of a DTS-HD frame.

Returns
Int

Size of the DTS-HD frame header in bytes.

parseDtsUhdHeader

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

Parses the 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: ByteArray!

The DTS-UHD header to parse.

uhdAudioChunkId: AtomicInteger!

An AtomicInteger 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
DtsUtil.DtsHeader!

The DtsHeader data extracted from the header.

parseDtsUhdHeaderSize

java-static fun parseDtsUhdHeaderSize(headerPrefix: ByteArray!): 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: ByteArray!

A byte array containing at least the first 47 bits of a DTS-UHD frame.

Returns
Int

Size of the DTS-UHD frame header in bytes.