Cleanup ReceiveSideCongestionController: remove inner wrapper helper
Bug: None Change-Id: Iff388a56176d90e300e0c12b34414ee21fa26bc8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267406 Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37429}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
9927cb752f
commit
56257afe10
@ -33,6 +33,7 @@ rtc_library("congestion_controller") {
|
||||
"../../api/units:time_delta",
|
||||
"../../api/units:timestamp",
|
||||
"../../rtc_base:logging",
|
||||
"../../rtc_base:macromagic",
|
||||
"../../rtc_base/synchronization:mutex",
|
||||
"../pacing",
|
||||
"../remote_bitrate_estimator",
|
||||
|
||||
@ -22,10 +22,10 @@
|
||||
#include "modules/pacing/packet_router.h"
|
||||
#include "modules/remote_bitrate_estimator/remote_estimator_proxy.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/thread_annotations.h"
|
||||
|
||||
namespace webrtc {
|
||||
class RemoteBitrateEstimator;
|
||||
class RemoteBitrateObserver;
|
||||
|
||||
// This class represents the congestion control state for receive
|
||||
// streams. For send side bandwidth estimation, this is simply
|
||||
@ -73,49 +73,20 @@ class ReceiveSideCongestionController : public CallStatsObserver {
|
||||
TimeDelta MaybeProcess();
|
||||
|
||||
private:
|
||||
class WrappingBitrateEstimator {
|
||||
public:
|
||||
WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock);
|
||||
|
||||
WrappingBitrateEstimator() = delete;
|
||||
WrappingBitrateEstimator(const WrappingBitrateEstimator&) = delete;
|
||||
WrappingBitrateEstimator& operator=(const WrappingBitrateEstimator&) =
|
||||
delete;
|
||||
|
||||
~WrappingBitrateEstimator();
|
||||
|
||||
void IncomingPacket(int64_t arrival_time_ms,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header);
|
||||
|
||||
TimeDelta Process();
|
||||
|
||||
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms);
|
||||
|
||||
void RemoveStream(unsigned int ssrc);
|
||||
|
||||
DataRate LatestEstimate() const;
|
||||
|
||||
void SetMinBitrate(int min_bitrate_bps);
|
||||
|
||||
private:
|
||||
void PickEstimatorFromHeader(const RTPHeader& header)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void PickEstimator() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
RemoteBitrateObserver* observer_;
|
||||
Clock* const clock_;
|
||||
mutable Mutex mutex_;
|
||||
std::unique_ptr<RemoteBitrateEstimator> rbe_;
|
||||
bool using_absolute_send_time_;
|
||||
uint32_t packets_since_absolute_send_time_;
|
||||
int min_bitrate_bps_;
|
||||
};
|
||||
void PickEstimatorFromHeader(const RTPHeader& header)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void PickEstimator() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
Clock& clock_;
|
||||
const FieldTrialBasedConfig field_trial_config_;
|
||||
RembThrottler remb_throttler_;
|
||||
WrappingBitrateEstimator remote_bitrate_estimator_;
|
||||
RemoteEstimatorProxy remote_estimator_proxy_;
|
||||
|
||||
mutable Mutex mutex_;
|
||||
std::unique_ptr<RemoteBitrateEstimator> rbe_ RTC_GUARDED_BY(mutex_);
|
||||
bool using_absolute_send_time_ RTC_GUARDED_BY(mutex_);
|
||||
uint32_t packets_since_absolute_send_time_ RTC_GUARDED_BY(mutex_);
|
||||
int min_bitrate_bps_ RTC_GUARDED_BY(mutex_);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -23,61 +23,24 @@ namespace {
|
||||
static const uint32_t kTimeOffsetSwitchThreshold = 30;
|
||||
} // namespace
|
||||
|
||||
ReceiveSideCongestionController::WrappingBitrateEstimator::
|
||||
WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock)
|
||||
: observer_(observer),
|
||||
clock_(clock),
|
||||
rbe_(new RemoteBitrateEstimatorSingleStream(observer_, clock_)),
|
||||
using_absolute_send_time_(false),
|
||||
packets_since_absolute_send_time_(0),
|
||||
min_bitrate_bps_(congestion_controller::GetMinBitrateBps()) {}
|
||||
|
||||
ReceiveSideCongestionController::WrappingBitrateEstimator::
|
||||
~WrappingBitrateEstimator() = default;
|
||||
|
||||
void ReceiveSideCongestionController::WrappingBitrateEstimator::IncomingPacket(
|
||||
int64_t arrival_time_ms,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header) {
|
||||
MutexLock lock(&mutex_);
|
||||
PickEstimatorFromHeader(header);
|
||||
rbe_->IncomingPacket(arrival_time_ms, payload_size, header);
|
||||
}
|
||||
|
||||
TimeDelta ReceiveSideCongestionController::WrappingBitrateEstimator::Process() {
|
||||
MutexLock lock(&mutex_);
|
||||
return rbe_->Process();
|
||||
}
|
||||
|
||||
void ReceiveSideCongestionController::WrappingBitrateEstimator::OnRttUpdate(
|
||||
int64_t avg_rtt_ms,
|
||||
int64_t max_rtt_ms) {
|
||||
void ReceiveSideCongestionController::OnRttUpdate(int64_t avg_rtt_ms,
|
||||
int64_t max_rtt_ms) {
|
||||
MutexLock lock(&mutex_);
|
||||
rbe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
|
||||
}
|
||||
|
||||
void ReceiveSideCongestionController::WrappingBitrateEstimator::RemoveStream(
|
||||
unsigned int ssrc) {
|
||||
void ReceiveSideCongestionController::RemoveStream(uint32_t ssrc) {
|
||||
MutexLock lock(&mutex_);
|
||||
rbe_->RemoveStream(ssrc);
|
||||
}
|
||||
|
||||
DataRate
|
||||
ReceiveSideCongestionController::WrappingBitrateEstimator::LatestEstimate()
|
||||
const {
|
||||
DataRate ReceiveSideCongestionController::LatestReceiveSideEstimate() const {
|
||||
MutexLock lock(&mutex_);
|
||||
return rbe_->LatestEstimate();
|
||||
}
|
||||
|
||||
void ReceiveSideCongestionController::WrappingBitrateEstimator::SetMinBitrate(
|
||||
int min_bitrate_bps) {
|
||||
MutexLock lock(&mutex_);
|
||||
rbe_->SetMinBitrate(min_bitrate_bps);
|
||||
min_bitrate_bps_ = min_bitrate_bps;
|
||||
}
|
||||
|
||||
void ReceiveSideCongestionController::WrappingBitrateEstimator::
|
||||
PickEstimatorFromHeader(const RTPHeader& header) {
|
||||
void ReceiveSideCongestionController::PickEstimatorFromHeader(
|
||||
const RTPHeader& header) {
|
||||
if (header.extension.hasAbsoluteSendTime) {
|
||||
// If we see AST in header, switch RBE strategy immediately.
|
||||
if (!using_absolute_send_time_) {
|
||||
@ -103,12 +66,13 @@ void ReceiveSideCongestionController::WrappingBitrateEstimator::
|
||||
}
|
||||
|
||||
// Instantiate RBE for Time Offset or Absolute Send Time extensions.
|
||||
void ReceiveSideCongestionController::WrappingBitrateEstimator::
|
||||
PickEstimator() {
|
||||
void ReceiveSideCongestionController::PickEstimator() {
|
||||
if (using_absolute_send_time_) {
|
||||
rbe_.reset(new RemoteBitrateEstimatorAbsSendTime(observer_, clock_));
|
||||
rbe_ = std::make_unique<RemoteBitrateEstimatorAbsSendTime>(&remb_throttler_,
|
||||
&clock_);
|
||||
} else {
|
||||
rbe_.reset(new RemoteBitrateEstimatorSingleStream(observer_, clock_));
|
||||
rbe_ = std::make_unique<RemoteBitrateEstimatorSingleStream>(
|
||||
&remb_throttler_, &clock_);
|
||||
}
|
||||
rbe_->SetMinBitrate(min_bitrate_bps_);
|
||||
}
|
||||
@ -120,10 +84,13 @@ ReceiveSideCongestionController::ReceiveSideCongestionController(
|
||||
NetworkStateEstimator* network_state_estimator)
|
||||
: clock_(*clock),
|
||||
remb_throttler_(std::move(remb_sender), clock),
|
||||
remote_bitrate_estimator_(&remb_throttler_, clock),
|
||||
remote_estimator_proxy_(std::move(feedback_sender),
|
||||
&field_trial_config_,
|
||||
network_state_estimator) {}
|
||||
network_state_estimator),
|
||||
rbe_(new RemoteBitrateEstimatorSingleStream(&remb_throttler_, clock)),
|
||||
using_absolute_send_time_(false),
|
||||
packets_since_absolute_send_time_(0),
|
||||
min_bitrate_bps_(congestion_controller::GetMinBitrateBps()) {}
|
||||
|
||||
void ReceiveSideCongestionController::OnReceivedPacket(
|
||||
int64_t arrival_time_ms,
|
||||
@ -132,8 +99,9 @@ void ReceiveSideCongestionController::OnReceivedPacket(
|
||||
remote_estimator_proxy_.IncomingPacket(arrival_time_ms, payload_size, header);
|
||||
if (!header.extension.hasTransportSequenceNumber) {
|
||||
// Receive-side BWE.
|
||||
remote_bitrate_estimator_.IncomingPacket(arrival_time_ms, payload_size,
|
||||
header);
|
||||
MutexLock lock(&mutex_);
|
||||
PickEstimatorFromHeader(header);
|
||||
rbe_->IncomingPacket(arrival_time_ms, payload_size, header);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,26 +110,15 @@ void ReceiveSideCongestionController::SetSendPeriodicFeedback(
|
||||
remote_estimator_proxy_.SetSendPeriodicFeedback(send_periodic_feedback);
|
||||
}
|
||||
|
||||
DataRate ReceiveSideCongestionController::LatestReceiveSideEstimate() const {
|
||||
return remote_bitrate_estimator_.LatestEstimate();
|
||||
}
|
||||
|
||||
void ReceiveSideCongestionController::RemoveStream(uint32_t ssrc) {
|
||||
remote_bitrate_estimator_.RemoveStream(ssrc);
|
||||
}
|
||||
|
||||
void ReceiveSideCongestionController::OnRttUpdate(int64_t avg_rtt_ms,
|
||||
int64_t max_rtt_ms) {
|
||||
remote_bitrate_estimator_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);
|
||||
}
|
||||
|
||||
void ReceiveSideCongestionController::OnBitrateChanged(int bitrate_bps) {
|
||||
remote_estimator_proxy_.OnBitrateChanged(bitrate_bps);
|
||||
}
|
||||
|
||||
TimeDelta ReceiveSideCongestionController::MaybeProcess() {
|
||||
Timestamp now = clock_.CurrentTime();
|
||||
TimeDelta time_until_rbe = remote_bitrate_estimator_.Process();
|
||||
mutex_.Lock();
|
||||
TimeDelta time_until_rbe = rbe_->Process();
|
||||
mutex_.Unlock();
|
||||
TimeDelta time_until_rep = remote_estimator_proxy_.Process(now);
|
||||
TimeDelta time_until = std::min(time_until_rbe, time_until_rep);
|
||||
return std::max(time_until, TimeDelta::Zero());
|
||||
|
||||
Reference in New Issue
Block a user