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 05d80d2f86
commit 46b05602ec
9 changed files with 50 additions and 15 deletions

View File

@ -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<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
if(!(mVoiceEngine = webrtc::VoiceEngine::Create()))
if(!(mVoiceEngine = webrtc::VoiceEngine::Create(config)))
{
CSFLogError(logTag, "%s Unable to create voice engine", __FUNCTION__);
return kMediaConduitSessionNotInited;

View File

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

View File

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

View File

@ -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

View File

@ -849,6 +849,10 @@ Channel::Channel(int32_t channelId,
Config audioproc_config;
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));
}

View File

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

View File

@ -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<CriticalSectionWrapper> lock_;
std::vector<ChannelOwner> channels_;
const Config& config_;
DISALLOW_COPY_AND_ASSIGN(ChannelManager);
};
} // namespace voe

View File

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

View File

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