forked from mirrors/gecko-dev
Backed out 2 changesets (bug 1738931) for causing mochitest failures on VideoConduit and WatchManager CLOSED TREE
Backed out changeset fbaeb0434e8a (bug 1738931) Backed out changeset 3964c080fafc (bug 1738931)
This commit is contained in:
parent
918e308488
commit
0c12096cf2
8 changed files with 40 additions and 144 deletions
|
|
@ -331,13 +331,13 @@ std::vector<uint32_t> WebrtcAudioConduit::GetLocalSSRCs() const {
|
|||
return std::vector<uint32_t>(1, mRecvStreamConfig.rtp.local_ssrc);
|
||||
}
|
||||
|
||||
bool WebrtcAudioConduit::OverrideRemoteSSRC(uint32_t aSsrc) {
|
||||
bool WebrtcAudioConduit::OverrideRemoteSSRC(uint32_t ssrc) {
|
||||
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
|
||||
|
||||
if (mRecvStreamConfig.rtp.remote_ssrc == aSsrc) {
|
||||
if (mRecvStreamConfig.rtp.remote_ssrc == ssrc) {
|
||||
return true;
|
||||
}
|
||||
mRecvStreamConfig.rtp.remote_ssrc = aSsrc;
|
||||
mRecvStreamConfig.rtp.remote_ssrc = ssrc;
|
||||
|
||||
const bool wasReceiving = mRecvStreamRunning;
|
||||
const bool hadRecvStream = mRecvStream;
|
||||
|
|
|
|||
|
|
@ -159,10 +159,10 @@ class WebrtcAudioConduit : public AudioSessionConduit,
|
|||
*
|
||||
* Call thread only.
|
||||
*/
|
||||
bool OverrideRemoteSSRC(uint32_t aSsrc);
|
||||
bool OverrideRemoteSSRC(uint32_t ssrc);
|
||||
|
||||
public:
|
||||
void UnsetRemoteSSRC(uint32_t aSsrc) override {}
|
||||
void UnsetRemoteSSRC(uint32_t ssrc) override {}
|
||||
|
||||
Maybe<webrtc::AudioReceiveStream::Stats> GetReceiverStats() const override;
|
||||
Maybe<webrtc::AudioSendStream::Stats> GetSenderStats() const override;
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ class MediaSessionConduit {
|
|||
virtual Ssrcs GetLocalSSRCs() const = 0;
|
||||
|
||||
virtual Maybe<Ssrc> GetRemoteSSRC() const = 0;
|
||||
virtual void UnsetRemoteSSRC(Ssrc aSsrc) = 0;
|
||||
virtual void UnsetRemoteSSRC(Ssrc ssrc) = 0;
|
||||
|
||||
virtual bool HasCodecPluginID(uint64_t aPluginID) const = 0;
|
||||
|
||||
|
|
@ -358,6 +358,8 @@ class VideoSessionConduit : public MediaSessionConduit {
|
|||
|
||||
virtual void DisableSsrcChanges() = 0;
|
||||
|
||||
void UnsetRemoteSSRC(Ssrc ssrc) override = 0;
|
||||
|
||||
/**
|
||||
* Function to deliver a capture video frame for encoding and transport.
|
||||
* If the frame's timestamp is 0, it will be automatcally generated.
|
||||
|
|
|
|||
|
|
@ -976,40 +976,33 @@ void WebrtcVideoConduit::CreateRecvStream() {
|
|||
mRecvStreamConfig.rtp.remote_ssrc);
|
||||
}
|
||||
|
||||
void WebrtcVideoConduit::NotifyUnsetCurrentRemoteSSRC() {
|
||||
void WebrtcVideoConduit::SetRemoteSSRCConfig(uint32_t ssrc, uint32_t rtxSsrc) {
|
||||
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
|
||||
CSFLogDebug(LOGTAG, "%s (%p): Unsetting SSRC %u in other conduits",
|
||||
__FUNCTION__, this, mRecvStreamConfig.rtp.remote_ssrc);
|
||||
mMutex.AssertNotCurrentThreadOwns();
|
||||
// Don't unset (and call back into) ourselves.
|
||||
mCall->UnregisterConduit(this);
|
||||
mCall->UnsetRemoteSSRC(mRecvStreamConfig.rtp.remote_ssrc);
|
||||
|
||||
CSFLogDebug(LOGTAG, "%s: SSRC %u (0x%x)", __FUNCTION__, ssrc, ssrc);
|
||||
mCall->UnsetRemoteSSRC(ssrc);
|
||||
|
||||
// Remote SSRC set -- listen for unsets from other conduits.
|
||||
mCall->RegisterConduit(this);
|
||||
|
||||
mRecvSSRC = mRecvStreamConfig.rtp.remote_ssrc = ssrc;
|
||||
mRecvStreamConfig.rtp.rtx_ssrc = rtxSsrc;
|
||||
}
|
||||
|
||||
void WebrtcVideoConduit::SetRemoteSSRCConfig(uint32_t aSsrc,
|
||||
uint32_t aRtxSsrc) {
|
||||
void WebrtcVideoConduit::SetRemoteSSRCAndRestartAsNeeded(uint32_t ssrc,
|
||||
uint32_t rtxSsrc) {
|
||||
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
|
||||
mMutex.AssertNotCurrentThreadOwns();
|
||||
|
||||
CSFLogDebug(LOGTAG, "%s: SSRC %u (0x%x)", __FUNCTION__, aSsrc, aSsrc);
|
||||
|
||||
if (mRecvStreamConfig.rtp.remote_ssrc != aSsrc) {
|
||||
mWatchManager.ManualNotify(
|
||||
&WebrtcVideoConduit::NotifyUnsetCurrentRemoteSSRC);
|
||||
}
|
||||
|
||||
mRecvSSRC = mRecvStreamConfig.rtp.remote_ssrc = aSsrc;
|
||||
mRecvStreamConfig.rtp.rtx_ssrc = aRtxSsrc;
|
||||
}
|
||||
|
||||
void WebrtcVideoConduit::SetRemoteSSRCAndRestartAsNeeded(uint32_t aSsrc,
|
||||
uint32_t aRtxSsrc) {
|
||||
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
|
||||
|
||||
if (mRecvStreamConfig.rtp.remote_ssrc == aSsrc &&
|
||||
mRecvStreamConfig.rtp.rtx_ssrc == aRtxSsrc) {
|
||||
if (mRecvStreamConfig.rtp.remote_ssrc == ssrc &&
|
||||
mRecvStreamConfig.rtp.rtx_ssrc == rtxSsrc) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetRemoteSSRCConfig(aSsrc, aRtxSsrc);
|
||||
SetRemoteSSRCConfig(ssrc, rtxSsrc);
|
||||
|
||||
const bool wasReceiving = mEngineReceiving;
|
||||
const bool hadRecvStream = mRecvStream;
|
||||
|
|
@ -1072,12 +1065,12 @@ void WebrtcVideoConduit::EnsureLocalSSRC() {
|
|||
mRecvStreamConfig.rtp.local_ssrc = ssrcs[0];
|
||||
}
|
||||
|
||||
void WebrtcVideoConduit::UnsetRemoteSSRC(uint32_t aSsrc) {
|
||||
void WebrtcVideoConduit::UnsetRemoteSSRC(uint32_t ssrc) {
|
||||
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
|
||||
mMutex.AssertNotCurrentThreadOwns();
|
||||
|
||||
if (mRecvStreamConfig.rtp.remote_ssrc != aSsrc &&
|
||||
mRecvStreamConfig.rtp.rtx_ssrc != aSsrc) {
|
||||
if (mRecvStreamConfig.rtp.remote_ssrc != ssrc &&
|
||||
mRecvStreamConfig.rtp.rtx_ssrc != ssrc) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1085,12 +1078,10 @@ void WebrtcVideoConduit::UnsetRemoteSSRC(uint32_t aSsrc) {
|
|||
uint32_t our_ssrc = 0;
|
||||
do {
|
||||
our_ssrc = GenerateRandomSSRC();
|
||||
} while (NS_WARN_IF(our_ssrc == aSsrc) ||
|
||||
NS_WARN_IF(std::find(ssrcs.begin(), ssrcs.end(), our_ssrc) !=
|
||||
ssrcs.end()));
|
||||
|
||||
CSFLogDebug(LOGTAG, "%s (%p): Generated remote SSRC %u", __FUNCTION__, this,
|
||||
our_ssrc);
|
||||
} while (NS_WARN_IF(our_ssrc == ssrc) ||
|
||||
NS_WARN_IF(std::any_of(
|
||||
ssrcs.begin(), ssrcs.end(),
|
||||
[&](const auto& aSsrc) { return our_ssrc == aSsrc; })));
|
||||
|
||||
// There is a (tiny) chance that this new random ssrc will collide with some
|
||||
// other conduit's remote ssrc, in which case that conduit will choose a new
|
||||
|
|
@ -1153,7 +1144,6 @@ MediaConduitErrorCode WebrtcVideoConduit::Init() {
|
|||
|
||||
void WebrtcVideoConduit::InitCall() {
|
||||
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
|
||||
mCall->RegisterConduit(this);
|
||||
mSendPluginCreated = mEncoderFactory->CreatedGmpPluginEvent().Connect(
|
||||
GetMainThreadSerialEventTarget(),
|
||||
[self = detail::RawPtr(this)](uint64_t aPluginID) {
|
||||
|
|
|
|||
|
|
@ -157,15 +157,9 @@ class WebrtcVideoConduit
|
|||
Ssrcs GetLocalSSRCs() const override;
|
||||
Maybe<Ssrc> GetRemoteSSRC() const override;
|
||||
|
||||
// Call thread.
|
||||
void UnsetRemoteSSRC(uint32_t aSsrc) override;
|
||||
|
||||
private:
|
||||
void NotifyUnsetCurrentRemoteSSRC();
|
||||
void SetRemoteSSRCConfig(uint32_t aSsrc, uint32_t aRtxSsrc);
|
||||
void SetRemoteSSRCAndRestartAsNeeded(uint32_t aSsrc, uint32_t aRtxSsrc);
|
||||
|
||||
public:
|
||||
void UnsetRemoteSSRC(uint32_t ssrc) override;
|
||||
void SetRemoteSSRCConfig(uint32_t ssrc, uint32_t rtxSsrc);
|
||||
void SetRemoteSSRCAndRestartAsNeeded(uint32_t ssrc, uint32_t rtxSsrc);
|
||||
// Creating a recv stream or a send stream requires a local ssrc to be
|
||||
// configured. This method will generate one if needed.
|
||||
void EnsureLocalSSRC();
|
||||
|
|
@ -323,8 +317,8 @@ class WebrtcVideoConduit
|
|||
explicit Control(const RefPtr<AbstractThread>& aCallThread);
|
||||
} mControl;
|
||||
|
||||
// WatchManager allowing Mirrors and other watch targets to trigger functions
|
||||
// that will update the webrtc.org configuration.
|
||||
// WatchManager allowing Mirrors to trigger functions that will update the
|
||||
// webrtc.org configuration.
|
||||
WatchManager<WebrtcVideoConduit> mWatchManager;
|
||||
|
||||
mutable Mutex mMutex;
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MEDIA_WEBRTC_SIGNALING_GTEST_MOCKCONDUIT_H_
|
||||
#define MEDIA_WEBRTC_SIGNALING_GTEST_MOCKCONDUIT_H_
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "MediaConduitInterface.h"
|
||||
|
||||
namespace webrtc {
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
const webrtc::Call::Stats& aObj) {
|
||||
aStream << aObj.ToString(0);
|
||||
return aStream;
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
namespace mozilla {
|
||||
class MockConduit : public MediaSessionConduit {
|
||||
public:
|
||||
MockConduit() = default;
|
||||
|
||||
MOCK_CONST_METHOD0(type, Type());
|
||||
MOCK_METHOD1(SetTransportActive, void(bool));
|
||||
MOCK_METHOD0(SenderRtpSendEvent, MediaEventSourceExc<MediaPacket>&());
|
||||
MOCK_METHOD0(SenderRtcpSendEvent, MediaEventSourceExc<MediaPacket>&());
|
||||
MOCK_METHOD0(ReceiverRtcpSendEvent, MediaEventSourceExc<MediaPacket>&());
|
||||
MOCK_METHOD1(ConnectReceiverRtpEvent,
|
||||
void(MediaEventSourceExc<MediaPacket, webrtc::RTPHeader>&));
|
||||
MOCK_METHOD1(ConnectReceiverRtcpEvent,
|
||||
void(MediaEventSourceExc<MediaPacket>&));
|
||||
MOCK_METHOD1(ConnectSenderRtcpEvent, void(MediaEventSourceExc<MediaPacket>&));
|
||||
MOCK_CONST_METHOD0(LastRtcpReceived, Maybe<DOMHighResTimeStamp>());
|
||||
MOCK_CONST_METHOD1(RtpSendBaseSeqFor, Maybe<uint16_t>(uint32_t));
|
||||
MOCK_CONST_METHOD0(GetNow, DOMHighResTimeStamp());
|
||||
MOCK_CONST_METHOD0(GetTimestampMaker, dom::RTCStatsTimestampMaker&());
|
||||
MOCK_CONST_METHOD0(GetLocalSSRCs, Ssrcs());
|
||||
MOCK_CONST_METHOD0(GetRemoteSSRC, Maybe<Ssrc>());
|
||||
MOCK_METHOD1(UnsetRemoteSSRC, void(Ssrc));
|
||||
MOCK_CONST_METHOD1(HasCodecPluginID, bool(uint64_t));
|
||||
MOCK_METHOD0(RtcpByeEvent, MediaEventSource<void>&());
|
||||
MOCK_METHOD0(RtcpTimeoutEvent, MediaEventSource<void>&());
|
||||
MOCK_METHOD3(SendRtp,
|
||||
bool(const uint8_t*, size_t, const webrtc::PacketOptions&));
|
||||
MOCK_METHOD2(SendSenderRtcp, bool(const uint8_t*, size_t));
|
||||
MOCK_METHOD2(SendReceiverRtcp, bool(const uint8_t*, size_t));
|
||||
MOCK_METHOD2(DeliverPacket, void(rtc::CopyOnWriteBuffer, PacketType));
|
||||
MOCK_METHOD0(Shutdown, void());
|
||||
MOCK_METHOD0(AsAudioSessionConduit, Maybe<RefPtr<AudioSessionConduit>>());
|
||||
MOCK_METHOD0(AsVideoSessionConduit, Maybe<RefPtr<VideoSessionConduit>>());
|
||||
MOCK_CONST_METHOD0(GetCallStats, Maybe<webrtc::Call::Stats>());
|
||||
|
||||
MOCK_CONST_METHOD0(GetUpstreamRtpSources, std::vector<webrtc::RtpSource>());
|
||||
};
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
#include "media/base/video_adapter.h"
|
||||
|
||||
#include "MockCall.h"
|
||||
#include "MockConduit.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace testing;
|
||||
|
|
@ -1938,35 +1937,4 @@ TEST_F(VideoConduitTest, TestLocalAndRemoteSsrcCollision) {
|
|||
Call()->mVideoSendConfig->rtp.ssrcs[0]);
|
||||
}
|
||||
|
||||
TEST_F(VideoConduitTest, TestExternalRemoteSsrcCollision) {
|
||||
auto other = MakeRefPtr<MockConduit>();
|
||||
mCallWrapper->RegisterConduit(other);
|
||||
|
||||
// First the mControl update should trigger an UnsetRemoteSSRC(1) from us.
|
||||
// Then we simulate another conduit using that same ssrc, which should trigger
|
||||
// us to generate a fresh ssrc that is not 0 and not 1.
|
||||
{
|
||||
InSequence s;
|
||||
EXPECT_CALL(*other, UnsetRemoteSSRC(1U)).Times(2);
|
||||
EXPECT_CALL(*other, UnsetRemoteSSRC(Not(testing::AnyOf(0U, 1U))));
|
||||
}
|
||||
|
||||
mControl.Update([&](auto& aControl) {
|
||||
aControl.mRemoteSsrc = 1;
|
||||
aControl.mReceiving = true;
|
||||
});
|
||||
EXPECT_TRUE(Call()->mVideoReceiveConfig);
|
||||
EXPECT_EQ(Call()->mVideoReceiveConfig->rtp.remote_ssrc, 1U);
|
||||
|
||||
mozilla::Unused << WaitFor(InvokeAsync(
|
||||
GetCurrentSerialEventTarget(), __func__, [wrapper = mCallWrapper] {
|
||||
wrapper->UnsetRemoteSSRC(1);
|
||||
return GenericPromise::CreateAndResolve(true, __func__);
|
||||
}));
|
||||
|
||||
EXPECT_TRUE(Call()->mVideoReceiveConfig);
|
||||
EXPECT_THAT(Call()->mVideoReceiveConfig->rtp.remote_ssrc,
|
||||
Not(testing::AnyOf(0U, 1U)));
|
||||
}
|
||||
|
||||
} // End namespace test.
|
||||
|
|
|
|||
|
|
@ -211,7 +211,9 @@ class WatchManager {
|
|||
|
||||
void ManualNotify(CallbackMethod aMethod) {
|
||||
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
|
||||
EnsureWatcher(aMethod).Notify();
|
||||
PerCallbackWatcher* watcher = GetWatcher(aMethod);
|
||||
MOZ_ASSERT(watcher);
|
||||
watcher->Notify();
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Reference in a new issue