OLD | NEW |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return hypothesis_; | 84 return hypothesis_; |
85 } | 85 } |
86 | 86 |
87 BandwidthUsage OveruseDetector::Detect(double offset, | 87 BandwidthUsage OveruseDetector::Detect(double offset, |
88 double ts_delta, | 88 double ts_delta, |
89 int num_of_deltas, | 89 int num_of_deltas, |
90 int64_t now_ms) { | 90 int64_t now_ms) { |
91 if (num_of_deltas < 2) { | 91 if (num_of_deltas < 2) { |
92 return kBwNormal; | 92 return kBwNormal; |
93 } | 93 } |
94 const double prev_offset = prev_offset_; | |
95 prev_offset_ = offset; | |
96 const double T = std::min(num_of_deltas, kMinNumDeltas) * offset; | 94 const double T = std::min(num_of_deltas, kMinNumDeltas) * offset; |
97 BWE_TEST_LOGGING_PLOT(1, "offset_ms#1", now_ms, offset); | 95 BWE_TEST_LOGGING_PLOT(1, "offset_ms#1", now_ms, offset); |
98 BWE_TEST_LOGGING_PLOT(1, "gamma_ms#1", now_ms, threshold_ / kMinNumDeltas); | 96 BWE_TEST_LOGGING_PLOT(1, "gamma_ms#1", now_ms, threshold_ / kMinNumDeltas); |
99 if (T > threshold_) { | 97 if (T > threshold_) { |
100 if (time_over_using_ == -1) { | 98 if (time_over_using_ == -1) { |
101 // Initialize the timer. Assume that we've been | 99 // Initialize the timer. Assume that we've been |
102 // over-using half of the time since the previous | 100 // over-using half of the time since the previous |
103 // sample. | 101 // sample. |
104 time_over_using_ = ts_delta / 2; | 102 time_over_using_ = ts_delta / 2; |
105 } else { | 103 } else { |
106 // Increment timer | 104 // Increment timer |
107 time_over_using_ += ts_delta; | 105 time_over_using_ += ts_delta; |
108 } | 106 } |
109 overuse_counter_++; | 107 overuse_counter_++; |
110 if (time_over_using_ > overusing_time_threshold_ && overuse_counter_ > 1) { | 108 if (time_over_using_ > overusing_time_threshold_ && overuse_counter_ > 1) { |
111 if (offset >= prev_offset) { | 109 if (offset >= prev_offset_) { |
112 time_over_using_ = 0; | 110 time_over_using_ = 0; |
113 overuse_counter_ = 0; | 111 overuse_counter_ = 0; |
114 hypothesis_ = kBwOverusing; | 112 hypothesis_ = kBwOverusing; |
115 } | 113 } |
116 } | 114 } |
117 } else if (T < -threshold_) { | 115 } else if (T < -threshold_) { |
118 time_over_using_ = -1; | 116 time_over_using_ = -1; |
119 overuse_counter_ = 0; | 117 overuse_counter_ = 0; |
120 hypothesis_ = kBwUnderusing; | 118 hypothesis_ = kBwUnderusing; |
121 } else { | 119 } else { |
122 time_over_using_ = -1; | 120 time_over_using_ = -1; |
123 overuse_counter_ = 0; | 121 overuse_counter_ = 0; |
124 hypothesis_ = kBwNormal; | 122 hypothesis_ = kBwNormal; |
125 } | 123 } |
| 124 prev_offset_ = offset; |
126 | 125 |
127 UpdateThreshold(T, now_ms); | 126 UpdateThreshold(T, now_ms); |
128 | 127 |
129 return hypothesis_; | 128 return hypothesis_; |
130 } | 129 } |
131 | 130 |
132 void OveruseDetector::UpdateThreshold(double modified_offset, int64_t now_ms) { | 131 void OveruseDetector::UpdateThreshold(double modified_offset, int64_t now_ms) { |
133 if (!in_experiment_) | 132 if (!in_experiment_) |
134 return; | 133 return; |
135 | 134 |
(...skipping 24 matching lines...) Expand all Loading... |
160 RTC_DCHECK(in_experiment_); | 159 RTC_DCHECK(in_experiment_); |
161 double k_up = 0.0; | 160 double k_up = 0.0; |
162 double k_down = 0.0; | 161 double k_down = 0.0; |
163 overusing_time_threshold_ = kOverUsingTimeThreshold; | 162 overusing_time_threshold_ = kOverUsingTimeThreshold; |
164 if (ReadExperimentConstants(&k_up, &k_down)) { | 163 if (ReadExperimentConstants(&k_up, &k_down)) { |
165 k_up_ = k_up; | 164 k_up_ = k_up; |
166 k_down_ = k_down; | 165 k_down_ = k_down; |
167 } | 166 } |
168 } | 167 } |
169 } // namespace webrtc | 168 } // namespace webrtc |
OLD | NEW |