Replace runtime thread checks by compile-time checks.
For all private methods of BitrateAllocator. Bug: None Change-Id: I9943d3ee4cdfe00a842e7c2258f57d88b96c4dda Reviewed-on: https://webrtc-review.googlesource.com/72860 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23052}
This commit is contained in:
@ -188,7 +188,6 @@ void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BitrateAllocator::UpdateAllocationLimits() {
|
void BitrateAllocator::UpdateAllocationLimits() {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
uint32_t total_requested_padding_bitrate = 0;
|
uint32_t total_requested_padding_bitrate = 0;
|
||||||
uint32_t total_requested_min_bitrate = 0;
|
uint32_t total_requested_min_bitrate = 0;
|
||||||
uint32_t total_requested_max_bitrate = 0;
|
uint32_t total_requested_max_bitrate = 0;
|
||||||
@ -267,7 +266,6 @@ void BitrateAllocator::SetBitrateAllocationStrategy(
|
|||||||
|
|
||||||
BitrateAllocator::ObserverConfigs::iterator
|
BitrateAllocator::ObserverConfigs::iterator
|
||||||
BitrateAllocator::FindObserverConfig(const BitrateAllocatorObserver* observer) {
|
BitrateAllocator::FindObserverConfig(const BitrateAllocatorObserver* observer) {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
for (auto it = bitrate_observer_configs_.begin();
|
for (auto it = bitrate_observer_configs_.begin();
|
||||||
it != bitrate_observer_configs_.end(); ++it) {
|
it != bitrate_observer_configs_.end(); ++it) {
|
||||||
if (it->observer == observer)
|
if (it->observer == observer)
|
||||||
@ -278,7 +276,6 @@ BitrateAllocator::FindObserverConfig(const BitrateAllocatorObserver* observer) {
|
|||||||
|
|
||||||
BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates(
|
BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates(
|
||||||
uint32_t bitrate) {
|
uint32_t bitrate) {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
if (bitrate_observer_configs_.empty())
|
if (bitrate_observer_configs_.empty())
|
||||||
return ObserverAllocation();
|
return ObserverAllocation();
|
||||||
|
|
||||||
@ -327,7 +324,6 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::AllocateBitrates(
|
|||||||
}
|
}
|
||||||
|
|
||||||
BitrateAllocator::ObserverAllocation BitrateAllocator::ZeroRateAllocation() {
|
BitrateAllocator::ObserverAllocation BitrateAllocator::ZeroRateAllocation() {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
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;
|
||||||
@ -336,7 +332,6 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::ZeroRateAllocation() {
|
|||||||
|
|
||||||
BitrateAllocator::ObserverAllocation BitrateAllocator::LowRateAllocation(
|
BitrateAllocator::ObserverAllocation BitrateAllocator::LowRateAllocation(
|
||||||
uint32_t bitrate) {
|
uint32_t bitrate) {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
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.
|
||||||
@ -398,7 +393,6 @@ BitrateAllocator::ObserverAllocation BitrateAllocator::LowRateAllocation(
|
|||||||
BitrateAllocator::ObserverAllocation BitrateAllocator::NormalRateAllocation(
|
BitrateAllocator::ObserverAllocation BitrateAllocator::NormalRateAllocation(
|
||||||
uint32_t bitrate,
|
uint32_t bitrate,
|
||||||
uint32_t sum_min_bitrates) {
|
uint32_t sum_min_bitrates) {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
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_) {
|
||||||
@ -419,7 +413,6 @@ 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) {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
ObserverAllocation allocation;
|
ObserverAllocation allocation;
|
||||||
|
|
||||||
for (const auto& observer_config : bitrate_observer_configs_) {
|
for (const auto& observer_config : bitrate_observer_configs_) {
|
||||||
@ -460,7 +453,6 @@ void BitrateAllocator::DistributeBitrateEvenly(uint32_t bitrate,
|
|||||||
bool include_zero_allocations,
|
bool include_zero_allocations,
|
||||||
int max_multiplier,
|
int max_multiplier,
|
||||||
ObserverAllocation* allocation) {
|
ObserverAllocation* allocation) {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
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;
|
||||||
@ -493,7 +485,6 @@ void BitrateAllocator::DistributeBitrateEvenly(uint32_t bitrate,
|
|||||||
|
|
||||||
bool BitrateAllocator::EnoughBitrateForAllObservers(uint32_t bitrate,
|
bool BitrateAllocator::EnoughBitrateForAllObservers(uint32_t bitrate,
|
||||||
uint32_t sum_min_bitrates) {
|
uint32_t sum_min_bitrates) {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
if (bitrate < sum_min_bitrates)
|
if (bitrate < sum_min_bitrates)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -513,7 +504,6 @@ void BitrateAllocator::DistributeBitrateRelatively(
|
|||||||
uint32_t remaining_bitrate,
|
uint32_t remaining_bitrate,
|
||||||
const ObserverAllocation& observers_capacities,
|
const ObserverAllocation& observers_capacities,
|
||||||
ObserverAllocation* allocation) {
|
ObserverAllocation* allocation) {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_);
|
|
||||||
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());
|
||||||
|
|
||||||
|
@ -166,31 +166,35 @@ class BitrateAllocator : public BitrateAllocatorInterface {
|
|||||||
|
|
||||||
// Calculates the minimum requested send bitrate and max padding bitrate and
|
// Calculates the minimum requested send bitrate and max padding bitrate and
|
||||||
// calls LimitObserver::OnAllocationLimitsChanged.
|
// calls LimitObserver::OnAllocationLimitsChanged.
|
||||||
void UpdateAllocationLimits();
|
void UpdateAllocationLimits() RTC_RUN_ON(&sequenced_checker_);
|
||||||
|
|
||||||
typedef std::vector<ObserverConfig> ObserverConfigs;
|
typedef std::vector<ObserverConfig> ObserverConfigs;
|
||||||
ObserverConfigs::iterator FindObserverConfig(
|
ObserverConfigs::iterator FindObserverConfig(
|
||||||
const BitrateAllocatorObserver* observer);
|
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)
|
||||||
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
|
|
||||||
// Allocates zero bitrate to all observers.
|
// Allocates zero bitrate to all observers.
|
||||||
ObserverAllocation ZeroRateAllocation();
|
ObserverAllocation ZeroRateAllocation() 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)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
|
|
||||||
// Splits |bitrate| evenly to observers already in |allocation|.
|
// Splits |bitrate| evenly to observers already in |allocation|.
|
||||||
// |include_zero_allocations| decides if zero allocations should be part of
|
// |include_zero_allocations| decides if zero allocations should be part of
|
||||||
@ -199,9 +203,11 @@ 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)
|
||||||
|
RTC_RUN_ON(&sequenced_checker_);
|
||||||
bool EnoughBitrateForAllObservers(uint32_t bitrate,
|
bool EnoughBitrateForAllObservers(uint32_t bitrate,
|
||||||
uint32_t sum_min_bitrates);
|
uint32_t sum_min_bitrates)
|
||||||
|
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
|
||||||
// proportional amount based upon its bitrate priority. If that amount is
|
// proportional amount based upon its bitrate priority. If that amount is
|
||||||
@ -212,7 +218,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);
|
ObserverAllocation* allocation) 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.
|
||||||
|
Reference in New Issue
Block a user