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

Side by Side Diff: webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.cc

Issue 2931873002: Test and fix for huge bwe drop after alr state. (Closed)
Patch Set: Renamed SentBeforeLeftAlr to SentInAlrState added a test. 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/congestion_controller/acknowledged_bitrate_estimator.h"
12
13 #include <utility>
14
15 #include "webrtc/base/ptr_util.h"
16 #include "webrtc/base/timeutils.h"
17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
18
19 namespace webrtc {
20
21 namespace {
22 bool IsInSendTimeHistory(const PacketFeedback& packet) {
23 return packet.send_time_ms >= 0;
24 }
25 } // namespace
26
27 std::unique_ptr<BitrateEstimator> BitrateEstimatorCreator::Create() const {
28 return rtc::MakeUnique<BitrateEstimator>();
29 }
30
31 AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator(
32 std::unique_ptr<BitrateEstimatorCreator> bitrate_estimator_creator)
33 : last_alr_state_(false),
34 bitrate_estimator_creator_(
35 bitrate_estimator_creator
36 ? std::move(bitrate_estimator_creator)
37 : rtc::MakeUnique<BitrateEstimatorCreator>()),
38 bitrate_estimator_(bitrate_estimator_creator_->Create()) {}
39
40 void AcknowledgedBitrateEstimator::IncomingPacketFeedbackVector(
41 const std::vector<PacketFeedback>& packet_feedback_vector,
42 bool alr_state) {
43 RTC_DCHECK(std::is_sorted(packet_feedback_vector.begin(),
44 packet_feedback_vector.end(),
45 PacketFeedbackComparator()));
46 MaybeResetBitrateEstimator(alr_state);
47 for (const auto& packet : packet_feedback_vector) {
48 if (IsInSendTimeHistory(packet) && !SentInAlrState(packet))
49 bitrate_estimator_->Update(packet.arrival_time_ms, packet.payload_size);
50 }
51 }
52
53 rtc::Optional<uint32_t> AcknowledgedBitrateEstimator::bitrate_bps() const {
54 return bitrate_estimator_->bitrate_bps();
55 }
56
57 bool AcknowledgedBitrateEstimator::SentInAlrState(
terelius 2017/06/13 14:03:20 I'd also prefer a more descriptive name for this f
tschumi 2017/06/14 07:47:44 Renamed it to "SentBeforeAlrEnded"
58 const PacketFeedback& packet) {
59 if (left_alr_state_ms_) {
60 if (*left_alr_state_ms_ > packet.send_time_ms) {
61 return true;
62 } else {
63 left_alr_state_ms_.reset();
terelius 2017/06/13 14:03:20 Do we really want to forget that we have left ALR
tschumi 2017/06/14 07:47:44 I'm not sure if it's worth to add additional compl
64 }
65 }
66 return false;
67 }
68
69 bool AcknowledgedBitrateEstimator::HasLeftAlrState(bool alr_state) const {
70 return last_alr_state_ && !alr_state;
terelius 2017/06/13 14:03:20 Maybe call them was_in_alr and currently_in_alr? A
tschumi 2017/06/14 07:47:43 Acknowledged.
71 }
72
73 void AcknowledgedBitrateEstimator::MaybeResetBitrateEstimator(bool alr_state) {
74 if (HasLeftAlrState(alr_state)) {
terelius 2017/06/13 14:03:20 Manually inline this function?
tschumi 2017/06/14 07:47:43 Don't you think the function name adds additional
75 bitrate_estimator_ = bitrate_estimator_creator_->Create();
76 left_alr_state_ms_ = rtc::Optional<int64_t>(rtc::TimeMillis());
77 }
78 last_alr_state_ = alr_state;
79 }
80
81 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698