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

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

Issue 2407143002: Remove GetFeedbackInterval in sender side BWE. (Closed)
Patch Set: Adapt unittest to the change. Created 4 years, 2 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
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 17 matching lines...) Expand all
28 constexpr int kTimestampGroupLengthMs = 5; 28 constexpr int kTimestampGroupLengthMs = 5;
29 constexpr int kAbsSendTimeFraction = 18; 29 constexpr int kAbsSendTimeFraction = 18;
30 constexpr int kAbsSendTimeInterArrivalUpshift = 8; 30 constexpr int kAbsSendTimeInterArrivalUpshift = 8;
31 constexpr int kInterArrivalShift = 31 constexpr int kInterArrivalShift =
32 kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift; 32 kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift;
33 constexpr double kTimestampToMs = 33 constexpr double kTimestampToMs =
34 1000.0 / static_cast<double>(1 << kInterArrivalShift); 34 1000.0 / static_cast<double>(1 << kInterArrivalShift);
35 // This ssrc is used to fulfill the current API but will be removed 35 // This ssrc is used to fulfill the current API but will be removed
36 // after the API has been changed. 36 // after the API has been changed.
37 constexpr uint32_t kFixedSsrc = 0; 37 constexpr uint32_t kFixedSsrc = 0;
38 constexpr int64_t kDefaultRttMs = 200;
38 } // namespace 39 } // namespace
39 40
40 namespace webrtc { 41 namespace webrtc {
41 42
42 DelayBasedBwe::DelayBasedBwe(Clock* clock) 43 DelayBasedBwe::DelayBasedBwe(Clock* clock)
43 : clock_(clock), 44 : clock_(clock),
44 inter_arrival_(), 45 inter_arrival_(),
45 estimator_(), 46 estimator_(),
46 detector_(OverUseDetectorOptions()), 47 detector_(OverUseDetectorOptions()),
47 incoming_bitrate_(kBitrateWindowMs, 8000), 48 incoming_bitrate_(kBitrateWindowMs, 8000),
48 last_update_ms_(-1), 49 last_update_ms_(-1),
49 last_seen_packet_ms_(-1), 50 last_seen_packet_ms_(-1),
50 uma_recorded_(false) { 51 uma_recorded_(false),
52 rtt_ms_(kDefaultRttMs) {
51 network_thread_.DetachFromThread(); 53 network_thread_.DetachFromThread();
52 } 54 }
53 55
54 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector( 56 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector(
55 const std::vector<PacketInfo>& packet_feedback_vector) { 57 const std::vector<PacketInfo>& packet_feedback_vector) {
56 RTC_DCHECK(network_thread_.CalledOnValidThread()); 58 RTC_DCHECK(network_thread_.CalledOnValidThread());
57 if (!uma_recorded_) { 59 if (!uma_recorded_) {
58 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram, 60 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram,
59 BweNames::kSendSideTransportSeqNum, 61 BweNames::kSendSideTransportSeqNum,
60 BweNames::kBweNamesMax); 62 BweNames::kBweNamesMax);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } else if (probing_bps > 0) { 127 } else if (probing_bps > 0) {
126 // No overuse, but probing measured a bitrate. 128 // No overuse, but probing measured a bitrate.
127 remote_rate_.SetEstimate(probing_bps, info.arrival_time_ms); 129 remote_rate_.SetEstimate(probing_bps, info.arrival_time_ms);
128 result.probe = true; 130 result.probe = true;
129 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms, 131 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms,
130 &result.target_bitrate_bps); 132 &result.target_bitrate_bps);
131 } 133 }
132 rtc::Optional<uint32_t> incoming_rate = 134 rtc::Optional<uint32_t> incoming_rate =
133 incoming_bitrate_.Rate(info.arrival_time_ms); 135 incoming_bitrate_.Rate(info.arrival_time_ms);
134 if (!result.updated && 136 if (!result.updated &&
135 (last_update_ms_ == -1 || 137 (last_update_ms_ == -1 || now_ms - last_update_ms_ > rtt_ms_)) {
stefan-webrtc 2016/10/17 18:59:49 Do you think there's a true value having this chec
136 now_ms - last_update_ms_ > remote_rate_.GetFeedbackInterval())) {
137 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms, 138 result.updated = UpdateEstimate(info.arrival_time_ms, now_ms,
138 &result.target_bitrate_bps); 139 &result.target_bitrate_bps);
139 } 140 }
140 if (result.updated) 141 if (result.updated)
141 last_update_ms_ = now_ms; 142 last_update_ms_ = now_ms;
142 143
143 return result; 144 return result;
144 } 145 }
145 146
146 bool DelayBasedBwe::UpdateEstimate(int64_t arrival_time_ms, 147 bool DelayBasedBwe::UpdateEstimate(int64_t arrival_time_ms,
147 int64_t now_ms, 148 int64_t now_ms,
148 uint32_t* target_bitrate_bps) { 149 uint32_t* target_bitrate_bps) {
149 // The first overuse should immediately trigger a new estimate. 150 // The first overuse should immediately trigger a new estimate.
150 // We also have to update the estimate immediately if we are overusing 151 // We also have to update the estimate immediately if we are overusing
151 // and the target bitrate is too high compared to what we are receiving. 152 // and the target bitrate is too high compared to what we are receiving.
152 const RateControlInput input(detector_.State(), 153 const RateControlInput input(detector_.State(),
153 incoming_bitrate_.Rate(arrival_time_ms), 154 incoming_bitrate_.Rate(arrival_time_ms),
154 estimator_->var_noise()); 155 estimator_->var_noise());
155 remote_rate_.Update(&input, now_ms); 156 remote_rate_.Update(&input, now_ms);
156 *target_bitrate_bps = remote_rate_.UpdateBandwidthEstimate(now_ms); 157 *target_bitrate_bps = remote_rate_.UpdateBandwidthEstimate(now_ms);
157 return remote_rate_.ValidEstimate(); 158 return remote_rate_.ValidEstimate();
158 } 159 }
159 160
160 void DelayBasedBwe::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 161 void DelayBasedBwe::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
162 rtt_ms_ = avg_rtt_ms;
161 remote_rate_.SetRtt(avg_rtt_ms); 163 remote_rate_.SetRtt(avg_rtt_ms);
162 } 164 }
163 165
164 bool DelayBasedBwe::LatestEstimate(std::vector<uint32_t>* ssrcs, 166 bool DelayBasedBwe::LatestEstimate(std::vector<uint32_t>* ssrcs,
165 uint32_t* bitrate_bps) const { 167 uint32_t* bitrate_bps) const {
166 // Currently accessed from both the process thread (see 168 // Currently accessed from both the process thread (see
167 // ModuleRtpRtcpImpl::Process()) and the configuration thread (see 169 // ModuleRtpRtcpImpl::Process()) and the configuration thread (see
168 // Call::GetStats()). Should in the future only be accessed from a single 170 // Call::GetStats()). Should in the future only be accessed from a single
169 // thread. 171 // thread.
170 RTC_DCHECK(ssrcs); 172 RTC_DCHECK(ssrcs);
171 RTC_DCHECK(bitrate_bps); 173 RTC_DCHECK(bitrate_bps);
172 if (!remote_rate_.ValidEstimate()) 174 if (!remote_rate_.ValidEstimate())
173 return false; 175 return false;
174 176
175 *ssrcs = {kFixedSsrc}; 177 *ssrcs = {kFixedSsrc};
176 *bitrate_bps = remote_rate_.LatestEstimate(); 178 *bitrate_bps = remote_rate_.LatestEstimate();
177 return true; 179 return true;
178 } 180 }
179 181
180 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { 182 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) {
181 // Called from both the configuration thread and the network thread. Shouldn't 183 // Called from both the configuration thread and the network thread. Shouldn't
182 // be called from the network thread in the future. 184 // be called from the network thread in the future.
183 remote_rate_.SetMinBitrate(min_bitrate_bps); 185 remote_rate_.SetMinBitrate(min_bitrate_bps);
184 } 186 }
185 } // namespace webrtc 187 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698