diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-09-28 12:57:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-28 12:57:45 +0200 |
commit | d18cbdf5e4a1132bfc5f581195f6bf7c3b9bed79 (patch) | |
tree | e87200b01a5b55ec516b528be52f382954efe4e5 /modules/gdnative/net | |
parent | 97f050067819c7d1fbef0cb38b071ff31b2b2188 (diff) | |
parent | 2d810e8cd948f1e25e514986dc6f9a7cb7c52026 (diff) |
Merge pull request #52481 from Faless/net/4.x_native_peers
[Net] Extension system for network peers, webrtc.
Diffstat (limited to 'modules/gdnative/net')
-rw-r--r-- | modules/gdnative/net/SCsub | 12 | ||||
-rw-r--r-- | modules/gdnative/net/multiplayer_peer_gdnative.cpp | 136 | ||||
-rw-r--r-- | modules/gdnative/net/multiplayer_peer_gdnative.h | 79 | ||||
-rw-r--r-- | modules/gdnative/net/packet_peer_gdnative.cpp | 72 | ||||
-rw-r--r-- | modules/gdnative/net/packet_peer_gdnative.h | 59 | ||||
-rw-r--r-- | modules/gdnative/net/register_types.cpp | 43 | ||||
-rw-r--r-- | modules/gdnative/net/register_types.h | 37 | ||||
-rw-r--r-- | modules/gdnative/net/stream_peer_gdnative.cpp | 77 | ||||
-rw-r--r-- | modules/gdnative/net/stream_peer_gdnative.h | 60 | ||||
-rw-r--r-- | modules/gdnative/net/webrtc_gdnative.cpp | 60 |
10 files changed, 0 insertions, 635 deletions
diff --git a/modules/gdnative/net/SCsub b/modules/gdnative/net/SCsub deleted file mode 100644 index b76500c003..0000000000 --- a/modules/gdnative/net/SCsub +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_gdnative") - -env_net = env_gdnative.Clone() - -has_webrtc = env_net["module_webrtc_enabled"] -if has_webrtc: - env_net.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"]) - -env_net.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp deleted file mode 100644 index 575d5f5060..0000000000 --- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*************************************************************************/ -/* multiplayer_peer_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "multiplayer_peer_gdnative.h" - -MultiplayerPeerGDNative::MultiplayerPeerGDNative() { - interface = nullptr; -} - -MultiplayerPeerGDNative::~MultiplayerPeerGDNative() { -} - -void MultiplayerPeerGDNative::set_native_multiplayer_peer(const godot_net_multiplayer_peer *p_interface) { - interface = p_interface; -} - -Error MultiplayerPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); -} - -Error MultiplayerPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size); -} - -int MultiplayerPeerGDNative::get_max_packet_size() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_max_packet_size(interface->data); -} - -int MultiplayerPeerGDNative::get_available_packet_count() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_available_packet_count(interface->data); -} - -/* MultiplayerPeer */ -void MultiplayerPeerGDNative::set_transfer_channel(int p_channel) { - ERR_FAIL_COND(interface == nullptr); - return interface->set_transfer_channel(interface->data, p_channel); -} - -int MultiplayerPeerGDNative::get_transfer_channel() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_transfer_channel(interface->data); -} - -void MultiplayerPeerGDNative::set_transfer_mode(Multiplayer::TransferMode p_mode) { - ERR_FAIL_COND(interface == nullptr); - interface->set_transfer_mode(interface->data, (godot_int)p_mode); -} - -Multiplayer::TransferMode MultiplayerPeerGDNative::get_transfer_mode() const { - ERR_FAIL_COND_V(interface == nullptr, Multiplayer::TRANSFER_MODE_UNRELIABLE); - return (Multiplayer::TransferMode)interface->get_transfer_mode(interface->data); -} - -void MultiplayerPeerGDNative::set_target_peer(int p_peer_id) { - ERR_FAIL_COND(interface == nullptr); - interface->set_target_peer(interface->data, p_peer_id); -} - -int MultiplayerPeerGDNative::get_packet_peer() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_packet_peer(interface->data); -} - -bool MultiplayerPeerGDNative::is_server() const { - ERR_FAIL_COND_V(interface == nullptr, false); - return interface->is_server(interface->data); -} - -void MultiplayerPeerGDNative::poll() { - ERR_FAIL_COND(interface == nullptr); - interface->poll(interface->data); -} - -int MultiplayerPeerGDNative::get_unique_id() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_unique_id(interface->data); -} - -void MultiplayerPeerGDNative::set_refuse_new_connections(bool p_enable) { - ERR_FAIL_COND(interface == nullptr); - interface->set_refuse_new_connections(interface->data, p_enable); -} - -bool MultiplayerPeerGDNative::is_refusing_new_connections() const { - ERR_FAIL_COND_V(interface == nullptr, true); - return interface->is_refusing_new_connections(interface->data); -} - -MultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connection_status() const { - ERR_FAIL_COND_V(interface == nullptr, CONNECTION_DISCONNECTED); - return (ConnectionStatus)interface->get_connection_status(interface->data); -} - -void MultiplayerPeerGDNative::_bind_methods() { - ADD_PROPERTY_DEFAULT("transfer_channel", 0); - ADD_PROPERTY_DEFAULT("transfer_mode", Multiplayer::TRANSFER_MODE_UNRELIABLE); - ADD_PROPERTY_DEFAULT("refuse_new_connections", true); -} - -extern "C" { - -void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_multiplayer_peer *p_impl) { - ((MultiplayerPeerGDNative *)p_obj)->set_native_multiplayer_peer(p_impl); -} -} diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.h b/modules/gdnative/net/multiplayer_peer_gdnative.h deleted file mode 100644 index 33e424d284..0000000000 --- a/modules/gdnative/net/multiplayer_peer_gdnative.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************/ -/* multiplayer_peer_gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef MULTIPLAYER_PEER_GDNATIVE_H -#define MULTIPLAYER_PEER_GDNATIVE_H - -#include "core/multiplayer/multiplayer_peer.h" -#include "modules/gdnative/gdnative.h" -#include "modules/gdnative/include/net/godot_net.h" - -class MultiplayerPeerGDNative : public MultiplayerPeer { - GDCLASS(MultiplayerPeerGDNative, MultiplayerPeer); - -protected: - static void _bind_methods(); - const godot_net_multiplayer_peer *interface; - -public: - MultiplayerPeerGDNative(); - ~MultiplayerPeerGDNative(); - - /* Sets the interface implementation from GDNative */ - void set_native_multiplayer_peer(const godot_net_multiplayer_peer *p_impl); - - /* Specific to PacketPeer */ - virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; - virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override; - virtual int get_max_packet_size() const override; - virtual int get_available_packet_count() const override; - - /* Specific to MultiplayerPeer */ - virtual void set_transfer_channel(int p_channel) override; - virtual int get_transfer_channel() const override; - virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) override; - virtual Multiplayer::TransferMode get_transfer_mode() const override; - virtual void set_target_peer(int p_peer_id) override; - - virtual int get_packet_peer() const override; - - virtual bool is_server() const override; - - virtual void poll() override; - - virtual int get_unique_id() const override; - - virtual void set_refuse_new_connections(bool p_enable) override; - virtual bool is_refusing_new_connections() const override; - - virtual ConnectionStatus get_connection_status() const override; -}; - -#endif // MULTIPLAYER_PEER_GDNATIVE_H diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp deleted file mode 100644 index 3bcdfed8ff..0000000000 --- a/modules/gdnative/net/packet_peer_gdnative.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************/ -/* packet_peer_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "packet_peer_gdnative.h" - -PacketPeerGDNative::PacketPeerGDNative() { - interface = nullptr; -} - -PacketPeerGDNative::~PacketPeerGDNative() { -} - -void PacketPeerGDNative::set_native_packet_peer(const godot_net_packet_peer *p_impl) { - interface = p_impl; -} - -void PacketPeerGDNative::_bind_methods() { -} - -Error PacketPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); -} - -Error PacketPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size); -} - -int PacketPeerGDNative::get_max_packet_size() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_max_packet_size(interface->data); -} - -int PacketPeerGDNative::get_available_packet_count() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_available_packet_count(interface->data); -} - -extern "C" { - -void GDAPI godot_net_bind_packet_peer(godot_object *p_obj, const godot_net_packet_peer *p_impl) { - ((PacketPeerGDNative *)p_obj)->set_native_packet_peer(p_impl); -} -} diff --git a/modules/gdnative/net/packet_peer_gdnative.h b/modules/gdnative/net/packet_peer_gdnative.h deleted file mode 100644 index 29013f9367..0000000000 --- a/modules/gdnative/net/packet_peer_gdnative.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************/ -/* packet_peer_gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef PACKET_PEER_GDNATIVE_H -#define PACKET_PEER_GDNATIVE_H - -#include "core/io/packet_peer.h" -#include "modules/gdnative/gdnative.h" -#include "modules/gdnative/include/net/godot_net.h" - -class PacketPeerGDNative : public PacketPeer { - GDCLASS(PacketPeerGDNative, PacketPeer); - -protected: - static void _bind_methods(); - const godot_net_packet_peer *interface; - -public: - PacketPeerGDNative(); - ~PacketPeerGDNative(); - - /* Sets the interface implementation from GDNative */ - void set_native_packet_peer(const godot_net_packet_peer *p_impl); - - /* Specific to PacketPeer */ - virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; - virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override; - virtual int get_max_packet_size() const override; - virtual int get_available_packet_count() const override; -}; - -#endif // PACKET_PEER_GDNATIVE_H diff --git a/modules/gdnative/net/register_types.cpp b/modules/gdnative/net/register_types.cpp deleted file mode 100644 index 46c383e5ae..0000000000 --- a/modules/gdnative/net/register_types.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************/ -/* register_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "register_types.h" -#include "multiplayer_peer_gdnative.h" -#include "packet_peer_gdnative.h" -#include "stream_peer_gdnative.h" - -void register_net_types() { - GDREGISTER_CLASS(MultiplayerPeerGDNative); - GDREGISTER_CLASS(PacketPeerGDNative); - GDREGISTER_CLASS(StreamPeerGDNative); -} - -void unregister_net_types() { -} diff --git a/modules/gdnative/net/register_types.h b/modules/gdnative/net/register_types.h deleted file mode 100644 index c99c6f6fbf..0000000000 --- a/modules/gdnative/net/register_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************/ -/* register_types.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef NET_REGISTER_TYPES_H -#define NET_REGISTER_TYPES_H - -void register_net_types(); -void unregister_net_types(); - -#endif // NET_REGISTER_TYPES_H diff --git a/modules/gdnative/net/stream_peer_gdnative.cpp b/modules/gdnative/net/stream_peer_gdnative.cpp deleted file mode 100644 index 72ab72323d..0000000000 --- a/modules/gdnative/net/stream_peer_gdnative.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************/ -/* stream_peer_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "stream_peer_gdnative.h" - -StreamPeerGDNative::StreamPeerGDNative() { - interface = nullptr; -} - -StreamPeerGDNative::~StreamPeerGDNative() { -} - -void StreamPeerGDNative::set_native_stream_peer(const godot_net_stream_peer *p_interface) { - interface = p_interface; -} - -void StreamPeerGDNative::_bind_methods() { -} - -Error StreamPeerGDNative::put_data(const uint8_t *p_data, int p_bytes) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)(interface->put_data(interface->data, p_data, p_bytes)); -} - -Error StreamPeerGDNative::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)(interface->put_partial_data(interface->data, p_data, p_bytes, &r_sent)); -} - -Error StreamPeerGDNative::get_data(uint8_t *p_buffer, int p_bytes) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)(interface->get_data(interface->data, p_buffer, p_bytes)); -} - -Error StreamPeerGDNative::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) { - ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); - return (Error)(interface->get_partial_data(interface->data, p_buffer, p_bytes, &r_received)); -} - -int StreamPeerGDNative::get_available_bytes() const { - ERR_FAIL_COND_V(interface == nullptr, 0); - return interface->get_available_bytes(interface->data); -} - -extern "C" { - -void GDAPI godot_net_bind_stream_peer(godot_object *p_obj, const godot_net_stream_peer *p_interface) { - ((StreamPeerGDNative *)p_obj)->set_native_stream_peer(p_interface); -} -} diff --git a/modules/gdnative/net/stream_peer_gdnative.h b/modules/gdnative/net/stream_peer_gdnative.h deleted file mode 100644 index dd5abceb83..0000000000 --- a/modules/gdnative/net/stream_peer_gdnative.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* stream_peer_gdnative.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef STREAM_PEER_GDNATIVE_H -#define STREAM_PEER_GDNATIVE_H - -#include "core/io/stream_peer.h" -#include "modules/gdnative/gdnative.h" -#include "modules/gdnative/include/net/godot_net.h" - -class StreamPeerGDNative : public StreamPeer { - GDCLASS(StreamPeerGDNative, StreamPeer); - -protected: - static void _bind_methods(); - const godot_net_stream_peer *interface; - -public: - StreamPeerGDNative(); - ~StreamPeerGDNative(); - - /* Sets the interface implementation from GDNative */ - void set_native_stream_peer(const godot_net_stream_peer *p_interface); - - /* Specific to StreamPeer */ - Error put_data(const uint8_t *p_data, int p_bytes) override; - Error put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) override; - Error get_data(uint8_t *p_buffer, int p_bytes) override; - Error get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) override; - int get_available_bytes() const override; -}; - -#endif // STREAM_PEER_GDNATIVE_H diff --git a/modules/gdnative/net/webrtc_gdnative.cpp b/modules/gdnative/net/webrtc_gdnative.cpp deleted file mode 100644 index 76ccbad009..0000000000 --- a/modules/gdnative/net/webrtc_gdnative.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* webrtc_gdnative.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "modules/gdnative/gdnative.h" -#include "modules/gdnative/include/net/godot_net.h" - -#ifdef WEBRTC_GDNATIVE_ENABLED -#include "modules/webrtc/webrtc_data_channel_gdnative.h" -#include "modules/webrtc/webrtc_peer_connection_gdnative.h" -#endif - -extern "C" { - -void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *p_impl) { -#ifdef WEBRTC_GDNATIVE_ENABLED - ((WebRTCPeerConnectionGDNative *)p_obj)->set_native_webrtc_peer_connection(p_impl); -#endif -} - -void GDAPI godot_net_bind_webrtc_data_channel(godot_object *p_obj, const godot_net_webrtc_data_channel *p_impl) { -#ifdef WEBRTC_GDNATIVE_ENABLED - ((WebRTCDataChannelGDNative *)p_obj)->set_native_webrtc_data_channel(p_impl); -#endif -} - -godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *p_lib) { -#ifdef WEBRTC_GDNATIVE_ENABLED - return (godot_error)WebRTCPeerConnectionGDNative::set_default_library(p_lib); -#else - return (godot_error)ERR_UNAVAILABLE; -#endif -} -} |