@UnstableApi
class AacUtil


Utility methods for handling AAC audio streams.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
annotation AacUtil.AacAudioObjectType

Valid AAC Audio object types.

Holds sample format information for AAC audio.

Constants

const Int

Maximum rate for an AAC ELD audio stream, in bytes per second.

const Int

Number of raw audio samples that are produced per channel when decoding an AAC HE access unit.

const Int

Maximum rate for an AAC HE V1 audio stream, in bytes per second.

const Int

Maximum rate for an AAC HE V2 audio stream, in bytes per second.

const Int

Number of raw audio samples that are produced per channel when decoding an AAC LC access unit.

const Int

Maximum rate for an AAC LC audio stream, in bytes per second.

const Int

Number of raw audio samples that are produced per channel when decoding an AAC LD access unit.

const Int

Number of raw audio samples that are produced per channel when decoding an AAC XHE access unit.

const Int

Maximum rate for an AAC XHE audio stream, in bytes per second.

const Int
const Int
const Int
const Int
const Int
const Int

Public functions

java-static ByteArray<Byte>!
buildAacLcAudioSpecificConfig(sampleRate: Int, channelCount: Int)

Builds a simple AAC LC AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1

java-static ByteArray<Byte>!
buildAudioSpecificConfig(
    audioObjectType: Int,
    sampleRateIndex: Int,
    channelConfig: Int
)

Builds a simple AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1

java-static AacUtil.Config!
parseAudioSpecificConfig(audioSpecificConfig: ByteArray!)

Parses an AAC AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1

java-static AacUtil.Config!
parseAudioSpecificConfig(
    bitArray: ParsableBitArray!,
    forceReadToEnd: Boolean
)

Parses an AAC AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1

Constants

AAC_ELD_MAX_RATE_BYTES_PER_SECOND

const val AAC_ELD_MAX_RATE_BYTES_PER_SECOND = 8000: Int

Maximum rate for an AAC ELD audio stream, in bytes per second.

Fraunhofer documentation shows AAC-ELD as useful for up to ~ 64 kbit/s so we use this value.

AAC_HE_AUDIO_SAMPLE_COUNT

const val AAC_HE_AUDIO_SAMPLE_COUNT = 2048: Int

Number of raw audio samples that are produced per channel when decoding an AAC HE access unit.

AAC_HE_V1_MAX_RATE_BYTES_PER_SECOND

const val AAC_HE_V1_MAX_RATE_BYTES_PER_SECOND = 16000: Int

Maximum rate for an AAC HE V1 audio stream, in bytes per second.

AAC_HE_V2_MAX_RATE_BYTES_PER_SECOND

const val AAC_HE_V2_MAX_RATE_BYTES_PER_SECOND = 7000: Int

Maximum rate for an AAC HE V2 audio stream, in bytes per second.

AAC_LC_AUDIO_SAMPLE_COUNT

const val AAC_LC_AUDIO_SAMPLE_COUNT = 1024: Int

Number of raw audio samples that are produced per channel when decoding an AAC LC access unit.

AAC_LC_MAX_RATE_BYTES_PER_SECOND

const val AAC_LC_MAX_RATE_BYTES_PER_SECOND = 100000: Int

Maximum rate for an AAC LC audio stream, in bytes per second.

AAC_LD_AUDIO_SAMPLE_COUNT

const val AAC_LD_AUDIO_SAMPLE_COUNT = 512: Int

Number of raw audio samples that are produced per channel when decoding an AAC LD access unit.

AAC_XHE_AUDIO_SAMPLE_COUNT

const val AAC_XHE_AUDIO_SAMPLE_COUNT = 1024: Int

Number of raw audio samples that are produced per channel when decoding an AAC XHE access unit.

AAC_XHE_MAX_RATE_BYTES_PER_SECOND

const val AAC_XHE_MAX_RATE_BYTES_PER_SECOND = 256000: Int

Maximum rate for an AAC XHE audio stream, in bytes per second.

Fraunhofer documentation says "500 kbit/s and above" for stereo, so we use a rate generously above the 500 kbit/s level.

AUDIO_OBJECT_TYPE_AAC_ELD

const val AUDIO_OBJECT_TYPE_AAC_ELD = 23: Int

AUDIO_OBJECT_TYPE_AAC_ER_BSAC

const val AUDIO_OBJECT_TYPE_AAC_ER_BSAC = 22: Int

AUDIO_OBJECT_TYPE_AAC_LC

const val AUDIO_OBJECT_TYPE_AAC_LC = 2: Int

AUDIO_OBJECT_TYPE_AAC_PS

const val AUDIO_OBJECT_TYPE_AAC_PS = 29: Int

AUDIO_OBJECT_TYPE_AAC_SBR

const val AUDIO_OBJECT_TYPE_AAC_SBR = 5: Int

AUDIO_OBJECT_TYPE_AAC_XHE

const val AUDIO_OBJECT_TYPE_AAC_XHE = 42: Int

Public functions

buildAacLcAudioSpecificConfig

java-static fun buildAacLcAudioSpecificConfig(sampleRate: Int, channelCount: Int): ByteArray<Byte>!

Builds a simple AAC LC AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1

Parameters
sampleRate: Int

The sample rate in Hz.

channelCount: Int

The channel count.

Returns
ByteArray<Byte>!

The AudioSpecificConfig.

buildAudioSpecificConfig

java-static fun buildAudioSpecificConfig(
    audioObjectType: Int,
    sampleRateIndex: Int,
    channelConfig: Int
): ByteArray<Byte>!

Builds a simple AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1

Parameters
audioObjectType: Int

The audio object type.

sampleRateIndex: Int

The sample rate index.

channelConfig: Int

The channel configuration.

Returns
ByteArray<Byte>!

The AudioSpecificConfig.

parseAudioSpecificConfig

java-static fun parseAudioSpecificConfig(audioSpecificConfig: ByteArray!): AacUtil.Config!

Parses an AAC AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1

Parameters
audioSpecificConfig: ByteArray!

A byte array containing the AudioSpecificConfig to parse.

Returns
AacUtil.Config!

The parsed configuration.

Throws
androidx.media3.common.ParserException

If the AudioSpecificConfig cannot be parsed because it is invalid or unsupported.

parseAudioSpecificConfig

java-static fun parseAudioSpecificConfig(
    bitArray: ParsableBitArray!,
    forceReadToEnd: Boolean
): AacUtil.Config!

Parses an AAC AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1

Parameters
bitArray: ParsableBitArray!

A ParsableBitArray containing the AudioSpecificConfig to parse. The position is advanced to the end of the AudioSpecificConfig.

forceReadToEnd: Boolean

Whether the entire AudioSpecificConfig should be read. Required for knowing the length of the configuration payload.

Returns
AacUtil.Config!

The parsed configuration.

Throws
androidx.media3.common.ParserException

If the AudioSpecificConfig cannot be parsed because it is invalid or unsupported.