ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.29k stars 633 forks source link

Sound echo on Conference call in Android SDK #3011

Open SelimEmre opened 3 years ago

SelimEmre commented 3 years ago

Short description

Sound echo issue not happening every time.

Ticket ID: 38631

Steps to reproduce

  1. Join the conference call with 3-4 users in Android SDK.
  2. Speak at a conference call
  3. Then that sound is repeating again in Loud speaker/phone speaker.

Expected behavior

It shouldn't be an echo.

Actual behavior

Echo happening.

thinkgopal commented 3 years ago

Hi @SelimEmre,

Have you found any resolution on this.

mekya commented 3 years ago

Can you try enabling echo cancellation? It's disabled by default.

this.getIntent().putExtra(EXTRA_AECDUMP_ENABLED, true);
Screen Shot 2021-03-01 at 12 37 04
thinkgopal commented 3 years ago

Hi @mekya Thank you for the reply. I will try this and get back if still facing same issue.

Thanks again.

thinkgopal commented 3 years ago

Hi @mekya

We have to change in WebRTCClient.java as we are using ConferenceManager to join to Conference room, correct?

peerConnectionParameters = new PeerConnectionClient.PeerConnectionParameters(videoCallEnabled, loopback, tracing, videoWidth, videoHeight, intent.getIntExtra(CallActivity.EXTRA_VIDEO_FPS, 0), videoStartBitrate, videoCodec, intent.getBooleanExtra(CallActivity.EXTRA_HWCODEC_ENABLED, true), intent.getBooleanExtra(CallActivity.EXTRA_FLEXFEC_ENABLED, false), audioStartBitrate, intent.getStringExtra(CallActivity.EXTRA_AUDIOCODEC), intent.getBooleanExtra(CallActivity.EXTRA_NOAUDIOPROCESSING_ENABLED, false), intent.getBooleanExtra(CallActivity.EXTRA_AECDUMP_ENABLED, false), intent.getBooleanExtra(CallActivity.EXTRA_SAVE_INPUT_AUDIO_TO_FILE_ENABLED, false), intent.getBooleanExtra(CallActivity.EXTRA_OPENSLES_ENABLED, false), intent.getBooleanExtra(CallActivity.EXTRA_DISABLE_BUILT_IN_AEC, false), intent.getBooleanExtra(CallActivity.EXTRA_DISABLE_BUILT_IN_AGC, false), intent.getBooleanExtra(CallActivity.EXTRA_DISABLE_BUILT_IN_NS, false), intent.getBooleanExtra(CallActivity.EXTRA_DISABLE_WEBRTC_AGC_AND_HPF, false), intent.getBooleanExtra(CallActivity.EXTRA_ENABLE_RTCEVENTLOG, false), dataChannelParameters, audioCallEnabled);

intent.getBooleanExtra(CallActivity.EXTRA_AECDUMP_ENABLED, true)//change from false to true to enable echo cancellation, testing

Please confirm.

mekya commented 3 years ago

Hi @thinkgopal ,

Yeah please try this one and let us know if it works for you.

thinkgopal commented 3 years ago

Hi @mekya ,

I tried this, but not working. Still getting echo sound.

mekya commented 3 years ago

Thank you for trying.

I understand you can reproduce the problem any time you want. In the issue rreport, it says that
"Sound echo issue not happening every time."

Do you provide some more information to let us reproduce the problem?

thinkgopal commented 3 years ago

Hi @mekya

Join in conference room using loud speaker and test. join with minimum 3 to 4 users. But all should be use loud speaker instead of earphone.

thinkgopal commented 3 years ago

https://drive.google.com/file/d/1CRmxL1oa293KEh6bCZgoANkAzbWMiGwE/view?usp=sharing

mekya commented 3 years ago

Ok. Moving to the backlog to schedule.

thinkgopal commented 3 years ago

Hi @mekya,

Everytime, we are able to reproduce the bug in all samsung devices, pixel 2 xl as well as in Xiaomi mi 8. Please help us to fix this as soon as possible because it's a very critical issue and not able to go live.

