Only create |remote_rate| when needed in RemoteBitrateEstimatorSingleStream.
R=stefan@webrtc.org BUG=None Review URL: https://codereview.webrtc.org/2532113002 . Cr-Commit-Position: refs/heads/master@{#15264}
This commit is contained in:
@ -133,7 +133,7 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket(
|
||||
incoming_bitrate_.Rate(now_ms);
|
||||
if (incoming_bitrate_bps &&
|
||||
(prior_state != kBwOverusing ||
|
||||
remote_rate_->TimeToReduceFurther(now_ms, *incoming_bitrate_bps))) {
|
||||
GetRemoteRate()->TimeToReduceFurther(now_ms, *incoming_bitrate_bps))) {
|
||||
// The first overuse should immediately trigger a new estimate.
|
||||
// We also have to update the estimate immediately if we are overusing
|
||||
// and the target bitrate is too high compared to what we are receiving.
|
||||
@ -189,19 +189,19 @@ void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
|
||||
}
|
||||
// We can't update the estimate if we don't have any active streams.
|
||||
if (overuse_detectors_.empty()) {
|
||||
remote_rate_.reset(new AimdRateControl());
|
||||
return;
|
||||
}
|
||||
AimdRateControl* remote_rate = GetRemoteRate();
|
||||
|
||||
double mean_noise_var = sum_var_noise /
|
||||
static_cast<double>(overuse_detectors_.size());
|
||||
const RateControlInput input(bw_state,
|
||||
incoming_bitrate_.Rate(now_ms),
|
||||
mean_noise_var);
|
||||
remote_rate_->Update(&input, now_ms);
|
||||
uint32_t target_bitrate = remote_rate_->UpdateBandwidthEstimate(now_ms);
|
||||
if (remote_rate_->ValidEstimate()) {
|
||||
process_interval_ms_ = remote_rate_->GetFeedbackInterval();
|
||||
remote_rate->Update(&input, now_ms);
|
||||
uint32_t target_bitrate = remote_rate->UpdateBandwidthEstimate(now_ms);
|
||||
if (remote_rate->ValidEstimate()) {
|
||||
process_interval_ms_ = remote_rate->GetFeedbackInterval();
|
||||
std::vector<uint32_t> ssrcs;
|
||||
GetSsrcs(&ssrcs);
|
||||
observer_->OnReceiveBitrateChanged(ssrcs, target_bitrate);
|
||||
@ -211,7 +211,7 @@ void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
|
||||
void RemoteBitrateEstimatorSingleStream::OnRttUpdate(int64_t avg_rtt_ms,
|
||||
int64_t max_rtt_ms) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
remote_rate_->SetRtt(avg_rtt_ms);
|
||||
GetRemoteRate()->SetRtt(avg_rtt_ms);
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) {
|
||||
@ -250,6 +250,12 @@ void RemoteBitrateEstimatorSingleStream::GetSsrcs(
|
||||
}
|
||||
}
|
||||
|
||||
AimdRateControl* RemoteBitrateEstimatorSingleStream::GetRemoteRate() {
|
||||
if (!remote_rate_)
|
||||
remote_rate_.reset(new AimdRateControl());
|
||||
return remote_rate_.get();
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::SetMinBitrate(int min_bitrate_bps) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
remote_rate_->SetMinBitrate(min_bitrate_bps);
|
||||
|
||||
@ -52,6 +52,10 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator {
|
||||
void GetSsrcs(std::vector<uint32_t>* ssrcs) const
|
||||
SHARED_LOCKS_REQUIRED(crit_sect_.get());
|
||||
|
||||
// Returns |remote_rate_| if the pointed to object exists,
|
||||
// otherwise creates it.
|
||||
AimdRateControl* GetRemoteRate() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get());
|
||||
|
||||
Clock* clock_;
|
||||
SsrcOveruseEstimatorMap overuse_detectors_ GUARDED_BY(crit_sect_.get());
|
||||
RateStatistics incoming_bitrate_ GUARDED_BY(crit_sect_.get());
|
||||
|
||||
Reference in New Issue
Block a user