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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 CallStats::~CallStats() { | 103 CallStats::~CallStats() { |
104 RTC_DCHECK(observers_.empty()); | 104 RTC_DCHECK(observers_.empty()); |
105 UpdateHistograms(); | 105 UpdateHistograms(); |
106 } | 106 } |
107 | 107 |
108 int64_t CallStats::TimeUntilNextProcess() { | 108 int64_t CallStats::TimeUntilNextProcess() { |
109 return last_process_time_ + kUpdateIntervalMs - clock_->TimeInMilliseconds(); | 109 return last_process_time_ + kUpdateIntervalMs - clock_->TimeInMilliseconds(); |
110 } | 110 } |
111 | 111 |
112 void CallStats::Process() { | 112 int32_t CallStats::Process() { |
113 rtc::CritScope cs(&crit_); | 113 rtc::CritScope cs(&crit_); |
114 int64_t now = clock_->TimeInMilliseconds(); | 114 int64_t now = clock_->TimeInMilliseconds(); |
115 if (now < last_process_time_ + kUpdateIntervalMs) | 115 if (now < last_process_time_ + kUpdateIntervalMs) |
116 return; | 116 return 0; |
117 | 117 |
118 last_process_time_ = now; | 118 last_process_time_ = now; |
119 | 119 |
120 RemoveOldReports(now, &reports_); | 120 RemoveOldReports(now, &reports_); |
121 max_rtt_ms_ = GetMaxRttMs(&reports_); | 121 max_rtt_ms_ = GetMaxRttMs(&reports_); |
122 UpdateAvgRttMs(&reports_, &avg_rtt_ms_); | 122 UpdateAvgRttMs(&reports_, &avg_rtt_ms_); |
123 | 123 |
124 // If there is a valid rtt, update all observers with the max rtt. | 124 // If there is a valid rtt, update all observers with the max rtt. |
125 if (max_rtt_ms_ >= 0) { | 125 if (max_rtt_ms_ >= 0) { |
126 RTC_DCHECK_GE(avg_rtt_ms_, 0); | 126 RTC_DCHECK_GE(avg_rtt_ms_, 0); |
127 for (std::list<CallStatsObserver*>::iterator it = observers_.begin(); | 127 for (std::list<CallStatsObserver*>::iterator it = observers_.begin(); |
128 it != observers_.end(); ++it) { | 128 it != observers_.end(); ++it) { |
129 (*it)->OnRttUpdate(avg_rtt_ms_, max_rtt_ms_); | 129 (*it)->OnRttUpdate(avg_rtt_ms_, max_rtt_ms_); |
130 } | 130 } |
131 // Sum for Histogram of average RTT reported over the entire call. | 131 // Sum for Histogram of average RTT reported over the entire call. |
132 sum_avg_rtt_ms_ += avg_rtt_ms_; | 132 sum_avg_rtt_ms_ += avg_rtt_ms_; |
133 ++num_avg_rtt_; | 133 ++num_avg_rtt_; |
134 } | 134 } |
| 135 return 0; |
135 } | 136 } |
136 | 137 |
137 int64_t CallStats::avg_rtt_ms() const { | 138 int64_t CallStats::avg_rtt_ms() const { |
138 rtc::CritScope cs(&crit_); | 139 rtc::CritScope cs(&crit_); |
139 return avg_rtt_ms_; | 140 return avg_rtt_ms_; |
140 } | 141 } |
141 | 142 |
142 RtcpRttStats* CallStats::rtcp_rtt_stats() const { | 143 RtcpRttStats* CallStats::rtcp_rtt_stats() const { |
143 return rtcp_rtt_stats_.get(); | 144 return rtcp_rtt_stats_.get(); |
144 } | 145 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 int64_t elapsed_sec = | 181 int64_t elapsed_sec = |
181 (clock_->TimeInMilliseconds() - time_of_first_rtt_ms_) / 1000; | 182 (clock_->TimeInMilliseconds() - time_of_first_rtt_ms_) / 1000; |
182 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 183 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
183 int64_t avg_rtt_ms = (sum_avg_rtt_ms_ + num_avg_rtt_ / 2) / num_avg_rtt_; | 184 int64_t avg_rtt_ms = (sum_avg_rtt_ms_ + num_avg_rtt_ / 2) / num_avg_rtt_; |
184 RTC_HISTOGRAM_COUNTS_10000( | 185 RTC_HISTOGRAM_COUNTS_10000( |
185 "WebRTC.Video.AverageRoundTripTimeInMilliseconds", avg_rtt_ms); | 186 "WebRTC.Video.AverageRoundTripTimeInMilliseconds", avg_rtt_ms); |
186 } | 187 } |
187 } | 188 } |
188 | 189 |
189 } // namespace webrtc | 190 } // namespace webrtc |
OLD | NEW |