diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp index 4a5d12a4710..2948a490800 100755 --- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp @@ -23,6 +23,8 @@ #include "mozilla/Telemetry.h" #endif +#include "webrtc/common.h" +#include "webrtc/modules/audio_processing/include/audio_processing.h" #include "webrtc/voice_engine/include/voe_errors.h" #include "webrtc/system_wrappers/interface/clock.h" #include "browser_logging/WebRtcLog.h" @@ -231,9 +233,25 @@ MediaConduitErrorCode WebrtcAudioConduit::Init() return kMediaConduitSessionNotInited; } #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 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(new webrtc::DelayAgnostic(aec_delay_agnostic)); + } + } +#endif + config.Set(new webrtc::ExtendedFilter(aec_extended_filter)); // 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__); return kMediaConduitSessionNotInited; diff --git a/media/webrtc/signaling/test/mediapipeline_unittest.cpp b/media/webrtc/signaling/test/mediapipeline_unittest.cpp index 85557de045b..06febf8c9fa 100644 --- a/media/webrtc/signaling/test/mediapipeline_unittest.cpp +++ b/media/webrtc/signaling/test/mediapipeline_unittest.cpp @@ -396,15 +396,10 @@ class MediaPipelineTest : public ::testing::Test { // Setup transport flows InitTransports(aIsRtcpMux); -#if 0 //DEBUG(pkerr) - mozilla::SyncRunnable::DispatchToThread( - test_utils->sts_target(), - WrapRunnable(&p1_, &TestAgent::CreatePipelines_s, aIsRtcpMux)); -#else NS_DispatchToMainThread( WrapRunnable(&p1_, &TestAgent::CreatePipelines_s, aIsRtcpMux), NS_DISPATCH_SYNC); -#endif + mozilla::SyncRunnable::DispatchToThread( test_utils->sts_target(), WrapRunnable(&p2_, &TestAgent::CreatePipelines_s, aIsRtcpMux)); diff --git a/media/webrtc/trunk/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/media/webrtc/trunk/webrtc/modules/audio_processing/echo_cancellation_impl.cc index 1915c579aab..c6a35f1b680 100644 --- a/media/webrtc/trunk/webrtc/modules/audio_processing/echo_cancellation_impl.cc +++ b/media/webrtc/trunk/webrtc/modules/audio_processing/echo_cancellation_impl.cc @@ -336,8 +336,8 @@ int EchoCancellationImpl::Initialize() { } void EchoCancellationImpl::SetExtraOptions(const Config& config) { - extended_filter_enabled_ = true; // XXX config.Get().enabled; - delay_agnostic_enabled_ = true; // XXX config.Get().enabled; + extended_filter_enabled_ = config.Get().enabled; + delay_agnostic_enabled_ = config.Get().enabled; Configure(); } diff --git a/media/webrtc/trunk/webrtc/modules/audio_processing/include/audio_processing.h b/media/webrtc/trunk/webrtc/modules/audio_processing/include/audio_processing.h index 72553ffa6e7..97b14b0d9cc 100644 --- a/media/webrtc/trunk/webrtc/modules/audio_processing/include/audio_processing.h +++ b/media/webrtc/trunk/webrtc/modules/audio_processing/include/audio_processing.h @@ -37,6 +37,18 @@ class LevelEstimator; class NoiseSuppression; 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 // 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 diff --git a/media/webrtc/trunk/webrtc/voice_engine/channel.cc b/media/webrtc/trunk/webrtc/voice_engine/channel.cc index ed250bd7747..c4ddd2fe94d 100644 --- a/media/webrtc/trunk/webrtc/voice_engine/channel.cc +++ b/media/webrtc/trunk/webrtc/voice_engine/channel.cc @@ -849,6 +849,10 @@ Channel::Channel(int32_t channelId, Config audioproc_config; audioproc_config.Set(new ExperimentalAgc(false)); + audioproc_config.Set( + new ExtendedFilter(config.Get().enabled)); + audioproc_config.Set( + new DelayAgnostic(config.Get().enabled)); rx_audioproc_.reset(AudioProcessing::Create(audioproc_config)); } diff --git a/media/webrtc/trunk/webrtc/voice_engine/channel_manager.cc b/media/webrtc/trunk/webrtc/voice_engine/channel_manager.cc index 93862574761..78c484f3dc6 100644 --- a/media/webrtc/trunk/webrtc/voice_engine/channel_manager.cc +++ b/media/webrtc/trunk/webrtc/voice_engine/channel_manager.cc @@ -46,10 +46,11 @@ ChannelOwner::ChannelRef::ChannelRef(class Channel* channel) : channel(channel), ref_count(1) {} ChannelManager::ChannelManager(uint32_t instance_id, const Config& config) - : instance_id_(instance_id), + : config_(config), + instance_id_(instance_id), last_channel_id_(-1), - lock_(CriticalSectionWrapper::CreateCriticalSection()), - config_(config) {} + lock_(CriticalSectionWrapper::CreateCriticalSection()) + {} ChannelOwner ChannelManager::CreateChannel() { return CreateChannelInternal(config_); diff --git a/media/webrtc/trunk/webrtc/voice_engine/channel_manager.h b/media/webrtc/trunk/webrtc/voice_engine/channel_manager.h index eae014ed09c..27e2865bafe 100644 --- a/media/webrtc/trunk/webrtc/voice_engine/channel_manager.h +++ b/media/webrtc/trunk/webrtc/voice_engine/channel_manager.h @@ -109,6 +109,7 @@ class ChannelManager { void DestroyAllChannels(); size_t NumOfChannels() const; + const Config& config_; private: // Create a channel given a configuration, |config|. @@ -121,8 +122,6 @@ class ChannelManager { rtc::scoped_ptr lock_; std::vector channels_; - const Config& config_; - DISALLOW_COPY_AND_ASSIGN(ChannelManager); }; } // namespace voe diff --git a/media/webrtc/trunk/webrtc/voice_engine/voe_base_impl.cc b/media/webrtc/trunk/webrtc/voice_engine/voe_base_impl.cc index ce22311e327..430ee40c675 100644 --- a/media/webrtc/trunk/webrtc/voice_engine/voe_base_impl.cc +++ b/media/webrtc/trunk/webrtc/voice_engine/voe_base_impl.cc @@ -424,7 +424,7 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm, } if (!audioproc) { - audioproc = AudioProcessing::Create(); + audioproc = AudioProcessing::Create(_shared->channel_manager().config_); if (!audioproc) { LOG(LS_ERROR) << "Failed to create AudioProcessing."; _shared->SetLastError(VE_NO_MEMORY); diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index c3b28631106..d96b07dc7ab 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -439,6 +439,12 @@ pref("media.getusermedia.noise_enabled", false); pref("media.getusermedia.aec_enabled", true); pref("media.getusermedia.noise_enabled", true); #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.agc_enabled", false); pref("media.getusermedia.agc", 1);