diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2019-06-13 15:52:46 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-01-03 19:35:20 +0100 |
commit | 5769d8b2de3a62e9e798d8fa59c71ba30f9cf88a (patch) | |
tree | d34c1a75c01ff606244d81234175977b9329937a /src | |
parent | 423454086e21d40a545f9e46d6e35c1b3c557d77 (diff) | |
download | fork-godot-webrtc-native-5769d8b2de3a62e9e798d8fa59c71ba30f9cf88a.tar.gz fork-godot-webrtc-native-5769d8b2de3a62e9e798d8fa59c71ba30f9cf88a.tar.bz2 fork-godot-webrtc-native-5769d8b2de3a62e9e798d8fa59c71ba30f9cf88a.zip |
Merge observers
Diffstat (limited to 'src')
-rw-r--r-- | src/GodotCreateSessionDescriptionObserver.cpp | 16 | ||||
-rw-r--r-- | src/GodotPeerConnectionObserver.cpp | 48 | ||||
-rw-r--r-- | src/GodotSetSessionDescriptionObserver.cpp | 11 | ||||
-rw-r--r-- | src/WebRTCLibObservers.cpp | 53 |
4 files changed, 53 insertions, 75 deletions
diff --git a/src/GodotCreateSessionDescriptionObserver.cpp b/src/GodotCreateSessionDescriptionObserver.cpp deleted file mode 100644 index f9d110c..0000000 --- a/src/GodotCreateSessionDescriptionObserver.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "WebRTCLibPeerConnection.hpp" - -using namespace godot_webrtc; - -WebRTCLibPeerConnection::GodotCSDO::GodotCSDO(WebRTCLibPeerConnection *parent) { - this->parent = parent; -} - -void WebRTCLibPeerConnection::GodotCSDO::OnSuccess(webrtc::SessionDescriptionInterface *desc) { - // serialize this offer and send it to the remote peer: - std::string sdp; // sdp = session description protocol - desc->ToString(&sdp); - parent->queue_signal("session_description_created", 2, desc->type().c_str(), sdp.c_str()); -}; - -void WebRTCLibPeerConnection::GodotCSDO::OnFailure(const std::string &error){}; diff --git a/src/GodotPeerConnectionObserver.cpp b/src/GodotPeerConnectionObserver.cpp deleted file mode 100644 index c3f8f39..0000000 --- a/src/GodotPeerConnectionObserver.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "WebRTCLibPeerConnection.hpp" -#include "WebRTCLibDataChannel.hpp" - -using namespace godot_webrtc; - -WebRTCLibPeerConnection::GodotPCO::GodotPCO(WebRTCLibPeerConnection *parent) { - this->parent = parent; -} - -void WebRTCLibPeerConnection::GodotPCO::OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) { -} - -void WebRTCLibPeerConnection::GodotPCO::OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) { -} - -void WebRTCLibPeerConnection::GodotPCO::OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) { -} - -void WebRTCLibPeerConnection::GodotPCO::OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) { - parent->queue_signal("data_channel_received", 1, WebRTCLibDataChannel::new_data_channel(data_channel)); -} - -void WebRTCLibPeerConnection::GodotPCO::OnRenegotiationNeeded() { -} - -void WebRTCLibPeerConnection::GodotPCO::OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) { -} - -void WebRTCLibPeerConnection::GodotPCO::OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) { -} - -void WebRTCLibPeerConnection::GodotPCO::OnIceCandidate(const webrtc::IceCandidateInterface *candidate) { - // Serialize the candidate and send it to the remote peer: - - 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); -} diff --git a/src/GodotSetSessionDescriptionObserver.cpp b/src/GodotSetSessionDescriptionObserver.cpp deleted file mode 100644 index 96d466c..0000000 --- a/src/GodotSetSessionDescriptionObserver.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "WebRTCLibPeerConnection.hpp" - -using namespace godot_webrtc; - -WebRTCLibPeerConnection::GodotSSDO::GodotSSDO(WebRTCLibPeerConnection *parent) { - this->parent = parent; -} - -void WebRTCLibPeerConnection::GodotSSDO::OnSuccess(){}; - -void WebRTCLibPeerConnection::GodotSSDO::OnFailure(const std::string &error){}; diff --git a/src/WebRTCLibObservers.cpp b/src/WebRTCLibObservers.cpp new file mode 100644 index 0000000..4564195 --- /dev/null +++ b/src/WebRTCLibObservers.cpp @@ -0,0 +1,53 @@ +#include "WebRTCLibDataChannel.hpp" +#include "WebRTCLibPeerConnection.hpp" + +using namespace godot_webrtc; + +// CreateSessionObseerver +WebRTCLibPeerConnection::GodotCSDO::GodotCSDO(WebRTCLibPeerConnection *parent) { + this->parent = parent; +} + +void WebRTCLibPeerConnection::GodotCSDO::OnSuccess(webrtc::SessionDescriptionInterface *desc) { + // serialize this offer and send it to the remote peer: + std::string sdp; // sdp = session description protocol + desc->ToString(&sdp); + parent->queue_signal("session_description_created", 2, desc->type().c_str(), sdp.c_str()); +}; + +void WebRTCLibPeerConnection::GodotCSDO::OnFailure(const std::string &error){}; + +// SetSessionObseerver +WebRTCLibPeerConnection::GodotSSDO::GodotSSDO(WebRTCLibPeerConnection *parent) { + this->parent = parent; +} + +void WebRTCLibPeerConnection::GodotSSDO::OnSuccess(){}; +void WebRTCLibPeerConnection::GodotSSDO::OnFailure(const std::string &error){}; + +// PeerConnectionObserver +WebRTCLibPeerConnection::GodotPCO::GodotPCO(WebRTCLibPeerConnection *parent) { + this->parent = parent; +} + +void WebRTCLibPeerConnection::GodotPCO::OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) { + parent->queue_signal("data_channel_received", 1, WebRTCLibDataChannel::new_data_channel(data_channel)); +} + +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); +} + +void WebRTCLibPeerConnection::GodotPCO::OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) {} +void WebRTCLibPeerConnection::GodotPCO::OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {} +void WebRTCLibPeerConnection::GodotPCO::OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {} +void WebRTCLibPeerConnection::GodotPCO::OnRenegotiationNeeded() {} +void WebRTCLibPeerConnection::GodotPCO::OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) {} +void WebRTCLibPeerConnection::GodotPCO::OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) {} |