Declares BitrateAllocator methods const.
Bug: webrtc:9883 Change-Id: I79e4f8d233281975c4073a381c7568469390b817 Reviewed-on: https://webrtc-review.googlesource.com/c/107725 Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25343}
This commit is contained in:

committed by
Commit Bot

parent
583d6d9d4f
commit
44a262a6aa
@ -248,7 +248,8 @@ void BitrateAllocator::RemoveObserver(BitrateAllocatorObserver* observer) {
|
|||||||
UpdateAllocationLimits();
|
UpdateAllocationLimits();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BitrateAllocator::GetStartBitrate(BitrateAllocatorObserver* observer) {
|
int BitrateAllocator::GetStartBitrate(
|
||||||
|
BitrateAllocatorObserver* observer) const {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
||||||
const auto& it = FindObserverConfig(observer);
|
const auto& it = FindObserverConfig(observer);
|
||||||
if (it == bitrate_observer_configs_.end()) {
|
if (it == bitrate_observer_configs_.end()) {
|
||||||
@ -272,6 +273,17 @@ void BitrateAllocator::SetBitrateAllocationStrategy(
|
|||||||
bitrate_allocation_strategy_ = std::move(bitrate_allocation_strategy);
|
bitrate_allocation_strategy_ = std::move(bitrate_allocation_strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BitrateAllocator::ObserverConfigs::const_iterator
|
||||||
|
BitrateAllocator::FindObserverConfig(
|
||||||
|
const BitrateAllocatorObserver* observer) const {
|
||||||
|
for (auto it = bitrate_observer_configs_.begin();
|
||||||
|
it != bitrate_observer_configs_.end(); ++it) {
|
||||||
|
if (it->observer == observer)
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
return bitrate_observer_configs_.end();
|
||||||
|
}
|
||||||
|
|
||||||
BitrateAllocator::ObserverConfigs::iterator
|
BitrateAllocator::ObserverConfigs::iterator
|
||||||
BitrateAllocator::FindObserverConfig(const BitrateAllocatorObserver* observer) {
|
BitrateAllocator::FindObserverConfig(const BitrateAllocatorObserver* observer) {
|
||||||
for (auto it = bitrate_observer_configs_.begin();
|
for (auto it = bitrate_observer_configs_.begin();
|
||||||
@ -283,7 +295,7 @@ BitrateAllocator::FindObserverConfig(const BitrateAllocatorObserver* observer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates(
|
BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates(
|
||||||
uint32_t bitrate) {
|
uint32_t bitrate) const {
|
||||||
if (bitrate_observer_configs_.empty())
|
if (bitrate_observer_configs_.empty())
|
||||||
return ObserverAllocation();
|
return ObserverAllocation();
|
||||||
|
|
||||||
@ -331,7 +343,8 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates(
|
|||||||
return MaxRateAllocation(bitrate, sum_max_bitrates);
|
return MaxRateAllocation(bitrate, sum_max_bitrates);
|
||||||
}
|
}
|
||||||
|
|
||||||
BitrateAllocator::ObserverAllocation BitrateAllocator::ZeroRateAllocation() {
|
BitrateAllocator::ObserverAllocation BitrateAllocator::ZeroRateAllocation()
|
||||||
|
const {
|
||||||
ObserverAllocation allocation;
|
ObserverAllocation allocation;
|
||||||
for (const auto& observer_config : bitrate_observer_configs_)
|
for (const auto& observer_config : bitrate_observer_configs_)
|
||||||
allocation[observer_config.observer] = 0;
|
allocation[observer_config.observer] = 0;
|
||||||
@ -339,7 +352,7 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::ZeroRateAllocation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitrateAllocator::ObserverAllocation BitrateAllocator::LowRateAllocation(
|
BitrateAllocator::ObserverAllocation BitrateAllocator::LowRateAllocation(
|
||||||
uint32_t bitrate) {
|
uint32_t bitrate) const {
|
||||||
ObserverAllocation allocation;
|
ObserverAllocation allocation;
|
||||||
// Start by allocating bitrate to observers enforcing a min bitrate, hence
|
// Start by allocating bitrate to observers enforcing a min bitrate, hence
|
||||||
// remaining_bitrate might turn negative.
|
// remaining_bitrate might turn negative.
|
||||||
@ -400,7 +413,7 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::LowRateAllocation(
|
|||||||
// min_bitrate_bps values, until one of the observers hits its max_bitrate_bps.
|
// min_bitrate_bps values, until one of the observers hits its max_bitrate_bps.
|
||||||
BitrateAllocator::ObserverAllocation BitrateAllocator::NormalRateAllocation(
|
BitrateAllocator::ObserverAllocation BitrateAllocator::NormalRateAllocation(
|
||||||
uint32_t bitrate,
|
uint32_t bitrate,
|
||||||
uint32_t sum_min_bitrates) {
|
uint32_t sum_min_bitrates) const {
|
||||||
ObserverAllocation allocation;
|
ObserverAllocation allocation;
|
||||||
ObserverAllocation observers_capacities;
|
ObserverAllocation observers_capacities;
|
||||||
for (const auto& observer_config : bitrate_observer_configs_) {
|
for (const auto& observer_config : bitrate_observer_configs_) {
|
||||||
@ -420,7 +433,7 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::NormalRateAllocation(
|
|||||||
|
|
||||||
BitrateAllocator::ObserverAllocation BitrateAllocator::MaxRateAllocation(
|
BitrateAllocator::ObserverAllocation BitrateAllocator::MaxRateAllocation(
|
||||||
uint32_t bitrate,
|
uint32_t bitrate,
|
||||||
uint32_t sum_max_bitrates) {
|
uint32_t sum_max_bitrates) const {
|
||||||
ObserverAllocation allocation;
|
ObserverAllocation allocation;
|
||||||
|
|
||||||
for (const auto& observer_config : bitrate_observer_configs_) {
|
for (const auto& observer_config : bitrate_observer_configs_) {
|
||||||
@ -457,10 +470,11 @@ uint32_t BitrateAllocator::ObserverConfig::MinBitrateWithHysteresis() const {
|
|||||||
return min_bitrate;
|
return min_bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitrateAllocator::DistributeBitrateEvenly(uint32_t bitrate,
|
void BitrateAllocator::DistributeBitrateEvenly(
|
||||||
bool include_zero_allocations,
|
uint32_t bitrate,
|
||||||
int max_multiplier,
|
bool include_zero_allocations,
|
||||||
ObserverAllocation* allocation) {
|
int max_multiplier,
|
||||||
|
ObserverAllocation* allocation) const {
|
||||||
RTC_DCHECK_EQ(allocation->size(), bitrate_observer_configs_.size());
|
RTC_DCHECK_EQ(allocation->size(), bitrate_observer_configs_.size());
|
||||||
|
|
||||||
ObserverSortingMap list_max_bitrates;
|
ObserverSortingMap list_max_bitrates;
|
||||||
@ -491,8 +505,9 @@ void BitrateAllocator::DistributeBitrateEvenly(uint32_t bitrate,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitrateAllocator::EnoughBitrateForAllObservers(uint32_t bitrate,
|
bool BitrateAllocator::EnoughBitrateForAllObservers(
|
||||||
uint32_t sum_min_bitrates) {
|
uint32_t bitrate,
|
||||||
|
uint32_t sum_min_bitrates) const {
|
||||||
if (bitrate < sum_min_bitrates)
|
if (bitrate < sum_min_bitrates)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -511,7 +526,7 @@ bool BitrateAllocator::EnoughBitrateForAllObservers(uint32_t bitrate,
|
|||||||
void BitrateAllocator::DistributeBitrateRelatively(
|
void BitrateAllocator::DistributeBitrateRelatively(
|
||||||
uint32_t remaining_bitrate,
|
uint32_t remaining_bitrate,
|
||||||
const ObserverAllocation& observers_capacities,
|
const ObserverAllocation& observers_capacities,
|
||||||
ObserverAllocation* allocation) {
|
ObserverAllocation* allocation) const {
|
||||||
RTC_DCHECK_EQ(allocation->size(), bitrate_observer_configs_.size());
|
RTC_DCHECK_EQ(allocation->size(), bitrate_observer_configs_.size());
|
||||||
RTC_DCHECK_EQ(observers_capacities.size(), bitrate_observer_configs_.size());
|
RTC_DCHECK_EQ(observers_capacities.size(), bitrate_observer_configs_.size());
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class BitrateAllocatorInterface {
|
|||||||
virtual void AddObserver(BitrateAllocatorObserver* observer,
|
virtual void AddObserver(BitrateAllocatorObserver* observer,
|
||||||
MediaStreamAllocationConfig config) = 0;
|
MediaStreamAllocationConfig config) = 0;
|
||||||
virtual void RemoveObserver(BitrateAllocatorObserver* observer) = 0;
|
virtual void RemoveObserver(BitrateAllocatorObserver* observer) = 0;
|
||||||
virtual int GetStartBitrate(BitrateAllocatorObserver* observer) = 0;
|
virtual int GetStartBitrate(BitrateAllocatorObserver* observer) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~BitrateAllocatorInterface() = default;
|
virtual ~BitrateAllocatorInterface() = default;
|
||||||
@ -120,7 +120,7 @@ class BitrateAllocator : public BitrateAllocatorInterface {
|
|||||||
|
|
||||||
// Returns initial bitrate allocated for |observer|. If |observer| is not in
|
// Returns initial bitrate allocated for |observer|. If |observer| is not in
|
||||||
// the list of added observers, a best guess is returned.
|
// the list of added observers, a best guess is returned.
|
||||||
int GetStartBitrate(BitrateAllocatorObserver* observer) override;
|
int GetStartBitrate(BitrateAllocatorObserver* observer) const override;
|
||||||
|
|
||||||
// Sets external allocation strategy. If strategy is not set default WebRTC
|
// Sets external allocation strategy. If strategy is not set default WebRTC
|
||||||
// allocation mechanism will be used. The strategy may be changed during call.
|
// allocation mechanism will be used. The strategy may be changed during call.
|
||||||
@ -171,31 +171,34 @@ class BitrateAllocator : public BitrateAllocatorInterface {
|
|||||||
void UpdateAllocationLimits() RTC_RUN_ON(&sequenced_checker_);
|
void UpdateAllocationLimits() RTC_RUN_ON(&sequenced_checker_);
|
||||||
|
|
||||||
typedef std::vector<ObserverConfig> ObserverConfigs;
|
typedef std::vector<ObserverConfig> ObserverConfigs;
|
||||||
|
ObserverConfigs::const_iterator FindObserverConfig(
|
||||||
|
const BitrateAllocatorObserver* observer) const
|
||||||
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
ObserverConfigs::iterator FindObserverConfig(
|
ObserverConfigs::iterator FindObserverConfig(
|
||||||
const BitrateAllocatorObserver* observer) RTC_RUN_ON(&sequenced_checker_);
|
const BitrateAllocatorObserver* observer) RTC_RUN_ON(&sequenced_checker_);
|
||||||
|
|
||||||
typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap;
|
typedef std::multimap<uint32_t, const ObserverConfig*> ObserverSortingMap;
|
||||||
typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation;
|
typedef std::map<BitrateAllocatorObserver*, int> ObserverAllocation;
|
||||||
|
|
||||||
ObserverAllocation AllocateBitrates(uint32_t bitrate)
|
ObserverAllocation AllocateBitrates(uint32_t bitrate) const
|
||||||
RTC_RUN_ON(&sequenced_checker_);
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
|
|
||||||
// Allocates zero bitrate to all observers.
|
// Allocates zero bitrate to all observers.
|
||||||
ObserverAllocation ZeroRateAllocation() RTC_RUN_ON(&sequenced_checker_);
|
ObserverAllocation ZeroRateAllocation() const RTC_RUN_ON(&sequenced_checker_);
|
||||||
// Allocates bitrate to observers when there isn't enough to allocate the
|
// Allocates bitrate to observers when there isn't enough to allocate the
|
||||||
// minimum to all observers.
|
// minimum to all observers.
|
||||||
ObserverAllocation LowRateAllocation(uint32_t bitrate)
|
ObserverAllocation LowRateAllocation(uint32_t bitrate) const
|
||||||
RTC_RUN_ON(&sequenced_checker_);
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
// Allocates bitrate to all observers when the available bandwidth is enough
|
// Allocates bitrate to all observers when the available bandwidth is enough
|
||||||
// to allocate the minimum to all observers but not enough to allocate the
|
// to allocate the minimum to all observers but not enough to allocate the
|
||||||
// max bitrate of each observer.
|
// max bitrate of each observer.
|
||||||
ObserverAllocation NormalRateAllocation(uint32_t bitrate,
|
ObserverAllocation NormalRateAllocation(uint32_t bitrate,
|
||||||
uint32_t sum_min_bitrates)
|
uint32_t sum_min_bitrates) const
|
||||||
RTC_RUN_ON(&sequenced_checker_);
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
// Allocates bitrate to observers when there is enough available bandwidth
|
// Allocates bitrate to observers when there is enough available bandwidth
|
||||||
// for all observers to be allocated their max bitrate.
|
// for all observers to be allocated their max bitrate.
|
||||||
ObserverAllocation MaxRateAllocation(uint32_t bitrate,
|
ObserverAllocation MaxRateAllocation(uint32_t bitrate,
|
||||||
uint32_t sum_max_bitrates)
|
uint32_t sum_max_bitrates) const
|
||||||
RTC_RUN_ON(&sequenced_checker_);
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
|
|
||||||
// Splits |bitrate| evenly to observers already in |allocation|.
|
// Splits |bitrate| evenly to observers already in |allocation|.
|
||||||
@ -205,9 +208,10 @@ class BitrateAllocator : public BitrateAllocatorInterface {
|
|||||||
void DistributeBitrateEvenly(uint32_t bitrate,
|
void DistributeBitrateEvenly(uint32_t bitrate,
|
||||||
bool include_zero_allocations,
|
bool include_zero_allocations,
|
||||||
int max_multiplier,
|
int max_multiplier,
|
||||||
ObserverAllocation* allocation)
|
ObserverAllocation* allocation) const
|
||||||
RTC_RUN_ON(&sequenced_checker_);
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
bool EnoughBitrateForAllObservers(uint32_t bitrate, uint32_t sum_min_bitrates)
|
bool EnoughBitrateForAllObservers(uint32_t bitrate,
|
||||||
|
uint32_t sum_min_bitrates) const
|
||||||
RTC_RUN_ON(&sequenced_checker_);
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
|
|
||||||
// From the available |bitrate|, each observer will be allocated a
|
// From the available |bitrate|, each observer will be allocated a
|
||||||
@ -219,7 +223,7 @@ class BitrateAllocator : public BitrateAllocatorInterface {
|
|||||||
void DistributeBitrateRelatively(
|
void DistributeBitrateRelatively(
|
||||||
uint32_t bitrate,
|
uint32_t bitrate,
|
||||||
const ObserverAllocation& observers_capacities,
|
const ObserverAllocation& observers_capacities,
|
||||||
ObserverAllocation* allocation) RTC_RUN_ON(&sequenced_checker_);
|
ObserverAllocation* allocation) const RTC_RUN_ON(&sequenced_checker_);
|
||||||
|
|
||||||
// Allow packets to be transmitted in up to 2 times max video bitrate if the
|
// Allow packets to be transmitted in up to 2 times max video bitrate if the
|
||||||
// bandwidth estimate allows it.
|
// bandwidth estimate allows it.
|
||||||
|
@ -21,7 +21,7 @@ class MockBitrateAllocator : public BitrateAllocatorInterface {
|
|||||||
MOCK_METHOD2(AddObserver,
|
MOCK_METHOD2(AddObserver,
|
||||||
void(BitrateAllocatorObserver*, MediaStreamAllocationConfig));
|
void(BitrateAllocatorObserver*, MediaStreamAllocationConfig));
|
||||||
MOCK_METHOD1(RemoveObserver, void(BitrateAllocatorObserver*));
|
MOCK_METHOD1(RemoveObserver, void(BitrateAllocatorObserver*));
|
||||||
MOCK_METHOD1(GetStartBitrate, int(BitrateAllocatorObserver*));
|
MOCK_CONST_METHOD1(GetStartBitrate, int(BitrateAllocatorObserver*));
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
#endif // CALL_TEST_MOCK_BITRATE_ALLOCATOR_H_
|
#endif // CALL_TEST_MOCK_BITRATE_ALLOCATOR_H_
|
||||||
|
Reference in New Issue
Block a user