Bug 987186 - also accept and respect mozNoiseSuppression and mozAutoGainControl draft
authorBrian Armstrong <brian.armstrong.ece+moz@gmail.com>
Tue, 19 Jan 2016 17:47:05 -0800
changeset 323632 f88c6fe71ba0e306583c81d836b82e423d9c2dfe
parent 323631 70e3d32d90592c6b71eb6680c4271bf035a1a70d
child 323633 5b9892ae3a8e786de7d56536d71418f556f57732
push id9759
push userbmo:brian.armstrong.ece+github@gmail.com
push dateWed, 20 Jan 2016 21:19:45 +0000
bugs987186
milestone46.0a1
Bug 987186 - also accept and respect mozNoiseSuppression and mozAutoGainControl
dom/media/tests/mochitest/test_getUserMedia_constraints.html
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
dom/webidl/MediaStreamTrack.webidl
dom/webidl/MediaTrackSupportedConstraints.webidl
--- a/dom/media/tests/mochitest/test_getUserMedia_constraints.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_constraints.html
@@ -75,17 +75,17 @@ var mustSupport = [
   // http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
   // OBE by http://w3c.github.io/mediacapture-screen-share
   'mediaSource',
 
   // Experimental https://bugzilla.mozilla.org/show_bug.cgi?id=1131568#c3
   'browserWindow', 'scrollWithPage',
   'viewportOffsetX', 'viewportOffsetY', 'viewportWidth', 'viewportHeight',
 
-  'echoCancellation'
+  'echoCancellation', 'mozNoiseSuppression', 'mozAutoGainControl'
 ];
 
 var mustFailWith = (msg, reason, constraint, f) =>
   f().then(() => ok(false, msg + " must fail"), e => {
     is(e.name, reason, msg + " must fail: " + e.message);
     if (constraint !== undefined) {
       is(e.constraint, constraint, msg + " must fail w/correct constraint.");
     }
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -248,28 +248,30 @@ MediaEngineWebRTCMicrophoneSource::Alloc
 }
 
 nsresult
 MediaEngineWebRTCMicrophoneSource::Restart(const dom::MediaTrackConstraints& aConstraints,
                                            const MediaEnginePrefs &aPrefs,
                                            const nsString& aDeviceId)
 {
   bool aec_on = aConstraints.mEchoCancellation.WasPassed() ? aConstraints.mEchoCancellation.Value() : aPrefs.mAecOn;
+  bool agc_on = aConstraints.mMozAutoGainControl.WasPassed() ? aConstraints.mMozAutoGainControl.Value() : aPrefs.mAgcOn;
+  bool noise_on = aConstraints.mMozNoiseSuppression.WasPassed() ? aConstraints.mMozNoiseSuppression.Value() : aPrefs.mNoiseOn;
 
   LOG(("Audio config: aec: %d, agc: %d, noise: %d",
        aec_on ? aPrefs.mAec : -1,
-       aPrefs.mAgcOn ? aPrefs.mAgc : -1,
-       aPrefs.mNoiseOn ? aPrefs.mNoise : -1));
+       agc_on ? aPrefs.mAgc : -1,
+       noise_on ? aPrefs.mNoise : -1));
 
   bool update_echo = (mEchoOn != aec_on);
-  bool update_agc = (mAgcOn != aPrefs.mAgcOn);
-  bool update_noise = (mNoiseOn != aPrefs.mNoiseOn);
+  bool update_agc = (mAgcOn != agc_on);
+  bool update_noise = (mNoiseOn != noise_on);
   mEchoOn = aec_on;
-  mAgcOn = aPrefs.mAgcOn;
-  mNoiseOn = aPrefs.mNoiseOn;
+  mAgcOn = agc_on;
+  mNoiseOn = noise_on;
 
   mPlayoutDelay = aPrefs.mPlayoutDelay;
   if ((webrtc::EcModes) aPrefs.mAec != webrtc::kEcUnchanged) {
     if (mEchoCancel != (webrtc::EcModes) aPrefs.mAec) {
       update_echo = true;
       mEchoCancel = (webrtc::EcModes) aPrefs.mAec;
     }
   }
--- a/dom/webidl/MediaStreamTrack.webidl
+++ b/dom/webidl/MediaStreamTrack.webidl
@@ -50,16 +50,18 @@ dictionary MediaTrackConstraintSet {
     long long browserWindow;
     boolean scrollWithPage;
     ConstrainDOMString deviceId;
     ConstrainLong viewportOffsetX;
     ConstrainLong viewportOffsetY;
     ConstrainLong viewportWidth;
     ConstrainLong viewportHeight;
     boolean echoCancellation;
+    boolean mozNoiseSuppression;
+    boolean mozAutoGainControl;
 };
 
 dictionary MediaTrackConstraints : MediaTrackConstraintSet {
     sequence<MediaTrackConstraintSet> advanced;
 };
 
 [Exposed=Window]
 interface MediaStreamTrack : EventTarget {
--- a/dom/webidl/MediaTrackSupportedConstraints.webidl
+++ b/dom/webidl/MediaTrackSupportedConstraints.webidl
@@ -12,16 +12,18 @@ dictionary MediaTrackSupportedConstraint
     boolean height = true;
     boolean aspectRatio;        // to be supported
     boolean frameRate = true;
     boolean facingMode = true;
     boolean volume;             // to be supported
     boolean sampleRate;         // to be supported
     boolean sampleSize;         // to be supported
     boolean echoCancellation = true;
+    boolean mozNoiseSuppression = true;
+    boolean mozAutoGainControl = true;
     boolean latency;            // to be supported
     boolean deviceId = true;
     boolean groupId;            // to be supported
 
     // Mozilla-specific extensions:
 
     // http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
     // OBE by http://w3c.github.io/mediacapture-screen-share