AudioStats

public abstract class AudioStats
extends Object

java.lang.Object
   ↳ androidx.camera.video.AudioStats


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

The audio information will be contained in every RecordingStats.

Summary

Constants

int AUDIO_STATE_ACTIVE

The recording is being recorded with audio data.

int AUDIO_STATE_DISABLED

The recording of audio is disabled.

int AUDIO_STATE_ENCODER_ERROR

The recording is muted because the audio encoder encountered errors.

int AUDIO_STATE_SOURCE_SILENCED

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

Public methods

abstract int getAudioState()

Returns the state of audio in the recording.

abstract Throwable getErrorCause()

Gets the error cause.

boolean hasAudio()

Indicates whether the recording is being recorded with audio.

boolean hasError()

Indicates whether an error occurred.

Inherited methods

Constants

AUDIO_STATE_ACTIVE

public static final int AUDIO_STATE_ACTIVE

The recording is being recorded with audio data.

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

Constant Value: 0 (0x00000000)

AUDIO_STATE_DISABLED

public static final int AUDIO_STATE_DISABLED

The recording of audio is disabled.

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

Constant Value: 1 (0x00000001)

AUDIO_STATE_ENCODER_ERROR

public static final int AUDIO_STATE_ENCODER_ERROR

The recording is muted because the audio encoder encountered errors.

When the audio encoder encountered errors, the recording will keep being recorded without audio for the rest of the recording. The audio stats generated after the audio encoder failed will contain this audio state.

Use getErrorCause() to get the error cause.

Constant Value: 3 (0x00000003)

AUDIO_STATE_SOURCE_SILENCED

public static final int AUDIO_STATE_SOURCE_SILENCED

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.

Constant Value: 2 (0x00000002)

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 Throwable getErrorCause ()

Gets the error cause.

Returns null if hasError() returns false.

Returns
Throwable

hasAudio

public boolean hasAudio ()

Indicates whether the recording is being recorded with audio.

Returns
boolean

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.

Returns
boolean