Probing EndToEndTests.

Add tests for inital probing and mid-call probing by reconfiguring max bitrate.

BUG=none

Review-Url: https://codereview.webrtc.org/2760623002
Cr-Commit-Position: refs/heads/master@{#17316}
This commit is contained in:
philipel 2017-03-21 03:24:27 -07:00 committed by Commit bot
parent 0a2391f74c
commit e828c9690a
5 changed files with 114 additions and 0 deletions

View File

@ -3,6 +3,8 @@ EndToEndTest.CanSwitchToUseAllSsrcs
EndToEndTest.SendsAndReceivesVP9
TestWithNewVideoJitterBuffer/EndToEndTest.SendsAndReceivesH264/*
VideoSendStreamTest.VP9FlexMode
EndToEndTest.InitialProbing
EndToEndTest.TriggerMidCallProbing
# Times out due to using a real VP8 encoder.
*EndToEndTest.VerifyHistogramStatsWithRed*

View File

@ -419,6 +419,8 @@ const uint32_t CallTest::kReceiverLocalVideoSsrc = 0x123456;
const uint32_t CallTest::kReceiverLocalAudioSsrc = 0x1234567;
const int CallTest::kNackRtpHistoryMs = 1000;
BaseTest::BaseTest() {}
BaseTest::BaseTest(unsigned int timeout_ms) : RtpRtcpObserver(timeout_ms) {
}
@ -496,6 +498,8 @@ bool SendTest::ShouldCreateReceivers() const {
return false;
}
EndToEndTest::EndToEndTest() {}
EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) {
}

View File

@ -150,6 +150,7 @@ class CallTest : public ::testing::Test {
class BaseTest : public RtpRtcpObserver {
public:
BaseTest();
explicit BaseTest(unsigned int timeout_ms);
virtual ~BaseTest();
@ -205,6 +206,7 @@ class SendTest : public BaseTest {
class EndToEndTest : public BaseTest {
public:
EndToEndTest();
explicit EndToEndTest(unsigned int timeout_ms);
bool ShouldCreateReceivers() const override;

View File

@ -67,6 +67,7 @@ class RtpRtcpObserver {
}
protected:
RtpRtcpObserver() : RtpRtcpObserver(0) {}
explicit RtpRtcpObserver(int event_timeout_ms)
: observation_complete_(false, false),
parser_(RtpHeaderParser::Create()),

View File

@ -2198,6 +2198,111 @@ TEST_F(EndToEndTest, RembWithSendSideBwe) {
RunBaseTest(&test);
}
class ProbingTest : public test::EndToEndTest {
public:
explicit ProbingTest(int start_bitrate_bps)
: clock_(Clock::GetRealTimeClock()),
start_bitrate_bps_(start_bitrate_bps),
state_(0),
sender_call_(nullptr) {}
~ProbingTest() {}
Call::Config GetSenderCallConfig() override {
Call::Config config(&event_log_);
config.bitrate_config.start_bitrate_bps = start_bitrate_bps_;
return config;
}
void OnCallsCreated(Call* sender_call, Call* receiver_call) override {
sender_call_ = sender_call;
}
protected:
Clock* const clock_;
const int start_bitrate_bps_;
int state_;
Call* sender_call_;
};
TEST_F(EndToEndTest, InitialProbing) {
class InitialProbingTest : public ProbingTest {
public:
InitialProbingTest() : ProbingTest(300000) {}
void PerformTest() override {
int64_t start_time_ms = clock_->TimeInMilliseconds();
do {
if (clock_->TimeInMilliseconds() - start_time_ms > kTimeoutMs) {
ADD_FAILURE() << "Timed out while waiting for initial probing.";
break;
}
Call::Stats stats = sender_call_->GetStats();
// Initial probing is done with a x3 and x6 multiplier of the start
// bitrate, so a x4 multiplier is a high enough threshold.
if (stats.send_bandwidth_bps > 4 * 300000)
break;
} while (!observation_complete_.Wait(20));
}
private:
const int kTimeoutMs = 1000;
} test;
RunBaseTest(&test);
}
TEST_F(EndToEndTest, TriggerMidCallProbing) {
class TriggerMidCallProbingTest : public ProbingTest {
public:
TriggerMidCallProbingTest() : ProbingTest(300000) {}
void PerformTest() override {
int64_t start_time_ms = clock_->TimeInMilliseconds();
do {
if (clock_->TimeInMilliseconds() - start_time_ms > kTimeoutMs) {
ADD_FAILURE() << "Timed out while waiting for mid-call probing.";
break;
}
Call::Stats stats = sender_call_->GetStats();
switch (state_) {
case 0:
if (stats.send_bandwidth_bps > 5 * 300000) {
Call::Config::BitrateConfig bitrate_config;
bitrate_config.max_bitrate_bps = 100000;
sender_call_->SetBitrateConfig(bitrate_config);
++state_;
}
break;
case 1:
if (stats.send_bandwidth_bps < 110000) {
Call::Config::BitrateConfig bitrate_config;
bitrate_config.max_bitrate_bps = 2500000;
sender_call_->SetBitrateConfig(bitrate_config);
++state_;
}
break;
case 2:
// During high cpu load the pacer will not be able to pace packets
// at the correct speed, but if we go from 110 to 1250 kbps
// in 5 seconds then it is due to probing.
if (stats.send_bandwidth_bps > 1250000)
observation_complete_.Set();
break;
}
} while (!observation_complete_.Wait(20));
}
private:
const int kTimeoutMs = 5000;
} test;
RunBaseTest(&test);
}
TEST_F(EndToEndTest, VerifyNackStats) {
static const int kPacketNumberToDrop = 200;
class NackObserver : public test::EndToEndTest {