Break out pacer thread from CongestionController to increase testability.

R=pbos@webrtc.org
TBR=mflodman@webrtc.org

Review URL: https://codereview.webrtc.org/1732863002 .

Cr-Commit-Position: refs/heads/master@{#11745}
This commit is contained in:
Stefan Holmer 2016-02-24 16:02:55 +01:00
parent 23353ab465
commit c379fcb248
5 changed files with 24 additions and 15 deletions

View File

@ -121,6 +121,7 @@ class Call : public webrtc::Call, public PacketReceiver,
const int num_cpu_cores_;
const rtc::scoped_ptr<ProcessThread> module_process_thread_;
const rtc::scoped_ptr<ProcessThread> pacer_thread_;
const rtc::scoped_ptr<CallStats> call_stats_;
const rtc::scoped_ptr<BitrateAllocator> 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();
}

View File

@ -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

View File

@ -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_);
}

View File

@ -72,7 +72,6 @@ class CongestionController : public CallStatsObserver, public Module {
rtc::ThreadChecker config_thread_checker_;
const rtc::scoped_ptr<PacedSender> pacer_;
const rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_;
const rtc::scoped_ptr<ProcessThread> pacer_thread_;
const rtc::scoped_ptr<BitrateController> bitrate_controller_;
PacketRouter packet_router_;
RemoteEstimatorProxy remote_estimator_proxy_;

View File

@ -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();