From ce3f086ec46f23358df086005fa14558def0d12f Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 9 Jul 2021 01:31:29 +0200 Subject: Move observers implementations into PeerConnection. --- src/WebRTCLibPeerConnection.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/WebRTCLibPeerConnection.cpp') diff --git a/src/WebRTCLibPeerConnection.cpp b/src/WebRTCLibPeerConnection.cpp index 4b83ae6..eedeff0 100644 --- a/src/WebRTCLibPeerConnection.cpp +++ b/src/WebRTCLibPeerConnection.cpp @@ -7,6 +7,25 @@ using namespace godot_webrtc; std::unique_ptr WebRTCLibPeerConnection::signaling_thread = nullptr; +// PeerConnectionObserver +void WebRTCLibPeerConnection::GodotPCO::OnIceCandidate(const webrtc::IceCandidateInterface *candidate) { + godot::Dictionary candidateSDP; + godot::String candidateSdpMidName = candidate->sdp_mid().c_str(); + int candidateSdpMlineIndexName = candidate->sdp_mline_index(); + std::string sdp; + candidate->ToString(&sdp); + godot::String candidateSdpName = sdp.c_str(); + parent->queue_signal("ice_candidate_created", 3, candidateSdpMidName, candidateSdpMlineIndexName, candidateSdpName); +} + +// CreateSessionDescriptionObserver +void WebRTCLibPeerConnection::GodotCSDO::OnSuccess(webrtc::SessionDescriptionInterface *desc) { + // serialize this offer and send it to the remote peer: + std::string sdp; + desc->ToString(&sdp); + parent->queue_signal("session_description_created", 2, desc->type().c_str(), sdp.c_str()); +} + void WebRTCLibPeerConnection::initialize_signaling() { if (signaling_thread.get() == nullptr) { signaling_thread = rtc::Thread::Create(); -- cgit v1.2.3