diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-08-21 21:17:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-21 21:17:48 +0200 |
commit | 22df2b79b6a6ec2114108c7f7058719d643c1a48 (patch) | |
tree | 85bf047f0f75f3faf6ca5455ca3fc1b37bb2bc8e /modules/webrtc | |
parent | 1a4dbd9ee2fd471108dc4d217aacab74cf412925 (diff) | |
parent | 5f9ed1979d5fe1294e297cfe3e9e98cace9c1186 (diff) |
Merge pull request #30851 from TheDevelo/webrtc-buffer
Allow setting buffer size of WebRTCDataChannel
Diffstat (limited to 'modules/webrtc')
-rw-r--r-- | modules/webrtc/register_types.cpp | 7 | ||||
-rw-r--r-- | modules/webrtc/webrtc_data_channel.cpp | 2 | ||||
-rw-r--r-- | modules/webrtc/webrtc_data_channel.h | 4 | ||||
-rw-r--r-- | modules/webrtc/webrtc_data_channel_js.cpp | 2 |
4 files changed, 14 insertions, 1 deletions
diff --git a/modules/webrtc/register_types.cpp b/modules/webrtc/register_types.cpp index 58b68d926b..6f97842064 100644 --- a/modules/webrtc/register_types.cpp +++ b/modules/webrtc/register_types.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "register_types.h" +#include "core/project_settings.h" #include "webrtc_data_channel.h" #include "webrtc_peer_connection.h" @@ -43,6 +44,12 @@ #include "webrtc_multiplayer.h" void register_webrtc_types() { +#define _SET_HINT(NAME, _VAL_, _MAX_) \ + GLOBAL_DEF(NAME, _VAL_); \ + ProjectSettings::get_singleton()->set_custom_property_info(NAME, PropertyInfo(Variant::INT, NAME, PROPERTY_HINT_RANGE, "2," #_MAX_ ",1,or_greater")); + + _SET_HINT(WRTC_IN_BUF, 64, 4096); + #ifdef JAVASCRIPT_ENABLED WebRTCPeerConnectionJS::make_default(); #elif defined(WEBRTC_GDNATIVE_ENABLED) diff --git a/modules/webrtc/webrtc_data_channel.cpp b/modules/webrtc/webrtc_data_channel.cpp index 2bd30e68f5..7b3843410a 100644 --- a/modules/webrtc/webrtc_data_channel.cpp +++ b/modules/webrtc/webrtc_data_channel.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "webrtc_data_channel.h" +#include "core/project_settings.h" void WebRTCDataChannel::_bind_methods() { ClassDB::bind_method(D_METHOD("poll"), &WebRTCDataChannel::poll); @@ -58,6 +59,7 @@ void WebRTCDataChannel::_bind_methods() { } WebRTCDataChannel::WebRTCDataChannel() { + _in_buffer_shift = nearest_shift((int)GLOBAL_GET(WRTC_IN_BUF) - 1) + 10; } WebRTCDataChannel::~WebRTCDataChannel() { diff --git a/modules/webrtc/webrtc_data_channel.h b/modules/webrtc/webrtc_data_channel.h index 0b161da784..7e2c08d9d7 100644 --- a/modules/webrtc/webrtc_data_channel.h +++ b/modules/webrtc/webrtc_data_channel.h @@ -33,6 +33,8 @@ #include "core/io/packet_peer.h" +#define WRTC_IN_BUF "network/limits/webrtc/max_channel_in_buffer_kb" + class WebRTCDataChannel : public PacketPeer { GDCLASS(WebRTCDataChannel, PacketPeer); @@ -50,6 +52,8 @@ public: }; protected: + unsigned int _in_buffer_shift; + static void _bind_methods(); public: diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp index 996db35cba..2edd212a50 100644 --- a/modules/webrtc/webrtc_data_channel_js.cpp +++ b/modules/webrtc/webrtc_data_channel_js.cpp @@ -56,7 +56,7 @@ EMSCRIPTEN_KEEPALIVE void _emrtc_on_ch_message(void *obj, uint8_t *p_data, uint3 } void WebRTCDataChannelJS::_on_open() { - in_buffer.resize(16); + in_buffer.resize(_in_buffer_shift); } void WebRTCDataChannelJS::_on_close() { |