Ensure that the start bitrate can be set multiple times.
If the start bitrate is set twice, it will be set to the sum of the start bitrates of the currently registered bitrate observers, or left unchanged if the current estimate actually is greater than the sum. BUG=3503 R=henrik.lundin@webrtc.org, pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/15839004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6491 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
496a98463b
commit
077593b805
@ -139,6 +139,21 @@ void BitrateControllerImpl::SetBitrateObserver(
|
|||||||
it->second->start_bitrate_ = start_bitrate;
|
it->second->start_bitrate_ = start_bitrate;
|
||||||
it->second->min_bitrate_ = min_bitrate;
|
it->second->min_bitrate_ = min_bitrate;
|
||||||
it->second->max_bitrate_ = max_bitrate;
|
it->second->max_bitrate_ = max_bitrate;
|
||||||
|
// Set the send-side bandwidth to the max of the sum of start bitrates and
|
||||||
|
// the current estimate, so that if the user wants to immediately use more
|
||||||
|
// bandwidth, that can be enforced.
|
||||||
|
uint32_t sum_start_bitrate = 0;
|
||||||
|
BitrateObserverConfList::iterator it;
|
||||||
|
for (it = bitrate_observers_.begin(); it != bitrate_observers_.end();
|
||||||
|
++it) {
|
||||||
|
sum_start_bitrate += it->second->start_bitrate_;
|
||||||
|
}
|
||||||
|
uint32_t current_estimate;
|
||||||
|
uint8_t loss;
|
||||||
|
uint32_t rtt;
|
||||||
|
bandwidth_estimation_.CurrentEstimate(¤t_estimate, &loss, &rtt);
|
||||||
|
bandwidth_estimation_.SetSendBitrate(std::max(sum_start_bitrate,
|
||||||
|
current_estimate));
|
||||||
} else {
|
} else {
|
||||||
// Add new settings.
|
// Add new settings.
|
||||||
bitrate_observers_.push_back(BitrateObserverConfiguration(observer,
|
bitrate_observers_.push_back(BitrateObserverConfiguration(observer,
|
||||||
@ -159,12 +174,10 @@ void BitrateControllerImpl::SetBitrateObserver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BitrateControllerImpl::UpdateMinMaxBitrate() {
|
void BitrateControllerImpl::UpdateMinMaxBitrate() {
|
||||||
uint32_t sum_start_bitrate = 0;
|
|
||||||
uint32_t sum_min_bitrate = 0;
|
uint32_t sum_min_bitrate = 0;
|
||||||
uint32_t sum_max_bitrate = 0;
|
uint32_t sum_max_bitrate = 0;
|
||||||
BitrateObserverConfList::iterator it;
|
BitrateObserverConfList::iterator it;
|
||||||
for (it = bitrate_observers_.begin(); it != bitrate_observers_.end(); ++it) {
|
for (it = bitrate_observers_.begin(); it != bitrate_observers_.end(); ++it) {
|
||||||
sum_start_bitrate += it->second->start_bitrate_;
|
|
||||||
sum_min_bitrate += it->second->min_bitrate_;
|
sum_min_bitrate += it->second->min_bitrate_;
|
||||||
sum_max_bitrate += it->second->max_bitrate_;
|
sum_max_bitrate += it->second->max_bitrate_;
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,24 @@ TEST_F(BitrateControllerTest, Basic) {
|
|||||||
controller_->RemoveBitrateObserver(&bitrate_observer);
|
controller_->RemoveBitrateObserver(&bitrate_observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(BitrateControllerTest, UpdatingBitrateObserver) {
|
||||||
|
TestBitrateObserver bitrate_observer;
|
||||||
|
controller_->SetBitrateObserver(&bitrate_observer, 200000, 100000, 1500000);
|
||||||
|
clock_.AdvanceTimeMilliseconds(25);
|
||||||
|
controller_->Process();
|
||||||
|
EXPECT_EQ(200000u, bitrate_observer.last_bitrate_);
|
||||||
|
|
||||||
|
controller_->SetBitrateObserver(&bitrate_observer, 1500000, 100000, 1500000);
|
||||||
|
clock_.AdvanceTimeMilliseconds(25);
|
||||||
|
controller_->Process();
|
||||||
|
EXPECT_EQ(1500000u, bitrate_observer.last_bitrate_);
|
||||||
|
|
||||||
|
controller_->SetBitrateObserver(&bitrate_observer, 500000, 100000, 1500000);
|
||||||
|
clock_.AdvanceTimeMilliseconds(25);
|
||||||
|
controller_->Process();
|
||||||
|
EXPECT_EQ(1500000u, bitrate_observer.last_bitrate_);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) {
|
TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) {
|
||||||
TestBitrateObserver bitrate_observer;
|
TestBitrateObserver bitrate_observer;
|
||||||
controller_->SetBitrateObserver(&bitrate_observer, 200000, 100000, 300000);
|
controller_->SetBitrateObserver(&bitrate_observer, 200000, 100000, 300000);
|
||||||
|
Loading…
Reference in New Issue
Block a user