Add field trial flag for increased receive buffers

Bug: webrtc:9637
Change-Id: Id84c78fa17fbd959af3ab81209e0636317f3da4b
Reviewed-on: https://webrtc-review.googlesource.com/94768
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24349}
This commit is contained in:
Erik Språng
2018-08-20 17:14:25 +02:00
committed by Commit Bot
parent d34a188649
commit 820ebd0f66
2 changed files with 68 additions and 2 deletions

View File

@ -1511,9 +1511,22 @@ void WebRtcVideoChannel::OnNetworkRouteChanged(
void WebRtcVideoChannel::SetInterface(NetworkInterface* iface) {
MediaChannel::SetInterface(iface);
// Set the RTP recv/send buffer to a bigger size
// Set the RTP recv/send buffer to a bigger size.
// The group here can be either a positive integer with an explicit size, in
// which case that is used as 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 = kVideoRtpBufferSize;
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 = kVideoRtpBufferSize;
}
MediaChannel::SetOption(NetworkInterface::ST_RTP, rtc::Socket::OPT_RCVBUF,
kVideoRtpBufferSize);
recv_buffer_size);
// Speculative change to increase the outbound socket buffer size.
// In b/15152257, we are seeing a significant number of packets discarded

View File

@ -1436,6 +1436,59 @@ TEST_F(WebRtcVideoChannelBaseTest, SetSendSetsTransportBufferSizes) {
EXPECT_EQ(64 * 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(64 * 1024, network_interface_.recvbuf_size());
}
}
// Test that stats work properly for a 1-1 call.
TEST_F(WebRtcVideoChannelBaseTest, GetStats) {
const int kDurationSec = 3;