From 1e98e7bf92e54461650801e95226be4e60c71a80 Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Thu, 24 Feb 2022 22:44:45 +0100 Subject: [PATCH] p2p: Add field trial WebRTC-SetSocketReceiveBuffer This field trial sets a non-zero receive buffer on the media UDP socket with the intention to result in less packet loss in situations when the application can't read packets fast enough from the socket. This can be due to e.g. external factors, e.g. operating system not scheduling the application for a longer time, or due to internal factors, e.g. slow processing, a long running garbage collector, and more. The size as set as the field trial parameter, as e.g. WebRTC-SetSocketReceiveBuffer/Enabled-250/ to set it to 250kb. Bug: webrtc:13753 Change-Id: Iae38d0db0c595d6e0148a2fdeb85ee8895e90560 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252581 Reviewed-by: Jonas Oreland Commit-Queue: Victor Boivie Cr-Commit-Position: refs/heads/main@{#36080} --- p2p/base/p2p_transport_channel.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 9fe9cac948..5667bc516b 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -786,6 +786,16 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) { SetOption(rtc::Socket::OPT_DSCP, *field_trials_.override_dscp); } + std::string field_trial_string = + webrtc::field_trial::FindFullName("WebRTC-SetSocketReceiveBuffer"); + int receive_buffer_size_kb = 0; + sscanf(field_trial_string.c_str(), "Enabled-%d", &receive_buffer_size_kb); + if (receive_buffer_size_kb > 0) { + RTC_LOG(LS_INFO) << "Set WebRTC-SetSocketReceiveBuffer: Enabled and set to " + << receive_buffer_size_kb << "kb"; + SetOption(rtc::Socket::OPT_RCVBUF, receive_buffer_size_kb * 1024); + } + RTC_DCHECK(ValidateIceConfig(config_).ok()); }