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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 return max_height; | 59 return max_height; |
60 } | 60 } |
61 | 61 |
62 uint64_t DelayPeakDetector::MaxPeakPeriod() const { | 62 uint64_t DelayPeakDetector::MaxPeakPeriod() const { |
63 auto max_period_element = std::max_element( | 63 auto max_period_element = std::max_element( |
64 peak_history_.begin(), peak_history_.end(), | 64 peak_history_.begin(), peak_history_.end(), |
65 [](Peak a, Peak b) { return a.period_ms < b.period_ms; }); | 65 [](Peak a, Peak b) { return a.period_ms < b.period_ms; }); |
66 if (max_period_element == peak_history_.end()) { | 66 if (max_period_element == peak_history_.end()) { |
67 return 0; // |peak_history_| is empty. | 67 return 0; // |peak_history_| is empty. |
68 } | 68 } |
69 RTC_DCHECK_GT(max_period_element->period_ms, 0u); | 69 RTC_DCHECK_GT(max_period_element->period_ms, 0); |
70 return max_period_element->period_ms; | 70 return max_period_element->period_ms; |
71 } | 71 } |
72 | 72 |
73 bool DelayPeakDetector::Update(int inter_arrival_time, int target_level) { | 73 bool DelayPeakDetector::Update(int inter_arrival_time, int target_level) { |
74 if (inter_arrival_time > target_level + peak_detection_threshold_ || | 74 if (inter_arrival_time > target_level + peak_detection_threshold_ || |
75 inter_arrival_time > 2 * target_level) { | 75 inter_arrival_time > 2 * target_level) { |
76 // A delay peak is observed. | 76 // A delay peak is observed. |
77 if (!peak_period_stopwatch_) { | 77 if (!peak_period_stopwatch_) { |
78 // This is the first peak. Reset the period counter. | 78 // This is the first peak. Reset the period counter. |
79 peak_period_stopwatch_ = tick_timer_->GetNewStopwatch(); | 79 peak_period_stopwatch_ = tick_timer_->GetNewStopwatch(); |
(...skipping 29 matching lines...) Expand all Loading... |
109 size_t s = peak_history_.size(); | 109 size_t s = peak_history_.size(); |
110 if (s >= kMinPeaksToTrigger && | 110 if (s >= kMinPeaksToTrigger && |
111 peak_period_stopwatch_->ElapsedMs() <= 2 * MaxPeakPeriod()) { | 111 peak_period_stopwatch_->ElapsedMs() <= 2 * MaxPeakPeriod()) { |
112 peak_found_ = true; | 112 peak_found_ = true; |
113 } else { | 113 } else { |
114 peak_found_ = false; | 114 peak_found_ = false; |
115 } | 115 } |
116 return peak_found_; | 116 return peak_found_; |
117 } | 117 } |
118 } // namespace webrtc | 118 } // namespace webrtc |
OLD | NEW |