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

Unified Diff: webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc

Issue 2808513003: Add SafeClamp(), which accepts args of different types (Closed)
Patch Set: rebase Created 3 years, 6 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/remote_bitrate_estimator/remote_estimator_proxy.cc
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
index 3700fc428d174aaba5d5b78279e8f13251f4057f..35bc667b5abe93998f2b85e9bdf1038b6c0d2338 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
@@ -15,10 +15,11 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
-#include "webrtc/system_wrappers/include/clock.h"
+#include "webrtc/base/safe_minmax.h"
#include "webrtc/modules/pacing/packet_router.h"
-#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
+#include "webrtc/system_wrappers/include/clock.h"
namespace webrtc {
@@ -104,8 +105,9 @@ void RemoteEstimatorProxy::OnBitrateChanged(int bitrate_bps) {
// Let TWCC reports occupy 5% of total bandwidth.
rtc::CritScope cs(&lock_);
- send_interval_ms_ = static_cast<int>(0.5 + kTwccReportSize * 8.0 * 1000.0 /
- (std::max(std::min(0.05 * bitrate_bps, kMaxTwccRate), kMinTwccRate)));
+ send_interval_ms_ = static_cast<int>(
+ 0.5 + kTwccReportSize * 8.0 * 1000.0 /
+ rtc::SafeClamp(0.05 * bitrate_bps, kMinTwccRate, kMaxTwccRate));
}
void RemoteEstimatorProxy::OnPacketArrival(uint16_t sequence_number,

Powered by Google App Engine
This is Rietveld 408576698