mirror of
https://github.com/godotengine/webrtc-native.git
synced 2026-01-03 14:09:58 +03:00
Add get_buffered_amount() to WebRTCDataChannel
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user