diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2022-09-11 17:31:57 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2022-09-16 13:07:06 +0200 |
commit | 1009e8bb1c822fbda2ae6d8178508b352cc6a5ff (patch) | |
tree | 191df97ffec9dbdf2836b230fabc074ddea9f82a /src/WebRTCLibPeerConnection.cpp | |
parent | 5fd359f67405d772f1a407e7a80b293d9e1f4b8b (diff) | |
download | fork-godot-webrtc-native-1009e8bb1c822fbda2ae6d8178508b352cc6a5ff.tar.gz fork-godot-webrtc-native-1009e8bb1c822fbda2ae6d8178508b352cc6a5ff.tar.bz2 fork-godot-webrtc-native-1009e8bb1c822fbda2ae6d8178508b352cc6a5ff.zip |
Add methods to get gathering and signaling state.
Diffstat (limited to 'src/WebRTCLibPeerConnection.cpp')
-rw-r--r-- | src/WebRTCLibPeerConnection.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/WebRTCLibPeerConnection.cpp b/src/WebRTCLibPeerConnection.cpp index 9b409a9..6f216e0 100644 --- a/src/WebRTCLibPeerConnection.cpp +++ b/src/WebRTCLibPeerConnection.cpp @@ -130,6 +130,42 @@ WebRTCPeerConnection::ConnectionState WebRTCLibPeerConnection::_get_connection_s } } +WebRTCLibPeerConnection::GatheringState WebRTCLibPeerConnection::_get_gathering_state() const { + ERR_FAIL_COND_V(peer_connection == nullptr, GATHERING_STATE_NEW); + + rtc::PeerConnection::GatheringState state = peer_connection->gatheringState(); + switch (state) { + case rtc::PeerConnection::GatheringState::New: + return GATHERING_STATE_NEW; + case rtc::PeerConnection::GatheringState::InProgress: + return GATHERING_STATE_GATHERING; + case rtc::PeerConnection::GatheringState::Complete: + return GATHERING_STATE_COMPLETE; + default: + return GATHERING_STATE_NEW; + } +} + +WebRTCLibPeerConnection::SignalingState WebRTCLibPeerConnection::_get_signaling_state() const { + ERR_FAIL_COND_V(peer_connection == nullptr, SIGNALING_STATE_CLOSED); + + rtc::PeerConnection::SignalingState state = peer_connection->signalingState(); + switch (state) { + case rtc::PeerConnection::SignalingState::Stable: + return SIGNALING_STATE_STABLE; + case rtc::PeerConnection::SignalingState::HaveLocalOffer: + return SIGNALING_STATE_HAVE_LOCAL_OFFER; + case rtc::PeerConnection::SignalingState::HaveRemoteOffer: + return SIGNALING_STATE_HAVE_REMOTE_OFFER; + case rtc::PeerConnection::SignalingState::HaveLocalPranswer: + return SIGNALING_STATE_HAVE_LOCAL_PRANSWER; + case rtc::PeerConnection::SignalingState::HaveRemotePranswer: + return SIGNALING_STATE_HAVE_REMOTE_PRANSWER; + default: + return SIGNALING_STATE_CLOSED; + } +} + Error WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) { rtc::Configuration config = {}; if (p_config.has("iceServers") && p_config["iceServers"].get_type() == Variant::ARRAY) { |