OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 int64_t rtt_ms) { | 154 int64_t rtt_ms) { |
155 rtc::CritScope lock(&crit_); | 155 rtc::CritScope lock(&crit_); |
156 stats_.decode_ms = decode_ms; | 156 stats_.decode_ms = decode_ms; |
157 stats_.max_decode_ms = max_decode_ms; | 157 stats_.max_decode_ms = max_decode_ms; |
158 stats_.current_delay_ms = current_delay_ms; | 158 stats_.current_delay_ms = current_delay_ms; |
159 stats_.target_delay_ms = target_delay_ms; | 159 stats_.target_delay_ms = target_delay_ms; |
160 stats_.jitter_buffer_ms = jitter_buffer_ms; | 160 stats_.jitter_buffer_ms = jitter_buffer_ms; |
161 stats_.min_playout_delay_ms = min_playout_delay_ms; | 161 stats_.min_playout_delay_ms = min_playout_delay_ms; |
162 stats_.render_delay_ms = render_delay_ms; | 162 stats_.render_delay_ms = render_delay_ms; |
163 decode_time_counter_.Add(decode_ms); | 163 decode_time_counter_.Add(decode_ms); |
164 // Network delay (rtt/2) + target_delay_ms (jitter delay + decode time + | |
165 // render delay). | |
166 delay_counter_.Add(target_delay_ms + rtt_ms / 2); | |
167 } | 164 } |
168 | 165 |
169 void ReceiveStatisticsProxy::RtcpPacketTypesCounterUpdated( | 166 void ReceiveStatisticsProxy::RtcpPacketTypesCounterUpdated( |
170 uint32_t ssrc, | 167 uint32_t ssrc, |
171 const RtcpPacketTypeCounter& packet_counter) { | 168 const RtcpPacketTypeCounter& packet_counter) { |
172 rtc::CritScope lock(&crit_); | 169 rtc::CritScope lock(&crit_); |
173 if (stats_.ssrc != ssrc) | 170 if (stats_.ssrc != ssrc) |
174 return; | 171 return; |
175 stats_.rtcp_packet_type_counts = packet_counter; | 172 stats_.rtcp_packet_type_counts = packet_counter; |
176 } | 173 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 210 } |
214 | 211 |
215 void ReceiveStatisticsProxy::OnDecodedFrame() { | 212 void ReceiveStatisticsProxy::OnDecodedFrame() { |
216 uint64_t now = clock_->TimeInMilliseconds(); | 213 uint64_t now = clock_->TimeInMilliseconds(); |
217 | 214 |
218 rtc::CritScope lock(&crit_); | 215 rtc::CritScope lock(&crit_); |
219 decode_fps_estimator_.Update(1, now); | 216 decode_fps_estimator_.Update(1, now); |
220 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now); | 217 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now); |
221 } | 218 } |
222 | 219 |
223 void ReceiveStatisticsProxy::OnRenderedFrame(int width, int height) { | 220 void ReceiveStatisticsProxy::OnRenderedFrame(const VideoFrame& frame) { |
| 221 int width = frame.width(); |
| 222 int height = frame.height(); |
224 RTC_DCHECK_GT(width, 0); | 223 RTC_DCHECK_GT(width, 0); |
225 RTC_DCHECK_GT(height, 0); | 224 RTC_DCHECK_GT(height, 0); |
226 uint64_t now = clock_->TimeInMilliseconds(); | 225 uint64_t now = clock_->TimeInMilliseconds(); |
227 | 226 |
228 rtc::CritScope lock(&crit_); | 227 rtc::CritScope lock(&crit_); |
229 renders_fps_estimator_.Update(1, now); | 228 renders_fps_estimator_.Update(1, now); |
230 stats_.render_frame_rate = renders_fps_estimator_.Rate(now); | 229 stats_.render_frame_rate = renders_fps_estimator_.Rate(now); |
231 render_width_counter_.Add(width); | 230 render_width_counter_.Add(width); |
232 render_height_counter_.Add(height); | 231 render_height_counter_.Add(height); |
233 render_fps_tracker_.AddSamples(1); | 232 render_fps_tracker_.AddSamples(1); |
234 render_pixel_tracker_.AddSamples(sqrt(width * height)); | 233 render_pixel_tracker_.AddSamples(sqrt(width * height)); |
| 234 |
| 235 if (frame.ntp_time_ms() > 0) { |
| 236 int64_t delay_ms = clock_->CurrentNtpInMilliseconds() - frame.ntp_time_ms(); |
| 237 if (delay_ms >= 0) |
| 238 delay_counter_.Add(delay_ms); |
| 239 } |
235 } | 240 } |
236 | 241 |
237 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, | 242 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, |
238 uint32_t frameRate) { | 243 uint32_t frameRate) { |
239 } | 244 } |
240 | 245 |
241 void ReceiveStatisticsProxy::OnFrameCountsUpdated( | 246 void ReceiveStatisticsProxy::OnFrameCountsUpdated( |
242 const FrameCounts& frame_counts) { | 247 const FrameCounts& frame_counts) { |
243 rtc::CritScope lock(&crit_); | 248 rtc::CritScope lock(&crit_); |
244 stats_.frame_counts = frame_counts; | 249 stats_.frame_counts = frame_counts; |
(...skipping 20 matching lines...) Expand all Loading... |
265 ++num_samples; | 270 ++num_samples; |
266 } | 271 } |
267 | 272 |
268 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 273 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
269 if (num_samples < min_required_samples || num_samples == 0) | 274 if (num_samples < min_required_samples || num_samples == 0) |
270 return -1; | 275 return -1; |
271 return sum / num_samples; | 276 return sum / num_samples; |
272 } | 277 } |
273 | 278 |
274 } // namespace webrtc | 279 } // namespace webrtc |
OLD | NEW |