Bug 1226347 - Part 2: Allow control of AEC via prefs. r=rjesup

This commit is contained in:
Paul Kerr [:pkerr] 2015-11-24 08:32:11 -08:00
parent c2a89050e6
commit d986a6ee32
9 changed files with 50 additions and 15 deletions

View File

@ -23,6 +23,8 @@
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
#endif #endif
#include "webrtc/common.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/voice_engine/include/voe_errors.h" #include "webrtc/voice_engine/include/voe_errors.h"
#include "webrtc/system_wrappers/interface/clock.h" #include "webrtc/system_wrappers/interface/clock.h"
#include "browser_logging/WebRtcLog.h" #include "browser_logging/WebRtcLog.h"
@ -231,9 +233,25 @@ MediaConduitErrorCode WebrtcAudioConduit::Init()
return kMediaConduitSessionNotInited; return kMediaConduitSessionNotInited;
} }
#endif #endif
webrtc::Config config;
bool aec_extended_filter = true; // Always default to the extended filter length
bool aec_delay_agnostic = false;
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
nsresult rv;
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
prefs->GetBoolPref("media.getusermedia.aec_extended_filter", &aec_extended_filter);
rv = prefs->GetBoolPref("media.getusermedia.aec_delay_agnostic", &aec_delay_agnostic);
if (NS_SUCCEEDED(rv)) {
// Only override platform setting if pref is defined.
config.Set<webrtc::DelayAgnostic>(new webrtc::DelayAgnostic(aec_delay_agnostic));
}
}
#endif
config.Set<webrtc::ExtendedFilter>(new webrtc::ExtendedFilter(aec_extended_filter));
// Per WebRTC APIs below function calls return nullptr on failure // Per WebRTC APIs below function calls return nullptr on failure
if(!(mVoiceEngine = webrtc::VoiceEngine::Create())) if(!(mVoiceEngine = webrtc::VoiceEngine::Create(config)))
{ {
CSFLogError(logTag, "%s Unable to create voice engine", __FUNCTION__); CSFLogError(logTag, "%s Unable to create voice engine", __FUNCTION__);
return kMediaConduitSessionNotInited; return kMediaConduitSessionNotInited;

View File

@ -396,15 +396,10 @@ class MediaPipelineTest : public ::testing::Test {
// Setup transport flows // Setup transport flows
InitTransports(aIsRtcpMux); InitTransports(aIsRtcpMux);
#if 0 //DEBUG(pkerr)
mozilla::SyncRunnable::DispatchToThread(
test_utils->sts_target(),
WrapRunnable(&p1_, &TestAgent::CreatePipelines_s, aIsRtcpMux));
#else
NS_DispatchToMainThread( NS_DispatchToMainThread(
WrapRunnable(&p1_, &TestAgent::CreatePipelines_s, aIsRtcpMux), WrapRunnable(&p1_, &TestAgent::CreatePipelines_s, aIsRtcpMux),
NS_DISPATCH_SYNC); NS_DISPATCH_SYNC);
#endif
mozilla::SyncRunnable::DispatchToThread( mozilla::SyncRunnable::DispatchToThread(
test_utils->sts_target(), test_utils->sts_target(),
WrapRunnable(&p2_, &TestAgent::CreatePipelines_s, aIsRtcpMux)); WrapRunnable(&p2_, &TestAgent::CreatePipelines_s, aIsRtcpMux));

View File

@ -336,8 +336,8 @@ int EchoCancellationImpl::Initialize() {
} }
void EchoCancellationImpl::SetExtraOptions(const Config& config) { void EchoCancellationImpl::SetExtraOptions(const Config& config) {
extended_filter_enabled_ = true; // XXX config.Get<ExtendedFilter>().enabled; extended_filter_enabled_ = config.Get<ExtendedFilter>().enabled;
delay_agnostic_enabled_ = true; // XXX config.Get<DelayAgnostic>().enabled; delay_agnostic_enabled_ = config.Get<DelayAgnostic>().enabled;
Configure(); Configure();
} }

View File

@ -37,6 +37,18 @@ class LevelEstimator;
class NoiseSuppression; class NoiseSuppression;
class VoiceDetection; class VoiceDetection;
struct ExtendedFilter {
ExtendedFilter() : enabled(false) {}
explicit ExtendedFilter(bool enabled) : enabled(enabled) {}
bool enabled;
};
struct DelayAgnostic {
DelayAgnostic() : enabled(false) {}
explicit DelayAgnostic(bool enabled) : enabled(enabled) {}
bool enabled;
};
// Use to enable the delay correction feature. This now engages an extended // Use to enable the delay correction feature. This now engages an extended
// filter mode in the AEC, along with robustness measures around the reported // filter mode in the AEC, along with robustness measures around the reported
// system delays. It comes with a significant increase in AEC complexity, but is // system delays. It comes with a significant increase in AEC complexity, but is

View File

@ -849,6 +849,10 @@ Channel::Channel(int32_t channelId,
Config audioproc_config; Config audioproc_config;
audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
audioproc_config.Set<ExtendedFilter>(
new ExtendedFilter(config.Get<ExtendedFilter>().enabled));
audioproc_config.Set<DelayAgnostic>(
new DelayAgnostic(config.Get<DelayAgnostic>().enabled));
rx_audioproc_.reset(AudioProcessing::Create(audioproc_config)); rx_audioproc_.reset(AudioProcessing::Create(audioproc_config));
} }

View File

@ -46,10 +46,11 @@ ChannelOwner::ChannelRef::ChannelRef(class Channel* channel)
: channel(channel), ref_count(1) {} : channel(channel), ref_count(1) {}
ChannelManager::ChannelManager(uint32_t instance_id, const Config& config) ChannelManager::ChannelManager(uint32_t instance_id, const Config& config)
: instance_id_(instance_id), : config_(config),
instance_id_(instance_id),
last_channel_id_(-1), last_channel_id_(-1),
lock_(CriticalSectionWrapper::CreateCriticalSection()), lock_(CriticalSectionWrapper::CreateCriticalSection())
config_(config) {} {}
ChannelOwner ChannelManager::CreateChannel() { ChannelOwner ChannelManager::CreateChannel() {
return CreateChannelInternal(config_); return CreateChannelInternal(config_);

View File

@ -109,6 +109,7 @@ class ChannelManager {
void DestroyAllChannels(); void DestroyAllChannels();
size_t NumOfChannels() const; size_t NumOfChannels() const;
const Config& config_;
private: private:
// Create a channel given a configuration, |config|. // Create a channel given a configuration, |config|.
@ -121,8 +122,6 @@ class ChannelManager {
rtc::scoped_ptr<CriticalSectionWrapper> lock_; rtc::scoped_ptr<CriticalSectionWrapper> lock_;
std::vector<ChannelOwner> channels_; std::vector<ChannelOwner> channels_;
const Config& config_;
DISALLOW_COPY_AND_ASSIGN(ChannelManager); DISALLOW_COPY_AND_ASSIGN(ChannelManager);
}; };
} // namespace voe } // namespace voe

View File

@ -424,7 +424,7 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm,
} }
if (!audioproc) { if (!audioproc) {
audioproc = AudioProcessing::Create(); audioproc = AudioProcessing::Create(_shared->channel_manager().config_);
if (!audioproc) { if (!audioproc) {
LOG(LS_ERROR) << "Failed to create AudioProcessing."; LOG(LS_ERROR) << "Failed to create AudioProcessing.";
_shared->SetLastError(VE_NO_MEMORY); _shared->SetLastError(VE_NO_MEMORY);

View File

@ -439,6 +439,12 @@ pref("media.getusermedia.noise_enabled", false);
pref("media.getusermedia.aec_enabled", true); pref("media.getusermedia.aec_enabled", true);
pref("media.getusermedia.noise_enabled", true); pref("media.getusermedia.noise_enabled", true);
#endif #endif
pref("media.getusermedia.aec_extended_filter", true);
#if defined(ANDROID)
pref("media.getusermedia.aec_delay_agnostic", true);
#else
pref("media.getusermedia.aec_delay_agnostic", false);
#endif
pref("media.getusermedia.noise", 1); pref("media.getusermedia.noise", 1);
pref("media.getusermedia.agc_enabled", false); pref("media.getusermedia.agc_enabled", false);
pref("media.getusermedia.agc", 1); pref("media.getusermedia.agc", 1);