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

Unified Diff: media/cast/congestion_control/congestion_control.cc

Issue 149093008: Cast:Refactor CongestionControl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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: media/cast/congestion_control/congestion_control.cc
diff --git a/media/cast/congestion_control/congestion_control.cc b/media/cast/congestion_control/congestion_control.cc
index 35687e7477a590996c3b48c360e5e61c6158c899..39d68b39f01e23b5b590b9a3cf8fa89333ae9c06 100644
--- a/media/cast/congestion_control/congestion_control.cc
+++ b/media/cast/congestion_control/congestion_control.cc
@@ -37,8 +37,7 @@ CongestionControl::CongestionControl(base::TickClock* clock,
DCHECK_GE(start_bitrate, min_bitrate_configured) << "Invalid config";
}
-CongestionControl::~CongestionControl() {
-}
+CongestionControl::~CongestionControl() {}
bool CongestionControl::OnAck(base::TimeDelta rtt, uint32* new_bitrate) {
base::TimeTicks now = clock_->NowTicks();
@@ -50,31 +49,36 @@ bool CongestionControl::OnAck(base::TimeDelta rtt, uint32* new_bitrate) {
return false;
}
// Are we at the max bitrate?
- if (max_bitrate_configured_ == bitrate_) return false;
+ if (max_bitrate_configured_ == bitrate_)
+ return false;
// Make sure RTT is never less than 1 ms.
rtt = std::max(rtt, base::TimeDelta::FromMilliseconds(1));
- base::TimeDelta elapsed_time = std::min(now - time_last_increase_,
- base::TimeDelta::FromMilliseconds(kMaxElapsedTimeMs));
- base::TimeDelta change_interval = std::max(rtt,
+ base::TimeDelta elapsed_time =
+ std::min(now - time_last_increase_,
+ base::TimeDelta::FromMilliseconds(kMaxElapsedTimeMs));
+ base::TimeDelta change_interval = std::max(
+ rtt,
base::TimeDelta::FromMilliseconds(kCongestionControlMinChangeIntervalMs));
- change_interval = std::min(change_interval,
+ change_interval = std::min(
+ change_interval,
base::TimeDelta::FromMilliseconds(kCongestionControlMaxChangeIntervalMs));
// Have enough time have passed?
- if (elapsed_time < change_interval) return false;
+ if (elapsed_time < change_interval)
+ return false;
time_last_increase_ = now;
// One packet per RTT multiplied by the elapsed time fraction.
// 1500 * 8 * (1000 / rtt_ms) * (elapsed_time_ms / 1000) =>
// 1500 * 8 * elapsed_time_ms / rtt_ms.
- uint32 bitrate_increase = (1500 * 8 * elapsed_time.InMilliseconds()) /
- rtt.InMilliseconds();
+ uint32 bitrate_increase =
+ (1500 * 8 * elapsed_time.InMilliseconds()) / rtt.InMilliseconds();
uint32 max_bitrate_increase =
kCongestionControlMaxBitrateIncreasePerMillisecond *
- elapsed_time.InMilliseconds();
+ elapsed_time.InMilliseconds();
bitrate_increase = std::min(max_bitrate_increase, bitrate_increase);
*new_bitrate = std::min(bitrate_increase + bitrate_, max_bitrate_configured_);
bitrate_ = *new_bitrate;
@@ -90,22 +94,26 @@ bool CongestionControl::OnNack(base::TimeDelta rtt, uint32* new_bitrate) {
time_last_decrease_ = now;
return false;
}
- base::TimeDelta elapsed_time = std::min(now - time_last_decrease_,
- base::TimeDelta::FromMilliseconds(kMaxElapsedTimeMs));
- base::TimeDelta change_interval = std::max(rtt,
+ base::TimeDelta elapsed_time =
+ std::min(now - time_last_decrease_,
+ base::TimeDelta::FromMilliseconds(kMaxElapsedTimeMs));
+ base::TimeDelta change_interval = std::max(
+ rtt,
base::TimeDelta::FromMilliseconds(kCongestionControlMinChangeIntervalMs));
- change_interval = std::min(change_interval,
+ change_interval = std::min(
+ change_interval,
base::TimeDelta::FromMilliseconds(kCongestionControlMaxChangeIntervalMs));
// Have enough time have passed?
- if (elapsed_time < change_interval) return false;
+ if (elapsed_time < change_interval)
+ return false;
time_last_decrease_ = now;
time_last_increase_ = now;
- *new_bitrate = std::max(
- static_cast<uint32>(bitrate_ * congestion_control_back_off_),
- min_bitrate_configured_);
+ *new_bitrate =
+ std::max(static_cast<uint32>(bitrate_ * congestion_control_back_off_),
+ min_bitrate_configured_);
bitrate_ = *new_bitrate;
return true;
« no previous file with comments | « media/cast/congestion_control/congestion_control.h ('k') | media/cast/congestion_control/congestion_control_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698