Fixes issue 555 by replacing the bitrate/observer map with a list.
The issue was caused by the fact that the key of the map was an address and therefore the order of the map wasn't deterministic, which the tests assumed. BUG=555 Review URL: https://webrtc-codereview.appspot.com/735006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2602 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
52ce651283
commit
1281dc0313
@ -45,7 +45,6 @@ class RtcpBandwidthObserverImpl : public RtcpBandwidthObserver {
|
||||
// Update last received for this SSRC.
|
||||
ssrc_to_last_received_extended_high_seq_num_[ssrc] =
|
||||
last_received_extended_high_seq_num;
|
||||
|
||||
owner_->OnReceivedRtcpReceiverReport(fraction_loss, rtt, number_of_packets,
|
||||
now_ms);
|
||||
}
|
||||
@ -63,7 +62,7 @@ BitrateControllerImpl::BitrateControllerImpl()
|
||||
}
|
||||
|
||||
BitrateControllerImpl::~BitrateControllerImpl() {
|
||||
std::map<BitrateObserver*, BitrateConfiguration*>::iterator it =
|
||||
BitrateObserverConfList::iterator it =
|
||||
bitrate_observers_.begin();
|
||||
while (it != bitrate_observers_.end()) {
|
||||
delete it->second;
|
||||
@ -77,6 +76,18 @@ RtcpBandwidthObserver* BitrateControllerImpl::CreateRtcpBandwidthObserver() {
|
||||
return new RtcpBandwidthObserverImpl(this);
|
||||
}
|
||||
|
||||
BitrateControllerImpl::BitrateObserverConfList::iterator
|
||||
BitrateControllerImpl::FindObserverConfigurationPair(const BitrateObserver*
|
||||
observer) {
|
||||
BitrateObserverConfList::iterator it = bitrate_observers_.begin();
|
||||
for (; it != bitrate_observers_.end(); ++it) {
|
||||
if (it->first == observer) {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
return bitrate_observers_.end();
|
||||
}
|
||||
|
||||
void BitrateControllerImpl::SetBitrateObserver(
|
||||
BitrateObserver* observer,
|
||||
const uint32_t start_bitrate,
|
||||
@ -84,8 +95,8 @@ void BitrateControllerImpl::SetBitrateObserver(
|
||||
const uint32_t max_bitrate) {
|
||||
CriticalSectionScoped cs(critsect_);
|
||||
|
||||
std::map<BitrateObserver*, BitrateConfiguration*>::iterator it =
|
||||
bitrate_observers_.find(observer);
|
||||
BitrateObserverConfList::iterator it = FindObserverConfigurationPair(
|
||||
observer);
|
||||
|
||||
if (it != bitrate_observers_.end()) {
|
||||
// Update current configuration.
|
||||
@ -94,9 +105,8 @@ void BitrateControllerImpl::SetBitrateObserver(
|
||||
it->second->max_bitrate_ = max_bitrate;
|
||||
} else {
|
||||
// Add new settings.
|
||||
bitrate_observers_[observer] = new BitrateConfiguration(start_bitrate,
|
||||
min_bitrate,
|
||||
max_bitrate);
|
||||
bitrate_observers_.push_back(BitrateObserverConfiguration(observer,
|
||||
new BitrateConfiguration(start_bitrate, min_bitrate, max_bitrate)));
|
||||
}
|
||||
uint32_t sum_start_bitrate = 0;
|
||||
uint32_t sum_min_bitrate = 0;
|
||||
@ -120,8 +130,8 @@ void BitrateControllerImpl::SetBitrateObserver(
|
||||
|
||||
void BitrateControllerImpl::RemoveBitrateObserver(BitrateObserver* observer) {
|
||||
CriticalSectionScoped cs(critsect_);
|
||||
std::map<BitrateObserver*, BitrateConfiguration*>::iterator it =
|
||||
bitrate_observers_.find(observer);
|
||||
BitrateObserverConfList::iterator it = FindObserverConfigurationPair(
|
||||
observer);
|
||||
if (it != bitrate_observers_.end()) {
|
||||
delete it->second;
|
||||
bitrate_observers_.erase(it);
|
||||
@ -165,7 +175,7 @@ void BitrateControllerImpl::OnNetworkChanged(const uint32_t bitrate,
|
||||
return;
|
||||
}
|
||||
uint32_t sum_min_bitrates = 0;
|
||||
std::map<BitrateObserver*, BitrateConfiguration*>::iterator it;
|
||||
BitrateObserverConfList::iterator it;
|
||||
for (it = bitrate_observers_.begin(); it != bitrate_observers_.end(); ++it) {
|
||||
sum_min_bitrates += it->second->min_bitrate_;
|
||||
}
|
||||
@ -182,7 +192,6 @@ void BitrateControllerImpl::OnNetworkChanged(const uint32_t bitrate,
|
||||
}
|
||||
uint32_t bitrate_per_observer = (bitrate - sum_min_bitrates) /
|
||||
number_of_observers;
|
||||
|
||||
// Use map to sort list based on max bitrate.
|
||||
ObserverSortingMap list_max_bitrates;
|
||||
for (it = bitrate_observers_.begin(); it != bitrate_observers_.end(); ++it) {
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
#include "modules/bitrate_controller/include/bitrate_controller.h"
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#include "system_wrappers/interface/critical_section_wrapper.h"
|
||||
@ -77,14 +78,19 @@ class BitrateControllerImpl : public BitrateController {
|
||||
|
||||
private:
|
||||
typedef std::multimap<uint32_t, ObserverConfiguration*> ObserverSortingMap;
|
||||
typedef std::pair<BitrateObserver*, BitrateConfiguration*>
|
||||
BitrateObserverConfiguration;
|
||||
typedef std::list<BitrateObserverConfiguration> BitrateObserverConfList;
|
||||
|
||||
BitrateObserverConfList::iterator
|
||||
FindObserverConfigurationPair(const BitrateObserver* observer);
|
||||
void OnNetworkChanged(const uint32_t bitrate,
|
||||
const uint8_t fraction_loss, // 0 - 255.
|
||||
const uint32_t rtt);
|
||||
|
||||
CriticalSectionWrapper* critsect_;
|
||||
SendSideBandwidthEstimation bandwidth_estimation_;
|
||||
std::map<BitrateObserver*, BitrateConfiguration*> bitrate_observers_;
|
||||
BitrateObserverConfList bitrate_observers_;
|
||||
};
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_MODULES_BITRATE_CONTROLLER_BITRATE_CONTROLLER_IMPL_H_
|
||||
|
||||
@ -180,8 +180,8 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) {
|
||||
TEST_F(BitrateControllerTest, TwoBitrateObserversOneRtcpObserver) {
|
||||
TestBitrateObserver bitrate_observer_1;
|
||||
TestBitrateObserver bitrate_observer_2;
|
||||
controller_->SetBitrateObserver(&bitrate_observer_1, 200000, 100000, 300000);
|
||||
controller_->SetBitrateObserver(&bitrate_observer_2, 200000, 200000, 300000);
|
||||
controller_->SetBitrateObserver(&bitrate_observer_1, 200000, 100000, 300000);
|
||||
|
||||
// Receive a high remb, test bitrate inc.
|
||||
bandwidth_observer_->OnReceivedEstimatedBitrate(400000);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user