Package com.twilio.voice
Class DefaultAudioDevice
java.lang.Object
com.twilio.voice.DefaultAudioDevice
- All Implemented Interfaces:
AudioDevice,AudioDeviceCapturer,AudioDeviceRenderer
DefaultAudioDevice is the default audio device module SDK uses when a custom one is not provided.
By default, the Voice SDK uses `DefaultAudioDevice` to capture and render audio. The SDK performs acoustic echo cancellation (AEC) and noise suppression (NS) using device hardware by default. Using device hardware is more efficient, but some devices do not implement these audio effects well. `DefaultAudioDevice` provides API `setUseHardwareAcousticEchoCanceler(...)` or `setUseHardwareNoiseSuppressor(...)` to toggle the default behavior. If you are experiencing echo or background noise on certain devices reference the following snippet for enabling software implementations of AEC and NS anytime before invoking `Voice.connect(...)` or `CallInvite.accept(...)`.
// Use software AEC DefaultAudioDevice defaultAudioDevice=new DefaultAudioDevice(); defaultAudioDevice.setUseHardwareAcousticEchoCanceler(false); Voice.setAudioDevice(defaultAudioDevice); // Use software NS DefaultAudioDevice defaultAudioDevice=new DefaultAudioDevice(); defaultAudioDevice.setUseHardwareNoiseSuppressor(false); Voice.setAudioDevice(defaultAudioDevice);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method is a no-op that returnsnull.This method is a no-op that returnsnull.booleanThis method is a no-op that returnsfalse.booleanThis method is a no-op that returnsfalse.booleanonStartCapturing(AudioDeviceContext audioDeviceContext) This method is a no-op that returnsfalse.booleanonStartRendering(AudioDeviceContext audioDeviceContext) This method is a no-op that returnsfalse.booleanThis method is a no-op that returnsfalse.booleanThis method is a no-op that returnsfalse.voidsetUseHardwareAcousticEchoCanceler(boolean useHardwareAcousticEchoCanceler) Control if the built-in hardware AEC should be used or not.voidsetUseHardwareNoiseSuppressor(boolean useHardwareNoiseSuppressor) Control if the built-in hardware noise suppressor should be used or not.booleanIndicates if the built-in hardware AEC is used or not.booleanIndicates if the built-in hardware noise suppressor is used or not.
-
Constructor Details
-
DefaultAudioDevice
public DefaultAudioDevice()
-
-
Method Details
-
setUseHardwareAcousticEchoCanceler
public void setUseHardwareAcousticEchoCanceler(boolean useHardwareAcousticEchoCanceler) Control if the built-in hardware AEC should be used or not. The default value istrue.- Parameters:
useHardwareAcousticEchoCanceler- true if audio device should use hardware AEC, false otherwise
-
setUseHardwareNoiseSuppressor
public void setUseHardwareNoiseSuppressor(boolean useHardwareNoiseSuppressor) Control if the built-in hardware noise suppressor should be used or not. The default value istrue.- Parameters:
useHardwareNoiseSuppressor- true if audio device should use hardware noise suppressor, false otherwise.
-
useHardwareAcousticEchoCanceler
public boolean useHardwareAcousticEchoCanceler()Indicates if the built-in hardware AEC is used or not. The default value istrue.- Returns:
- true if the built-in hardware AEC is used.
-
useHardwareNoiseSuppressor
public boolean useHardwareNoiseSuppressor()Indicates if the built-in hardware noise suppressor is used or not. The default value istrue.- Returns:
- true if the built-in hardware noise suppressor is used.
-
getCapturerFormat
This method is a no-op that returnsnull.- Specified by:
getCapturerFormatin interfaceAudioDeviceCapturer- Returns:
AudioFormat
-
onInitCapturer
public boolean onInitCapturer()This method is a no-op that returnsfalse.- Specified by:
onInitCapturerin interfaceAudioDeviceCapturer- Returns:
- A boolean value to indicate if initialization was successful.
-
onStartCapturing
This method is a no-op that returnsfalse.- Specified by:
onStartCapturingin interfaceAudioDeviceCapturer- Returns:
- A boolean value that indicates if capturing has started or not.
-
onStopCapturing
public boolean onStopCapturing()This method is a no-op that returnsfalse.- Specified by:
onStopCapturingin interfaceAudioDeviceCapturer- Returns:
- A boolean value that indicates if capturing has stopped or not.
-
getRendererFormat
This method is a no-op that returnsnull.- Specified by:
getRendererFormatin interfaceAudioDeviceRenderer- Returns:
AudioFormat
-
onInitRenderer
public boolean onInitRenderer()This method is a no-op that returnsfalse.- Specified by:
onInitRendererin interfaceAudioDeviceRenderer- Returns:
- A boolean value to indicate if initialization was successful.
-
onStartRendering
This method is a no-op that returnsfalse.- Specified by:
onStartRenderingin interfaceAudioDeviceRenderer- Returns:
- A boolean value that indicates if rendering has started or not.
-
onStopRendering
public boolean onStopRendering()This method is a no-op that returnsfalse.- Specified by:
onStopRenderingin interfaceAudioDeviceRenderer- Returns:
- A boolean value that indicates if rendering has stopped or not.
-