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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 int64_t rtt_ms) { | 163 int64_t rtt_ms) { |
164 rtc::CritScope lock(&crit_); | 164 rtc::CritScope lock(&crit_); |
165 stats_.decode_ms = decode_ms; | 165 stats_.decode_ms = decode_ms; |
166 stats_.max_decode_ms = max_decode_ms; | 166 stats_.max_decode_ms = max_decode_ms; |
167 stats_.current_delay_ms = current_delay_ms; | 167 stats_.current_delay_ms = current_delay_ms; |
168 stats_.target_delay_ms = target_delay_ms; | 168 stats_.target_delay_ms = target_delay_ms; |
169 stats_.jitter_buffer_ms = jitter_buffer_ms; | 169 stats_.jitter_buffer_ms = jitter_buffer_ms; |
170 stats_.min_playout_delay_ms = min_playout_delay_ms; | 170 stats_.min_playout_delay_ms = min_playout_delay_ms; |
171 stats_.render_delay_ms = render_delay_ms; | 171 stats_.render_delay_ms = render_delay_ms; |
172 decode_time_counter_.Add(decode_ms); | 172 decode_time_counter_.Add(decode_ms); |
| 173 // Network delay (rtt/2) + target_delay_ms (jitter delay + decode time + |
| 174 // render delay). |
| 175 delay_counter_.Add(target_delay_ms + rtt_ms / 2); |
173 } | 176 } |
174 | 177 |
175 void ReceiveStatisticsProxy::RtcpPacketTypesCounterUpdated( | 178 void ReceiveStatisticsProxy::RtcpPacketTypesCounterUpdated( |
176 uint32_t ssrc, | 179 uint32_t ssrc, |
177 const RtcpPacketTypeCounter& packet_counter) { | 180 const RtcpPacketTypeCounter& packet_counter) { |
178 rtc::CritScope lock(&crit_); | 181 rtc::CritScope lock(&crit_); |
179 if (stats_.ssrc != ssrc) | 182 if (stats_.ssrc != ssrc) |
180 return; | 183 return; |
181 stats_.rtcp_packet_type_counts = packet_counter; | 184 stats_.rtcp_packet_type_counts = packet_counter; |
182 } | 185 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 222 } |
220 | 223 |
221 void ReceiveStatisticsProxy::OnDecodedFrame() { | 224 void ReceiveStatisticsProxy::OnDecodedFrame() { |
222 uint64_t now = clock_->TimeInMilliseconds(); | 225 uint64_t now = clock_->TimeInMilliseconds(); |
223 | 226 |
224 rtc::CritScope lock(&crit_); | 227 rtc::CritScope lock(&crit_); |
225 decode_fps_estimator_.Update(1, now); | 228 decode_fps_estimator_.Update(1, now); |
226 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now); | 229 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now); |
227 } | 230 } |
228 | 231 |
229 void ReceiveStatisticsProxy::OnRenderedFrame(const VideoFrame& frame) { | 232 void ReceiveStatisticsProxy::OnRenderedFrame(int width, int height) { |
230 int width = frame.width(); | |
231 int height = frame.height(); | |
232 RTC_DCHECK_GT(width, 0); | 233 RTC_DCHECK_GT(width, 0); |
233 RTC_DCHECK_GT(height, 0); | 234 RTC_DCHECK_GT(height, 0); |
234 uint64_t now = clock_->TimeInMilliseconds(); | 235 uint64_t now = clock_->TimeInMilliseconds(); |
235 | 236 |
236 rtc::CritScope lock(&crit_); | 237 rtc::CritScope lock(&crit_); |
237 renders_fps_estimator_.Update(1, now); | 238 renders_fps_estimator_.Update(1, now); |
238 stats_.render_frame_rate = renders_fps_estimator_.Rate(now); | 239 stats_.render_frame_rate = renders_fps_estimator_.Rate(now); |
239 render_width_counter_.Add(width); | 240 render_width_counter_.Add(width); |
240 render_height_counter_.Add(height); | 241 render_height_counter_.Add(height); |
241 render_fps_tracker_.AddSamples(1); | 242 render_fps_tracker_.AddSamples(1); |
242 render_pixel_tracker_.AddSamples(sqrt(width * height)); | 243 render_pixel_tracker_.AddSamples(sqrt(width * height)); |
243 | |
244 if (frame.ntp_time_ms() > 0) { | |
245 int64_t delay_ms = clock_->CurrentNtpInMilliseconds() - frame.ntp_time_ms(); | |
246 if (delay_ms >= 0) | |
247 delay_counter_.Add(delay_ms); | |
248 } | |
249 } | 244 } |
250 | 245 |
251 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms) { | 246 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms) { |
252 rtc::CritScope lock(&crit_); | 247 rtc::CritScope lock(&crit_); |
253 sync_offset_counter_.Add(std::abs(sync_offset_ms)); | 248 sync_offset_counter_.Add(std::abs(sync_offset_ms)); |
254 stats_.sync_offset_ms = sync_offset_ms; | 249 stats_.sync_offset_ms = sync_offset_ms; |
255 } | 250 } |
256 | 251 |
257 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, | 252 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, |
258 uint32_t frameRate) { | 253 uint32_t frameRate) { |
(...skipping 26 matching lines...) Expand all Loading... |
285 ++num_samples; | 280 ++num_samples; |
286 } | 281 } |
287 | 282 |
288 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 283 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
289 if (num_samples < min_required_samples || num_samples == 0) | 284 if (num_samples < min_required_samples || num_samples == 0) |
290 return -1; | 285 return -1; |
291 return sum / num_samples; | 286 return sum / num_samples; |
292 } | 287 } |
293 | 288 |
294 } // namespace webrtc | 289 } // namespace webrtc |
OLD | NEW |