Bug 1319445 - Don't use direct listener for audio in PeerConnection with full duplex. r?jesup, r?padenot draft
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 22 Nov 2016 17:56:16 +0100
changeset 458832 737d59b84c8f8511a810cef84277a44e932de2ab
parent 458532 7011ed1427de2b6f075c46cc6f4618d3e9fcd2a4
child 458833 49a4ca2fbb4f2cb38656b6a53bbf4ead4584a10f
child 459668 09f9e38230e83f924aec88c968ca34b04eaea4b8
push id41084
push userbmo:pehrson@telenordigital.com
push dateWed, 11 Jan 2017 07:27:23 +0000
reviewersjesup, padenot
bugs1319445
milestone53.0a1
Bug 1319445 - Don't use direct listener for audio in PeerConnection with full duplex. r?jesup, r?padenot MozReview-Commit-ID: 278Rrdzr3lQ
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -43,16 +43,17 @@
 #include "transportlayer.h"
 #include "transportlayerdtls.h"
 #include "transportlayerice.h"
 #include "runnable_utils.h"
 #include "libyuv/convert.h"
 #include "mozilla/SharedThreadPool.h"
 #if !defined(MOZILLA_EXTERNAL_LINKAGE)
 #include "mozilla/PeerIdentity.h"
+#include "mozilla/Preferences.h"
 #include "mozilla/TaskQueue.h"
 #endif
 #include "mozilla/gfx/Point.h"
 #include "mozilla/gfx/Types.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "mozilla/Sprintf.h"
 
@@ -1449,21 +1450,32 @@ void MediaPipelineTransmit::AttachToTrac
   description_ += track_id;
   description_ += "]";
 
   // TODO(ekr@rtfm.com): Check for errors
   MOZ_MTLOG(ML_DEBUG, "Attaching pipeline to track "
             << static_cast<void *>(domtrack_) << " conduit type=" <<
             (conduit_->type() == MediaSessionConduit::AUDIO ?"audio":"video"));
 
-  // Register the Listener directly with the source if we can.
-  // We also register it as a non-direct listener so we fall back to that
-  // if installing the direct listener fails. As a direct listener we get access
-  // to direct unqueued (and not resampled) data.
-  domtrack_->AddDirectListener(listener_);
+#if !defined(MOZILLA_EXTERNAL_LINKAGE)
+  // With full duplex we don't risk having audio come in late to the MSG
+  // so we won't need a direct listener.
+  const bool enableDirectListener =
+    !Preferences::GetBool("media.navigator.audio.full_duplex", false);
+#else
+  const bool enableDirectListener = true;
+#endif
+
+  if (enableDirectListener) {
+    // Register the Listener directly with the source if we can.
+    // We also register it as a non-direct listener so we fall back to that
+    // if installing the direct listener fails. As a direct listener we get access
+    // to direct unqueued (and not resampled) data.
+    domtrack_->AddDirectListener(listener_);
+  }
   domtrack_->AddListener(listener_);
 
 #ifndef MOZILLA_INTERNAL_API
   // this enables the unit tests that can't fiddle with principals and the like
   listener_->SetEnabled(true);
 #endif
 }