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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/overuse_detector.cc

Issue 2800633004: Resolve dependency between rtc_event_log_api and remote_bitrate_estimator (Closed)
Patch Set: Rebased Created 3 years, 8 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) 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
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // the field trial string to "WebRTC-AdaptiveBweThreshold/Disabled/". 63 // the field trial string to "WebRTC-AdaptiveBweThreshold/Disabled/".
64 : in_experiment_(!AdaptiveThresholdExperimentIsDisabled()), 64 : in_experiment_(!AdaptiveThresholdExperimentIsDisabled()),
65 k_up_(0.0087), 65 k_up_(0.0087),
66 k_down_(0.039), 66 k_down_(0.039),
67 overusing_time_threshold_(100), 67 overusing_time_threshold_(100),
68 threshold_(12.5), 68 threshold_(12.5),
69 last_update_ms_(-1), 69 last_update_ms_(-1),
70 prev_offset_(0.0), 70 prev_offset_(0.0),
71 time_over_using_(-1), 71 time_over_using_(-1),
72 overuse_counter_(0), 72 overuse_counter_(0),
73 hypothesis_(kBwNormal) { 73 hypothesis_(BandwidthUsage::kBwNormal) {
74 if (!AdaptiveThresholdExperimentIsDisabled()) 74 if (!AdaptiveThresholdExperimentIsDisabled())
75 InitializeExperiment(); 75 InitializeExperiment();
76 } 76 }
77 77
78 OveruseDetector::~OveruseDetector() {} 78 OveruseDetector::~OveruseDetector() {}
79 79
80 BandwidthUsage OveruseDetector::State() const { 80 BandwidthUsage OveruseDetector::State() const {
81 return hypothesis_; 81 return hypothesis_;
82 } 82 }
83 83
84 BandwidthUsage OveruseDetector::Detect(double offset, 84 BandwidthUsage OveruseDetector::Detect(double offset,
85 double ts_delta, 85 double ts_delta,
86 int num_of_deltas, 86 int num_of_deltas,
87 int64_t now_ms) { 87 int64_t now_ms) {
88 if (num_of_deltas < 2) { 88 if (num_of_deltas < 2) {
89 return kBwNormal; 89 return BandwidthUsage::kBwNormal;
90 } 90 }
91 const double T = std::min(num_of_deltas, kMinNumDeltas) * offset; 91 const double T = std::min(num_of_deltas, kMinNumDeltas) * offset;
92 BWE_TEST_LOGGING_PLOT(1, "offset_ms#1", now_ms, offset); 92 BWE_TEST_LOGGING_PLOT(1, "offset_ms#1", now_ms, offset);
93 BWE_TEST_LOGGING_PLOT(1, "gamma_ms#1", now_ms, threshold_ / kMinNumDeltas); 93 BWE_TEST_LOGGING_PLOT(1, "gamma_ms#1", now_ms, threshold_ / kMinNumDeltas);
94 if (T > threshold_) { 94 if (T > threshold_) {
95 if (time_over_using_ == -1) { 95 if (time_over_using_ == -1) {
96 // Initialize the timer. Assume that we've been 96 // Initialize the timer. Assume that we've been
97 // over-using half of the time since the previous 97 // over-using half of the time since the previous
98 // sample. 98 // sample.
99 time_over_using_ = ts_delta / 2; 99 time_over_using_ = ts_delta / 2;
100 } else { 100 } else {
101 // Increment timer 101 // Increment timer
102 time_over_using_ += ts_delta; 102 time_over_using_ += ts_delta;
103 } 103 }
104 overuse_counter_++; 104 overuse_counter_++;
105 if (time_over_using_ > overusing_time_threshold_ && overuse_counter_ > 1) { 105 if (time_over_using_ > overusing_time_threshold_ && overuse_counter_ > 1) {
106 if (offset >= prev_offset_) { 106 if (offset >= prev_offset_) {
107 time_over_using_ = 0; 107 time_over_using_ = 0;
108 overuse_counter_ = 0; 108 overuse_counter_ = 0;
109 hypothesis_ = kBwOverusing; 109 hypothesis_ = BandwidthUsage::kBwOverusing;
110 } 110 }
111 } 111 }
112 } else if (T < -threshold_) { 112 } else if (T < -threshold_) {
113 time_over_using_ = -1; 113 time_over_using_ = -1;
114 overuse_counter_ = 0; 114 overuse_counter_ = 0;
115 hypothesis_ = kBwUnderusing; 115 hypothesis_ = BandwidthUsage::kBwUnderusing;
116 } else { 116 } else {
117 time_over_using_ = -1; 117 time_over_using_ = -1;
118 overuse_counter_ = 0; 118 overuse_counter_ = 0;
119 hypothesis_ = kBwNormal; 119 hypothesis_ = BandwidthUsage::kBwNormal;
120 } 120 }
121 prev_offset_ = offset; 121 prev_offset_ = offset;
122 122
123 UpdateThreshold(T, now_ms); 123 UpdateThreshold(T, now_ms);
124 124
125 return hypothesis_; 125 return hypothesis_;
126 } 126 }
127 127
128 void OveruseDetector::UpdateThreshold(double modified_offset, int64_t now_ms) { 128 void OveruseDetector::UpdateThreshold(double modified_offset, int64_t now_ms) {
129 if (!in_experiment_) 129 if (!in_experiment_)
(...skipping 26 matching lines...) Expand all
156 RTC_DCHECK(in_experiment_); 156 RTC_DCHECK(in_experiment_);
157 double k_up = 0.0; 157 double k_up = 0.0;
158 double k_down = 0.0; 158 double k_down = 0.0;
159 overusing_time_threshold_ = kOverUsingTimeThreshold; 159 overusing_time_threshold_ = kOverUsingTimeThreshold;
160 if (ReadExperimentConstants(&k_up, &k_down)) { 160 if (ReadExperimentConstants(&k_up, &k_down)) {
161 k_up_ = k_up; 161 k_up_ = k_up;
162 k_down_ = k_down; 162 k_down_ = k_down;
163 } 163 }
164 } 164 }
165 } // namespace webrtc 165 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698