From 04bf88fa7d6ce4ba369ecc9ce33be2c57bd392df Mon Sep 17 00:00:00 2001 From: Noemi Erli Date: Wed, 27 Mar 2019 21:40:55 +0200 Subject: [PATCH] Backed out 4 changesets (bug 1506884) for mochitest failures CLOSED TREE Backed out changeset c1e32495cfa2 (bug 1506884) Backed out changeset 0182d6543001 (bug 1506884) Backed out changeset 5837db3740b5 (bug 1506884) Backed out changeset 1584d9804aa1 (bug 1506884) --- .../gtest/audioconduit_unittests.cpp | 2 - .../gtest/mediaconduit_unittests.cpp | 15 +---- .../gtest/mediapipeline_unittest.cpp | 11 +--- .../src/media-conduit/AudioConduit.cpp | 32 +++++------ .../src/media-conduit/AudioConduit.h | 56 ++++++------------- .../src/media-conduit/VideoConduit.h | 1 - modules/libpref/init/all.js | 11 ++++ 7 files changed, 48 insertions(+), 80 deletions(-) diff --git a/media/webrtc/signaling/gtest/audioconduit_unittests.cpp b/media/webrtc/signaling/gtest/audioconduit_unittests.cpp index ec4d1a6938ab..b6198a5b011a 100644 --- a/media/webrtc/signaling/gtest/audioconduit_unittests.cpp +++ b/media/webrtc/signaling/gtest/audioconduit_unittests.cpp @@ -78,8 +78,6 @@ class AudioConduitTest : public ::testing::Test { mAudioConduit->Init(); } - ~AudioConduitTest() { mAudioConduit->DeleteStreams(); } - MockCall* mCall; RefPtr mAudioConduit; }; diff --git a/media/webrtc/signaling/gtest/mediaconduit_unittests.cpp b/media/webrtc/signaling/gtest/mediaconduit_unittests.cpp index cc6762e2406b..9087d6278fd7 100644 --- a/media/webrtc/signaling/gtest/mediaconduit_unittests.cpp +++ b/media/webrtc/signaling/gtest/mediaconduit_unittests.cpp @@ -274,20 +274,7 @@ class WebrtcMediaTransport : public mozilla::TransportInterface { public: WebrtcMediaTransport() : numPkts(0), mAudio(false), mVideo(false) {} - ~WebrtcMediaTransport() { - if (mAudioSession) { - mAudioSession->DeleteStreams(); - } - if (mOtherAudioSession) { - mOtherAudioSession->DeleteStreams(); - } - if (mVideoSession) { - mVideoSession->DeleteStreams(); - } - if (mOtherVideoSession) { - mOtherVideoSession->DeleteStreams(); - } - } + ~WebrtcMediaTransport() {} virtual nsresult SendRtpPacket(const uint8_t* data, size_t len) { ++numPkts; diff --git a/media/webrtc/signaling/gtest/mediapipeline_unittest.cpp b/media/webrtc/signaling/gtest/mediapipeline_unittest.cpp index 487bb4c1c817..51befc7547ce 100644 --- a/media/webrtc/signaling/gtest/mediapipeline_unittest.cpp +++ b/media/webrtc/signaling/gtest/mediapipeline_unittest.cpp @@ -267,15 +267,8 @@ class TestAgent { void Shutdown_s() { transport_->Shutdown(); } void Shutdown() { - if (audio_pipeline_) { - audio_pipeline_->Shutdown_m(); - } - if (audio_stream_track_) { - audio_stream_track_->Stop(); - } - if (audio_conduit_) { - audio_conduit_->DeleteStreams(); - } + if (audio_pipeline_) audio_pipeline_->Shutdown_m(); + if (audio_stream_track_) audio_stream_track_->Stop(); mozilla::SyncRunnable::DispatchToThread( test_utils->sts_target(), WrapRunnable(this, &TestAgent::Shutdown_s)); diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp index 2dbfb5db7649..1e8a96949dc4 100644 --- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp @@ -75,15 +75,15 @@ WebrtcAudioConduit::~WebrtcAudioConduit() { MOZ_ASSERT(NS_IsMainThread()); MutexAutoLock lock(mMutex); + DeleteSendStream(); + DeleteRecvStream(); + DeleteChannels(); // We don't Terminate() the VoEBase here, because the Call (owned by // PeerConnectionMedia) actually owns the (shared) VoEBase/VoiceEngine // here mPtrVoEBase = nullptr; - - MOZ_ASSERT(!mSendStream && !mRecvStream, - "Call DeleteStreams prior to ~WebrtcAudioConduit."); } bool WebrtcAudioConduit::SetLocalSSRCs( @@ -364,6 +364,18 @@ MediaConduitErrorCode WebrtcAudioConduit::ConfigureSendMediaCodec( mDtmfEnabled = codecConfig->mDtmfEnabled; + // TEMPORARY - see bug 694814 comment 2 + nsresult rv; + nsCOMPtr prefs = + do_GetService("@mozilla.org/preferences-service;1", &rv); + if (NS_SUCCEEDED(rv)) { + nsCOMPtr branch = do_QueryInterface(prefs); + + if (branch) { + branch->GetIntPref("media.peerconnection.capture_delay", &mCaptureDelay); + } + } + condError = StartTransmitting(); if (condError != kMediaConduitNoError) { return condError; @@ -559,6 +571,7 @@ MediaConduitErrorCode WebrtcAudioConduit::SendAudioFrame( return kMediaConduitSessionNotInited; } + capture_delay = mCaptureDelay; // Insert the samples mPtrVoEBase->audio_transport()->PushCaptureData( mSendChannel, audio_data, @@ -923,7 +936,6 @@ MediaConduitErrorCode WebrtcAudioConduit::ValidateCodecConfig( } void WebrtcAudioConduit::DeleteSendStream() { - MOZ_ASSERT(NS_IsMainThread()); mMutex.AssertCurrentThreadOwns(); if (mSendStream) { mSendStream->Stop(); @@ -936,7 +948,6 @@ void WebrtcAudioConduit::DeleteSendStream() { } MediaConduitErrorCode WebrtcAudioConduit::CreateSendStream() { - MOZ_ASSERT(NS_IsMainThread()); mMutex.AssertCurrentThreadOwns(); mSendStream = mCall->Call()->CreateAudioSendStream(mSendStreamConfig); @@ -948,7 +959,6 @@ MediaConduitErrorCode WebrtcAudioConduit::CreateSendStream() { } void WebrtcAudioConduit::DeleteRecvStream() { - MOZ_ASSERT(NS_IsMainThread()); mMutex.AssertCurrentThreadOwns(); if (mRecvStream) { mRecvStream->Stop(); @@ -961,7 +971,6 @@ void WebrtcAudioConduit::DeleteRecvStream() { } MediaConduitErrorCode WebrtcAudioConduit::CreateRecvStream() { - MOZ_ASSERT(NS_IsMainThread()); mMutex.AssertCurrentThreadOwns(); mRecvStreamConfig.rtcp_send_transport = this; @@ -1025,14 +1034,6 @@ MediaConduitErrorCode WebrtcAudioConduit::DeliverPacket(const void* data, return kMediaConduitNoError; } -void WebrtcAudioConduit::DeleteStreams() { - MOZ_ASSERT(NS_IsMainThread()); - - MutexAutoLock lock(mMutex); - DeleteSendStream(); - DeleteRecvStream(); -} - MediaConduitErrorCode WebrtcAudioConduit::CreateChannels() { MOZ_ASSERT(NS_IsMainThread()); @@ -1074,7 +1075,6 @@ MediaConduitErrorCode WebrtcAudioConduit::CreateChannels() { void WebrtcAudioConduit::DeleteChannels() { MOZ_ASSERT(NS_IsMainThread()); - mMutex.AssertCurrentThreadOwns(); if (mSendChannel != -1) { mSendChannelProxy = nullptr; diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.h b/media/webrtc/signaling/src/media-conduit/AudioConduit.h index fe1ed63364e1..1c9da79e77be 100644 --- a/media/webrtc/signaling/src/media-conduit/AudioConduit.h +++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.h @@ -170,11 +170,12 @@ class WebrtcAudioConduit : public AudioSessionConduit, void SetPCHandle(const std::string& aPCHandle) override {} MediaConduitErrorCode DeliverPacket(const void* data, int len) override; - void DeleteStreams() override; + void DeleteStreams() override {} WebrtcAudioConduit(RefPtr aCall, nsCOMPtr aStsThread) - : mTransportMonitor("WebrtcAudioConduit"), + : mFakeAudioDevice(new webrtc::FakeAudioDeviceModule()), + mTransportMonitor("WebrtcAudioConduit"), mTransmitterTransport(nullptr), mReceiverTransport(nullptr), mCall(aCall), @@ -191,6 +192,7 @@ class WebrtcAudioConduit : public AudioSessionConduit, mSendChannel(-1), mDtmfEnabled(false), mMutex("WebrtcAudioConduit::mMutex"), + mCaptureDelay(150), mStsThread(aStsThread) {} virtual ~WebrtcAudioConduit(); @@ -250,16 +252,7 @@ class WebrtcAudioConduit : public AudioSessionConduit, protected: // These are protected so they can be accessed by unit tests - - // Written only on main thread. Accessed from audio thread. - // Accessed from mStsThread during stats calls. - // This is safe, provided audio and stats calls stop before we - // destroy the AudioConduit. std::unique_ptr mRecvChannelProxy = nullptr; - - // Written only on main thread. Accessed from mStsThread during stats calls. - // This is safe, provided stats calls stop before we destroy the - // AudioConduit. std::unique_ptr mSendChannelProxy = nullptr; private: @@ -288,39 +281,20 @@ class WebrtcAudioConduit : public AudioSessionConduit, MediaConduitErrorCode CreateChannels(); virtual void DeleteChannels(); + UniquePtr mFakeAudioDevice; mozilla::ReentrantMonitor mTransportMonitor; - - // Accessed on any thread under mTransportMonitor. RefPtr mTransmitterTransport; - - // Accessed on any thread under mTransportMonitor. RefPtr mReceiverTransport; - - // Accessed from main thread and audio threads. Used to create and destroy - // channels and to send audio data. Access to channels is protected by - // locking in channel.cc. ScopedCustomReleasePtr mPtrVoEBase; - // Const so can be accessed on any thread. Most methods are called on - // main thread. const RefPtr mCall; - - // Written only on main thread. Guarded by mMutex, except for reads on main. webrtc::AudioReceiveStream::Config mRecvStreamConfig; - - // Written only on main thread. Guarded by mMutex, except for reads on main. webrtc::AudioReceiveStream* mRecvStream; - - // Written only on main thread. Guarded by mMutex, except for reads on main. webrtc::AudioSendStream::Config mSendStreamConfig; - - // Written only on main thread. Guarded by mMutex, except for reads on main. webrtc::AudioSendStream* mSendStream; // accessed on creation, and when receiving packets Atomic mRecvSSRC; // this can change during a stream! - - // Accessed only on mStsThread. RtpPacketQueue mRtpPacketQueue; // engine states of our interets @@ -329,22 +303,28 @@ class WebrtcAudioConduit : public AudioSessionConduit, mozilla::Atomic mEngineReceiving; // If true => VoiceEngine Receive-subsystem is up // and playout is enabled + // Keep track of each inserted RTP block and the time it was inserted + // so we can estimate the clock time for a specific TimeStamp coming out + // (for when we send data to MediaStreamTracks). Blocks are aged out as + // needed. + struct Processing { + TimeStamp mTimeStamp; + uint32_t mRTPTimeStamp; // RTP timestamps received + }; + AutoTArray mProcessing; - // Accessed only on main thread. int mRecvChannel; - - // Accessed on main thread and from audio thread. int mSendChannel; - - // Accessed only on main thread. bool mDtmfEnabled; Mutex mMutex; + nsAutoPtr mCurSendCodecConfig; + + // Current "capture" delay (really output plus input delay) + int32_t mCaptureDelay; - // Accessed from audio thread. webrtc::AudioFrame mAudioFrame; // for output pulls - // Accessed from both main and mStsThread. Uses locks internally. RtpSourceObserver mRtpSourceObserver; // Socket transport service thread. Any thread. diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.h b/media/webrtc/signaling/src/media-conduit/VideoConduit.h index a232fa2d28b4..62e0b4596116 100644 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h @@ -591,7 +591,6 @@ class WebrtcVideoConduit // and when receiving packets (sts). Atomic mRecvSSRC; // this can change during a stream! - // Accessed only on mStsThread. RtpPacketQueue mRtpPacketQueue; // The lifetime of these codecs are maintained by the VideoConduit instance. diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index f0daba01c2c0..a0b18acd48e5 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -528,8 +528,19 @@ pref("media.getusermedia.aec_extended_filter", true); pref("media.getusermedia.noise", 1); // kModerate pref("media.getusermedia.agc_enabled", true); pref("media.getusermedia.agc", 1); // kAdaptiveDigital +// capture_delay: Adjustments for OS-specific input delay (lower bound) +// playout_delay: Adjustments for OS-specific AudioStream+cubeb+output delay (lower bound) // full_duplex: enable cubeb full-duplex capture/playback pref("media.navigator.audio.full_duplex", true); +#if defined(XP_MACOSX) +pref("media.peerconnection.capture_delay", 50); +#elif defined(XP_WIN) +pref("media.peerconnection.capture_delay", 50); +#elif defined(ANDROID) +pref("media.peerconnection.capture_delay", 100); +#else +pref("media.peerconnection.capture_delay", 70); +#endif #endif pref("dom.webaudio.enabled", true);