diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc index 48072d0a0b..cd31b028bd 100644 --- a/webrtc/call/call.cc +++ b/webrtc/call/call.cc @@ -173,7 +173,7 @@ class Call : public webrtc::Call, const int num_cpu_cores_; const std::unique_ptr module_process_thread_; - const std::unique_ptr pacer_thread_; + const std::unique_ptr congestion_controller_thread_; const std::unique_ptr call_stats_; const std::unique_ptr bitrate_allocator_; Call::Config config_; @@ -277,7 +277,8 @@ Call::Call(const Call::Config& config) : clock_(Clock::GetRealTimeClock()), num_cpu_cores_(CpuInfo::DetectNumberOfCores()), module_process_thread_(ProcessThread::Create("ModuleProcessThread")), - pacer_thread_(ProcessThread::Create("PacerThread")), + congestion_controller_thread_( + ProcessThread::Create("CongestionControllerThread")), call_stats_(new CallStats(clock_)), bitrate_allocator_(new BitrateAllocator(this)), config_(config), @@ -324,11 +325,8 @@ Call::Call(const Call::Config& config) module_process_thread_->Start(); module_process_thread_->RegisterModule(call_stats_.get()); - module_process_thread_->RegisterModule(congestion_controller_.get()); - pacer_thread_->RegisterModule(congestion_controller_->pacer()); - pacer_thread_->RegisterModule( - congestion_controller_->GetRemoteBitrateEstimator(true)); - pacer_thread_->Start(); + congestion_controller_thread_->RegisterModule(congestion_controller_.get()); + congestion_controller_thread_->Start(); } Call::~Call() { @@ -342,11 +340,8 @@ Call::~Call() { RTC_CHECK(video_receive_ssrcs_.empty()); RTC_CHECK(video_receive_streams_.empty()); - pacer_thread_->Stop(); - pacer_thread_->DeRegisterModule(congestion_controller_->pacer()); - pacer_thread_->DeRegisterModule( - congestion_controller_->GetRemoteBitrateEstimator(true)); - module_process_thread_->DeRegisterModule(congestion_controller_.get()); + congestion_controller_thread_->Stop(); + congestion_controller_thread_->DeRegisterModule(congestion_controller_.get()); module_process_thread_->DeRegisterModule(call_stats_.get()); module_process_thread_->Stop(); call_stats_->DeregisterStatsObserver(congestion_controller_.get()); diff --git a/webrtc/modules/congestion_controller/congestion_controller.cc b/webrtc/modules/congestion_controller/congestion_controller.cc index 94b3d8c6da..cbe3f2fe8a 100644 --- a/webrtc/modules/congestion_controller/congestion_controller.cc +++ b/webrtc/modules/congestion_controller/congestion_controller.cc @@ -327,15 +327,19 @@ void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { } int64_t CongestionController::TimeUntilNextProcess() { - return std::min(bitrate_controller_->TimeUntilNextProcess(), - remote_bitrate_estimator_->TimeUntilNextProcess()); + return std::min({bitrate_controller_->TimeUntilNextProcess(), + remote_bitrate_estimator_->TimeUntilNextProcess(), + pacer_->TimeUntilNextProcess(), + remote_estimator_proxy_.TimeUntilNextProcess()}); } void CongestionController::Process() { bitrate_controller_->Process(); remote_bitrate_estimator_->Process(); - probe_controller_->Process(); MaybeTriggerOnNetworkChanged(); + probe_controller_->Process(); + pacer_->Process(); + remote_estimator_proxy_.Process(); } void CongestionController::MaybeTriggerOnNetworkChanged() { diff --git a/webrtc/modules/pacing/alr_detector.cc b/webrtc/modules/pacing/alr_detector.cc index b31d4482bb..9a917983be 100644 --- a/webrtc/modules/pacing/alr_detector.cc +++ b/webrtc/modules/pacing/alr_detector.cc @@ -36,6 +36,10 @@ AlrDetector::AlrDetector() AlrDetector::~AlrDetector() {} void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t now_ms) { + // TODO(nisse): It's unclear what guarantees there are that this + // function isn't called before SetEstimatedBitrate. Document that + // guarantee, if it exists. Or else, remove the DCHECK and tolerate + // that current estimate is zero, e.g., by just returning false. RTC_DCHECK(estimated_bitrate_bps_); rate_.Update(bytes_sent, now_ms); diff --git a/webrtc/modules/pacing/paced_sender.cc b/webrtc/modules/pacing/paced_sender.cc index a0d7eda73f..55a060cbc3 100644 --- a/webrtc/modules/pacing/paced_sender.cc +++ b/webrtc/modules/pacing/paced_sender.cc @@ -450,9 +450,11 @@ void PacedSender::Process() { bytes_sent += SendPadding(padding_needed, probe_cluster_id); } } - if (is_probing && bytes_sent > 0) - prober_->ProbeSent(clock_->TimeInMilliseconds(), bytes_sent); - alr_detector_->OnBytesSent(bytes_sent, now_us / 1000); + if (bytes_sent > 0) { + if (is_probing) + prober_->ProbeSent(clock_->TimeInMilliseconds(), bytes_sent); + alr_detector_->OnBytesSent(bytes_sent, now_us / 1000); + } } bool PacedSender::SendPacket(const paced_sender::Packet& packet,