Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: webrtc/call/congestion_controller.cc

Issue 1704983002: Simplify CongestionController. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comments addressed. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/call/congestion_controller.h ('k') | webrtc/call/mock/mock_congestion_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/call/congestion_controller.cc
diff --git a/webrtc/call/congestion_controller.cc b/webrtc/call/congestion_controller.cc
index 59713d30576cec2b98ed55752e6e457b0d92f2d9..e2b9c23834ac45b52081d05dc62f95b80dbd032a 100644
--- a/webrtc/call/congestion_controller.cc
+++ b/webrtc/call/congestion_controller.cc
@@ -19,15 +19,11 @@
#include "webrtc/base/thread_annotations.h"
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
#include "webrtc/modules/pacing/paced_sender.h"
-#include "webrtc/modules/pacing/packet_router.h"
#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h"
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h"
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h"
-#include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h"
-#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,55 +136,46 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator {
CongestionController::CongestionController(
Clock* clock,
- ProcessThread* process_thread,
- CallStats* call_stats,
BitrateObserver* bitrate_observer,
RemoteBitrateObserver* remote_bitrate_observer)
: clock_(clock),
- packet_router_(new PacketRouter()),
pacer_(new PacedSender(clock_,
- packet_router_.get(),
- BitrateController::kDefaultStartBitrateKbps,
- PacedSender::kDefaultPaceMultiplier *
- BitrateController::kDefaultStartBitrateKbps,
- 0)),
+ &packet_router_,
+ BitrateController::kDefaultStartBitrateKbps,
+ PacedSender::kDefaultPaceMultiplier *
+ BitrateController::kDefaultStartBitrateKbps,
+ 0)),
remote_bitrate_estimator_(
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)),
+ remote_estimator_proxy_(clock_, &packet_router_),
+ transport_feedback_adapter_(bitrate_controller_.get(), clock_),
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) {
- call_stats_->RegisterStatsObserver(remote_bitrate_estimator_.get());
-
+ transport_feedback_adapter_.SetBitrateEstimator(
+ new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_,
+ clock_));
+ transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate(
+ min_bitrate_bps_);
pacer_thread_->RegisterModule(pacer_.get());
- pacer_thread_->RegisterModule(remote_estimator_proxy_.get());
+ pacer_thread_->RegisterModule(&remote_estimator_proxy_);
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());
+ pacer_thread_->DeRegisterModule(&remote_estimator_proxy_);
}
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 +189,11 @@ 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())
- transport_feedback_adapter_->GetBitrateEstimator()->SetMinBitrate(
- min_bitrate_bps);
min_bitrate_bps_ = min_bitrate_bps;
+ transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate(
+ min_bitrate_bps_);
}
BitrateController* CongestionController::GetBitrateController() const {
@@ -215,27 +201,18 @@ BitrateController* CongestionController::GetBitrateController() const {
}
RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator(
- bool send_side_bwe) const {
-
- if (send_side_bwe)
- return remote_estimator_proxy_.get();
- else
+ bool send_side_bwe) {
+ if (send_side_bwe) {
+ return &remote_estimator_proxy_;
+ } else {
return remote_bitrate_estimator_.get();
+ }
}
TransportFeedbackObserver*
CongestionController::GetTransportFeedbackObserver() {
- if (transport_feedback_adapter_.get() == nullptr) {
- transport_feedback_adapter_.reset(new TransportFeedbackAdapter(
- bitrate_controller_.get(), clock_, process_thread_));
- 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();
+ RTC_DCHECK(config_thread_checker_.CalledOnValidThread());
+ return &transport_feedback_adapter_;
}
void CongestionController::UpdatePacerBitrate(int bitrate_kbps,
@@ -257,9 +234,24 @@ void CongestionController::SignalNetworkState(NetworkState state) {
}
void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) {
- if (transport_feedback_adapter_) {
- transport_feedback_adapter_->OnSentPacket(sent_packet.packet_id,
- sent_packet.send_time_ms);
- }
+ 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);
+ transport_feedback_adapter_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);
+}
+
+int64_t CongestionController::TimeUntilNextProcess() {
+ return std::min(bitrate_controller_->TimeUntilNextProcess(),
+ remote_bitrate_estimator_->TimeUntilNextProcess());
+}
+
+int32_t CongestionController::Process() {
+ bitrate_controller_->Process();
+ remote_bitrate_estimator_->Process();
+ return 0;
+}
+
} // namespace webrtc
« no previous file with comments | « webrtc/call/congestion_controller.h ('k') | webrtc/call/mock/mock_congestion_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698