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

Side by Side Diff: webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc

Issue 1411673003: Added protobuf message for loss-based BWE events, and wired it up to the send side bandwidth estima… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 1 month 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
« no previous file with comments | « webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h" 11 #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h"
12 12
13 #include <cmath> 13 #include <cmath>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/system_wrappers/include/field_trial.h" 16 #include "webrtc/system_wrappers/include/field_trial.h"
17 #include "webrtc/system_wrappers/include/logging.h" 17 #include "webrtc/system_wrappers/include/logging.h"
18 #include "webrtc/system_wrappers/include/metrics.h" 18 #include "webrtc/system_wrappers/include/metrics.h"
19 #include "webrtc/call/rtc_event_log.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 namespace { 22 namespace {
22 const int64_t kBweIncreaseIntervalMs = 1000; 23 const int64_t kBweIncreaseIntervalMs = 1000;
23 const int64_t kBweDecreaseIntervalMs = 300; 24 const int64_t kBweDecreaseIntervalMs = 300;
24 const int64_t kStartPhaseMs = 2000; 25 const int64_t kStartPhaseMs = 2000;
25 const int64_t kBweConverganceTimeMs = 20000; 26 const int64_t kBweConverganceTimeMs = 20000;
26 const int kLimitNumPackets = 20; 27 const int kLimitNumPackets = 20;
27 const int kDefaultMinBitrateBps = 10000; 28 const int kDefaultMinBitrateBps = 10000;
28 const int kDefaultMaxBitrateBps = 1000000000; 29 const int kDefaultMaxBitrateBps = 1000000000;
(...skipping 23 matching lines...) Expand all
52 has_decreased_since_last_fraction_loss_(false), 53 has_decreased_since_last_fraction_loss_(false),
53 time_last_receiver_block_ms_(-1), 54 time_last_receiver_block_ms_(-1),
54 last_fraction_loss_(0), 55 last_fraction_loss_(0),
55 last_round_trip_time_ms_(0), 56 last_round_trip_time_ms_(0),
56 bwe_incoming_(0), 57 bwe_incoming_(0),
57 time_last_decrease_ms_(0), 58 time_last_decrease_ms_(0),
58 first_report_time_ms_(-1), 59 first_report_time_ms_(-1),
59 initially_lost_packets_(0), 60 initially_lost_packets_(0),
60 bitrate_at_2_seconds_kbps_(0), 61 bitrate_at_2_seconds_kbps_(0),
61 uma_update_state_(kNoUpdate), 62 uma_update_state_(kNoUpdate),
62 rampup_uma_stats_updated_(kNumUmaRampupMetrics, false) {} 63 rampup_uma_stats_updated_(kNumUmaRampupMetrics, false),
64 event_log_(nullptr) {}
63 65
64 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {} 66 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {}
65 67
66 void SendSideBandwidthEstimation::SetSendBitrate(int bitrate) { 68 void SendSideBandwidthEstimation::SetSendBitrate(int bitrate) {
67 RTC_DCHECK_GT(bitrate, 0); 69 RTC_DCHECK_GT(bitrate, 0);
68 bitrate_ = bitrate; 70 bitrate_ = bitrate;
69 71
70 // Clear last sent bitrate history so the new value can be used directly 72 // Clear last sent bitrate history so the new value can be used directly
71 // and not capped. 73 // and not capped.
72 min_bitrate_history_.clear(); 74 min_bitrate_history_.clear();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // If instead one would do: bitrate_ *= 1.08^(delta time), it would 201 // If instead one would do: bitrate_ *= 1.08^(delta time), it would
200 // take over one second since the lower packet loss to achieve 108kbps. 202 // take over one second since the lower packet loss to achieve 108kbps.
201 bitrate_ = static_cast<uint32_t>( 203 bitrate_ = static_cast<uint32_t>(
202 min_bitrate_history_.front().second * 1.08 + 0.5); 204 min_bitrate_history_.front().second * 1.08 + 0.5);
203 205
204 // Add 1 kbps extra, just to make sure that we do not get stuck 206 // Add 1 kbps extra, just to make sure that we do not get stuck
205 // (gives a little extra increase at low rates, negligible at higher 207 // (gives a little extra increase at low rates, negligible at higher
206 // rates). 208 // rates).
207 bitrate_ += 1000; 209 bitrate_ += 1000;
208 210
211 if (event_log_) {
212 event_log_->LogBwePacketLossEvent(
213 bitrate_, last_fraction_loss_,
214 expected_packets_since_last_loss_update_);
215 }
209 } else if (last_fraction_loss_ <= 26) { 216 } else if (last_fraction_loss_ <= 26) {
210 // Loss between 2% - 10%: Do nothing. 217 // Loss between 2% - 10%: Do nothing.
211 } else { 218 } else {
212 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs + 219 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs +
213 // rtt. 220 // rtt.
214 if (!has_decreased_since_last_fraction_loss_ && 221 if (!has_decreased_since_last_fraction_loss_ &&
215 (now_ms - time_last_decrease_ms_) >= 222 (now_ms - time_last_decrease_ms_) >=
216 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) { 223 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) {
217 time_last_decrease_ms_ = now_ms; 224 time_last_decrease_ms_ = now_ms;
218 225
219 // Reduce rate: 226 // Reduce rate:
220 // newRate = rate * (1 - 0.5*lossRate); 227 // newRate = rate * (1 - 0.5*lossRate);
221 // where packetLoss = 256*lossRate; 228 // where packetLoss = 256*lossRate;
222 bitrate_ = static_cast<uint32_t>( 229 bitrate_ = static_cast<uint32_t>(
223 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) / 230 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) /
224 512.0); 231 512.0);
225 has_decreased_since_last_fraction_loss_ = true; 232 has_decreased_since_last_fraction_loss_ = true;
226 } 233 }
234 if (event_log_) {
235 event_log_->LogBwePacketLossEvent(
236 bitrate_, last_fraction_loss_,
237 expected_packets_since_last_loss_update_);
238 }
227 } 239 }
228 } 240 }
229 bitrate_ = CapBitrateToThresholds(now_ms, bitrate_); 241 bitrate_ = CapBitrateToThresholds(now_ms, bitrate_);
230 } 242 }
231 243
232 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const { 244 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const {
233 return first_report_time_ms_ == -1 || 245 return first_report_time_ms_ == -1 ||
234 now_ms - first_report_time_ms_ < kStartPhaseMs; 246 now_ms - first_report_time_ms_ < kStartPhaseMs;
235 } 247 }
236 248
(...skipping 30 matching lines...) Expand all
267 now_ms - last_low_bitrate_log_ms_ > kLowBitrateLogPeriodMs) { 279 now_ms - last_low_bitrate_log_ms_ > kLowBitrateLogPeriodMs) {
268 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 280 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000
269 << " kbps is below configured min bitrate " 281 << " kbps is below configured min bitrate "
270 << min_bitrate_configured_ / 1000 << " kbps."; 282 << min_bitrate_configured_ / 1000 << " kbps.";
271 last_low_bitrate_log_ms_ = now_ms; 283 last_low_bitrate_log_ms_ = now_ms;
272 } 284 }
273 bitrate = min_bitrate_configured_; 285 bitrate = min_bitrate_configured_;
274 } 286 }
275 return bitrate; 287 return bitrate;
276 } 288 }
289
290 void SendSideBandwidthEstimation::SetEventLog(RtcEventLog* event_log) {
291 event_log_ = event_log;
292 }
293
277 } // namespace webrtc 294 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698