In RemoteBitrateEstimator unwrap remote_rate_ member from unique_ptr
That member is always created during construction and thus doesn't need to be wrapped into unique_ptr and rechecked for beeing nullptr Bug: None Change-Id: I5d608c9b7bdfd8ec6e3296245359610ec1cf176c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285660 Reviewed-by: Emil Lundmark <lndmrk@webrtc.org> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Emil Lundmark <lndmrk@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38785}
This commit is contained in:
parent
cf7077693c
commit
f889217015
@ -63,7 +63,7 @@ RemoteBitrateEstimatorSingleStream::RemoteBitrateEstimatorSingleStream(
|
||||
: clock_(clock),
|
||||
incoming_bitrate_(kBitrateWindowMs, 8000),
|
||||
last_valid_incoming_bitrate_(0),
|
||||
remote_rate_(new AimdRateControl(&field_trials_)),
|
||||
remote_rate_(&field_trials_),
|
||||
observer_(observer),
|
||||
last_process_time_(-1),
|
||||
process_interval_ms_(kProcessIntervalMs),
|
||||
@ -144,7 +144,7 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket(
|
||||
incoming_bitrate_.Rate(now_ms);
|
||||
if (incoming_bitrate_bps &&
|
||||
(prior_state != BandwidthUsage::kBwOverusing ||
|
||||
GetRemoteRate()->TimeToReduceFurther(
|
||||
remote_rate_.TimeToReduceFurther(
|
||||
Timestamp::Millis(now_ms),
|
||||
DataRate::BitsPerSec(*incoming_bitrate_bps)))) {
|
||||
// The first overuse should immediately trigger a new estimate.
|
||||
@ -193,14 +193,13 @@ void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
|
||||
if (overuse_detectors_.empty()) {
|
||||
return;
|
||||
}
|
||||
AimdRateControl* remote_rate = GetRemoteRate();
|
||||
|
||||
const RateControlInput input(
|
||||
bw_state, OptionalRateFromOptionalBps(incoming_bitrate_.Rate(now_ms)));
|
||||
uint32_t target_bitrate =
|
||||
remote_rate->Update(&input, Timestamp::Millis(now_ms)).bps<uint32_t>();
|
||||
if (remote_rate->ValidEstimate()) {
|
||||
process_interval_ms_ = remote_rate->GetFeedbackInterval().ms();
|
||||
remote_rate_.Update(&input, Timestamp::Millis(now_ms)).bps<uint32_t>();
|
||||
if (remote_rate_.ValidEstimate()) {
|
||||
process_interval_ms_ = remote_rate_.GetFeedbackInterval().ms();
|
||||
RTC_DCHECK_GT(process_interval_ms_, 0);
|
||||
std::vector<uint32_t> ssrcs;
|
||||
GetSsrcs(&ssrcs);
|
||||
@ -212,7 +211,7 @@ void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
|
||||
void RemoteBitrateEstimatorSingleStream::OnRttUpdate(int64_t avg_rtt_ms,
|
||||
int64_t max_rtt_ms) {
|
||||
MutexLock lock(&mutex_);
|
||||
GetRemoteRate()->SetRtt(TimeDelta::Millis(avg_rtt_ms));
|
||||
remote_rate_.SetRtt(TimeDelta::Millis(avg_rtt_ms));
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) {
|
||||
@ -226,10 +225,10 @@ void RemoteBitrateEstimatorSingleStream::RemoveStream(unsigned int ssrc) {
|
||||
|
||||
DataRate RemoteBitrateEstimatorSingleStream::LatestEstimate() const {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!remote_rate_->ValidEstimate() || overuse_detectors_.empty()) {
|
||||
if (!remote_rate_.ValidEstimate() || overuse_detectors_.empty()) {
|
||||
return DataRate::Zero();
|
||||
}
|
||||
return remote_rate_->LatestEstimate();
|
||||
return remote_rate_.LatestEstimate();
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorSingleStream::GetSsrcs(
|
||||
@ -243,10 +242,4 @@ void RemoteBitrateEstimatorSingleStream::GetSsrcs(
|
||||
}
|
||||
}
|
||||
|
||||
AimdRateControl* RemoteBitrateEstimatorSingleStream::GetRemoteRate() {
|
||||
if (!remote_rate_)
|
||||
remote_rate_.reset(new AimdRateControl(&field_trials_));
|
||||
return remote_rate_.get();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
@ -65,16 +64,12 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator {
|
||||
void GetSsrcs(std::vector<uint32_t>* ssrcs) const
|
||||
RTC_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
// Returns `remote_rate_` if the pointed to object exists,
|
||||
// otherwise creates it.
|
||||
AimdRateControl* GetRemoteRate() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
Clock* const clock_;
|
||||
const FieldTrialBasedConfig field_trials_;
|
||||
SsrcOveruseEstimatorMap overuse_detectors_ RTC_GUARDED_BY(mutex_);
|
||||
RateStatistics incoming_bitrate_ RTC_GUARDED_BY(mutex_);
|
||||
uint32_t last_valid_incoming_bitrate_ RTC_GUARDED_BY(mutex_);
|
||||
std::unique_ptr<AimdRateControl> remote_rate_ RTC_GUARDED_BY(mutex_);
|
||||
AimdRateControl remote_rate_ RTC_GUARDED_BY(mutex_);
|
||||
RemoteBitrateObserver* const observer_ RTC_GUARDED_BY(mutex_);
|
||||
mutable Mutex mutex_;
|
||||
int64_t last_process_time_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user