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

Unified Diff: webrtc/modules/congestion_controller/congestion_controller.cc

Issue 1958053002: Revert "Reland of Remove SendPacer from ViEEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 4 years, 7 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
Index: webrtc/modules/congestion_controller/congestion_controller.cc
diff --git a/webrtc/modules/congestion_controller/congestion_controller.cc b/webrtc/modules/congestion_controller/congestion_controller.cc
index d557843be24ee10937d7e8c99a2c041d0b2d3375..14a73fe1cdccfb1a3bdaed8f6771f5fe1af3cc1f 100644
--- a/webrtc/modules/congestion_controller/congestion_controller.cc
+++ b/webrtc/modules/congestion_controller/congestion_controller.cc
@@ -20,6 +20,7 @@
#include "webrtc/base/socket.h"
#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/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"
@@ -140,76 +141,28 @@ CongestionController::CongestionController(
BitrateObserver* bitrate_observer,
RemoteBitrateObserver* remote_bitrate_observer)
: clock_(clock),
- observer_(nullptr),
- packet_router_(new PacketRouter()),
pacer_(new PacedSender(clock_,
- packet_router_.get(),
- BitrateController::kDefaultStartBitratebps)),
- remote_bitrate_estimator_(
- new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
- bitrate_controller_(
- BitrateController::CreateBitrateController(clock_, bitrate_observer)),
- remote_estimator_proxy_(clock_, packet_router_.get()),
- transport_feedback_adapter_(bitrate_controller_.get(), clock_),
- min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
- send_queue_is_full_(false) {
- Init();
-}
-
-CongestionController::CongestionController(
- Clock* clock,
- Observer* observer,
- RemoteBitrateObserver* remote_bitrate_observer)
- : clock_(clock),
- observer_(observer),
- packet_router_(new PacketRouter()),
- pacer_(new PacedSender(clock_,
- packet_router_.get(),
- BitrateController::kDefaultStartBitratebps)),
- remote_bitrate_estimator_(
- new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
- bitrate_controller_(BitrateController::CreateBitrateController(clock_)),
- remote_estimator_proxy_(clock_, packet_router_.get()),
- transport_feedback_adapter_(bitrate_controller_.get(), clock_),
- min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
- send_queue_is_full_(false) {
- Init();
-}
-
-CongestionController::CongestionController(
- Clock* clock,
- Observer* observer,
- RemoteBitrateObserver* remote_bitrate_observer,
- std::unique_ptr<PacketRouter> packet_router,
- std::unique_ptr<PacedSender> pacer)
- : clock_(clock),
- observer_(observer),
- packet_router_(std::move(packet_router)),
- pacer_(std::move(pacer)),
+ &packet_router_,
+ BitrateController::kDefaultStartBitrateKbps,
+ PacedSender::kDefaultPaceMultiplier *
+ BitrateController::kDefaultStartBitrateKbps,
+ 0)),
remote_bitrate_estimator_(
new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
// Constructed last as this object calls the provided callback on
// construction.
- bitrate_controller_(BitrateController::CreateBitrateController(clock_)),
- remote_estimator_proxy_(clock_, packet_router_.get()),
+ 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),
- send_queue_is_full_(false) {
- Init();
-}
-
-CongestionController::~CongestionController() {}
-
-void CongestionController::Init() {
+ min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) {
transport_feedback_adapter_.SetBitrateEstimator(
new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_));
transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate(
min_bitrate_bps_);
- // This calls the observer_, which means that the observer provided by the
- // user must be ready to accept a bitrate update when it constructs the
- // controller. We do this to avoid having to keep synchronized initial values
- // in both the controller and the allocator.
- MaybeTriggerOnNetworkChanged();
+}
+
+CongestionController::~CongestionController() {
}
@@ -236,7 +189,6 @@ void CongestionController::SetBweBitrates(int min_bitrate_bps,
min_bitrate_bps_ = min_bitrate_bps;
transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate(
min_bitrate_bps_);
- MaybeTriggerOnNetworkChanged();
}
BitrateController* CongestionController::GetBitrateController() const {
@@ -257,9 +209,10 @@ CongestionController::GetTransportFeedbackObserver() {
return &transport_feedback_adapter_;
}
-void CongestionController::SetAllocatedSendBitrate(int allocated_bitrate_bps,
- int padding_bitrate_bps) {
- pacer_->SetAllocatedSendBitrate(allocated_bitrate_bps, padding_bitrate_bps);
+void CongestionController::UpdatePacerBitrate(int bitrate_kbps,
+ int max_bitrate_kbps,
+ int min_bitrate_kbps) {
+ pacer_->UpdateBitrate(bitrate_kbps, max_bitrate_kbps, min_bitrate_kbps);
}
int64_t CongestionController::GetPacerQueuingDelayMs() const {
@@ -292,36 +245,6 @@ int64_t CongestionController::TimeUntilNextProcess() {
void CongestionController::Process() {
bitrate_controller_->Process();
remote_bitrate_estimator_->Process();
- MaybeTriggerOnNetworkChanged();
-}
-
-void CongestionController::MaybeTriggerOnNetworkChanged() {
- // TODO(perkj): |observer_| can be nullptr if the ctor that accepts a
- // BitrateObserver is used. Remove this check once the ctor is removed.
- if (!observer_)
- return;
-
- uint32_t bitrate_bps;
- uint8_t fraction_loss;
- int64_t rtt;
- bool network_changed = bitrate_controller_->GetNetworkParameters(
- &bitrate_bps, &fraction_loss, &rtt);
- if (network_changed)
- pacer_->SetEstimatedBitrate(bitrate_bps);
- bool send_queue_is_full =
- pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs;
- bitrate_bps = send_queue_is_full ? 0 : bitrate_bps;
- if ((network_changed && !send_queue_is_full) ||
- UpdateSendQueueStatus(send_queue_is_full)) {
- observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt);
- }
-}
-
-bool CongestionController::UpdateSendQueueStatus(bool send_queue_is_full) {
- rtc::CritScope cs(&critsect_);
- bool result = send_queue_is_full_ != send_queue_is_full;
- send_queue_is_full_ = send_queue_is_full;
- return result;
}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698