diff options
author | David Snopek <dsnopek@gmail.com> | 2021-07-20 11:54:25 -0500 |
---|---|---|
committer | David Snopek <dsnopek@gmail.com> | 2021-07-21 10:48:09 -0500 |
commit | 3bdf6cdc1320dfd7ac0f1704976a633ef3c911d8 (patch) | |
tree | 1216800fdd5f0ea965433f70b8df8c6a5d37a498 /src | |
parent | 072ba5c1d09359058aab20cb8cdfdf4a4546e574 (diff) | |
download | fork-godot-webrtc-native-3bdf6cdc1320dfd7ac0f1704976a633ef3c911d8.tar.gz fork-godot-webrtc-native-3bdf6cdc1320dfd7ac0f1704976a633ef3c911d8.tar.bz2 fork-godot-webrtc-native-3bdf6cdc1320dfd7ac0f1704976a633ef3c911d8.zip |
Add get_buffered_amount() to WebRTCDataChannel
Diffstat (limited to 'src')
-rw-r--r-- | src/WebRTCLibDataChannel.cpp | 5 | ||||
-rw-r--r-- | src/WebRTCLibDataChannel.hpp | 1 | ||||
-rw-r--r-- | src/net/WebRTCDataChannelNative.cpp | 4 | ||||
-rw-r--r-- | src/net/WebRTCDataChannelNative.hpp | 20 |
4 files changed, 29 insertions, 1 deletions
diff --git a/src/WebRTCLibDataChannel.cpp b/src/WebRTCLibDataChannel.cpp index f29d562..bab9c79 100644 --- a/src/WebRTCLibDataChannel.cpp +++ b/src/WebRTCLibDataChannel.cpp @@ -144,6 +144,11 @@ bool WebRTCLibDataChannel::is_negotiated() const { return channel->negotiated(); } +int WebRTCLibDataChannel::get_buffered_amount() const { + ERR_FAIL_COND_V(channel.get() == nullptr, 0); + return channel->buffered_amount(); +} + godot_error WebRTCLibDataChannel::poll() { return GODOT_OK; } diff --git a/src/WebRTCLibDataChannel.hpp b/src/WebRTCLibDataChannel.hpp index 1d1ce0f..63c7fdd 100644 --- a/src/WebRTCLibDataChannel.hpp +++ b/src/WebRTCLibDataChannel.hpp @@ -87,6 +87,7 @@ public: int get_max_retransmits() const; const char *get_protocol() const; bool is_negotiated() const; + int get_buffered_amount() const; godot_error poll(); void close(); diff --git a/src/net/WebRTCDataChannelNative.cpp b/src/net/WebRTCDataChannelNative.cpp index 86d0afa..4e6b114 100644 --- a/src/net/WebRTCDataChannelNative.cpp +++ b/src/net/WebRTCDataChannelNative.cpp @@ -113,6 +113,10 @@ bool is_negotiated_wdc(const void *user) { return ((WebRTCDataChannelNative *)user)->is_negotiated(); } +int get_buffered_amount_wdc(const void *user) { + return ((WebRTCDataChannelNative *)user)->get_buffered_amount(); +} + godot_error poll_wdc(void *user) { return ((WebRTCDataChannelNative *)user)->poll(); } diff --git a/src/net/WebRTCDataChannelNative.hpp b/src/net/WebRTCDataChannelNative.hpp index 37b8616..20ef38e 100644 --- a/src/net/WebRTCDataChannelNative.hpp +++ b/src/net/WebRTCDataChannelNative.hpp @@ -54,13 +54,30 @@ int get_max_packet_life_time_wdc(const void *); int get_max_retransmits_wdc(const void *); const char *get_protocol_wdc(const void *); bool is_negotiated_wdc(const void *); +int get_buffered_amount_wdc(const void *); godot_error poll_wdc(void *); void close_wdc(void *); +#if GODOT_NET_WEBRTC_API_MAJOR == 3 && GODOT_NET_WEBRTC_API_MINOR < 4 +extern "C" { +/* Extensions to WebRTCDataChannel */ +typedef struct { + int (*get_buffered_amount)(const void *); + + void *next; /* For extension? */ +} godot_net_webrtc_data_channel_ext; +} +#endif + class WebRTCDataChannelNative : public godot::WebRTCDataChannelGDNative { GODOT_CLASS(WebRTCDataChannelNative, godot::WebRTCDataChannelGDNative); protected: + godot_net_webrtc_data_channel_ext interface_ext = { + &get_buffered_amount_wdc, + NULL, + }; + godot_net_webrtc_data_channel interface = { { 3, 1 }, this, @@ -84,7 +101,7 @@ protected: &poll_wdc, &close_wdc, - NULL, + &interface_ext, }; public: @@ -105,6 +122,7 @@ public: 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 godot_error poll() = 0; virtual void close() = 0; |