Refactor in BitrateController module.
- Move condition of 0 bps as max meaning 1gbps from SendSideBandwidthEstimation to BitrateController.
- Remove condition on bitrate=0 meaning bandwidth estimation off as that could only happen when no observers existed
and in which case the estimation would be ignored.
- Add MaybeTriggerOnNetworkChanged which only runs rate allocation if any of the dependent variables has changed
thus allowing to remove many of the bool returns that try to indicate if the estimation has changed which would not
be aware if the observers have changed.
- SendSideBandwidthEstimation now has a UpdateBitrate and has clear code paths to which calls update bitrate.
- Changes in enforce_min_bitrate so the 10kbps min is set from the BitrateController and not from the outside this keep valid as observers are changed.
R=henrik.lundin@webrtc.org, stefan@webrtc.org
BUG=3065
Review URL: https://webrtc-codereview.appspot.com/10189004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5752 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc b/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc
index 30f85a8..c53928b 100644
--- a/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc
+++ b/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc
@@ -92,9 +92,9 @@
webrtc::ReportBlockList report_blocks;
report_blocks.push_back(CreateReportBlock(1, 2, 0, 1));
bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 1);
- EXPECT_EQ(0u, bitrate_observer.last_bitrate_);
+ EXPECT_EQ(200000u, bitrate_observer.last_bitrate_);
EXPECT_EQ(0, bitrate_observer.last_fraction_loss_);
- EXPECT_EQ(0u, bitrate_observer.last_rtt_);
+ EXPECT_EQ(50u, bitrate_observer.last_rtt_);
// Test bitrate increase 8% per second.
report_blocks.clear();
@@ -161,9 +161,9 @@
bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 1);
second_bandwidth_observer->OnReceivedRtcpReceiverReport(
report_blocks, 100, 1);
- EXPECT_EQ(0u, bitrate_observer.last_bitrate_);
+ EXPECT_EQ(200000u, bitrate_observer.last_bitrate_);
EXPECT_EQ(0, bitrate_observer.last_fraction_loss_);
- EXPECT_EQ(0u, bitrate_observer.last_rtt_);
+ EXPECT_EQ(100u, bitrate_observer.last_rtt_);
// Test bitrate increase 8% per second.
report_blocks.clear();
@@ -323,11 +323,6 @@
webrtc::ReportBlockList report_blocks;
report_blocks.push_back(CreateReportBlock(1, 2, 0, 1));
bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 1);
-
- // Test bitrate increase 8% per second, distributed equally.
- report_blocks.clear();
- report_blocks.push_back(CreateReportBlock(1, 2, 0, 21));
- bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 1001);
EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_);
EXPECT_EQ(0, bitrate_observer_1.last_fraction_loss_);
EXPECT_EQ(50u, bitrate_observer_1.last_rtt_);
@@ -336,21 +331,22 @@
EXPECT_EQ(0, bitrate_observer_2.last_fraction_loss_);
EXPECT_EQ(50u, bitrate_observer_2.last_rtt_);
+ // Test bitrate increase 8% per second, distributed equally.
report_blocks.clear();
- report_blocks.push_back(CreateReportBlock(1, 2, 0, 41));
- bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 2001);
+ report_blocks.push_back(CreateReportBlock(1, 2, 0, 21));
+ bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 1001);
EXPECT_EQ(112500u, bitrate_observer_1.last_bitrate_);
EXPECT_EQ(212500u, bitrate_observer_2.last_bitrate_);
report_blocks.clear();
- report_blocks.push_back(CreateReportBlock(1, 2, 0, 61));
- bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 3001);
+ report_blocks.push_back(CreateReportBlock(1, 2, 0, 41));
+ bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 2001);
EXPECT_EQ(126000u, bitrate_observer_1.last_bitrate_);
EXPECT_EQ(226000u, bitrate_observer_2.last_bitrate_);
report_blocks.clear();
- report_blocks.push_back(CreateReportBlock(1, 2, 0, 81));
- bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 4001);
+ report_blocks.push_back(CreateReportBlock(1, 2, 0, 61));
+ bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 3001);
EXPECT_EQ(140580u, bitrate_observer_1.last_bitrate_);
EXPECT_EQ(240580u, bitrate_observer_2.last_bitrate_);
@@ -434,8 +430,12 @@
EXPECT_EQ(150000u, bitrate_observer_1.last_bitrate_);
// Low REMB.
- bandwidth_observer_->OnReceivedEstimatedBitrate(1000);
- EXPECT_EQ(1000u, bitrate_observer_1.last_bitrate_);
+ bandwidth_observer_->OnReceivedEstimatedBitrate(10000);
+ EXPECT_EQ(10000u, bitrate_observer_1.last_bitrate_);
+
+ // Keeps at least 10 kbps.
+ bandwidth_observer_->OnReceivedEstimatedBitrate(9000);
+ EXPECT_EQ(10000u, bitrate_observer_1.last_bitrate_);
controller_->RemoveBitrateObserver(&bitrate_observer_1);
}
@@ -469,9 +469,15 @@
EXPECT_EQ(200000u, bitrate_observer_3.last_bitrate_); // Remainder.
// Low REMB.
- bandwidth_observer_->OnReceivedEstimatedBitrate(1000);
+ bandwidth_observer_->OnReceivedEstimatedBitrate(10000);
// Verify that the first observer gets all the rate, and the rest get zero.
- EXPECT_EQ(1000u, bitrate_observer_1.last_bitrate_);
+ EXPECT_EQ(10000u, bitrate_observer_1.last_bitrate_);
+ EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_);
+ EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_);
+
+ // Verify it keeps an estimate of at least 10kbps.
+ bandwidth_observer_->OnReceivedEstimatedBitrate(9000);
+ EXPECT_EQ(10000u, bitrate_observer_1.last_bitrate_);
EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_);
EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_);