Stay organized with collections Save and categorize content based on your preferences.

AudioStats

@RequiresApi(value = 21)
@AutoValue
public 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

static final int

The recording is being recorded with audio data.

static final int

The recording of audio is disabled.

static final int

The recording is muted because the audio encoder encountered errors.

static final int

The recording is muted because the audio source encountered errors.

static final int

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

Public methods

abstract int

Returns the state of audio in the recording.

abstract @Nullable Throwable

Gets the error cause.

boolean

Indicates whether the recording is being recorded with audio.

boolean

Indicates whether an error occurred.

Constants

AUDIO_STATE_ACTIVE

public static final int AUDIO_STATE_ACTIVE = 0

The recording is being recorded with audio data.

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

AUDIO_STATE_DISABLED

public static final int AUDIO_STATE_DISABLED = 1

The recording of audio is disabled.

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

AUDIO_STATE_ENCODER_ERROR

public static final int AUDIO_STATE_ENCODER_ERROR = 3

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_SOURCE_ERROR

public static final int AUDIO_STATE_SOURCE_ERROR = 4

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

public static final int AUDIO_STATE_SOURCE_SILENCED = 2

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 methods

getAudioState

public abstract int getAudioState()

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

public abstract @Nullable Throwable getErrorCause()

Gets the error cause.

Returns null if hasError returns false.

hasAudio

public boolean hasAudio()

Indicates whether the recording is being recorded with audio.

hasError

public boolean hasError()

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.