| Index: webrtc/modules/congestion_controller/probe_bitrate_estimator_unittest.cc
|
| diff --git a/webrtc/modules/congestion_controller/probe_bitrate_estimator_unittest.cc b/webrtc/modules/congestion_controller/probe_bitrate_estimator_unittest.cc
|
| index a96e1d857f4880c61292ae5f34a35722d68017fc..a476bbaf0f9c0e0de5434ad9ce77d18631e911b8 100644
|
| --- a/webrtc/modules/congestion_controller/probe_bitrate_estimator_unittest.cc
|
| +++ b/webrtc/modules/congestion_controller/probe_bitrate_estimator_unittest.cc
|
| @@ -19,7 +19,11 @@
|
|
|
| namespace webrtc {
|
|
|
| -constexpr int INVALID_BPS = -1;
|
| +namespace {
|
| +constexpr int kInvalidBitrate = -1;
|
| +constexpr int kDefaultMinProbes = 5;
|
| +constexpr int kDefaultMinBytes = 5000;
|
| +} // anonymous namespace
|
|
|
| class TestProbeBitrateEstimator : public ::testing::Test {
|
| public:
|
| @@ -30,15 +34,18 @@ class TestProbeBitrateEstimator : public ::testing::Test {
|
| void AddPacketFeedback(int probe_cluster_id,
|
| size_t size_bytes,
|
| int64_t send_time_ms,
|
| - int64_t arrival_time_ms) {
|
| + int64_t arrival_time_ms,
|
| + int min_probes = kDefaultMinProbes,
|
| + int min_bytes = kDefaultMinBytes) {
|
| + PacedPacketInfo pacing_info(probe_cluster_id, min_probes, min_bytes);
|
| PacketFeedback packet_feedback(arrival_time_ms, send_time_ms, 0, size_bytes,
|
| - PacedPacketInfo(probe_cluster_id, -1, -1));
|
| + pacing_info);
|
| measured_bps_ =
|
| probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback);
|
| }
|
|
|
| protected:
|
| - int measured_bps_ = INVALID_BPS;
|
| + int measured_bps_ = kInvalidBitrate;
|
| ProbeBitrateEstimator probe_bitrate_estimator_;
|
| };
|
|
|
| @@ -51,6 +58,50 @@ TEST_F(TestProbeBitrateEstimator, OneCluster) {
|
| EXPECT_NEAR(measured_bps_, 800000, 10);
|
| }
|
|
|
| +TEST_F(TestProbeBitrateEstimator, OneClusterTooFewProbes) {
|
| + AddPacketFeedback(0, 2000, 0, 10);
|
| + AddPacketFeedback(0, 2000, 10, 20);
|
| + AddPacketFeedback(0, 2000, 20, 30);
|
| +
|
| + EXPECT_EQ(kInvalidBitrate, measured_bps_);
|
| +}
|
| +
|
| +TEST_F(TestProbeBitrateEstimator, OneClusterTooFewBytes) {
|
| + const int kMinBytes = 6000;
|
| + AddPacketFeedback(0, 800, 0, 10, kDefaultMinProbes, kMinBytes);
|
| + AddPacketFeedback(0, 800, 10, 20, kDefaultMinProbes, kMinBytes);
|
| + AddPacketFeedback(0, 800, 20, 30, kDefaultMinProbes, kMinBytes);
|
| + AddPacketFeedback(0, 800, 30, 40, kDefaultMinProbes, kMinBytes);
|
| + AddPacketFeedback(0, 800, 40, 50, kDefaultMinProbes, kMinBytes);
|
| +
|
| + EXPECT_EQ(kInvalidBitrate, measured_bps_);
|
| +}
|
| +
|
| +TEST_F(TestProbeBitrateEstimator, SmallCluster) {
|
| + const int kMinBytes = 1000;
|
| + AddPacketFeedback(0, 150, 0, 10, kDefaultMinProbes, kMinBytes);
|
| + AddPacketFeedback(0, 150, 10, 20, kDefaultMinProbes, kMinBytes);
|
| + AddPacketFeedback(0, 150, 20, 30, kDefaultMinProbes, kMinBytes);
|
| + AddPacketFeedback(0, 150, 30, 40, kDefaultMinProbes, kMinBytes);
|
| + AddPacketFeedback(0, 150, 40, 50, kDefaultMinProbes, kMinBytes);
|
| + AddPacketFeedback(0, 150, 50, 60, kDefaultMinProbes, kMinBytes);
|
| + EXPECT_NEAR(measured_bps_, 120000, 10);
|
| +}
|
| +
|
| +TEST_F(TestProbeBitrateEstimator, LargeCluster) {
|
| + const int kMinProbes = 30;
|
| + const int kMinBytes = 312500;
|
| +
|
| + int64_t send_time = 0;
|
| + int64_t receive_time = 5;
|
| + for (int i = 0; i < 25; ++i) {
|
| + AddPacketFeedback(0, 12500, send_time, receive_time, kMinProbes, kMinBytes);
|
| + ++send_time;
|
| + ++receive_time;
|
| + }
|
| + EXPECT_NEAR(measured_bps_, 100000000, 10);
|
| +}
|
| +
|
| TEST_F(TestProbeBitrateEstimator, FastReceive) {
|
| AddPacketFeedback(0, 1000, 0, 15);
|
| AddPacketFeedback(0, 1000, 10, 30);
|
| @@ -66,7 +117,7 @@ TEST_F(TestProbeBitrateEstimator, TooFastReceive) {
|
| AddPacketFeedback(0, 1000, 20, 25);
|
| AddPacketFeedback(0, 1000, 40, 27);
|
|
|
| - EXPECT_EQ(measured_bps_, INVALID_BPS);
|
| + EXPECT_EQ(measured_bps_, kInvalidBitrate);
|
| }
|
|
|
| TEST_F(TestProbeBitrateEstimator, SlowReceive) {
|
| @@ -84,7 +135,7 @@ TEST_F(TestProbeBitrateEstimator, BurstReceive) {
|
| AddPacketFeedback(0, 1000, 20, 50);
|
| AddPacketFeedback(0, 1000, 40, 50);
|
|
|
| - EXPECT_EQ(measured_bps_, INVALID_BPS);
|
| + EXPECT_EQ(measured_bps_, kInvalidBitrate);
|
| }
|
|
|
| TEST_F(TestProbeBitrateEstimator, MultipleClusters) {
|
| @@ -92,11 +143,9 @@ TEST_F(TestProbeBitrateEstimator, MultipleClusters) {
|
| AddPacketFeedback(0, 1000, 10, 20);
|
| AddPacketFeedback(0, 1000, 20, 30);
|
| AddPacketFeedback(0, 1000, 40, 60);
|
| -
|
| EXPECT_NEAR(measured_bps_, 480000, 10);
|
|
|
| AddPacketFeedback(0, 1000, 50, 60);
|
| -
|
| EXPECT_NEAR(measured_bps_, 640000, 10);
|
|
|
| AddPacketFeedback(1, 1000, 60, 70);
|
| @@ -122,7 +171,7 @@ TEST_F(TestProbeBitrateEstimator, IgnoreOldClusters) {
|
| // Coming in 6s later
|
| AddPacketFeedback(0, 1000, 40 + 6000, 60 + 6000);
|
|
|
| - EXPECT_EQ(measured_bps_, INVALID_BPS);
|
| + EXPECT_EQ(measured_bps_, kInvalidBitrate);
|
| }
|
|
|
| TEST_F(TestProbeBitrateEstimator, IgnoreSizeLastSendPacket) {
|
|
|