Index: webrtc/call/congestion_controller.cc |
diff --git a/webrtc/call/congestion_controller.cc b/webrtc/call/congestion_controller.cc |
index 59713d30576cec2b98ed55752e6e457b0d92f2d9..aa279a8e428fdede14378a075323375b51a4012c 100644 |
--- a/webrtc/call/congestion_controller.cc |
+++ b/webrtc/call/congestion_controller.cc |
@@ -27,7 +27,6 @@ |
#include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h" |
#include "webrtc/modules/utility/include/process_thread.h" |
#include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
-#include "webrtc/video/call_stats.h" |
#include "webrtc/video/payload_router.h" |
namespace webrtc { |
@@ -140,8 +139,6 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
CongestionController::CongestionController( |
Clock* clock, |
- ProcessThread* process_thread, |
- CallStats* call_stats, |
BitrateObserver* bitrate_observer, |
RemoteBitrateObserver* remote_bitrate_observer) |
: clock_(clock), |
@@ -156,39 +153,28 @@ CongestionController::CongestionController( |
new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), |
remote_estimator_proxy_( |
new RemoteEstimatorProxy(clock_, packet_router_.get())), |
- process_thread_(process_thread), |
- call_stats_(call_stats), |
pacer_thread_(ProcessThread::Create("PacerThread")), |
// Constructed last as this object calls the provided callback on |
// construction. |
bitrate_controller_( |
BitrateController::CreateBitrateController(clock_, bitrate_observer)), |
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) { |
- call_stats_->RegisterStatsObserver(remote_bitrate_estimator_.get()); |
- |
pacer_thread_->RegisterModule(pacer_.get()); |
pacer_thread_->RegisterModule(remote_estimator_proxy_.get()); |
pacer_thread_->Start(); |
- |
- process_thread_->RegisterModule(remote_bitrate_estimator_.get()); |
- process_thread_->RegisterModule(bitrate_controller_.get()); |
} |
CongestionController::~CongestionController() { |
pacer_thread_->Stop(); |
pacer_thread_->DeRegisterModule(pacer_.get()); |
pacer_thread_->DeRegisterModule(remote_estimator_proxy_.get()); |
- process_thread_->DeRegisterModule(bitrate_controller_.get()); |
- process_thread_->DeRegisterModule(remote_bitrate_estimator_.get()); |
- call_stats_->DeregisterStatsObserver(remote_bitrate_estimator_.get()); |
- if (transport_feedback_adapter_.get()) |
- call_stats_->DeregisterStatsObserver(transport_feedback_adapter_.get()); |
} |
void CongestionController::SetBweBitrates(int min_bitrate_bps, |
int start_bitrate_bps, |
int max_bitrate_bps) { |
+ RTC_DCHECK(config_thread_checker_.CalledOnValidThread()); |
// TODO(holmer): We should make sure the default bitrates are set to 10 kbps, |
// and that we don't try to set the min bitrate to 0 from any applications. |
// The congestion controller should allow a min bitrate of 0. |
@@ -202,12 +188,14 @@ void CongestionController::SetBweBitrates(int min_bitrate_bps, |
bitrate_controller_->SetStartBitrate(start_bitrate_bps); |
} |
bitrate_controller_->SetMinMaxBitrate(min_bitrate_bps, max_bitrate_bps); |
- if (remote_bitrate_estimator_.get()) |
+ if (remote_bitrate_estimator_) |
remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); |
- if (transport_feedback_adapter_.get()) |
+ min_bitrate_bps_ = min_bitrate_bps; |
+ |
+ rtc::CritScope lock(&crit_); |
+ if (transport_feedback_adapter_) |
transport_feedback_adapter_->GetBitrateEstimator()->SetMinBitrate( |
min_bitrate_bps); |
- min_bitrate_bps_ = min_bitrate_bps; |
} |
BitrateController* CongestionController::GetBitrateController() const { |
@@ -216,7 +204,6 @@ BitrateController* CongestionController::GetBitrateController() const { |
RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator( |
bool send_side_bwe) const { |
- |
if (send_side_bwe) |
return remote_estimator_proxy_.get(); |
else |
@@ -225,15 +212,16 @@ RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator( |
TransportFeedbackObserver* |
the sun
2016/02/17 12:47:26
So, you may return a pointer to the TFA on one thr
stefan-webrtc
2016/02/17 13:32:48
Yes, it turned out to be fairly easy to make that
|
CongestionController::GetTransportFeedbackObserver() { |
+ RTC_DCHECK(config_thread_checker_.CalledOnValidThread()); |
+ rtc::CritScope lock(&crit_); |
if (transport_feedback_adapter_.get() == nullptr) { |
pbos-webrtc
2016/02/17 12:17:12
!transport_feedback_adapter_
stefan-webrtc
2016/02/17 13:32:48
Done.
|
- transport_feedback_adapter_.reset(new TransportFeedbackAdapter( |
- bitrate_controller_.get(), clock_, process_thread_)); |
+ transport_feedback_adapter_.reset( |
+ new TransportFeedbackAdapter(bitrate_controller_.get(), clock_)); |
transport_feedback_adapter_->SetBitrateEstimator( |
new RemoteBitrateEstimatorAbsSendTime(transport_feedback_adapter_.get(), |
clock_)); |
transport_feedback_adapter_->GetBitrateEstimator()->SetMinBitrate( |
min_bitrate_bps_); |
- call_stats_->RegisterStatsObserver(transport_feedback_adapter_.get()); |
} |
return transport_feedback_adapter_.get(); |
} |
@@ -257,9 +245,42 @@ void CongestionController::SignalNetworkState(NetworkState state) { |
} |
void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { |
+ rtc::CritScope lock(&crit_); |
if (transport_feedback_adapter_) { |
transport_feedback_adapter_->OnSentPacket(sent_packet.packet_id, |
sent_packet.send_time_ms); |
} |
} |
+ |
+void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
+ remote_bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
+ |
+ rtc::CritScope lock(&crit_); |
+ if (transport_feedback_adapter_) |
+ transport_feedback_adapter_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
+} |
+ |
+int64_t CongestionController::TimeUntilNextProcess() { |
+ int64_t time_until_process = |
+ std::min(bitrate_controller_->TimeUntilNextProcess(), |
+ remote_bitrate_estimator_->TimeUntilNextProcess()); |
+ rtc::CritScope lock(&crit_); |
+ if (transport_feedback_adapter_) { |
+ time_until_process = |
+ std::min(transport_feedback_adapter_->GetBitrateEstimator() |
+ ->TimeUntilNextProcess(), |
+ time_until_process); |
+ } |
+ return time_until_process; |
+} |
+ |
+int32_t CongestionController::Process() { |
+ bitrate_controller_->Process(); |
+ remote_bitrate_estimator_->Process(); |
+ rtc::CritScope lock(&crit_); |
+ if (transport_feedback_adapter_) |
+ transport_feedback_adapter_->GetBitrateEstimator()->Process(); |
+ return 0; |
+} |
+ |
} // namespace webrtc |