How to enable echo-cancellation on Android Voip App?

19 views Asked by At

My Voip App is using OpenSL/ES(Android NDK API) for the microphone and speaker control. But echo canceller doesn't work on this App. When I call, I hear an echo.

I am investigating that how to enable echo-cancellation on this app.

OpenSL/ES defines an interface called SLEchoSuppressorItf, and by using this, it seemed like it could cancel the echo that occurs on Voip calls.

However, SLEchoSuppressorItf is valid in full spec OpenSL/ES, I found out that it is not implemented in the Android version of OpenSL.

For this reason, I tried using the AcousticEchoCanceler class of Java API instead of SLEchoSuppressorItf(OpenSL/ES) to see if it would work. Below is its source code.

int bufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT);

// Create AudioRecord object
audioRecord = new AudioRecord(MediaRecorder.AudioSource.VOICE_COMMUNICATION, 
                              SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT, bufferSize);

//Confirm AcousticEchoCanceler is available on this device
if (AcousticEchoCanceler.isAvailable()) 
{
    // Create AcousticEchoCanceler instance
    echoCanceler = AcousticEchoCanceler.create(audioRecord.getAudioSessionId());

    // Enabel echo canceler
    if (echoCanceler != null) {
        echoCanceler.setEnabled(true);
    Logger.log(Log.DEBUG, "CallManagerState", "AcousticEchoCanceler setEnabled");
    }
}

However, when I execute this code also, the echo canceller did not work. (When I call, I hear an echo again)

[QUESTION1] Does the Java API's AcousticEchoCanceler only have an effect on instances of the Java API's AudioRecord? In other words, does the Java API's AcousticEchoCanceler have no effect on OpenSL/ES(Android NDK API) instances?

[QUESTION2] If QUESTION1 is YES, how can I enable echo canceller in a VoIP App implemented with OpenSL/ES(Android NDK API)?

1

There are 1 answers

0
Tim On

Please note that it could be that AEC works but is unable to handle your environment/setups - for example very long echo tail. Please see the following post https://solicall.com/analyze-the-echo-path-yourself/