AudioStats

@RequiresApi(value = 21)
@AutoValue
abstract class AudioStats


The audio information about an Recording at a point in time.

The audio information will be contained in every RecordingStats.

Summary

Constants

const Double

Should audio recording be disabled, any attempts to retrieve the amplitude will return this value.

const Int

The recording is being recorded with audio data.

const Int

The recording of audio is disabled.

const Int

The recording is muted because the audio encoder encountered errors.

const Int

The recording is muted by mute.

const Int

The recording is muted because the audio source encountered errors.

const Int

The recording is muted because the audio source is silenced by the system.

Public functions

Double

Returns the maximum absolute amplitude of the audio most recently sampled in the past 2 nanoseconds

abstract Int

Returns the state of audio in the recording.

abstract Throwable?

Gets the error cause.

Boolean

Indicates whether the recording is being recorded with audio.

Boolean

Indicates whether an error occurred.

Constants

AUDIO_AMPLITUDE_NONE

Added in 1.4.0-alpha04
const val AUDIO_AMPLITUDE_NONE = 0.0: Double

Should audio recording be disabled, any attempts to retrieve the amplitude will return this value.

AUDIO_STATE_ACTIVE

Added in 1.1.0
const val AUDIO_STATE_ACTIVE = 0: Int

The recording is being recorded with audio data.

When audio is active, the recorded video file will contain audio data.

AUDIO_STATE_DISABLED

Added in 1.1.0
const val AUDIO_STATE_DISABLED = 1: Int

The recording of audio is disabled.

This audio state results from a PendingRecording that was started without calling withAudioEnabled.

AUDIO_STATE_ENCODER_ERROR

Added in 1.1.0
const val AUDIO_STATE_ENCODER_ERROR = 3: Int

The recording is muted because the audio encoder encountered errors.

If the audio source encounters errors during recording, audio stats generated after the error will contain this audio state, and the recording will proceed without audio.

Use getErrorCause to get the error cause.

AUDIO_STATE_MUTED

Added in 1.3.0
const val AUDIO_STATE_MUTED = 5: Int

The recording is muted by mute.

AUDIO_STATE_SOURCE_ERROR

Added in 1.3.0
const val AUDIO_STATE_SOURCE_ERROR = 4: Int

The recording is muted because the audio source encountered errors.

If the audio source encounters errors during recording, audio stats generated after the error will contain this audio state, and the recording will proceed without audio.

Use getErrorCause to get the error cause.

AUDIO_STATE_SOURCE_SILENCED

Added in 1.1.0
const val AUDIO_STATE_SOURCE_SILENCED = 2: Int

The recording is muted because the audio source is silenced by the system.

If the audio source is occupied by a privilege application, such as the dialer, depending on the system version, the system may silence the application that are using the audio source. Use getErrorCause to get the error cause.

Public functions

getAudioAmplitude

Added in 1.4.0-alpha04
fun getAudioAmplitude(): Double

Returns the maximum absolute amplitude of the audio most recently sampled in the past 2 nanoseconds

The amplitude is the maximum absolute value over all channels which the audio was most recently sampled from.

Amplitude is a relative measure of the maximum sound pressure/voltage range of the device microphone.

Returns AUDIO_AMPLITUDE_NONE if audio is disabled.

The amplitude value returned will be a double between 0 and 1.

getAudioState

Added in 1.1.0
abstract fun getAudioState(): Int

Returns the state of audio in the recording.

The audio state describes whether audio is enabled for the recording and if audio is currently recording or is silenced due to system priority or errors.

Returns
Int

The state of the audio at the time of these audio stats being generated. One of AUDIO_STATE_ACTIVE, AUDIO_STATE_DISABLED, AUDIO_STATE_SOURCE_SILENCED, or AUDIO_STATE_ENCODER_ERROR.

getErrorCause

Added in 1.1.0
abstract fun getErrorCause(): Throwable?

Gets the error cause.

Returns null if hasError returns false.

hasAudio

Added in 1.1.0
fun hasAudio(): Boolean

Indicates whether the recording is being recorded with audio.

hasError

Added in 1.1.0
fun hasError(): Boolean

Indicates whether an error occurred.

Returns true if the audio is muted due to unexpected error like audio source is occupied or audio encoder encountered errors, otherwise false.