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 <jonaso@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36080}
This commit is contained in:
Victor Boivie 2022-02-24 22:44:45 +01:00 committed by WebRTC LUCI CQ
parent cb24158698
commit 1e98e7bf92

View File

@ -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());
}