diff options
author | Roxie Linden <roxie@lindenlab.com> | 2023-09-12 15:17:08 -0700 |
---|---|---|
committer | Roxie Linden <roxie@lindenlab.com> | 2024-02-22 23:11:33 -0800 |
commit | a974a1517901eb0a93099853a89bf55904737cec (patch) | |
tree | bf7496e58e72d3c3f9f0779305ea1e23192c6e55 /indra/llwebrtc | |
parent | 6d81e64348009c1bb656fe500e9a08ab7f739311 (diff) |
do some thread safety to prevent webrtc threads from conflicting with viewer threads.
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r-- | indra/llwebrtc/llwebrtc.cpp | 35 | ||||
-rw-r--r-- | indra/llwebrtc/llwebrtc.h | 1 |
2 files changed, 32 insertions, 4 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index e7a9072b2e..c2631b2ea3 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -389,6 +389,36 @@ void LLWebRTCImpl::OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGath void LLWebRTCImpl::OnConnectionChange(webrtc::PeerConnectionInterface::PeerConnectionState new_state) { RTC_LOG(LS_ERROR) << __FUNCTION__ << " Peer Connection State Change " << new_state; + + switch (new_state) + { + case webrtc::PeerConnectionInterface::PeerConnectionState::kConnected: + { + if (new_state == webrtc::PeerConnectionInterface::PeerConnectionState::kConnected) + { + for (auto &observer : mSignalingObserverList) + { + observer->OnAudioEstablished(this); + } + } + break; + } + case webrtc::PeerConnectionInterface::PeerConnectionState::kDisconnected: + { + if (new_state == webrtc::PeerConnectionInterface::PeerConnectionState::kConnected) + { + for (auto &observer : mSignalingObserverList) + { + observer->OnRenegotiationNeeded(); + } + } + break; + } + default: + { + break; + } + } } void LLWebRTCImpl::OnIceCandidate(const webrtc::IceCandidateInterface *candidate) @@ -447,10 +477,6 @@ void LLWebRTCImpl::OnSetRemoteDescriptionComplete(webrtc::RTCError error) RTC_LOG(LS_ERROR) << ToString(error.type()) << ": " << error.message(); return; } - for (auto &observer : mSignalingObserverList) - { - observer->OnAudioEstablished(this); - } } // @@ -467,6 +493,7 @@ void LLWebRTCImpl::OnSetLocalDescriptionComplete(webrtc::RTCError error) auto desc = mPeerConnection->pending_local_description(); std::string sdp; desc->ToString(&sdp); + RTC_LOG(LS_INFO) << __FUNCTION__ << " Local SDP: " << sdp; for (auto &observer : mSignalingObserverList) { observer->OnOfferAvailable(sdp); diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h index cb639ee116..acc3665e95 100644 --- a/indra/llwebrtc/llwebrtc.h +++ b/indra/llwebrtc/llwebrtc.h @@ -106,6 +106,7 @@ class LLWebRTCSignalingObserver virtual void OnIceGatheringState(IceGatheringState state) = 0; virtual void OnIceCandidate(const LLWebRTCIceCandidate& candidate) = 0; virtual void OnOfferAvailable(const std::string& sdp) = 0; + virtual void OnRenegotiationNeeded() = 0; virtual void OnAudioEstablished(LLWebRTCAudioInterface *audio_interface) = 0; }; |