diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/WebRTCDataChannelNative.cpp | 38 | ||||
-rw-r--r-- | src/net/WebRTCDataChannelNative.hpp | 40 | ||||
-rw-r--r-- | src/net/WebRTCPeerConnectionNative.cpp | 24 | ||||
-rw-r--r-- | src/net/WebRTCPeerConnectionNative.hpp | 22 |
4 files changed, 70 insertions, 54 deletions
diff --git a/src/net/WebRTCDataChannelNative.cpp b/src/net/WebRTCDataChannelNative.cpp index 4e6b114..4639021 100644 --- a/src/net/WebRTCDataChannelNative.cpp +++ b/src/net/WebRTCDataChannelNative.cpp @@ -31,6 +31,8 @@ #include "WebRTCDataChannelNative.hpp" #include "net/WebRTCPeerConnectionNative.hpp" +using namespace godot; + void WebRTCDataChannelNative::register_interface(const godot_net_webrtc_data_channel *p_interface) { ERR_FAIL_COND(!WebRTCPeerConnectionNative::_net_api); WebRTCPeerConnectionNative::_net_api->godot_net_bind_webrtc_data_channel(_owner, p_interface); @@ -54,73 +56,73 @@ WebRTCDataChannelNative::~WebRTCDataChannelNative() { * and you could use void *user for any kind of state struct pointer you have. */ godot_error get_packet_wdc(void *user, const uint8_t **r_buffer, int *r_len) { - return ((WebRTCDataChannelNative *)user)->get_packet(r_buffer, r_len); + return (godot_error)(((WebRTCDataChannelNative *)user)->_get_packet(r_buffer, r_len)); } godot_error put_packet_wdc(void *user, const uint8_t *p_buffer, int p_len) { - return ((WebRTCDataChannelNative *)user)->put_packet(p_buffer, p_len); + return (godot_error)(((WebRTCDataChannelNative *)user)->_put_packet(p_buffer, p_len)); } godot_int get_available_packet_count_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->get_available_packet_count(); + return ((WebRTCDataChannelNative *)user)->_get_available_packet_count(); } godot_int get_max_packet_size_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->get_max_packet_size(); + return ((WebRTCDataChannelNative *)user)->_get_max_packet_size(); } void set_write_mode_wdc(void *user, godot_int write_mode) { - ((WebRTCDataChannelNative *)user)->set_write_mode(write_mode); + ((WebRTCDataChannelNative *)user)->_set_write_mode(write_mode); } godot_int get_write_mode_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->get_write_mode(); + return ((WebRTCDataChannelNative *)user)->_get_write_mode(); } bool was_string_packet_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->was_string_packet(); + return ((WebRTCDataChannelNative *)user)->_was_string_packet(); } godot_int get_ready_state_wdc(const void *user) { - return (godot_int)(((WebRTCDataChannelNative *)user)->get_ready_state()); + return (godot_int)(((WebRTCDataChannelNative *)user)->_get_ready_state()); } const char *get_label_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->get_label(); + return ((WebRTCDataChannelNative *)user)->_get_label().utf8().get_data(); } bool is_ordered_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->is_ordered(); + return ((WebRTCDataChannelNative *)user)->_is_ordered(); } int get_id_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->get_id(); + return ((WebRTCDataChannelNative *)user)->_get_id(); } int get_max_packet_life_time_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->get_max_packet_life_time(); + return ((WebRTCDataChannelNative *)user)->_get_max_packet_life_time(); } int get_max_retransmits_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->get_max_retransmits(); + return ((WebRTCDataChannelNative *)user)->_get_max_retransmits(); } const char *get_protocol_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->get_protocol(); + return ((WebRTCDataChannelNative *)user)->_get_protocol().utf8().get_data(); } bool is_negotiated_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->is_negotiated(); + return ((WebRTCDataChannelNative *)user)->_is_negotiated(); } int get_buffered_amount_wdc(const void *user) { - return ((WebRTCDataChannelNative *)user)->get_buffered_amount(); + return ((WebRTCDataChannelNative *)user)->_get_buffered_amount(); } godot_error poll_wdc(void *user) { - return ((WebRTCDataChannelNative *)user)->poll(); + return (godot_error)(((WebRTCDataChannelNative *)user)->_poll()); } void close_wdc(void *user) { - ((WebRTCDataChannelNative *)user)->close(); + ((WebRTCDataChannelNative *)user)->_close(); } diff --git a/src/net/WebRTCDataChannelNative.hpp b/src/net/WebRTCDataChannelNative.hpp index 20ef38e..a8ab697 100644 --- a/src/net/WebRTCDataChannelNative.hpp +++ b/src/net/WebRTCDataChannelNative.hpp @@ -69,6 +69,8 @@ typedef struct { } #endif +namespace godot { + class WebRTCDataChannelNative : public godot::WebRTCDataChannelGDNative { GODOT_CLASS(WebRTCDataChannelNative, godot::WebRTCDataChannelGDNative); @@ -110,30 +112,32 @@ public: void _init(); void register_interface(const godot_net_webrtc_data_channel *interface); - virtual void set_write_mode(godot_int mode) = 0; - virtual godot_int get_write_mode() const = 0; - virtual bool was_string_packet() const = 0; + virtual void _set_write_mode(int64_t mode) = 0; + virtual int64_t _get_write_mode() const = 0; + virtual bool _was_string_packet() const = 0; - virtual ChannelState get_ready_state() const = 0; - virtual const char *get_label() const = 0; - virtual bool is_ordered() const = 0; - virtual int get_id() const = 0; - virtual int get_max_packet_life_time() const = 0; - virtual int get_max_retransmits() const = 0; - virtual const char *get_protocol() const = 0; - virtual bool is_negotiated() const = 0; - virtual int get_buffered_amount() const = 0; + virtual int64_t _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; + virtual int64_t _get_max_packet_life_time() const = 0; + virtual int64_t _get_max_retransmits() const = 0; + virtual godot::String _get_protocol() const = 0; + virtual bool _is_negotiated() const = 0; + virtual int64_t _get_buffered_amount() const = 0; - virtual godot_error poll() = 0; - virtual void close() = 0; + virtual int64_t _poll() = 0; + virtual void _close() = 0; /* PacketPeer */ - virtual godot_error get_packet(const uint8_t **r_buffer, int *r_len) = 0; - virtual godot_error put_packet(const uint8_t *p_buffer, int p_len) = 0; - virtual godot_int get_available_packet_count() const = 0; - virtual godot_int get_max_packet_size() const = 0; + 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 int64_t _get_available_packet_count() const = 0; + virtual int64_t _get_max_packet_size() const = 0; ~WebRTCDataChannelNative(); }; +}; // namespace godot + #endif // WEBRTC_DATA_CHANNEL_NATIVE diff --git a/src/net/WebRTCPeerConnectionNative.cpp b/src/net/WebRTCPeerConnectionNative.cpp index c8c7587..508004f 100644 --- a/src/net/WebRTCPeerConnectionNative.cpp +++ b/src/net/WebRTCPeerConnectionNative.cpp @@ -30,6 +30,8 @@ #include "WebRTCPeerConnectionNative.hpp" +using namespace godot; + const godot_gdnative_ext_net_3_2_api_struct *WebRTCPeerConnectionNative::_net_api = NULL; void WebRTCPeerConnectionNative::register_interface(const godot_net_webrtc_peer_connection *p_interface) { @@ -55,19 +57,23 @@ WebRTCPeerConnectionNative::~WebRTCPeerConnectionNative() { * and you could use void *user for any kind of state struct pointer you have. */ godot_int get_connection_state_wp(const void *user) { - return (godot_int)((WebRTCPeerConnectionNative *)user)->get_connection_state(); + return (godot_int)((WebRTCPeerConnectionNative *)user)->_get_connection_state(); } godot_error initialize_wp(void *user, const godot_dictionary *p_config) { - return ((WebRTCPeerConnectionNative *)user)->initialize(p_config); + return (godot_error)(((WebRTCPeerConnectionNative *)user)->_initialize(*(Dictionary *)p_config)); } godot_object *create_data_channel_wp(void *user, const char *p_channel, const godot_dictionary *p_channel_config) { - return ((WebRTCPeerConnectionNative *)user)->create_data_channel(p_channel, p_channel_config); + Object *ptr = ((WebRTCPeerConnectionNative *)user)->_create_data_channel(p_channel, *(Dictionary *)p_channel_config); + if (ptr) { + return ptr->_owner; + } + return nullptr; } godot_error create_offer_wp(void *user) { - return ((WebRTCPeerConnectionNative *)user)->create_offer(); + return (godot_error)(((WebRTCPeerConnectionNative *)user)->_create_offer()); } godot_error create_answer_wp(void *user) { @@ -75,21 +81,21 @@ godot_error create_answer_wp(void *user) { } godot_error set_remote_description_wp(void *user, const char *type, const char *sdp) { - return ((WebRTCPeerConnectionNative *)user)->set_remote_description(type, sdp); + return (godot_error)(((WebRTCPeerConnectionNative *)user)->_set_remote_description(type, sdp)); } godot_error set_local_description_wp(void *user, const char *type, const char *sdp) { - return ((WebRTCPeerConnectionNative *)user)->set_local_description(type, sdp); + return (godot_error)(((WebRTCPeerConnectionNative *)user)->_set_local_description(type, sdp)); } godot_error add_ice_candidate_wp(void *user, const char *sdpMidName, int sdpMlineIndexName, const char *sdpName) { - return ((WebRTCPeerConnectionNative *)user)->add_ice_candidate(sdpMidName, sdpMlineIndexName, sdpName); + return (godot_error)(((WebRTCPeerConnectionNative *)user)->_add_ice_candidate(sdpMidName, sdpMlineIndexName, sdpName)); } godot_error poll_wp(void *user) { - return ((WebRTCPeerConnectionNative *)user)->poll(); + return (godot_error)((WebRTCPeerConnectionNative *)user)->_poll(); } void close_wp(void *user) { - ((WebRTCPeerConnectionNative *)user)->close(); + ((WebRTCPeerConnectionNative *)user)->_close(); } diff --git a/src/net/WebRTCPeerConnectionNative.hpp b/src/net/WebRTCPeerConnectionNative.hpp index fb75a46..1613b53 100644 --- a/src/net/WebRTCPeerConnectionNative.hpp +++ b/src/net/WebRTCPeerConnectionNative.hpp @@ -50,6 +50,8 @@ godot_error add_ice_candidate_wp(void *, const char *, int, const char *); godot_error poll_wp(void *); void close_wp(void *); +namespace godot { + class WebRTCPeerConnectionNative : public godot::WebRTCPeerConnectionGDNative { GODOT_CLASS(WebRTCPeerConnectionNative, godot::WebRTCPeerConnectionGDNative); @@ -79,18 +81,20 @@ public: void _init(); void register_interface(const godot_net_webrtc_peer_connection *interface); - virtual ConnectionState get_connection_state() const = 0; + virtual int64_t _get_connection_state() const = 0; - virtual godot_error initialize(const godot_dictionary *p_config) = 0; - virtual godot_object *create_data_channel(const char *p_channel, const godot_dictionary *p_channel_config) = 0; - virtual godot_error create_offer() = 0; - virtual godot_error set_remote_description(const char *type, const char *sdp) = 0; - virtual godot_error set_local_description(const char *type, const char *sdp) = 0; - virtual godot_error add_ice_candidate(const char *sdpMidName, int sdpMlineIndexName, const char *sdpName) = 0; - virtual godot_error poll() = 0; - virtual void close() = 0; + virtual int64_t _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 void _close() = 0; ~WebRTCPeerConnectionNative(); }; +}; // namespace godot + #endif // WEBRTC_PEER_NATIVE |