Make UDP receive buffer size configurable via field trial
Bug: chromium:939340 Change-Id: I2ab18554d12a1e9c62f5d3d8f8237cc4d0a1a78c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131395 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Johannes Kron <kron@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27476}
This commit is contained in:
parent
d1c6085cb3
commit
5a0665bea4
@ -1532,8 +1532,21 @@ void WebRtcVideoChannel::SetInterface(
|
||||
MediaChannel::SetInterface(iface, media_transport);
|
||||
// Set the RTP recv/send buffer to a bigger size.
|
||||
|
||||
// The group should be a positive integer with an explicit size, in
|
||||
// which case that is used as UDP recevie buffer size. All other values shall
|
||||
// result in the default value being used.
|
||||
const std::string group_name =
|
||||
webrtc::field_trial::FindFullName("WebRTC-IncreasedReceivebuffers");
|
||||
int recv_buffer_size = kVideoRtpRecvBufferSize;
|
||||
if (!group_name.empty() &&
|
||||
(sscanf(group_name.c_str(), "%d", &recv_buffer_size) != 1 ||
|
||||
recv_buffer_size <= 0)) {
|
||||
RTC_LOG(LS_WARNING) << "Invalid receive buffer size: " << group_name;
|
||||
recv_buffer_size = kVideoRtpRecvBufferSize;
|
||||
}
|
||||
|
||||
MediaChannel::SetOption(NetworkInterface::ST_RTP, rtc::Socket::OPT_RCVBUF,
|
||||
kVideoRtpRecvBufferSize);
|
||||
recv_buffer_size);
|
||||
|
||||
// Speculative change to increase the outbound socket buffer size.
|
||||
// In b/15152257, we are seeing a significant number of packets discarded
|
||||
|
||||
@ -1497,6 +1497,59 @@ TEST_F(WebRtcVideoChannelBaseTest, SetSendSetsTransportBufferSizes) {
|
||||
EXPECT_EQ(256 * 1024, network_interface_.recvbuf_size());
|
||||
}
|
||||
|
||||
// Test that we properly set the send and recv buffer sizes when overriding
|
||||
// via field trials.
|
||||
TEST_F(WebRtcVideoChannelBaseTest, OverridesRecvBufferSize) {
|
||||
// Set field trial to override the default recv buffer size, and then re-run
|
||||
// setup where the interface is created and configured.
|
||||
const int kCustomRecvBufferSize = 123456;
|
||||
webrtc::test::ScopedFieldTrials field_trial(
|
||||
"WebRTC-IncreasedReceivebuffers/123456/");
|
||||
SetUp();
|
||||
|
||||
EXPECT_TRUE(SetOneCodec(DefaultCodec()));
|
||||
EXPECT_TRUE(SetSend(true));
|
||||
EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size());
|
||||
EXPECT_EQ(kCustomRecvBufferSize, network_interface_.recvbuf_size());
|
||||
}
|
||||
|
||||
// Test that we properly set the send and recv buffer sizes when overriding
|
||||
// via field trials with suffix.
|
||||
TEST_F(WebRtcVideoChannelBaseTest, OverridesRecvBufferSizeWithSuffix) {
|
||||
// Set field trial to override the default recv buffer size, and then re-run
|
||||
// setup where the interface is created and configured.
|
||||
const int kCustomRecvBufferSize = 123456;
|
||||
webrtc::test::ScopedFieldTrials field_trial(
|
||||
"WebRTC-IncreasedReceivebuffers/123456_Dogfood/");
|
||||
SetUp();
|
||||
|
||||
EXPECT_TRUE(SetOneCodec(DefaultCodec()));
|
||||
EXPECT_TRUE(SetSend(true));
|
||||
EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size());
|
||||
EXPECT_EQ(kCustomRecvBufferSize, network_interface_.recvbuf_size());
|
||||
}
|
||||
|
||||
// Test that we properly set the send and recv buffer sizes when overriding
|
||||
// via field trials that don't make any sense.
|
||||
TEST_F(WebRtcVideoChannelBaseTest, InvalidRecvBufferSize) {
|
||||
// Set bogus field trial values to override the default recv buffer size, and
|
||||
// then re-run setup where the interface is created and configured. The
|
||||
// default value should still be used.
|
||||
|
||||
for (std::string group : {" ", "NotANumber", "-1", "0"}) {
|
||||
std::string field_trial_string = "WebRTC-IncreasedReceivebuffers/";
|
||||
field_trial_string += group;
|
||||
field_trial_string += "/";
|
||||
webrtc::test::ScopedFieldTrials field_trial(field_trial_string);
|
||||
SetUp();
|
||||
|
||||
EXPECT_TRUE(SetOneCodec(DefaultCodec()));
|
||||
EXPECT_TRUE(SetSend(true));
|
||||
EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size());
|
||||
EXPECT_EQ(256 * 1024, network_interface_.recvbuf_size());
|
||||
}
|
||||
}
|
||||
|
||||
// Test that stats work properly for a 1-1 call.
|
||||
TEST_F(WebRtcVideoChannelBaseTest, GetStats) {
|
||||
const int kDurationSec = 3;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user