WebRTC Android 回声消除

文章介绍了WebRTC在Android平台上实现回声消除的方法,包括使用AudioManager设置通话模式,通过WebRtcAudioUtils和MediaConstraints启用AEC、AGC及NS功能,以及在JavaAudioDeviceModule构建时的配置。重点讨论了针对电脑和移动端的不同回声消除模块AEC和AECM的使用。

WebRTC Android 回声消除

前言

WebRTC源代码中设计了两个回声消除模块,AEC(Acoustic Echo Canceller)和AECM(Acoustic Echo Canceller Mobile),AEC是在电脑端使用的回声消除器,而AECM是在移动端使用。由于电脑与移动设备的差别比较明显,在处理速度上,编解码器的性能上和内存方面都有着较大的差异。

主体

AudioManager 设置为通话模式,如下:

audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
audioManager.setSpeakerphoneOn(false);

创建 PeerConnect的时候设置如下:

WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true);
WebRtcAudioUtils.useWebRtcBasedAcousticEchoCanceler();
WebRtcAudioUtils.setWebRtcBasedAutomaticGainControl(true);
WebRtcAudioUtils.useWebRtcBasedAutomaticGainControl();
WebRtcAudioUtils.setWebRtcBasedNoiseSuppressor(true);
WebRtcAudioUtils.useWebRtcBasedNoiseSuppressor();
WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true);

或者进行如下设置:

audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googEchoCancellation", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googEchoCancellation2", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googDAEchoCancellation", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googTypingNoiseDetection", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googAutoGainControl", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googAutoGainControl2", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googNoiseSuppression", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googNoiseSuppression2", "true"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googAudioMirroring", "false"));
audioConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googHighpassFilter", "true"));

JavaAudioDeviceModule 创建时进行如下设置:

private JavaAudioDeviceModule audioDeviceModule;
private JavaAudioDeviceModule.Builder audioDeviceModuleBuilder;

audioDeviceModuleBuilder = JavaAudioDeviceModule.builder(ContextUtils.getApplicationContext());
this.audioDeviceModule = audioDeviceModuleBuilder
               .setAudioSource(MediaRecorder.AudioSource.CAMCORDER)
               .setUseHardwareAcousticEchoCanceler(false)
               .setUseHardwareNoiseSuppressor(false)
               .createAudioDeviceModule();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

五一编程

程序之路有我与你同行

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值