summaryrefslogtreecommitdiff
path: root/indra/llwebrtc
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r--indra/llwebrtc/llwebrtc.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index 34d950b804..a92b480e3a 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -589,6 +589,9 @@ void LLWebRTCPeerConnectionImpl::terminate()
rtc::scoped_refptr<webrtc::MediaStreamInterface> localStream;
mLocalStream.swap(localStream);
+ mSignalingObserverList.clear();
+ mDataObserverList.clear();
+
mWebRTCImpl->PostSignalingTask(
[=]()
{
@@ -1100,7 +1103,10 @@ void LLWebRTCPeerConnectionImpl::OnSetRemoteDescriptionComplete(webrtc::RTCError
}
}
mCachedIceCandidates.clear();
- OnIceGatheringChange(mPeerConnection->ice_gathering_state());
+ if (mPeerConnection)
+ {
+ OnIceGatheringChange(mPeerConnection->ice_gathering_state());
+ }
}
@@ -1117,6 +1123,10 @@ void LLWebRTCPeerConnectionImpl::OnSetLocalDescriptionComplete(webrtc::RTCError
void LLWebRTCPeerConnectionImpl::OnStateChange()
{
+ if (!mDataChannel)
+ {
+ return;
+ }
RTC_LOG(LS_INFO) << __FUNCTION__ << " Data Channel State: " << webrtc::DataChannelInterface::DataStateString(mDataChannel->state());
switch (mDataChannel->state())
{
@@ -1160,7 +1170,12 @@ void LLWebRTCPeerConnectionImpl::sendData(const std::string& data, bool binary)
{
rtc::CopyOnWriteBuffer cowBuffer(data.data(), data.length());
webrtc::DataBuffer buffer(cowBuffer, binary);
- mDataChannel->Send(buffer);
+ mWebRTCImpl->PostNetworkTask([this, buffer]() {
+ if (mDataChannel)
+ {
+ mDataChannel->Send(buffer);
+ }
+ });
}
}