#include "call/bitrate_allocator.h"
#include <algorithm>
#include <cmath>
#include <memory>
#include <utility>
#include "absl/algorithm/container.h"
#include "api/units/data_rate.h"
#include "api/units/time_delta.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_minmax.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/metrics.h"
namespace webrtc {
namespace {
AllocatableTrack;
const uint8_t kTransmissionMaxBitrateMultiplier = …;
const int kDefaultBitrateBps = …;
const double kToggleFactor = …;
const uint32_t kMinToggleBitrateBps = …;
const int64_t kBweLogIntervalMs = …;
double MediaRatio(uint32_t allocated_bitrate, uint32_t protection_bitrate) { … }
bool EnoughBitrateForAllObservers(
const std::vector<AllocatableTrack>& allocatable_tracks,
uint32_t bitrate,
uint32_t sum_min_bitrates) { … }
void DistributeBitrateEvenly(
const std::vector<AllocatableTrack>& allocatable_tracks,
uint32_t bitrate,
bool include_zero_allocations,
int max_multiplier,
std::map<BitrateAllocatorObserver*, int>* allocation) { … }
void DistributeBitrateRelatively(
const std::vector<AllocatableTrack>& allocatable_tracks,
uint32_t remaining_bitrate,
const std::map<BitrateAllocatorObserver*, int>& observers_capacities,
std::map<BitrateAllocatorObserver*, int>* allocation) { … }
std::map<BitrateAllocatorObserver*, int> LowRateAllocation(
const std::vector<AllocatableTrack>& allocatable_tracks,
uint32_t bitrate) { … }
std::map<BitrateAllocatorObserver*, int> NormalRateAllocation(
const std::vector<AllocatableTrack>& allocatable_tracks,
uint32_t bitrate,
uint32_t sum_min_bitrates) { … }
std::map<BitrateAllocatorObserver*, int> MaxRateAllocation(
const std::vector<AllocatableTrack>& allocatable_tracks,
uint32_t bitrate,
uint32_t sum_max_bitrates) { … }
std::map<BitrateAllocatorObserver*, int> ZeroRateAllocation(
const std::vector<AllocatableTrack>& allocatable_tracks) { … }
absl::optional<std::map<BitrateAllocatorObserver*, int>> MaybeApplySurplus(
const std::map<BitrateAllocatorObserver*, int>& allocation,
const std::vector<AllocatableTrack>& allocatable_tracks,
DataRate bitrate,
DataRate upper_elastic_limit) { … }
std::map<BitrateAllocatorObserver*, int> AllocateBitrates(
const std::vector<AllocatableTrack>& allocatable_tracks,
uint32_t bitrate,
DataRate upper_elastic_limit) { … }
}
BitrateAllocator::BitrateAllocator(LimitObserver* limit_observer,
DataRate upper_elastic_rate_limit)
: … { … }
BitrateAllocator::~BitrateAllocator() { … }
void BitrateAllocator::UpdateStartRate(uint32_t start_rate_bps) { … }
void BitrateAllocator::OnNetworkEstimateChanged(TargetTransferRate msg) { … }
void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
MediaStreamAllocationConfig config) { … }
bool BitrateAllocator::RecomputeAllocationIfNeeded() { … }
void BitrateAllocator::UpdateAllocationLimits() { … }
void BitrateAllocator::RemoveObserver(BitrateAllocatorObserver* observer) { … }
int BitrateAllocator::GetStartBitrate(
BitrateAllocatorObserver* observer) const { … }
uint32_t bitrate_allocator_impl::AllocatableTrack::LastAllocatedBitrate()
const { … }
uint32_t bitrate_allocator_impl::AllocatableTrack::MinBitrateWithHysteresis()
const { … }
const char kElasticBitrateAllocator[] = …;
DataRate GetElasticRateAllocationFieldTrialParameter(
const FieldTrialsView& field_trials) { … }
}