Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acoustic echo / feedback with android tutorial app, when using speaker mode #73

Open
kiran-pn opened this issue Jan 2, 2020 · 3 comments

Comments

@kiran-pn
Copy link

kiran-pn commented Jan 2, 2020

Hello,

I am using the Android-sample app from here: https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-android

I added the following Audio-Manager related code when the socket is connected, to make the the sound come out from the device's speaker. Without that, the sound actually plays from the earpiece instead of the speaker:
audioManager.setSpeakerphoneOn(true); audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);

So, when using the app with 2 mobile devices, we observe that there is a lot of echo. See below scenario:
• Person A & Person B joined the session.
• Person A says "Hello!"
• Person B hears 'Hello' on his device speaker, & this again gets transmitted back to Person A & he also hears his 'Hello' back as an echo.

Needless to say, this doesn't provide a very good experience when conversing.

We found that the issue isn't present when using other apps based on WebRTC on the same set of devices, so this isn't a hardware issue.

I tried to use the following in the code, but it didn't help either:
WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true); WebRtcAudioUtils.setWebRtcBasedNoiseSuppressor(true);

@pabloFuente / @CSantosM : Is there any way to minimize/eliminate this somehow? Either via server-side config changes or from the app-side?
Also, is there a plan to update the Android-tutorial app to use the 'Unified Plan' from WebRTC? (See: https://webrtc.org/web-apis/chrome/unified-plan/ )

@tibinvpaul
Copy link

Hey, @pabloFuente - could you help with this, please?

@jaswant0605
Copy link

jaswant0605 commented Oct 27, 2020

You can fix this by disabling the hardware based AEC and Noise Suppressor.

Took me a while to figure this out but

WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true); 
WebRtcAudioUtils.setWebRtcBasedNoiseSuppressor(true);

Didn't worked for me. Instead I fixed it by setting audio device module parameter in Session.java. this will surely fix your issue.

Also please make sure both the devices aren't near each other, else there will be a lot of echo!.

AudioDeviceModule adm = createAudioDeviceModule();

 peerConnectionFactory = PeerConnectionFactory.builder()

                .setVideoEncoderFactory(encoderFactory)

                .setVideoDecoderFactory(decoderFactory)

                .setAudioDeviceModule(adm)

                .setOptions(options)

                .createPeerConnectionFactory();
 private AudioDeviceModule createAudioDeviceModule() {

        return builder(activity)

                .setAudioSource(MediaRecorder.AudioSource.MIC)

                .setUseHardwareAcousticEchoCanceler(false)

                .setUseHardwareNoiseSuppressor(false)

                // .setInputSampleRate(16000)

                .createAudioDeviceModule();

    }

@Caerbannog
Copy link

Hi,

I'm not using OpenVidu, but for your information, some other projects decided to call setWebRtcBasedAcousticEchoCanceler(false) on specific phone models.
See: signalapp/Signal-Android#7635

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants