WebRTC Android: sound from phone speaker is going into conference through phone mic and causing echo
Asked Answered
A

3

11

In some mobile devices(like Motorola One Power - Android 10, Redmi Note 5 Pro - Android 7.1.2), sound from the phone speaker is going into the conference through the phone mic and causes an echo. This echo issue is coming only when the Phone Speaker is in the ON state.

I have used MODE_IN_COMMUNICATION mode of AudioManager:

mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);

Also, used below audio constraints to create Audio Source by using createAudioSource() API of PeerConnectionFactory:

audioConstraints = new MediaConstraints();
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googEchoCancellation", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googAutoGainControl", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googHighpassFilter", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googNoiseSuppression", "true"));

Any help or guidance in resolving the issue will be well appreciated.

Alcoholicity answered 18/6, 2020 at 11:58 Comment(0)
A
5

Some phones can't do hardware echo cancellation, even though they advertise it's available. Redmi Note 5 is definitely one of them, take a look at https://github.com/signalapp/Signal-Android/blob/master/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java, search for HARDWARE_AEC_BLACKLIST. So, to enable WebRTC AEC, use below methods of JavaAudioDeviceModule.class

setUseHardwareAcousticEchoCanceler(false)       
setUseHardwareNoiseSuppressor(false) 

(For reference, please have a look into createJavaAudioDevice() of PeerConnectionClient.java - Checkout official android example on googlesource.com

Alcoholicity answered 24/6, 2020 at 13:25 Comment(0)
C
0

Android AudioManager it provides access to volume and ringer mode control.

First of all find out whether microphone is on or off using isMicrophoneMute() method.

the find out all the connected audio devices with the help getDevices() which will help to figure out which mic user want to mute

Once you detect targeted mic, Sets the microphone mute using setMicrophoneMute()

Caesura answered 29/6, 2020 at 6:21 Comment(0)
T
0
WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true)
WebRtcAudioUtils.setWebRtcBasedNoiseSuppressor(true)
Tmesis answered 3/8, 2023 at 7:45 Comment(1)
Answer needs supporting information Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Bellow

© 2022 - 2024 — McMap. All rights reserved.