From 92da4a3c26d6e937df8d84af542fbcac27600d6a Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 14 May 2024 22:11:48 +0200 Subject: [PATCH] Allow specifying custom libdatachannel configuration options This includes: - enableIceTcp - enableIceUdpMux - portRangeBegin - portRangeEnd - mtu e.g. ``` var pc := WebRTCPeerConnection.new() if OS.get_name() != "Web": pc.initialize({ "libdatachannel": { "enableIceUdpMux": true, "portRangeBegin": 4343, "portRangeEnd": 4343, }, }) ``` --- src/WebRTCLibPeerConnection.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/WebRTCLibPeerConnection.cpp b/src/WebRTCLibPeerConnection.cpp index bc730a7..8bec57d 100644 --- a/src/WebRTCLibPeerConnection.cpp +++ b/src/WebRTCLibPeerConnection.cpp @@ -196,6 +196,24 @@ Error WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) { ERR_FAIL_COND_V(err != OK, FAILED); } } + if (p_config.has("libdatachannel") && p_config["libdatachannel"].get_type() == Variant::DICTIONARY) { + Dictionary lib_cfg = p_config["libdatachannel"]; + if (lib_cfg.has("enableIceTcp") && lib_cfg["enableIceTcp"].get_type() == Variant::BOOL) { + config.enableIceTcp = lib_cfg["enableIceTcp"].operator bool(); + } + if (lib_cfg.has("enableIceUdpMux") && lib_cfg["enableIceUdpMux"].get_type() == Variant::BOOL) { + config.enableIceUdpMux = lib_cfg["enableIceUdpMux"].operator bool(); + } + if (lib_cfg.has("portRangeBegin") && lib_cfg["portRangeBegin"].get_type() == Variant::INT) { + config.portRangeBegin = lib_cfg["portRangeBegin"].operator int(); + } + if (lib_cfg.has("portRangeEnd") && lib_cfg["portRangeEnd"].get_type() == Variant::INT) { + config.portRangeEnd = lib_cfg["portRangeEnd"].operator int(); + } + if (lib_cfg.has("mtu") && lib_cfg["mtu"].get_type() == Variant::INT) { + config.mtu = lib_cfg["mtu"].operator int(); + } + } return _create_pc(config); }