diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc index 2cc296dd36..a3b4ec60de 100644 --- a/webrtc/call/call.cc +++ b/webrtc/call/call.cc @@ -694,8 +694,11 @@ void Call::OnNetworkRouteChanged(const std::string& transport_name, LOG(LS_INFO) << "Network route changed on transport " << transport_name << ": new local network id " << network_route.local_network_id << " new remote network id " << network_route.remote_network_id - << " Reset bitrate to " - << config_.bitrate_config.start_bitrate_bps << "bps"; + << " Reset bitrates to min: " + << config_.bitrate_config.min_bitrate_bps + << " bps, start: " << config_.bitrate_config.start_bitrate_bps + << " bps, max: " << config_.bitrate_config.start_bitrate_bps + << " bps."; congestion_controller_->ResetBweAndBitrates( config_.bitrate_config.start_bitrate_bps, config_.bitrate_config.min_bitrate_bps, diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc b/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc index bfc44ea709..43060e2d1a 100644 --- a/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc +++ b/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc @@ -17,6 +17,7 @@ #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/pacing/mock/mock_paced_sender.h" #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "webrtc/test/field_trial.h" using ::testing::Exactly; using ::testing::Return; @@ -67,18 +68,16 @@ class BitrateControllerTest : public ::testing::Test { ~BitrateControllerTest() {} virtual void SetUp() { - controller_ = BitrateController::CreateBitrateController( - &clock_, &bitrate_observer_, &event_log_); + controller_.reset(BitrateController::CreateBitrateController( + &clock_, &bitrate_observer_, &event_log_)); controller_->SetStartBitrate(kStartBitrateBps); EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); controller_->SetMinMaxBitrate(kMinBitrateBps, kMaxBitrateBps); EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); - bandwidth_observer_ = controller_->CreateRtcpBandwidthObserver(); + bandwidth_observer_.reset(controller_->CreateRtcpBandwidthObserver()); } virtual void TearDown() { - delete bandwidth_observer_; - delete controller_; } const int kMinBitrateBps = 100000; @@ -90,8 +89,8 @@ class BitrateControllerTest : public ::testing::Test { webrtc::SimulatedClock clock_; TestBitrateObserver bitrate_observer_; - BitrateController* controller_; - RtcpBandwidthObserver* bandwidth_observer_; + std::unique_ptr controller_; + std::unique_ptr bandwidth_observer_; testing::NiceMock event_log_; }; @@ -184,10 +183,12 @@ TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) { } TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { + const uint32_t kSsrc1 = 1; + const uint32_t kSsrc2 = 2; // REMBs during the first 2 seconds apply immediately. int64_t time_ms = 1; webrtc::ReportBlockList report_blocks; - report_blocks.push_back(CreateReportBlock(1, 2, 0, 1)); + report_blocks.push_back(CreateReportBlock(kSsrc1, 2, 0, 1)); bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); report_blocks.clear(); time_ms += 500; @@ -196,57 +197,65 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { controller_->CreateRtcpBandwidthObserver(); // Test start bitrate. - report_blocks.push_back(CreateReportBlock(1, 2, 0, 21)); + report_blocks.push_back(CreateReportBlock(2, 2, 0, 21)); second_bandwidth_observer->OnReceivedRtcpReceiverReport( report_blocks, 100, 1); - EXPECT_EQ(217000, bitrate_observer_.last_bitrate_); + EXPECT_EQ(200000, bitrate_observer_.last_bitrate_); EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_); EXPECT_EQ(100, bitrate_observer_.last_rtt_); time_ms += 500; // Test bitrate increase 8% per second. report_blocks.clear(); - report_blocks.push_back(CreateReportBlock(1, 2, 0, 21)); + report_blocks.push_back(CreateReportBlock(kSsrc1, 2, 0, 21)); bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); time_ms += 500; + report_blocks.front().remoteSSRC = kSsrc2; second_bandwidth_observer->OnReceivedRtcpReceiverReport( report_blocks, 100, time_ms); - EXPECT_EQ(235360, bitrate_observer_.last_bitrate_); + EXPECT_EQ(217000, bitrate_observer_.last_bitrate_); EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_); EXPECT_EQ(100, bitrate_observer_.last_rtt_); time_ms += 500; // Extra report should not change estimate. report_blocks.clear(); - report_blocks.push_back(CreateReportBlock(1, 2, 0, 31)); + report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 31)); second_bandwidth_observer->OnReceivedRtcpReceiverReport( report_blocks, 100, time_ms); - EXPECT_EQ(235360, bitrate_observer_.last_bitrate_); + EXPECT_EQ(217000, bitrate_observer_.last_bitrate_); time_ms += 500; report_blocks.clear(); - report_blocks.push_back(CreateReportBlock(1, 2, 0, 41)); + report_blocks.push_back(CreateReportBlock(kSsrc1, 2, 0, 41)); bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); - EXPECT_EQ(255189, bitrate_observer_.last_bitrate_); + EXPECT_EQ(235360, bitrate_observer_.last_bitrate_); // Second report should not change estimate. report_blocks.clear(); - report_blocks.push_back(CreateReportBlock(1, 2, 0, 41)); + report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 41)); second_bandwidth_observer->OnReceivedRtcpReceiverReport( report_blocks, 100, time_ms); - EXPECT_EQ(255189, bitrate_observer_.last_bitrate_); + EXPECT_EQ(235360, bitrate_observer_.last_bitrate_); time_ms += 1000; // Reports from only one bandwidth observer is ok. report_blocks.clear(); - report_blocks.push_back(CreateReportBlock(1, 2, 0, 61)); + report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 61)); + second_bandwidth_observer->OnReceivedRtcpReceiverReport( + report_blocks, 50, time_ms); + EXPECT_EQ(255189, bitrate_observer_.last_bitrate_); + time_ms += 1000; + + report_blocks.clear(); + report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 81)); second_bandwidth_observer->OnReceivedRtcpReceiverReport( report_blocks, 50, time_ms); EXPECT_EQ(276604, bitrate_observer_.last_bitrate_); time_ms += 1000; report_blocks.clear(); - report_blocks.push_back(CreateReportBlock(1, 2, 0, 81)); + report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 121)); second_bandwidth_observer->OnReceivedRtcpReceiverReport( report_blocks, 50, time_ms); EXPECT_EQ(299732, bitrate_observer_.last_bitrate_); @@ -254,14 +263,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { // Reach max cap. report_blocks.clear(); - report_blocks.push_back(CreateReportBlock(1, 2, 0, 121)); - second_bandwidth_observer->OnReceivedRtcpReceiverReport( - report_blocks, 50, time_ms); - EXPECT_EQ(300000, bitrate_observer_.last_bitrate_); - time_ms += 1000; - - report_blocks.clear(); - report_blocks.push_back(CreateReportBlock(1, 2, 0, 141)); + report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 141)); second_bandwidth_observer->OnReceivedRtcpReceiverReport( report_blocks, 50, time_ms); EXPECT_EQ(300000, bitrate_observer_.last_bitrate_); @@ -301,7 +303,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverMultipleReportBlocks) { int last_bitrate = 0; // Ramp up to max bitrate. - for (int i = 0; i < 6; ++i) { + for (int i = 0; i < 7; ++i) { report_blocks.push_back(CreateReportBlock(1, 2, 0, sequence_number[0])); report_blocks.push_back(CreateReportBlock(1, 3, 0, sequence_number[1])); bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, @@ -406,3 +408,107 @@ TEST_F(BitrateControllerTest, SetReservedBitrate) { bandwidth_observer_->OnReceivedEstimatedBitrate(1); EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); } + +TEST_F(BitrateControllerTest, TimeoutsWithoutFeedback) { + { + webrtc::test::ScopedFieldTrials override_field_trials( + "WebRTC-SendSideBwe/Enabled/"); + SetUp(); + int expected_bitrate_bps = 300000; + controller_->SetBitrates(300000, kDefaultMinBitrateBps, + kDefaultMaxBitrateBps); + + webrtc::ReportBlockList report_blocks; + report_blocks.push_back(CreateReportBlock(1, 2, 0, 1)); + bandwidth_observer_->OnReceivedRtcpReceiverReport( + report_blocks, 50, clock_.TimeInMilliseconds()); + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(500); + + report_blocks.push_back(CreateReportBlock(1, 2, 0, 21)); + bandwidth_observer_->OnReceivedRtcpReceiverReport( + report_blocks, 50, clock_.TimeInMilliseconds()); + report_blocks.clear(); + expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000; + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(1500); + + report_blocks.push_back(CreateReportBlock(1, 2, 0, 41)); + bandwidth_observer_->OnReceivedRtcpReceiverReport( + report_blocks, 50, clock_.TimeInMilliseconds()); + expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000; + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(1000); + + // 1 seconds since feedback, expect increase. + controller_->Process(); + expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000; + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(800); + + // 1.8 seconds since feedback, expect no increase. + controller_->Process(); + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(3701); + + // More than 4.5 seconds since feedback, expect decrease. + controller_->Process(); + expected_bitrate_bps *= 0.8; + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(500); + + // Only one timeout every second. + controller_->Process(); + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(501); + + // New timeout allowed. + controller_->Process(); + expected_bitrate_bps *= 0.8; + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + } +} + +TEST_F(BitrateControllerTest, StopIncreaseWithoutPacketReports) { + int expected_bitrate_bps = 300000; + controller_->SetBitrates(300000, kDefaultMinBitrateBps, + kDefaultMaxBitrateBps); + + webrtc::ReportBlockList report_blocks; + report_blocks.push_back(CreateReportBlock(1, 2, 0, 1)); + bandwidth_observer_->OnReceivedRtcpReceiverReport( + report_blocks, 50, clock_.TimeInMilliseconds()); + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(500); + + report_blocks.push_back(CreateReportBlock(1, 2, 0, 21)); + bandwidth_observer_->OnReceivedRtcpReceiverReport( + report_blocks, 50, clock_.TimeInMilliseconds()); + report_blocks.clear(); + expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000; + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(1500); + + // 1.2 seconds without packets reported as received, no increase. + report_blocks.push_back(CreateReportBlock(1, 2, 0, 21)); + bandwidth_observer_->OnReceivedRtcpReceiverReport( + report_blocks, 50, clock_.TimeInMilliseconds()); + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(1000); + + // 5 packets reported as received since last, too few, no increase. + report_blocks.push_back(CreateReportBlock(1, 2, 0, 26)); + bandwidth_observer_->OnReceivedRtcpReceiverReport( + report_blocks, 50, clock_.TimeInMilliseconds()); + report_blocks.clear(); + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(100); + + // 15 packets reported as received since last, enough to increase. + report_blocks.push_back(CreateReportBlock(1, 2, 0, 41)); + bandwidth_observer_->OnReceivedRtcpReceiverReport( + report_blocks, 50, clock_.TimeInMilliseconds()); + expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000; + EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); + clock_.AdvanceTimeMilliseconds(1000); +} diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc index 523036daf1..f306fb255d 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc @@ -30,6 +30,10 @@ const int kDefaultMinBitrateBps = 10000; const int kDefaultMaxBitrateBps = 1000000000; const int64_t kLowBitrateLogPeriodMs = 10000; const int64_t kRtcEventLogPeriodMs = 5000; +// Expecting that RTCP feedback is sent uniformly within [0.5, 1.5]s intervals. +const int64_t kFeedbackIntervalMs = 1500; +const int64_t kFeedbackTimeoutIntervals = 3; +const int64_t kTimeoutIntervalMs = 1000; struct UmaRampUpMetric { const char* metric_name; @@ -53,7 +57,9 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log) max_bitrate_configured_(kDefaultMaxBitrateBps), last_low_bitrate_log_ms_(-1), has_decreased_since_last_fraction_loss_(false), - time_last_receiver_block_ms_(-1), + last_feedback_ms_(-1), + last_packet_report_ms_(-1), + last_timeout_ms_(-1), last_fraction_loss_(0), last_logged_fraction_loss_(0), last_round_trip_time_ms_(0), @@ -66,7 +72,9 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log) uma_update_state_(kNoUpdate), rampup_uma_stats_updated_(kNumUmaRampupMetrics, false), event_log_(event_log), - last_rtc_event_log_ms_(-1) { + last_rtc_event_log_ms_(-1), + in_timeout_experiment_(webrtc::field_trial::FindFullName( + "WebRTC-SendSideBwe") == "Enabled") { RTC_DCHECK(event_log); } @@ -130,6 +138,7 @@ void SendSideBandwidthEstimation::UpdateReceiverBlock(uint8_t fraction_loss, int64_t rtt, int number_of_packets, int64_t now_ms) { + last_feedback_ms_ = now_ms; if (first_report_time_ms_ == -1) first_report_time_ms_ = now_ms; @@ -155,9 +164,9 @@ void SendSideBandwidthEstimation::UpdateReceiverBlock(uint8_t fraction_loss, // Reset accumulators. lost_packets_since_last_loss_update_Q8_ = 0; expected_packets_since_last_loss_update_ = 0; + last_packet_report_ms_ = now_ms; + UpdateEstimate(now_ms); } - time_last_receiver_block_ms_ = now_ms; - UpdateEstimate(now_ms); UpdateUmaStats(now_ms, rtt, (fraction_loss * number_of_packets) >> 8); } @@ -201,8 +210,9 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { uint32_t prev_bitrate = bitrate_; if (bwe_incoming_ > bitrate_) bitrate_ = CapBitrateToThresholds(now_ms, bwe_incoming_); - if (delay_based_bitrate_bps_ > bitrate_) + if (delay_based_bitrate_bps_ > bitrate_) { bitrate_ = CapBitrateToThresholds(now_ms, delay_based_bitrate_bps_); + } if (bitrate_ != prev_bitrate) { min_bitrate_history_.clear(); min_bitrate_history_.push_back(std::make_pair(now_ms, bitrate_)); @@ -210,10 +220,14 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { } } UpdateMinHistory(now_ms); - // Only start updating bitrate when receiving receiver blocks. - // TODO(pbos): Handle the case when no receiver report is received for a very - // long time. - if (time_last_receiver_block_ms_ != -1) { + if (last_packet_report_ms_ == -1) { + // No feedback received. + bitrate_ = CapBitrateToThresholds(now_ms, bitrate_); + return; + } + int64_t time_since_packet_report_ms = now_ms - last_packet_report_ms_; + int64_t time_since_feedback_ms = now_ms - last_feedback_ms_; + if (time_since_packet_report_ms < 1.2 * kFeedbackIntervalMs) { if (last_fraction_loss_ <= 5) { // Loss < 2%: Increase rate by 8% of the min bitrate in the last // kBweIncreaseIntervalMs. @@ -223,7 +237,8 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { // If sending a constant 100kbps it can rampup immediatly to 108kbps // whenever a receiver report is received with lower packet loss. // If instead one would do: bitrate_ *= 1.08^(delta time), it would - // take over one second since the lower packet loss to achieve 108kbps. + // take over one second since the lower packet loss to achieve + // 108kbps. bitrate_ = static_cast( min_bitrate_history_.front().second * 1.08 + 0.5); @@ -234,8 +249,8 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { } else if (last_fraction_loss_ <= 26) { // Loss between 2% - 10%: Do nothing. } else { - // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs + - // rtt. + // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs + // + rtt. if (!has_decreased_since_last_fraction_loss_ && (now_ms - time_last_decrease_ms_) >= (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) { @@ -250,6 +265,20 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { has_decreased_since_last_fraction_loss_ = true; } } + } else if (time_since_feedback_ms > + kFeedbackTimeoutIntervals * kFeedbackIntervalMs && + (last_timeout_ms_ == -1 || + now_ms - last_timeout_ms_ > kTimeoutIntervalMs)) { + if (in_timeout_experiment_) { + LOG(LS_WARNING) << "Feedback timed out (" << time_since_feedback_ms + << " ms), reducing bitrate."; + bitrate_ *= 0.8; + // Reset accumulators since we've already acted on missing feedback and + // shouldn't to act again on these old lost packets. + lost_packets_since_last_loss_update_Q8_ = 0; + expected_packets_since_last_loss_update_ = 0; + last_timeout_ms_ = now_ms; + } } uint32_t capped_bitrate = CapBitrateToThresholds(now_ms, bitrate_); if (capped_bitrate != bitrate_ || diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h index dc9de10f7f..9529068e4f 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h @@ -82,7 +82,9 @@ class SendSideBandwidthEstimation { int64_t last_low_bitrate_log_ms_; bool has_decreased_since_last_fraction_loss_; - int64_t time_last_receiver_block_ms_; + int64_t last_feedback_ms_; + int64_t last_packet_report_ms_; + int64_t last_timeout_ms_; uint8_t last_fraction_loss_; uint8_t last_logged_fraction_loss_; int64_t last_round_trip_time_ms_; @@ -97,6 +99,7 @@ class SendSideBandwidthEstimation { std::vector rampup_uma_stats_updated_; RtcEventLog* event_log_; int64_t last_rtc_event_log_ms_; + bool in_timeout_experiment_; }; } // namespace webrtc #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_ diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc index 12f8603068..0a15a4123d 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc @@ -89,7 +89,7 @@ TEST(SendSideBweTest, DoesntReapplyBitrateDecreaseWithoutFollowingRemb) { // Signal heavy loss to go down in bitrate. bwe.UpdateReceiverBlock(kFractionLoss, kRttMs, 100, now_ms); // Trigger an update 2 seconds later to not be rate limited. - now_ms += 2000; + now_ms += 1000; bwe.UpdateEstimate(now_ms); bwe.CurrentEstimate(&bitrate_bps, &fraction_loss, &rtt_ms); @@ -107,7 +107,7 @@ TEST(SendSideBweTest, DoesntReapplyBitrateDecreaseWithoutFollowingRemb) { int last_bitrate_bps = bitrate_bps; // Trigger an update 2 seconds later to not be rate limited (but it still // shouldn't update). - now_ms += 2000; + now_ms += 1000; bwe.UpdateEstimate(now_ms); bwe.CurrentEstimate(&bitrate_bps, &fraction_loss, &rtt_ms); diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc index 6bdfa847df..254ee0e285 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc @@ -970,56 +970,6 @@ TEST(BweTestFramework_VideoSenderTest, FeedbackIneffective) { EXPECT_EQ(820000u, source.bits_per_second()); TestVideoSender(&sender, 10000, 1000, 500, 1025000); } - -TEST(BweTestFramework_AdaptiveVideoSenderTest, FeedbackChangesBitrate) { - AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); - VideoSender sender(NULL, &source, kRembEstimator); - EXPECT_EQ(820000u, source.bits_per_second()); - TestVideoSender(&sender, 9961, 1000, 500, 1025000); - - // Make sure we can reduce the bitrate. - RembFeedback* feedback = new RembFeedback(0, 0, 0, 512000, RTCPReportBlock()); - Packets packets; - packets.push_back(feedback); - sender.RunFor(0, &packets); - EXPECT_EQ(512000u, source.bits_per_second()); - TestVideoSender(&sender, 10000, 750, 160, 640000); - - // Increase the bitrate to the initial bitrate and verify that the output is - // the same. - feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); - packets.push_back(feedback); - sender.RunFor(10000, &packets); - EXPECT_EQ(820000u, source.bits_per_second()); - - for (auto* packet : packets) - delete packet; -} - -TEST(BweTestFramework_AdaptiveVideoSenderTest, Paced_FeedbackChangesBitrate) { - AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); - PacedVideoSender sender(NULL, &source, kRembEstimator); - EXPECT_EQ(820000u, source.bits_per_second()); - TestVideoSender(&sender, 9998, 1000, 500, 1025000); - - // Make sure we can reduce the bitrate. - RembFeedback* feedback = new RembFeedback(0, 1, 0, 512000, RTCPReportBlock()); - Packets packets; - packets.push_back(feedback); - sender.RunFor(10000, &packets); - ASSERT_EQ(512000u, source.bits_per_second()); - TestVideoSender(&sender, 10000, 750, 160, 640000); - - // Increase the bitrate to the initial bitrate and verify that the output is - // the same. - feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); - packets.push_back(feedback); - sender.RunFor(10000, &packets); - EXPECT_EQ(820000u, source.bits_per_second()); - - for (auto* packet : packets) - delete packet; -} } // namespace bwe } // namespace testing } // namespace webrtc