summaryrefslogtreecommitdiff
path: root/src/WebRTCLibPeerConnection.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-07-02 01:03:44 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-07-02 15:12:41 +0200
commitda20ebf3970e311af4fa7a0e0b52a58041ceac3e (patch)
tree4264358c3618a6db142d4cef4c0452decc3188d0 /src/WebRTCLibPeerConnection.cpp
parent3711ad23f6c936b494041845254565efed8ca6f8 (diff)
downloadfork-godot-webrtc-native-da20ebf3970e311af4fa7a0e0b52a58041ceac3e.tar.gz
fork-godot-webrtc-native-da20ebf3970e311af4fa7a0e0b52a58041ceac3e.tar.bz2
fork-godot-webrtc-native-da20ebf3970e311af4fa7a0e0b52a58041ceac3e.zip
Unified signalling thread.
Diffstat (limited to 'src/WebRTCLibPeerConnection.cpp')
-rw-r--r--src/WebRTCLibPeerConnection.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/WebRTCLibPeerConnection.cpp b/src/WebRTCLibPeerConnection.cpp
index d88760c..d95b1e6 100644
--- a/src/WebRTCLibPeerConnection.cpp
+++ b/src/WebRTCLibPeerConnection.cpp
@@ -5,6 +5,21 @@
using namespace godot_webrtc;
+std::unique_ptr<rtc::Thread> WebRTCLibPeerConnection::signaling_thread = nullptr;
+
+void WebRTCLibPeerConnection::initialize_signaling() {
+ if (signaling_thread.get() == nullptr) {
+ signaling_thread = rtc::Thread::Create();
+ }
+ signaling_thread->Start();
+}
+
+void WebRTCLibPeerConnection::deinitialize_signaling() {
+ if (signaling_thread.get() != nullptr) {
+ signaling_thread->Stop();
+ }
+}
+
godot_error _parse_ice_server(webrtc::PeerConnectionInterface::RTCConfiguration &r_config, godot::Dictionary p_server) {
godot::Variant v;
webrtc::PeerConnectionInterface::IceServer ice_server;
@@ -193,8 +208,7 @@ void WebRTCLibPeerConnection::_init() {
// create a PeerConnectionFactoryInterface:
webrtc::PeerConnectionFactoryDependencies deps;
- signaling_thread = rtc::Thread::Create();
- ERR_FAIL_COND(!signaling_thread->Start());
+ ERR_FAIL_COND(signaling_thread.get() == nullptr);
deps.signaling_thread = signaling_thread.get();
pc_factory = webrtc::CreateModularPeerConnectionFactory(std::move(deps));