Merge pull request #60 from Faless/bump/alpha16

Update to Godot alpha16
This commit is contained in:
Fabio Alessandrelli
2022-09-11 18:26:08 +02:00
committed by GitHub
15 changed files with 67 additions and 86 deletions

View File

@@ -37,21 +37,11 @@ jobs:
matrix:
include:
# Android
- platform: android
arch: 'x86_32'
gdnative_flags: 'android_arch=x86'
sconsflags: ''
os: 'ubuntu-20.04'
- platform: android
arch: 'x86_64'
gdnative_flags: 'android_arch=x86_64'
sconsflags: ''
os: 'ubuntu-20.04'
- platform: android
arch: 'arm32'
gdnative_flags: 'android_arch=armv7'
sconsflags: ''
os: 'ubuntu-20.04'
- platform: android
arch: 'arm64'
gdnative_flags: 'android_arch=arm64v8'
@@ -84,12 +74,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: ''

View File

@@ -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"

View File

@@ -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":

2
deps/openssl vendored

View File

@@ -11,8 +11,6 @@ osx.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.arm64.dylib
windows.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_64.dll"
windows.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_32.dll"
android.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64.so"
android.arm32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm32.so"
android.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so"
android.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_32.so"
ios.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.arm64.dylib"
ios.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.x86_64.simulator.dylib"

View File

@@ -11,10 +11,8 @@ entry/X11.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64
entry/X11.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so"
entry/Server.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so"
entry/Server.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so"
entry/Android.armeabi-v7a = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm32.so"
entry/Android.arm64-v8a = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64.so"
entry/Android.x64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so"
entry/Android.x86 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_32.so"
entry/iOS.armv7 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.armv32.dylib"
entry/iOS.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.arm64.dylib"
entry/iOS.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.x86_64.simulator.dylib"

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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()) {

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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();