WebRTC AEC on Android

dbautista picture dbautista · Oct 10, 2012 · Viewed 10.2k times · Source

I'm developing a SIP softphone app for Android, and facing the echo cancellation problem. I've tried to solve it using Speex with no success. So my next shot is WebRTC AEC (Acoustic Echo Cancellation), but I cannot find any documentation about how to use it.

In my app, the audio is managed with AudioTrack and AudioRecord classes in Java, but the sockets that sends and receive are in a C code (integrated with JNI). WebRTC is a mega-project, and I only want to integrate the AEC module.

Does someone know which files I have to include, which flags does the compiler need, which function calls to do, and so on? I have the CSipSimple code, which also uses the WebRTC (but for other uses too) and I can't find out the easy and proper way to include and use it.

Thanks.

Answer

junglecat picture junglecat · Feb 4, 2013

You'll need the following files:

aec/modules/audio_processing/aec/aec_core_sse2.c
aec/modules/audio_processing/aec/aec_core.c
aec/modules/audio_processing/aec/aec_rdft_sse2.c
aec/modules/audio_processing/aec/aec_rdft.c
aec/modules/audio_processing/aec/aec_resampler.c
aec/modules/audio_processing/aec/echo_cancellation.c
aec/modules/audio_processing/utility/ring_buffer.c
aec/modules/audio_processing/utility/delay_estimator.c
aec/modules/audio_processing/utility/delay_estimator_wrapper.c
aec/system_wrappers/source/cpu_features.cc
aec/common_audio/signal_processing/randomization_functions.c

Usage:

void * aec = 0;
int status = WebRtcAecm_Create(&aec);
status = WebRtcAecm_Init(aec, 8000 /* sample rate */);

// Buffer the far end frames
int status = WebRtcAecm_BufferFarend(
    aec, play_frm, 160
);

// Cancel echo
status = WebRtcAecm_Process(
    aec, (WebRtc_Word16 *)buf, (WebRtc_Word16 *)buf,
    tmp_frm, 160,
    echo_tail / tail_factor
);