earlier code snippet(not working, getting echo issue): PeerConnectionClient.java return JavaAudioDeviceModule.builder(appContext) .setSamplesReadyCallback(saveRecordedAudioToFile) .setUseHardwareAcousticEchoCanceler(!peerConnectionParameters.disableBuiltInAEC) .setUseHardwareNoiseSuppressor(!peerConnectionParameters.disableBuiltInNS) .setAudioRecordErrorCallback(audioRecordErrorCallback) .setAudioTrackErrorCallback(audioTrackErrorCallback) .setAudioRecordStateCallback(audioRecordStateCallback) .setAudioTrackStateCallback(audioTrackStateCallback) .createAudioDeviceModule(); @Nullable private AudioTrack createAudioTrack() { if (localAudioTrack == null) { //changes, 25th apr 21 - start , added to reduce noise and echo /*

current code snippet(not working, still getting echo issue): PeerConnectionClient.java /*

package io.antmedia.webrtcandroidframework.apprtc;

import android.content.Context; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.util.Log;

import androidx.annotation.Nullable;

import org.webrtc.AudioSource; import org.webrtc.AudioTrack; import org.webrtc.CameraVideoCapturer; import org.webrtc.CandidatePairChangeEvent; import org.webrtc.DataChannel; import org.webrtc.DefaultVideoDecoderFactory; import org.webrtc.DefaultVideoEncoderFactory; import org.webrtc.EglBase; import org.webrtc.IceCandidate; import org.webrtc.Logging; import org.webrtc.MediaConstraints; import org.webrtc.MediaStream; import org.webrtc.MediaStreamTrack; import org.webrtc.PeerConnection; import org.webrtc.PeerConnection.IceConnectionState; import org.webrtc.PeerConnection.PeerConnectionState; import org.webrtc.PeerConnectionFactory; import org.webrtc.RtpParameters; import org.webrtc.RtpReceiver; import org.webrtc.RtpSender; import org.webrtc.RtpTransceiver; import org.webrtc.SdpObserver; import org.webrtc.SessionDescription; import org.webrtc.SoftwareVideoDecoderFactory; import org.webrtc.SoftwareVideoEncoderFactory; import org.webrtc.StatsObserver; import org.webrtc.StatsReport; import org.webrtc.SurfaceTextureHelper; import org.webrtc.VideoCapturer; import org.webrtc.VideoDecoderFactory; import org.webrtc.VideoEncoderFactory; import org.webrtc.VideoSink; import org.webrtc.VideoSource; import org.webrtc.VideoTrack; import org.webrtc.audio.AudioDeviceModule; import org.webrtc.audio.JavaAudioDeviceModule; import org.webrtc.audio.JavaAudioDeviceModule.AudioRecordErrorCallback; import org.webrtc.audio.JavaAudioDeviceModule.AudioRecordStateCallback; import org.webrtc.audio.JavaAudioDeviceModule.AudioTrackErrorCallback; import org.webrtc.audio.JavaAudioDeviceModule.AudioTrackStateCallback; import org.webrtc.voiceengine.WebRtcAudioUtils;

import java.io.File; import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.regex.Matcher; import java.util.regex.Pattern;

import io.antmedia.webrtcandroidframework.IDataChannelObserver; import io.antmedia.webrtcandroidframework.apprtc.AppRTCClient.SignalingParameters;

/**

mekya commented 3 years ago

hi @thinkgopal ,

I've put this into this week's sprint. I hope we can return back to you with a solution later this week.

Thank you for your cooperation.

SelimEmre commented 3 years ago

Hi @thinkgopal,

I have investigated this issue in detail. It seems this issue is a chronic issue in latest version of devices. ​ People are recommending using setUseHardwareAcousticEchoCanceler and setUseHardwareNoiseSuppressor with false parameters. But as I saw you already used with false parameter. ​ So, I'm still investigating.