简体   繁体   English

Android上的WebRTC AEC

[英]WebRTC AEC on Android

I'm developing a SIP softphone app for Android , and facing the echo cancellation problem. 我正在为Android开发SIP软电话应用程序,并面临回声消除问题。 I've tried to solve it using Speex with no success. 我试图使用Speex解决它没有成功。 So my next shot is WebRTC AEC (Acoustic Echo Cancellation), but I cannot find any documentation about how to use it. 所以我的下一个镜头是WebRTC AEC (声学回声消除),但我找不到任何关于如何使用它的文档。

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). 在我的应用程序中,音频使用Java中的AudioTrack和AudioRecord类进行管理,但发送和接收的套接字是C代码(与JNI集成)。 WebRTC is a mega-project, and I only want to integrate the AEC module. WebRTC是一个大型项目,我只想集成AEC模块。

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. 我有CSipSimple代码,它也使用WebRTC(但也用于其他用途),我找不到包含和使用它的简单方法。

Thanks. 谢谢。

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
);

这不能解答您的问题,但如果您无法在webrtc.org上找到所需内容 ,请尝试使用discuss-webrtc小组。

Note: Version of android referenced below is 4.1 (JellyBean) 注意:下面引用的android版本是4.1(JellyBean)

The response is probably too late. 回应可能为时已晚。 However, for anyone interested in answers to dbaustista 's questions, consider following: 但是,对于任何对dbaustista问题的答案感兴趣的人,请考虑以下事项:

AEC is modeled by AudioEffect class. AEC由AudioEffect类建模。 So, an AEC AudioEffect object needs to be added to the "effects-chain" of the RecordThread. 因此,需要将AEC AudioEffect对象添加到RecordThread的“效果链”中。 I believe the implementation of AEC is built into the libaudioprocessing library. 我相信AEC的实现是内置于libaudioprocessing库中的。 See additional notes below. 请参阅以下附加说明。

Library 图书馆

/system/etc/audio_effects.conf
libraries {
...
   pre_processing {
     path /system/lib/soundfx/libaudiopreprocessing.so
   }
}

Interface 接口

media/AudioEffect.h

Example

The example below shows you how to add an AudioEffect object to a PlaybackThread . 下面的示例显示如何将AudioEffect对象添加到PlaybackThread Apply similar logic to the RecordThread ie Add the AEC object to the effects-chain of the RecordThread. 将类似的逻辑应用于RecordThread,即将AEC对象添加到RecordThread的效果链中。

mediaframeworktest/functional/audio/MediaAudioEffectTest.java mediaframeworktest /功能/音频/ MediaAudioEffectTest.java

      AudioTrack track = new AudioTrack(
                                  AudioManager.STREAM_MUSIC,
                                  44100,
                                  AudioFormat.CHANNEL_OUT_MONO,
                                  AudioFormat.ENCODING_PCM_16BIT,
                                  AudioTrack.getMinBufferSize(44100,
                                  AudioFormat.CHANNEL_OUT_MONO,
                                  AudioFormat.ENCODING_PCM_16BIT),
                                  AudioTrack.MODE_STREAM);
      assertNotNull(msg + ": could not create AudioTrack", track);
      AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB,
              AudioEffect.EFFECT_TYPE_NULL,
              0,
              0);

      track.attachAuxEffect(effect.getId());
      track.setAuxEffectSendLevel(1.0f);

AEC Config Options AEC配置选项

TODO: add example configuration of AEC TODO:添加AEC的示例配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM