summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-09-11 14:16:30 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-09-11 15:34:08 +0200
commit6e52fce98660dc9eaa832d682bf38e2ea742e5b6 (patch)
treed3b59859a2dec39c1a43d87b6836e78f127738df
parenta93af67d756e65161b81683c32fa66efd6f47ec6 (diff)
downloadfork-godot-webrtc-native-6e52fce98660dc9eaa832d682bf38e2ea742e5b6.tar.gz
fork-godot-webrtc-native-6e52fce98660dc9eaa832d682bf38e2ea742e5b6.tar.bz2
fork-godot-webrtc-native-6e52fce98660dc9eaa832d682bf38e2ea742e5b6.zip
Update sources to alpha16
-rw-r--r--.github/workflows/build_release.yml4
-rw-r--r--SConstruct7
-rw-r--r--builders.py4
-rw-r--r--src/WebRTCLibDataChannel.cpp24
-rw-r--r--src/WebRTCLibDataChannel.hpp13
-rw-r--r--src/WebRTCLibPeerConnection.cpp38
-rw-r--r--src/WebRTCLibPeerConnection.hpp15
-rw-r--r--src/net/WebRTCDataChannelNative.cpp2
-rw-r--r--src/net/WebRTCDataChannelNative.hpp12
-rw-r--r--src/net/WebRTCPeerConnectionNative.hpp14
10 files changed, 64 insertions, 69 deletions
diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml
index d9cfd6e..2d0f044 100644
--- a/.github/workflows/build_release.yml
+++ b/.github/workflows/build_release.yml
@@ -84,12 +84,12 @@ jobs:
os: 'ubuntu-20.04'
# macOS
- - platform: osx
+ - platform: macos
arch: 'x86_64'
gdnative_flags: 'macos_arch=x86_64 bits=64'
sconsflags: ''
os: 'macos-11'
- - platform: osx
+ - platform: macos
gdnative_flags: 'macos_arch=arm64 bits=64'
arch: 'arm64'
sconsflags: ''
diff --git a/SConstruct b/SConstruct
index d352db5..66c6177 100644
--- a/SConstruct
+++ b/SConstruct
@@ -23,6 +23,9 @@ opts.Add(EnumVariable("godot_version", "The Godot target version", "4", ["3", "4
opts.Update(env)
if env["godot_version"] == "3":
+ if "platform" in ARGUMENTS and ARGUMENTS["platform"] == "macos":
+ ARGUMENTS["platform"] = "osx" # compatibility with old osx name
+
env = SConscript("godot-cpp-3.x/SConstruct")
# Patch base env
@@ -41,6 +44,10 @@ if env["godot_version"] == "3":
if env["platform"] == "windows" and env["use_mingw"]:
env.Append(LINKFLAGS=["-static-libgcc"])
+ if env["platform"] == "osx":
+ env["platform"] = "macos" # compatibility with old osx name
+ ARGUMENTS["platform"] = "macos"
+
# Normalize suffix
if env["platform"] in ["windows", "linux"]:
env["arch"] = "x86_32" if env["bits"] == "32" else "x86_64"
diff --git a/builders.py b/builders.py
index 2c682bc..8f85cd3 100644
--- a/builders.py
+++ b/builders.py
@@ -88,7 +88,7 @@ def ssl_action(target, source, env):
ssl_env.PrependENVPath("PATH", os.path.dirname(env["CC"]))
ssl_env["ENV"]["ANDROID_NDK_ROOT"] = os.environ.get("ANDROID_NDK_ROOT", "")
- elif env["platform"] == "osx":
+ elif env["platform"] == "macos":
if env["arch"] == "x86_64":
args.extend(["darwin64-x86_64"])
elif env["arch"] == "arm64":
@@ -191,7 +191,7 @@ def rtc_action(target, source, env):
"-DCMAKE_C_FLAGS=-m64",
"-DCMAKE_CXX_FLAGS=-m64"
])
- elif env["platform"] == "osx":
+ elif env["platform"] == "macos":
if env["macos_deployment_target"] != "default":
args.extend(["-DCMAKE_OSX_DEPLOYMENT_TARGET=%s" % env["macos_deployment_target"]])
if env["arch"] == "x86_64":
diff --git a/src/WebRTCLibDataChannel.cpp b/src/WebRTCLibDataChannel.cpp
index 5c4ad5d..d4ded1e 100644
--- a/src/WebRTCLibDataChannel.cpp
+++ b/src/WebRTCLibDataChannel.cpp
@@ -33,10 +33,10 @@
#ifdef GDNATIVE_WEBRTC
#include "GDNativeLibrary.hpp"
#include "NativeScript.hpp"
-#define ERR_UNAVAILABLE GODOT_ERR_UNAVAILABLE
-#define FAILED GODOT_FAILED
-#define ERR_INVALID_PARAMETER GODOT_ERR_INVALID_PARAMETER
-#define OK GODOT_OK
+#define ERR_UNAVAILABLE Error::ERR_UNAVAILABLE
+#define FAILED Error::FAILED
+#define ERR_INVALID_PARAMETER Error::ERR_INVALID_PARAMETER
+#define OK Error::OK
#endif
#include <stdio.h>
@@ -108,12 +108,12 @@ void WebRTCLibDataChannel::queue_packet(const uint8_t *data, uint32_t size, bool
mutex->unlock();
}
-void WebRTCLibDataChannel::_set_write_mode(int64_t p_mode) {
+void WebRTCLibDataChannel::_set_write_mode(WriteMode p_mode) {
ERR_FAIL_COND(p_mode != WRITE_MODE_TEXT && p_mode != WRITE_MODE_BINARY);
- write_mode = (WriteMode)p_mode;
+ write_mode = p_mode;
}
-int64_t WebRTCLibDataChannel::_get_write_mode() const {
+WebRTCDataChannel::WriteMode WebRTCLibDataChannel::_get_write_mode() const {
return write_mode;
}
@@ -121,7 +121,7 @@ bool WebRTCLibDataChannel::_was_string_packet() const {
return current_packet.second;
}
-int64_t WebRTCLibDataChannel::_get_ready_state() const {
+WebRTCDataChannel::ChannelState WebRTCLibDataChannel::_get_ready_state() const {
ERR_FAIL_COND_V(!channel, STATE_CLOSED);
return channel_state;
}
@@ -166,7 +166,7 @@ int64_t WebRTCLibDataChannel::_get_buffered_amount() const {
return channel->bufferedAmount();
}
-int64_t WebRTCLibDataChannel::_poll() {
+Error WebRTCLibDataChannel::_poll() {
return OK;
}
@@ -177,7 +177,7 @@ void WebRTCLibDataChannel::_close() try {
} catch (...) {
}
-int64_t WebRTCLibDataChannel::_get_packet(const uint8_t **r_buffer, int32_t *r_len) {
+Error WebRTCLibDataChannel::_get_packet(const uint8_t **r_buffer, int32_t *r_len) {
ERR_FAIL_COND_V(packet_queue.empty(), ERR_UNAVAILABLE);
mutex->lock();
@@ -191,10 +191,10 @@ int64_t WebRTCLibDataChannel::_get_packet(const uint8_t **r_buffer, int32_t *r_l
mutex->unlock();
- return 0;
+ return OK;
}
-int64_t WebRTCLibDataChannel::_put_packet(const uint8_t *p_buffer, int64_t p_len) try {
+Error WebRTCLibDataChannel::_put_packet(const uint8_t *p_buffer, int64_t p_len) try {
ERR_FAIL_COND_V(!channel, FAILED);
ERR_FAIL_COND_V(channel->isClosed(), FAILED);
if (write_mode == WRITE_MODE_TEXT) {
diff --git a/src/WebRTCLibDataChannel.hpp b/src/WebRTCLibDataChannel.hpp
index 05f1ceb..758e018 100644
--- a/src/WebRTCLibDataChannel.hpp
+++ b/src/WebRTCLibDataChannel.hpp
@@ -40,6 +40,7 @@
#define GDCLASS(arg1, arg2) GODOT_CLASS(arg1, arg2)
#endif
#else
+#include <godot_cpp/classes/global_constants_binds.hpp>
#include <godot_cpp/classes/web_rtc_data_channel_extension.hpp>
#endif
@@ -75,20 +76,20 @@ public:
static WebRTCLibDataChannel *new_data_channel(std::shared_ptr<rtc::DataChannel> p_channel, bool p_negotiated);
/* PacketPeer */
- virtual int64_t _get_packet(const uint8_t **r_buffer, int32_t *r_len) override;
- virtual int64_t _put_packet(const uint8_t *p_buffer, int64_t p_len) override;
+ virtual godot::Error _get_packet(const uint8_t **r_buffer, int32_t *r_len) override;
+ virtual godot::Error _put_packet(const uint8_t *p_buffer, int64_t p_len) override;
virtual int64_t _get_available_packet_count() const override;
virtual int64_t _get_max_packet_size() const override;
/* WebRTCDataChannel */
- int64_t _poll() override;
+ godot::Error _poll() override;
void _close() override;
- void _set_write_mode(int64_t p_mode) override;
- int64_t _get_write_mode() const override;
+ void _set_write_mode(WriteMode p_mode) override;
+ WriteMode _get_write_mode() const override;
bool _was_string_packet() const override;
- int64_t _get_ready_state() const override;
+ ChannelState _get_ready_state() const override;
godot::String _get_label() const override;
bool _is_ordered() const override;
int64_t _get_id() const override;
diff --git a/src/WebRTCLibPeerConnection.cpp b/src/WebRTCLibPeerConnection.cpp
index cda018a..9b409a9 100644
--- a/src/WebRTCLibPeerConnection.cpp
+++ b/src/WebRTCLibPeerConnection.cpp
@@ -35,24 +35,10 @@ using namespace godot;
using namespace godot_webrtc;
#ifdef GDNATIVE_WEBRTC
-struct CastableError {
- godot::Error err_enum;
- int64_t err_int;
-
- operator int64_t() { return err_int; }
- operator godot::Error() { return err_enum; }
- CastableError(godot::Error p_enum, int64_t p_int) {
- err_enum = p_enum;
- err_int = p_int;
- }
-};
-#define MKERR(m_err) CastableError(godot::Error::m_err, GODOT_##m_err)
-#define OK MKERR(OK)
-#define FAILED MKERR(FAILED)
-#define ERR_UNCONFIGURED MKERR(ERR_UNCONFIGURED)
-#define ERR_UNAVAILABLE MKERR(ERR_UNAVAILABLE)
-#define ERR_INVALID_PARAMETER MKERR(ERR_INVALID_PARAMETER)
-#define ERR_BUG MKERR(ERR_BUG)
+#define OK Error::OK
+#define FAILED Error::FAILED
+#define ERR_UNCONFIGURED Error::ERR_UNCONFIGURED
+#define ERR_INVALID_PARAMETER Error::ERR_INVALID_PARAMETER
#endif
void WebRTCLibPeerConnection::initialize_signaling() {
@@ -124,7 +110,7 @@ Error WebRTCLibPeerConnection::_parse_channel_config(rtc::DataChannelInit &r_con
return OK;
}
-int64_t WebRTCLibPeerConnection::_get_connection_state() const {
+WebRTCPeerConnection::ConnectionState WebRTCLibPeerConnection::_get_connection_state() const {
ERR_FAIL_COND_V(peer_connection == nullptr, STATE_CLOSED);
rtc::PeerConnection::State state = peer_connection->state();
@@ -144,7 +130,7 @@ int64_t WebRTCLibPeerConnection::_get_connection_state() const {
}
}
-int64_t WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
+Error WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
rtc::Configuration config = {};
if (p_config.has("iceServers") && p_config["iceServers"].get_type() == Variant::ARRAY) {
Array servers = p_config["iceServers"];
@@ -155,7 +141,7 @@ int64_t WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
ERR_FAIL_COND_V(err != OK, FAILED);
}
}
- return (int64_t)_create_pc(config);
+ return _create_pc(config);
}
Object *WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, const Dictionary &p_channel_config) try {
@@ -178,7 +164,7 @@ Object *WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, c
ERR_FAIL_V(nullptr);
}
-int64_t WebRTCLibPeerConnection::_create_offer() try {
+Error WebRTCLibPeerConnection::_create_offer() try {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
ERR_FAIL_COND_V(_get_connection_state() != STATE_NEW, FAILED);
peer_connection->setLocalDescription(rtc::Description::Type::Offer);
@@ -188,7 +174,7 @@ int64_t WebRTCLibPeerConnection::_create_offer() try {
ERR_FAIL_V(FAILED);
}
-int64_t WebRTCLibPeerConnection::_set_remote_description(const String &p_type, const String &p_sdp) try {
+Error WebRTCLibPeerConnection::_set_remote_description(const String &p_type, const String &p_sdp) try {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
std::string sdp(p_sdp.utf8().get_data());
std::string type(p_type.utf8().get_data());
@@ -204,7 +190,7 @@ int64_t WebRTCLibPeerConnection::_set_remote_description(const String &p_type, c
ERR_FAIL_V(FAILED);
}
-int64_t WebRTCLibPeerConnection::_set_local_description(const String &p_type, const String &p_sdp) {
+Error WebRTCLibPeerConnection::_set_local_description(const String &p_type, const String &p_sdp) {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
// XXX Library quirk. It doesn't seem possible to create offers/answers without setting the local description.
// Ignore this call for now to avoid crash (it's already set automatically!).
@@ -212,7 +198,7 @@ int64_t WebRTCLibPeerConnection::_set_local_description(const String &p_type, co
return OK;
}
-int64_t WebRTCLibPeerConnection::_add_ice_candidate(const String &sdpMidName, int64_t sdpMlineIndexName, const String &sdpName) try {
+Error WebRTCLibPeerConnection::_add_ice_candidate(const String &sdpMidName, int64_t sdpMlineIndexName, const String &sdpName) try {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
rtc::Candidate candidate(sdpName.utf8().get_data(), sdpMidName.utf8().get_data());
peer_connection->addRemoteCandidate(candidate);
@@ -222,7 +208,7 @@ int64_t WebRTCLibPeerConnection::_add_ice_candidate(const String &sdpMidName, in
ERR_FAIL_V(FAILED);
}
-int64_t WebRTCLibPeerConnection::_poll() {
+Error WebRTCLibPeerConnection::_poll() {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
while (!signal_queue.empty()) {
diff --git a/src/WebRTCLibPeerConnection.hpp b/src/WebRTCLibPeerConnection.hpp
index 1a759b2..2f7c6e3 100644
--- a/src/WebRTCLibPeerConnection.hpp
+++ b/src/WebRTCLibPeerConnection.hpp
@@ -40,6 +40,7 @@
#define GDCLASS(arg1, arg2) GODOT_CLASS(arg1, arg2)
#endif
#else
+#include <godot_cpp/classes/global_constants_binds.hpp>
#include <godot_cpp/classes/web_rtc_peer_connection_extension.hpp>
#endif
@@ -71,15 +72,15 @@ public:
void _init();
- int64_t _get_connection_state() const override;
+ ConnectionState _get_connection_state() const override;
- int64_t _initialize(const godot::Dictionary &p_config) override;
+ godot::Error _initialize(const godot::Dictionary &p_config) override;
godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
- int64_t _create_offer() override;
- int64_t _set_remote_description(const godot::String &type, const godot::String &sdp) override;
- int64_t _set_local_description(const godot::String &type, const godot::String &sdp) override;
- int64_t _add_ice_candidate(const godot::String &sdpMidName, int64_t sdpMlineIndexName, const godot::String &sdpName) override;
- int64_t _poll() override;
+ godot::Error _create_offer() override;
+ godot::Error _set_remote_description(const godot::String &type, const godot::String &sdp) override;
+ godot::Error _set_local_description(const godot::String &type, const godot::String &sdp) override;
+ godot::Error _add_ice_candidate(const godot::String &sdpMidName, int64_t sdpMlineIndexName, const godot::String &sdpName) override;
+ godot::Error _poll() override;
void _close() override;
WebRTCLibPeerConnection();
diff --git a/src/net/WebRTCDataChannelNative.cpp b/src/net/WebRTCDataChannelNative.cpp
index 4639021..c594dd6 100644
--- a/src/net/WebRTCDataChannelNative.cpp
+++ b/src/net/WebRTCDataChannelNative.cpp
@@ -72,7 +72,7 @@ godot_int get_max_packet_size_wdc(const void *user) {
}
void set_write_mode_wdc(void *user, godot_int write_mode) {
- ((WebRTCDataChannelNative *)user)->_set_write_mode(write_mode);
+ ((WebRTCDataChannelNative *)user)->_set_write_mode((godot::WebRTCDataChannel::WriteMode)write_mode);
}
godot_int get_write_mode_wdc(const void *user) {
diff --git a/src/net/WebRTCDataChannelNative.hpp b/src/net/WebRTCDataChannelNative.hpp
index a8ab697..d00929d 100644
--- a/src/net/WebRTCDataChannelNative.hpp
+++ b/src/net/WebRTCDataChannelNative.hpp
@@ -112,11 +112,11 @@ public:
void _init();
void register_interface(const godot_net_webrtc_data_channel *interface);
- virtual void _set_write_mode(int64_t mode) = 0;
- virtual int64_t _get_write_mode() const = 0;
+ virtual void _set_write_mode(WriteMode mode) = 0;
+ virtual WriteMode _get_write_mode() const = 0;
virtual bool _was_string_packet() const = 0;
- virtual int64_t _get_ready_state() const = 0;
+ virtual ChannelState _get_ready_state() const = 0;
virtual godot::String _get_label() const = 0;
virtual bool _is_ordered() const = 0;
virtual int64_t _get_id() const = 0;
@@ -126,12 +126,12 @@ public:
virtual bool _is_negotiated() const = 0;
virtual int64_t _get_buffered_amount() const = 0;
- virtual int64_t _poll() = 0;
+ virtual godot::Error _poll() = 0;
virtual void _close() = 0;
/* PacketPeer */
- virtual int64_t _get_packet(const uint8_t **r_buffer, int32_t *r_len) = 0;
- virtual int64_t _put_packet(const uint8_t *p_buffer, int64_t p_len) = 0;
+ virtual godot::Error _get_packet(const uint8_t **r_buffer, int32_t *r_len) = 0;
+ virtual godot::Error _put_packet(const uint8_t *p_buffer, int64_t p_len) = 0;
virtual int64_t _get_available_packet_count() const = 0;
virtual int64_t _get_max_packet_size() const = 0;
diff --git a/src/net/WebRTCPeerConnectionNative.hpp b/src/net/WebRTCPeerConnectionNative.hpp
index 1613b53..10c1c9e 100644
--- a/src/net/WebRTCPeerConnectionNative.hpp
+++ b/src/net/WebRTCPeerConnectionNative.hpp
@@ -81,15 +81,15 @@ public:
void _init();
void register_interface(const godot_net_webrtc_peer_connection *interface);
- virtual int64_t _get_connection_state() const = 0;
+ virtual ConnectionState _get_connection_state() const = 0;
- virtual int64_t _initialize(const godot::Dictionary &p_config) = 0;
+ virtual godot::Error _initialize(const godot::Dictionary &p_config) = 0;
virtual godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) = 0;
- virtual int64_t _create_offer() = 0;
- virtual int64_t _set_remote_description(const godot::String &type, const godot::String &sdp) = 0;
- virtual int64_t _set_local_description(const godot::String &type, const godot::String &sdp) = 0;
- virtual int64_t _add_ice_candidate(const godot::String &sdpMidName, int64_t sdpMlineIndexName, const godot::String &sdpName) = 0;
- virtual int64_t _poll() = 0;
+ virtual godot::Error _create_offer() = 0;
+ virtual godot::Error _set_remote_description(const godot::String &type, const godot::String &sdp) = 0;
+ virtual godot::Error _set_local_description(const godot::String &type, const godot::String &sdp) = 0;
+ virtual godot::Error _add_ice_candidate(const godot::String &sdpMidName, int64_t sdpMlineIndexName, const godot::String &sdpName) = 0;
+ virtual godot::Error _poll() = 0;
virtual void _close() = 0;
~WebRTCPeerConnectionNative();