зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1627313 - Activate an HPF on getUserMedia microphone input, when processing is enabled. r=achronop
The high-pass filter helps fixing the DC bias on input, which is critical for the AEC to work well. It's not controllable by authors, enabled if any of AEC, AGC or Noise suppression is activated, disabled otherwise, and therefore not taken into account when activating the pass-through mode. `media.getusermedia.hpf_enabled` allows controlling it's activation. This defaults to `true`. Differential Revision: https://phabricator.services.mozilla.com/D70393 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4935907607
Коммит
96206c08cb
|
@ -1899,6 +1899,7 @@ MediaManager::MediaManager(UniquePtr<base::Thread> aMediaThread)
|
|||
mPrefs.mAecOn = false;
|
||||
mPrefs.mUseAecMobile = false;
|
||||
mPrefs.mAgcOn = false;
|
||||
mPrefs.mHPFOn = false;
|
||||
mPrefs.mNoiseOn = false;
|
||||
mPrefs.mExtendedFilter = true;
|
||||
mPrefs.mDelayAgnostic = true;
|
||||
|
@ -1925,13 +1926,15 @@ MediaManager::MediaManager(UniquePtr<base::Thread> aMediaThread)
|
|||
}
|
||||
}
|
||||
LOG("%s: default prefs: %dx%d @%dfps, %dHz test tones, aec: %s,"
|
||||
"agc: %s, noise: %s, aec level: %d, agc level: %d, noise level: %d,"
|
||||
"agc: %s, hpf: %s, noise: %s, aec level: %d, agc level: %d, noise level: "
|
||||
"%d,"
|
||||
"%sfull_duplex, extended aec %s, delay_agnostic %s "
|
||||
"channels %d",
|
||||
__FUNCTION__, mPrefs.mWidth, mPrefs.mHeight, mPrefs.mFPS, mPrefs.mFreq,
|
||||
mPrefs.mAecOn ? "on" : "off", mPrefs.mAgcOn ? "on" : "off",
|
||||
mPrefs.mNoiseOn ? "on" : "off", mPrefs.mAec, mPrefs.mAgc, mPrefs.mNoise,
|
||||
mPrefs.mFullDuplex ? "" : "not ", mPrefs.mExtendedFilter ? "on" : "off",
|
||||
mPrefs.mHPFOn ? "on" : "off", mPrefs.mNoiseOn ? "on" : "off", mPrefs.mAec,
|
||||
mPrefs.mAgc, mPrefs.mNoise, mPrefs.mFullDuplex ? "" : "not ",
|
||||
mPrefs.mExtendedFilter ? "on" : "off",
|
||||
mPrefs.mDelayAgnostic ? "on" : "off", mPrefs.mChannels);
|
||||
}
|
||||
|
||||
|
@ -2037,6 +2040,7 @@ MediaManager* MediaManager::Get() {
|
|||
prefs->AddObserver("media.getusermedia.aec", sSingleton, false);
|
||||
prefs->AddObserver("media.getusermedia.agc_enabled", sSingleton, false);
|
||||
prefs->AddObserver("media.getusermedia.agc", sSingleton, false);
|
||||
prefs->AddObserver("media.getusermedia.hpf_enabled", sSingleton, false);
|
||||
prefs->AddObserver("media.getusermedia.noise_enabled", sSingleton, false);
|
||||
prefs->AddObserver("media.getusermedia.noise", sSingleton, false);
|
||||
prefs->AddObserver("media.ondevicechange.fakeDeviceChangeEvent.enabled",
|
||||
|
@ -3477,6 +3481,7 @@ void MediaManager::GetPrefs(nsIPrefBranch* aBranch, const char* aData) {
|
|||
#ifdef MOZ_WEBRTC
|
||||
GetPrefBool(aBranch, "media.getusermedia.aec_enabled", aData, &mPrefs.mAecOn);
|
||||
GetPrefBool(aBranch, "media.getusermedia.agc_enabled", aData, &mPrefs.mAgcOn);
|
||||
GetPrefBool(aBranch, "media.getusermedia.hpf_enabled", aData, &mPrefs.mHPFOn);
|
||||
GetPrefBool(aBranch, "media.getusermedia.noise_enabled", aData,
|
||||
&mPrefs.mNoiseOn);
|
||||
GetPref(aBranch, "media.getusermedia.aec", aData, &mPrefs.mAec);
|
||||
|
@ -3533,6 +3538,7 @@ void MediaManager::Shutdown() {
|
|||
prefs->RemoveObserver("media.getusermedia.aec_enabled", this);
|
||||
prefs->RemoveObserver("media.getusermedia.aec", this);
|
||||
prefs->RemoveObserver("media.getusermedia.agc_enabled", this);
|
||||
prefs->RemoveObserver("media.getusermedia.hpf_enabled", this);
|
||||
prefs->RemoveObserver("media.getusermedia.agc", this);
|
||||
prefs->RemoveObserver("media.getusermedia.noise_enabled", this);
|
||||
prefs->RemoveObserver("media.getusermedia.noise", this);
|
||||
|
|
|
@ -28,6 +28,7 @@ class MediaEnginePrefs {
|
|||
mAecOn(false),
|
||||
mUseAecMobile(false),
|
||||
mAgcOn(false),
|
||||
mHPFOn(false),
|
||||
mNoiseOn(false),
|
||||
mAec(0),
|
||||
mAgc(0),
|
||||
|
@ -45,6 +46,7 @@ class MediaEnginePrefs {
|
|||
bool mAecOn;
|
||||
bool mUseAecMobile;
|
||||
bool mAgcOn;
|
||||
bool mHPFOn;
|
||||
bool mNoiseOn;
|
||||
int32_t mAec;
|
||||
int32_t mAgc;
|
||||
|
|
|
@ -236,6 +236,35 @@ void MediaEngineWebRTCMicrophoneSource::UpdateAGCSettings(
|
|||
}));
|
||||
}
|
||||
|
||||
void MediaEngineWebRTCMicrophoneSource::UpdateHPFSettings(bool aEnable) {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
RefPtr<MediaEngineWebRTCMicrophoneSource> that = this;
|
||||
NS_DispatchToMainThread(
|
||||
NS_NewRunnableFunction(__func__, [that, track = mTrack, aEnable] {
|
||||
class Message : public ControlMessage {
|
||||
public:
|
||||
Message(AudioInputProcessing* aInputProcessing, bool aEnable)
|
||||
: ControlMessage(nullptr),
|
||||
mInputProcessing(aInputProcessing),
|
||||
mEnable(aEnable) {}
|
||||
|
||||
void Run() override { mInputProcessing->UpdateHPFSettings(mEnable); }
|
||||
|
||||
protected:
|
||||
RefPtr<AudioInputProcessing> mInputProcessing;
|
||||
bool mEnable;
|
||||
};
|
||||
|
||||
if (track->IsDestroyed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
track->GraphImpl()->AppendMessage(
|
||||
MakeUnique<Message>(that->mInputProcessing, aEnable));
|
||||
}));
|
||||
}
|
||||
|
||||
void MediaEngineWebRTCMicrophoneSource::UpdateNSSettings(
|
||||
bool aEnable, webrtc::NoiseSuppression::Level aLevel) {
|
||||
AssertIsOnOwningThread();
|
||||
|
@ -324,6 +353,7 @@ void MediaEngineWebRTCMicrophoneSource::ApplySettings(
|
|||
UpdateAECSettings(
|
||||
aPrefs.mAecOn, aPrefs.mUseAecMobile,
|
||||
static_cast<webrtc::EchoCancellation::SuppressionLevel>(aPrefs.mAec));
|
||||
UpdateHPFSettings(aPrefs.mHPFOn);
|
||||
|
||||
UpdateAPMExtraOptions(mExtendedFilter, mDelayAgnostic);
|
||||
}
|
||||
|
@ -357,6 +387,8 @@ void MediaEngineWebRTCMicrophoneSource::ApplySettings(
|
|||
uint32_t mRequestedInputChannelCount;
|
||||
};
|
||||
|
||||
// The high-pass filter is not taken into account when activating the
|
||||
// pass through, since it's not controllable from content.
|
||||
bool passThrough = !(prefs.mAecOn || prefs.mAgcOn || prefs.mNoiseOn);
|
||||
if (track->IsDestroyed()) {
|
||||
return;
|
||||
|
@ -690,6 +722,10 @@ void AudioInputProcessing::UpdateAGCSettings(bool aEnable,
|
|||
HANDLE_APM_ERROR(mAudioProcessing->gain_control()->Enable(aEnable));
|
||||
}
|
||||
|
||||
void AudioInputProcessing::UpdateHPFSettings(bool aEnable) {
|
||||
HANDLE_APM_ERROR(mAudioProcessing->high_pass_filter()->Enable(aEnable));
|
||||
}
|
||||
|
||||
void AudioInputProcessing::UpdateNSSettings(
|
||||
bool aEnable, webrtc::NoiseSuppression::Level aLevel) {
|
||||
if (aLevel != NoiseSuppression::Level::kLow &&
|
||||
|
|
|
@ -95,6 +95,7 @@ class MediaEngineWebRTCMicrophoneSource : public MediaEngineSource {
|
|||
void UpdateAECSettings(bool aEnable, bool aUseAecMobile,
|
||||
webrtc::EchoCancellation::SuppressionLevel aLevel);
|
||||
void UpdateAGCSettings(bool aEnable, webrtc::GainControl::Mode aMode);
|
||||
void UpdateHPFSettings(bool aEnable);
|
||||
void UpdateNSSettings(bool aEnable, webrtc::NoiseSuppression::Level aLevel);
|
||||
void UpdateAPMExtraOptions(bool aExtendedFilter, bool aDelayAgnostic);
|
||||
|
||||
|
@ -191,6 +192,7 @@ class AudioInputProcessing : public AudioDataListener {
|
|||
void UpdateAECSettings(bool aEnable, bool aUseAecMobile,
|
||||
webrtc::EchoCancellation::SuppressionLevel aLevel);
|
||||
void UpdateAGCSettings(bool aEnable, webrtc::GainControl::Mode aMode);
|
||||
void UpdateHPFSettings(bool aEnable);
|
||||
void UpdateNSSettings(bool aEnable, webrtc::NoiseSuppression::Level aLevel);
|
||||
void UpdateAPMExtraOptions(bool aExtendedFilter, bool aDelayAgnostic);
|
||||
|
||||
|
|
|
@ -526,6 +526,7 @@ pref("media.videocontrols.picture-in-picture.video-toggle.min-video-secs", 45);
|
|||
pref("media.getusermedia.noise", 1); // kModerate
|
||||
pref("media.getusermedia.agc_enabled", true);
|
||||
pref("media.getusermedia.agc", 1); // kAdaptiveDigital
|
||||
pref("media.getusermedia.hpf_enabled", true);
|
||||
// full_duplex: enable cubeb full-duplex capture/playback
|
||||
pref("media.navigator.audio.full_duplex", true);
|
||||
#endif // MOZ_WEBRTC
|
||||
|
|
Загрузка…
Ссылка в новой задаче