Simplify bwe tests.
R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/29999004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7576 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
2dc6f3154d
commit
4abadab708
@ -40,45 +40,45 @@ TEST_F(RemoteBitrateEstimatorSingleTest, RateIncreaseReordering) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RemoteBitrateEstimatorSingleTest, RateIncreaseRtpTimestamps) {
|
TEST_F(RemoteBitrateEstimatorSingleTest, RateIncreaseRtpTimestamps) {
|
||||||
RateIncreaseRtpTimestampsTestHelper();
|
RateIncreaseRtpTimestampsTestHelper(1621);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the time it takes for the estimator to reduce the bitrate when
|
// Verify that the time it takes for the estimator to reduce the bitrate when
|
||||||
// the capacity is tightened stays the same.
|
// the capacity is tightened stays the same.
|
||||||
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropOneStream) {
|
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropOneStream) {
|
||||||
CapacityDropTestHelper(1, false, 956214, 367);
|
CapacityDropTestHelper(1, false, 367);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the time it takes for the estimator to reduce the bitrate when
|
// Verify that the time it takes for the estimator to reduce the bitrate when
|
||||||
// the capacity is tightened stays the same. This test also verifies that we
|
// the capacity is tightened stays the same. This test also verifies that we
|
||||||
// handle wrap-arounds in this scenario.
|
// handle wrap-arounds in this scenario.
|
||||||
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropOneStreamWrap) {
|
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropOneStreamWrap) {
|
||||||
CapacityDropTestHelper(1, true, 956214, 367);
|
CapacityDropTestHelper(1, true, 367);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the time it takes for the estimator to reduce the bitrate when
|
// Verify that the time it takes for the estimator to reduce the bitrate when
|
||||||
// the capacity is tightened stays the same. This test also verifies that we
|
// the capacity is tightened stays the same. This test also verifies that we
|
||||||
// handle wrap-arounds in this scenario. This is a multi-stream test.
|
// handle wrap-arounds in this scenario. This is a multi-stream test.
|
||||||
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropTwoStreamsWrap) {
|
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropTwoStreamsWrap) {
|
||||||
CapacityDropTestHelper(2, true, 927088, 267);
|
CapacityDropTestHelper(2, true, 267);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the time it takes for the estimator to reduce the bitrate when
|
// Verify that the time it takes for the estimator to reduce the bitrate when
|
||||||
// the capacity is tightened stays the same. This test also verifies that we
|
// the capacity is tightened stays the same. This test also verifies that we
|
||||||
// handle wrap-arounds in this scenario. This is a multi-stream test.
|
// handle wrap-arounds in this scenario. This is a multi-stream test.
|
||||||
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropThreeStreamsWrap) {
|
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropThreeStreamsWrap) {
|
||||||
CapacityDropTestHelper(3, true, 920944, 333);
|
CapacityDropTestHelper(3, true, 333);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropThirteenStreamsWrap) {
|
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropThirteenStreamsWrap) {
|
||||||
CapacityDropTestHelper(13, true, 938944, 300);
|
CapacityDropTestHelper(13, true, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropNineteenStreamsWrap) {
|
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropNineteenStreamsWrap) {
|
||||||
CapacityDropTestHelper(19, true, 926718, 300);
|
CapacityDropTestHelper(19, true, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropThirtyStreamsWrap) {
|
TEST_F(RemoteBitrateEstimatorSingleTest, CapacityDropThirtyStreamsWrap) {
|
||||||
CapacityDropTestHelper(30, true, 927016, 300);
|
CapacityDropTestHelper(30, true, 300);
|
||||||
}
|
}
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
enum { kMtu = 1200 };
|
enum { kMtu = 1200, kAcceptedBitrateErrorBps = 50000u };
|
||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
@ -225,6 +225,7 @@ void RemoteBitrateEstimatorTest::IncomingPacket(uint32_t ssrc,
|
|||||||
memset(&header, 0, sizeof(header));
|
memset(&header, 0, sizeof(header));
|
||||||
header.ssrc = ssrc;
|
header.ssrc = ssrc;
|
||||||
header.timestamp = rtp_timestamp;
|
header.timestamp = rtp_timestamp;
|
||||||
|
header.extension.hasAbsoluteSendTime = true;
|
||||||
header.extension.absoluteSendTime = absolute_send_time;
|
header.extension.absoluteSendTime = absolute_send_time;
|
||||||
bitrate_estimator_->IncomingPacket(arrival_time + kArrivalTimeClockOffsetMs,
|
bitrate_estimator_->IncomingPacket(arrival_time + kArrivalTimeClockOffsetMs,
|
||||||
payload_size, header);
|
payload_size, header);
|
||||||
@ -340,7 +341,7 @@ void RemoteBitrateEstimatorTest::InitialBehaviorTestHelper(
|
|||||||
EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
|
EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
|
||||||
ASSERT_EQ(1u, ssrcs.size());
|
ASSERT_EQ(1u, ssrcs.size());
|
||||||
EXPECT_EQ(kDefaultSsrc, ssrcs.front());
|
EXPECT_EQ(kDefaultSsrc, ssrcs.front());
|
||||||
EXPECT_EQ(expected_converge_bitrate, bitrate_bps);
|
EXPECT_NEAR(expected_converge_bitrate, bitrate_bps, kAcceptedBitrateErrorBps);
|
||||||
EXPECT_TRUE(bitrate_observer_->updated());
|
EXPECT_TRUE(bitrate_observer_->updated());
|
||||||
bitrate_observer_->Reset();
|
bitrate_observer_->Reset();
|
||||||
EXPECT_EQ(bitrate_observer_->latest_bitrate(), bitrate_bps);
|
EXPECT_EQ(bitrate_observer_->latest_bitrate(), bitrate_bps);
|
||||||
@ -372,7 +373,9 @@ void RemoteBitrateEstimatorTest::RateIncreaseReorderingTestHelper(
|
|||||||
}
|
}
|
||||||
bitrate_estimator_->Process();
|
bitrate_estimator_->Process();
|
||||||
EXPECT_TRUE(bitrate_observer_->updated());
|
EXPECT_TRUE(bitrate_observer_->updated());
|
||||||
EXPECT_EQ(expected_bitrate_bps, bitrate_observer_->latest_bitrate());
|
EXPECT_NEAR(expected_bitrate_bps,
|
||||||
|
bitrate_observer_->latest_bitrate(),
|
||||||
|
kAcceptedBitrateErrorBps);
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
|
clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
|
||||||
timestamp += 2 * 90 * kFrameIntervalMs;
|
timestamp += 2 * 90 * kFrameIntervalMs;
|
||||||
@ -387,15 +390,17 @@ void RemoteBitrateEstimatorTest::RateIncreaseReorderingTestHelper(
|
|||||||
}
|
}
|
||||||
bitrate_estimator_->Process();
|
bitrate_estimator_->Process();
|
||||||
EXPECT_TRUE(bitrate_observer_->updated());
|
EXPECT_TRUE(bitrate_observer_->updated());
|
||||||
EXPECT_EQ(expected_bitrate_bps, bitrate_observer_->latest_bitrate());
|
EXPECT_NEAR(expected_bitrate_bps,
|
||||||
|
bitrate_observer_->latest_bitrate(),
|
||||||
|
kAcceptedBitrateErrorBps);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we initially increase the bitrate as expected.
|
// Make sure we initially increase the bitrate as expected.
|
||||||
void RemoteBitrateEstimatorTest::RateIncreaseRtpTimestampsTestHelper() {
|
void RemoteBitrateEstimatorTest::RateIncreaseRtpTimestampsTestHelper(
|
||||||
|
int expected_iterations) {
|
||||||
// This threshold corresponds approximately to increasing linearly with
|
// This threshold corresponds approximately to increasing linearly with
|
||||||
// bitrate(i) = 1.04 * bitrate(i-1) + 1000
|
// bitrate(i) = 1.04 * bitrate(i-1) + 1000
|
||||||
// until bitrate(i) > 500000, with bitrate(1) ~= 30000.
|
// until bitrate(i) > 500000, with bitrate(1) ~= 30000.
|
||||||
const int kExpectedIterations = 1621;
|
|
||||||
unsigned int bitrate_bps = 30000;
|
unsigned int bitrate_bps = 30000;
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
AddDefaultStream();
|
AddDefaultStream();
|
||||||
@ -412,15 +417,14 @@ void RemoteBitrateEstimatorTest::RateIncreaseRtpTimestampsTestHelper() {
|
|||||||
bitrate_observer_->Reset();
|
bitrate_observer_->Reset();
|
||||||
}
|
}
|
||||||
++iterations;
|
++iterations;
|
||||||
ASSERT_LE(iterations, kExpectedIterations);
|
ASSERT_LE(iterations, expected_iterations);
|
||||||
}
|
}
|
||||||
ASSERT_EQ(kExpectedIterations, iterations);
|
ASSERT_EQ(expected_iterations, iterations);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteBitrateEstimatorTest::CapacityDropTestHelper(
|
void RemoteBitrateEstimatorTest::CapacityDropTestHelper(
|
||||||
int number_of_streams,
|
int number_of_streams,
|
||||||
bool wrap_time_stamp,
|
bool wrap_time_stamp,
|
||||||
unsigned int expected_converge_bitrate,
|
|
||||||
unsigned int expected_bitrate_drop_delta) {
|
unsigned int expected_bitrate_drop_delta) {
|
||||||
const int kFramerate = 30;
|
const int kFramerate = 30;
|
||||||
const int kStartBitrate = 900e3;
|
const int kStartBitrate = 900e3;
|
||||||
@ -430,14 +434,11 @@ void RemoteBitrateEstimatorTest::CapacityDropTestHelper(
|
|||||||
const unsigned int kReducedCapacityBps = 500e3;
|
const unsigned int kReducedCapacityBps = 500e3;
|
||||||
|
|
||||||
int steady_state_time = 0;
|
int steady_state_time = 0;
|
||||||
int expected_overuse_start_time = 0;
|
|
||||||
if (number_of_streams <= 1) {
|
if (number_of_streams <= 1) {
|
||||||
steady_state_time = 10;
|
steady_state_time = 10;
|
||||||
expected_overuse_start_time = 10000;
|
|
||||||
AddDefaultStream();
|
AddDefaultStream();
|
||||||
} else {
|
} else {
|
||||||
steady_state_time = 8 * number_of_streams;
|
steady_state_time = 8 * number_of_streams;
|
||||||
expected_overuse_start_time = 8000;
|
|
||||||
int bitrate_sum = 0;
|
int bitrate_sum = 0;
|
||||||
int kBitrateDenom = number_of_streams * (number_of_streams - 1);
|
int kBitrateDenom = number_of_streams * (number_of_streams - 1);
|
||||||
for (int i = 0; i < number_of_streams; i++) {
|
for (int i = 0; i < number_of_streams; i++) {
|
||||||
@ -471,13 +472,12 @@ void RemoteBitrateEstimatorTest::CapacityDropTestHelper(
|
|||||||
kMinExpectedBitrate,
|
kMinExpectedBitrate,
|
||||||
kMaxExpectedBitrate,
|
kMaxExpectedBitrate,
|
||||||
kInitialCapacityBps);
|
kInitialCapacityBps);
|
||||||
EXPECT_EQ(expected_converge_bitrate, bitrate_bps);
|
EXPECT_NEAR(kInitialCapacityBps, bitrate_bps, 100000u);
|
||||||
bitrate_observer_->Reset();
|
bitrate_observer_->Reset();
|
||||||
|
|
||||||
// Reduce the capacity and verify the decrease time.
|
// Reduce the capacity and verify the decrease time.
|
||||||
stream_generator_->set_capacity_bps(kReducedCapacityBps);
|
stream_generator_->set_capacity_bps(kReducedCapacityBps);
|
||||||
int64_t overuse_start_time = clock_.TimeInMilliseconds();
|
int64_t overuse_start_time = clock_.TimeInMilliseconds();
|
||||||
EXPECT_EQ(expected_overuse_start_time, overuse_start_time);
|
|
||||||
int64_t bitrate_drop_time = -1;
|
int64_t bitrate_drop_time = -1;
|
||||||
for (int i = 0; i < 100 * number_of_streams; ++i) {
|
for (int i = 0; i < 100 * number_of_streams; ++i) {
|
||||||
GenerateAndProcessFrame(kDefaultSsrc, bitrate_bps);
|
GenerateAndProcessFrame(kDefaultSsrc, bitrate_bps);
|
||||||
|
@ -191,10 +191,9 @@ class RemoteBitrateEstimatorTest : public ::testing::Test {
|
|||||||
|
|
||||||
void InitialBehaviorTestHelper(unsigned int expected_converge_bitrate);
|
void InitialBehaviorTestHelper(unsigned int expected_converge_bitrate);
|
||||||
void RateIncreaseReorderingTestHelper(unsigned int expected_bitrate);
|
void RateIncreaseReorderingTestHelper(unsigned int expected_bitrate);
|
||||||
void RateIncreaseRtpTimestampsTestHelper();
|
void RateIncreaseRtpTimestampsTestHelper(int expected_iterations);
|
||||||
void CapacityDropTestHelper(int number_of_streams,
|
void CapacityDropTestHelper(int number_of_streams,
|
||||||
bool wrap_time_stamp,
|
bool wrap_time_stamp,
|
||||||
unsigned int expected_converge_bitrate,
|
|
||||||
unsigned int expected_bitrate_drop_delta);
|
unsigned int expected_bitrate_drop_delta);
|
||||||
|
|
||||||
static const unsigned int kDefaultSsrc;
|
static const unsigned int kDefaultSsrc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user