Bug 694814: Patch 5 - Move AEC from PeerConnection to getUserMedia rs=padenot
☠☠ backed out by 63be52cd09c5 ☠ ☠
authorRandell Jesup <rjesup@jesup.org>
Wed, 02 Apr 2014 13:58:19 -0400
changeset 195792 6dc08e9fc7e89104ff27237cf81df5c8082fb81a
parent 195791 74e5c32c6fa2d51efbb2416ff1eae8a7b2f8ec3c
child 195793 1cf98d1c6b75e0c7b78e57befd9538d5e26f33b6
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs694814
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 694814: Patch 5 - Move AEC from PeerConnection to getUserMedia rs=padenot
content/media/webrtc/MediaEngineWebRTCAudio.cpp
dom/media/MediaManager.cpp
media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
media/webrtc/signaling/src/media-conduit/AudioConduit.h
--- a/content/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/content/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -183,48 +183,50 @@ MediaEngineWebRTCAudioSource::Config(boo
                                      bool aNoiseOn, uint32_t aNoise,
                                      int32_t aPlayoutDelay)
 {
   LOG(("Audio config: aec: %d, agc: %d, noise: %d",
        aEchoOn ? aEcho : -1,
        aAgcOn ? aAGC : -1,
        aNoiseOn ? aNoise : -1));
 
-  bool update_agc = (mAgcOn == aAgcOn);
-  bool update_noise = (mNoiseOn == aNoiseOn);
+  bool update_echo = (mEchoOn != aEchoOn);
+  bool update_agc = (mAgcOn != aAgcOn);
+  bool update_noise = (mNoiseOn != aNoiseOn);
+  mEchoOn = aEchoOn;
   mAgcOn = aAgcOn;
   mNoiseOn = aNoiseOn;
 
+  if ((webrtc::EcModes) aEcho != webrtc::kEcUnchanged) {
+    if (mEchoCancel != (webrtc::EcModes) aEcho) {
+      update_echo = true;
+      mEchoCancel = (webrtc::EcModes) aEcho;
+    }
+  }
   if ((webrtc::AgcModes) aAGC != webrtc::kAgcUnchanged) {
     if (mAGC != (webrtc::AgcModes) aAGC) {
       update_agc = true;
       mAGC = (webrtc::AgcModes) aAGC;
     }
   }
   if ((webrtc::NsModes) aNoise != webrtc::kNsUnchanged) {
     if (mNoiseSuppress != (webrtc::NsModes) aNoise) {
       update_noise = true;
       mNoiseSuppress = (webrtc::NsModes) aNoise;
     }
   }
   mPlayoutDelay = aPlayoutDelay;
 
   if (mInitDone) {
     int error;
-#if 0
-    // Until we can support feeding our full output audio from the browser
-    // through the MediaStream, this won't work.  Or we need to move AEC to
-    // below audio input and output, perhaps invoked from here.
-    mEchoOn = aEchoOn;
-    if ((webrtc::EcModes) aEcho != webrtc::kEcUnchanged)
-      mEchoCancel = (webrtc::EcModes) aEcho;
-    mVoEProcessing->SetEcStatus(mEchoOn, aEcho);
-#else
-    (void) aEcho; (void) aEchoOn; (void) mEchoCancel; // suppress warnings
-#endif
+
+    if (update_echo &&
+      0 != (error = mVoEProcessing->SetEcStatus(mEchoOn, (webrtc::EcModes) aEcho))) {
+      LOG(("%s Error setting Echo Status: %d ",__FUNCTION__, error));
+    }
 
     if (update_agc &&
       0 != (error = mVoEProcessing->SetAgcStatus(mAgcOn, (webrtc::AgcModes) aAGC))) {
       LOG(("%s Error setting AGC Status: %d ",__FUNCTION__, error));
     }
     if (update_noise &&
       0 != (error = mVoEProcessing->SetNsStatus(mNoiseOn, (webrtc::NsModes) aNoise))) {
       LOG(("%s Error setting NoiseSuppression Status: %d ",__FUNCTION__, error));
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -587,28 +587,16 @@ public:
     // that the MediaStream has started consuming. The listener is freed
     // when the page is invalidated (on navigation or close).
     mListener->Activate(stream.forget(), mAudioSource, mVideoSource);
 
     // Note: includes JS callbacks; must be released on MainThread
     TracksAvailableCallback* tracksAvailableCallback =
       new TracksAvailableCallback(mManager, mSuccess, mWindowID, trackunion);
 
-    // Dispatch to the media thread to ask it to start the sources,
-    // because that can take a while.
-    // Pass ownership of trackunion to the MediaOperationRunnable
-    // to ensure it's kept alive until the MediaOperationRunnable runs (at least).
-    nsIThread *mediaThread = MediaManager::GetThread();
-    nsRefPtr<MediaOperationRunnable> runnable(
-      new MediaOperationRunnable(MEDIA_START, mListener, trackunion,
-                                 tracksAvailableCallback,
-                                 mAudioSource, mVideoSource, false, mWindowID,
-                                 mError.forget()));
-    mediaThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
-
 #ifdef MOZ_WEBRTC
     // Right now these configs are only of use if webrtc is available
     nsresult rv;
     nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
     if (NS_SUCCEEDED(rv)) {
       nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
 
       if (branch) {
@@ -629,16 +617,28 @@ public:
         mListener->AudioConfig(aec_on, (uint32_t) aec,
                                agc_on, (uint32_t) agc,
                                noise_on, (uint32_t) noise,
                                playout_delay);
       }
     }
 #endif
 
+    // Dispatch to the media thread to ask it to start the sources,
+    // because that can take a while.
+    // Pass ownership of trackunion to the MediaOperationRunnable
+    // to ensure it's kept alive until the MediaOperationRunnable runs (at least).
+    nsIThread *mediaThread = MediaManager::GetThread();
+    nsRefPtr<MediaOperationRunnable> runnable(
+      new MediaOperationRunnable(MEDIA_START, mListener, trackunion,
+                                 tracksAvailableCallback,
+                                 mAudioSource, mVideoSource, false, mWindowID,
+                                 mError.forget()));
+    mediaThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
+
     // We won't need mError now.
     mError = nullptr;
     return NS_OK;
   }
 
 private:
   nsCOMPtr<nsIDOMGetUserMediaSuccessCallback> mSuccess;
   nsCOMPtr<nsIDOMGetUserMediaErrorCallback> mError;
--- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
@@ -408,37 +408,21 @@ WebrtcAudioConduit::ConfigureSendMediaCo
 #ifdef MOZILLA_INTERNAL_API
   // TEMPORARY - see bug 694814 comment 2
   nsresult rv;
   nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
   if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
 
     if (branch) {
-      int32_t aec = 0; // 0 == unchanged
-      bool aec_on = false;
-
-      branch->GetBoolPref("media.peerconnection.aec_enabled", &aec_on);
-      branch->GetIntPref("media.peerconnection.aec", &aec);
-
-      CSFLogDebug(logTag,"Audio config: aec: %d", aec_on ? aec : -1);
-      mEchoOn = aec_on;
-      if (static_cast<webrtc::EcModes>(aec) != webrtc::kEcUnchanged)
-        mEchoCancel = static_cast<webrtc::EcModes>(aec);
-
       branch->GetIntPref("media.peerconnection.capture_delay", &mCaptureDelay);
     }
   }
 #endif
 
-  if (0 != (error = mPtrVoEProcessing->SetEcStatus(mEchoOn, mEchoCancel))) {
-    CSFLogError(logTag,"%s Error setting EVStatus: %d ",__FUNCTION__, error);
-    return kMediaConduitUnknownError;
-  }
-
   //Let's Send Transport State-machine on the Engine
   if(mPtrVoEBase->StartSend(mChannel) == -1)
   {
     error = mPtrVoEBase->LastError();
     CSFLogError(logTag, "%s StartSend failed %d", __FUNCTION__, error);
     return kMediaConduitUnknownError;
   }
 
--- a/media/webrtc/signaling/src/media-conduit/AudioConduit.h
+++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.h
@@ -157,18 +157,16 @@ public:
                       mShutDown(false),
                       mVoiceEngine(nullptr),
                       mTransport(nullptr),
                       mEngineTransmitting(false),
                       mEngineReceiving(false),
                       mChannel(-1),
                       mCurSendCodecConfig(nullptr),
                       mCaptureDelay(150),
-                      mEchoOn(true),
-                      mEchoCancel(webrtc::kEcAec),
 #ifdef MOZILLA_INTERNAL_API
                       mLastTimestamp(0),
 #endif // MOZILLA_INTERNAL_API
                       mSamples(0),
                       mLastSyncLog(0)
   {
   }
 
@@ -259,19 +257,16 @@ private:
 
   int mChannel;
   RecvCodecList    mRecvCodecList;
   AudioCodecConfig* mCurSendCodecConfig;
 
   // Current "capture" delay (really output plus input delay)
   int32_t mCaptureDelay;
 
-  bool mEchoOn;
-  webrtc::EcModes  mEchoCancel;
-
 #ifdef MOZILLA_INTERNAL_API
   uint32_t mLastTimestamp;
 #endif // MOZILLA_INTERNAL_API
 
   uint32_t mSamples;
   uint32_t mLastSyncLog;
 };