Skip to content

Commit d7fc6cd

Browse files
authored
Merge pull request #61 from Faless/bump/beta1
[Extension] Update to Godot 4.0 beta 1
2 parents 822e053 + 1009e8b commit d7fc6cd

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

src/WebRTCLibPeerConnection.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,42 @@ WebRTCPeerConnection::ConnectionState WebRTCLibPeerConnection::_get_connection_s
130130
}
131131
}
132132

133+
WebRTCLibPeerConnection::GatheringState WebRTCLibPeerConnection::_get_gathering_state() const {
134+
ERR_FAIL_COND_V(peer_connection == nullptr, GATHERING_STATE_NEW);
135+
136+
rtc::PeerConnection::GatheringState state = peer_connection->gatheringState();
137+
switch (state) {
138+
case rtc::PeerConnection::GatheringState::New:
139+
return GATHERING_STATE_NEW;
140+
case rtc::PeerConnection::GatheringState::InProgress:
141+
return GATHERING_STATE_GATHERING;
142+
case rtc::PeerConnection::GatheringState::Complete:
143+
return GATHERING_STATE_COMPLETE;
144+
default:
145+
return GATHERING_STATE_NEW;
146+
}
147+
}
148+
149+
WebRTCLibPeerConnection::SignalingState WebRTCLibPeerConnection::_get_signaling_state() const {
150+
ERR_FAIL_COND_V(peer_connection == nullptr, SIGNALING_STATE_CLOSED);
151+
152+
rtc::PeerConnection::SignalingState state = peer_connection->signalingState();
153+
switch (state) {
154+
case rtc::PeerConnection::SignalingState::Stable:
155+
return SIGNALING_STATE_STABLE;
156+
case rtc::PeerConnection::SignalingState::HaveLocalOffer:
157+
return SIGNALING_STATE_HAVE_LOCAL_OFFER;
158+
case rtc::PeerConnection::SignalingState::HaveRemoteOffer:
159+
return SIGNALING_STATE_HAVE_REMOTE_OFFER;
160+
case rtc::PeerConnection::SignalingState::HaveLocalPranswer:
161+
return SIGNALING_STATE_HAVE_LOCAL_PRANSWER;
162+
case rtc::PeerConnection::SignalingState::HaveRemotePranswer:
163+
return SIGNALING_STATE_HAVE_REMOTE_PRANSWER;
164+
default:
165+
return SIGNALING_STATE_CLOSED;
166+
}
167+
}
168+
133169
Error WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
134170
rtc::Configuration config = {};
135171
if (p_config.has("iceServers") && p_config["iceServers"].get_type() == Variant::ARRAY) {

src/WebRTCLibPeerConnection.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class WebRTCLibPeerConnection : public godot::WebRTCPeerConnectionExtension {
7373
void _init();
7474

7575
ConnectionState _get_connection_state() const override;
76+
GatheringState _get_gathering_state() const override;
77+
SignalingState _get_signaling_state() const override;
7678

7779
godot::Error _initialize(const godot::Dictionary &p_config) override;
7880
godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;

src/net/WebRTCPeerConnectionNative.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,30 @@ class WebRTCPeerConnectionNative : public godot::WebRTCPeerConnectionGDNative {
7575
};
7676

7777
public:
78+
enum GatheringState {
79+
GATHERING_STATE_NEW,
80+
GATHERING_STATE_GATHERING,
81+
GATHERING_STATE_COMPLETE,
82+
};
83+
84+
enum SignalingState {
85+
SIGNALING_STATE_STABLE,
86+
SIGNALING_STATE_HAVE_LOCAL_OFFER,
87+
SIGNALING_STATE_HAVE_REMOTE_OFFER,
88+
SIGNALING_STATE_HAVE_LOCAL_PRANSWER,
89+
SIGNALING_STATE_HAVE_REMOTE_PRANSWER,
90+
SIGNALING_STATE_CLOSED,
91+
};
92+
7893
static void _register_methods();
7994
static const godot_gdnative_ext_net_3_2_api_struct *_net_api;
8095

8196
void _init();
8297
void register_interface(const godot_net_webrtc_peer_connection *interface);
8398

8499
virtual ConnectionState _get_connection_state() const = 0;
100+
virtual GatheringState _get_gathering_state() const = 0;
101+
virtual SignalingState _get_signaling_state() const = 0;
85102

86103
virtual godot::Error _initialize(const godot::Dictionary &p_config) = 0;
87104
virtual godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) = 0;

0 commit comments

Comments
 (0)