WebRTC: Add DeleteStreams to media conduits.

This commit is contained in:
wolfbeast 2018-07-01 12:57:51 +02:00 • committed by Roy Tam
commit 4131396b59
6 changed files with 16 additions and 4 deletions

View file

@ -161,6 +161,8 @@ public:
virtual uint64_t CodecPluginID() override { return 0; } virtual uint64_t CodecPluginID() override { return 0; }
virtual void DeleteStreams() override {}
WebrtcAudioConduit(): WebrtcAudioConduit():
mVoiceEngine(nullptr), mVoiceEngine(nullptr),
mTransportMonitor("WebrtcAudioConduit"), mTransportMonitor("WebrtcAudioConduit"),

View file

@ -227,6 +227,8 @@ public:
uint64_t* bytesSent) = 0; uint64_t* bytesSent) = 0;
virtual uint64_t CodecPluginID() = 0; virtual uint64_t CodecPluginID() = 0;
virtual void DeleteStreams() = 0;
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaSessionConduit) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaSessionConduit)

View file

@ -109,7 +109,7 @@ WebrtcVideoConduit::~WebrtcVideoConduit()
// Release AudioConduit first by dropping reference on MainThread, where it expects to be // Release AudioConduit first by dropping reference on MainThread, where it expects to be
SyncTo(nullptr); SyncTo(nullptr);
Destroy(); MOZ_ASSERT(!mSendStream && !mRecvStream, "Call DeleteStreams prior to ~WebrtcVideoConduit.");
} }
bool WebrtcVideoConduit::SetLocalSSRC(unsigned int ssrc) bool WebrtcVideoConduit::SetLocalSSRC(unsigned int ssrc)
@ -478,7 +478,7 @@ WebrtcVideoConduit::Init()
} }
void void
WebrtcVideoConduit::Destroy() WebrtcVideoConduit::DeleteStreams()
{ {
// The first one of a pair to be deleted shuts down media for both // The first one of a pair to be deleted shuts down media for both
//Deal with External Capturer //Deal with External Capturer

View file

@ -269,6 +269,8 @@ public:
return mSendingHeight; return mSendingHeight;
} }
virtual void DeleteStreams() override;
unsigned int SendingMaxFs() override { unsigned int SendingMaxFs() override {
if(mCurSendCodecConfig) { if(mCurSendCodecConfig) {
return mCurSendCodecConfig->mEncodingConstraints.maxFs; return mCurSendCodecConfig->mEncodingConstraints.maxFs;
@ -288,7 +290,6 @@ public:
MediaConduitErrorCode InitMain(); MediaConduitErrorCode InitMain();
virtual MediaConduitErrorCode Init(); virtual MediaConduitErrorCode Init();
virtual void Destroy();
int GetChannel() { return mChannel; } int GetChannel() { return mChannel; }
webrtc::VideoEngine* GetVideoEngine() { return mVideoEngine; } webrtc::VideoEngine* GetVideoEngine() { return mVideoEngine; }

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public :SelfDestruct_m/* 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, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -1036,6 +1036,11 @@ PeerConnectionMedia::SelfDestruct_m()
mLocalSourceStreams.Clear(); mLocalSourceStreams.Clear();
mRemoteSourceStreams.Clear(); mRemoteSourceStreams.Clear();
// Clean up our send and receive streams
for (auto i = mConduits.begin(); i != mConduits.end(); ++i) {
i->second.second->DeleteStreams();
}
mMainThread = nullptr; mMainThread = nullptr;
// Final self-destruct. // Final self-destruct.

View file

@ -810,6 +810,8 @@ class TransportConduitTest : public ::testing::Test
err = videoSession->ConfigureSendMediaCodec(nullptr); err = videoSession->ConfigureSendMediaCodec(nullptr);
EXPECT_TRUE(err != mozilla::kMediaConduitNoError); EXPECT_TRUE(err != mozilla::kMediaConduitNoError);
videoSession->DeleteStreams();
mozilla::SyncRunnable::DispatchToThread(gMainThread, mozilla::SyncRunnable::DispatchToThread(gMainThread,
WrapRunnable( WrapRunnable(