diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc index d538761f7b..41ac328eab 100644 --- a/webrtc/call/call.cc +++ b/webrtc/call/call.cc @@ -121,6 +121,7 @@ class Call : public webrtc::Call, public PacketReceiver, const int num_cpu_cores_; const rtc::scoped_ptr module_process_thread_; + const rtc::scoped_ptr pacer_thread_; const rtc::scoped_ptr call_stats_; const rtc::scoped_ptr bitrate_allocator_; Call::Config config_; @@ -183,6 +184,7 @@ 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")), call_stats_(new CallStats(clock_)), bitrate_allocator_(new BitrateAllocator()), config_(config), @@ -214,17 +216,21 @@ Call::Call(const Call::Config& config) } Trace::CreateTrace(); - module_process_thread_->Start(); - module_process_thread_->RegisterModule(call_stats_.get()); - module_process_thread_->RegisterModule(congestion_controller_.get()); call_stats_->RegisterStatsObserver(congestion_controller_.get()); congestion_controller_->SetBweBitrates( config_.bitrate_config.min_bitrate_bps, config_.bitrate_config.start_bitrate_bps, config_.bitrate_config.max_bitrate_bps); - congestion_controller_->GetBitrateController()->SetEventLog(event_log_); + + 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(); } Call::~Call() { @@ -239,10 +245,14 @@ Call::~Call() { RTC_CHECK(video_receive_ssrcs_.empty()); RTC_CHECK(video_receive_streams_.empty()); - call_stats_->DeregisterStatsObserver(congestion_controller_.get()); + pacer_thread_->Stop(); + pacer_thread_->DeRegisterModule(congestion_controller_->pacer()); + pacer_thread_->DeRegisterModule( + congestion_controller_->GetRemoteBitrateEstimator(true)); module_process_thread_->DeRegisterModule(congestion_controller_.get()); module_process_thread_->DeRegisterModule(call_stats_.get()); module_process_thread_->Stop(); + call_stats_->DeregisterStatsObserver(congestion_controller_.get()); Trace::ReturnTrace(); } diff --git a/webrtc/modules/congestion_controller/OWNERS b/webrtc/modules/congestion_controller/OWNERS new file mode 100644 index 0000000000..673c6bfe23 --- /dev/null +++ b/webrtc/modules/congestion_controller/OWNERS @@ -0,0 +1,9 @@ +mflodman@webrtc.org +stefan@webrtc.org + +# These are for the common case of adding or renaming files. If you're doing +# structural changes, please get a review from a reviewer in this file. +per-file *.gyp=* +per-file *.gypi=* + +per-file BUILD.gn=kjellander@webrtc.org diff --git a/webrtc/modules/congestion_controller/congestion_controller.cc b/webrtc/modules/congestion_controller/congestion_controller.cc index 0282e8148e..50074d50e4 100644 --- a/webrtc/modules/congestion_controller/congestion_controller.cc +++ b/webrtc/modules/congestion_controller/congestion_controller.cc @@ -147,7 +147,6 @@ CongestionController::CongestionController( 0)), remote_bitrate_estimator_( new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), - pacer_thread_(ProcessThread::Create("PacerThread")), // Constructed last as this object calls the provided callback on // construction. bitrate_controller_( @@ -160,15 +159,9 @@ CongestionController::CongestionController( clock_)); transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( min_bitrate_bps_); - pacer_thread_->RegisterModule(pacer_.get()); - pacer_thread_->RegisterModule(&remote_estimator_proxy_); - pacer_thread_->Start(); } CongestionController::~CongestionController() { - pacer_thread_->Stop(); - pacer_thread_->DeRegisterModule(pacer_.get()); - pacer_thread_->DeRegisterModule(&remote_estimator_proxy_); } diff --git a/webrtc/modules/congestion_controller/include/congestion_controller.h b/webrtc/modules/congestion_controller/include/congestion_controller.h index 8c8972dd3a..f4381e2a4d 100644 --- a/webrtc/modules/congestion_controller/include/congestion_controller.h +++ b/webrtc/modules/congestion_controller/include/congestion_controller.h @@ -72,7 +72,6 @@ class CongestionController : public CallStatsObserver, public Module { rtc::ThreadChecker config_thread_checker_; const rtc::scoped_ptr pacer_; const rtc::scoped_ptr remote_bitrate_estimator_; - const rtc::scoped_ptr pacer_thread_; const rtc::scoped_ptr bitrate_controller_; PacketRouter packet_router_; RemoteEstimatorProxy remote_estimator_proxy_; diff --git a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc index fb5d9d03c6..ee17ad78db 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc @@ -72,8 +72,6 @@ int64_t RemoteEstimatorProxy::TimeUntilNextProcess() { } int32_t RemoteEstimatorProxy::Process() { - // TODO(sprang): Perhaps we need a dedicated thread here instead? - if (TimeUntilNextProcess() > 0) return 0; last_process_time_ms_ = clock_->TimeInMilliseconds();