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

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

Issue 2970653004: Reimplemeted "Test and fix for huge bwe drop after alr state" (Closed)
Patch Set: Respond to comments Created 3 years, 5 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/acknowledged_bitrate_estimator.cc
diff --git a/webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.cc b/webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b150734df19352bda5211ca759bed3724c704fb3
--- /dev/null
+++ b/webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.cc
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.h"
+
+#include <utility>
+
+#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
+#include "webrtc/rtc_base/ptr_util.h"
+
+namespace webrtc {
+
+namespace {
+bool IsInSendTimeHistory(const PacketFeedback& packet) {
+ return packet.send_time_ms >= 0;
+}
+} // namespace
+
+AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator()
+ : AcknowledgedBitrateEstimator(rtc::MakeUnique<BitrateEstimator>()) {}
+
+AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator(
+ std::unique_ptr<BitrateEstimator> bitrate_estimator)
+ : bitrate_estimator_(std::move(bitrate_estimator)) {}
+
+void AcknowledgedBitrateEstimator::IncomingPacketFeedbackVector(
+ const std::vector<PacketFeedback>& packet_feedback_vector) {
+ RTC_DCHECK(std::is_sorted(packet_feedback_vector.begin(),
+ packet_feedback_vector.end(),
+ PacketFeedbackComparator()));
+ for (const auto& packet : packet_feedback_vector) {
+ if (IsInSendTimeHistory(packet)) {
+ MaybeExpectFastRateChange(packet.send_time_ms);
+ bitrate_estimator_->Update(packet.arrival_time_ms, packet.payload_size);
+ }
+ }
+}
+
+rtc::Optional<uint32_t> AcknowledgedBitrateEstimator::bitrate_bps() const {
+ return bitrate_estimator_->bitrate_bps();
+}
+
+void AcknowledgedBitrateEstimator::SetAlrEndedTimeMs(
+ int64_t alr_ended_time_ms) {
+ alr_ended_time_ms_.emplace(alr_ended_time_ms);
+}
+
+void AcknowledgedBitrateEstimator::MaybeExpectFastRateChange(
+ int64_t packet_send_time_ms) {
+ if (alr_ended_time_ms_ && packet_send_time_ms > *alr_ended_time_ms_) {
+ bitrate_estimator_->ExpectFastRateChange();
+ alr_ended_time_ms_.reset();
+ }
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698