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 16 matching lines...) Expand all Loading... |
27 const VideoReceiveStream::Config* config, | 27 const VideoReceiveStream::Config* config, |
28 Clock* clock) | 28 Clock* clock) |
29 : clock_(clock), | 29 : clock_(clock), |
30 config_(*config), | 30 config_(*config), |
31 start_ms_(clock->TimeInMilliseconds()), | 31 start_ms_(clock->TimeInMilliseconds()), |
32 // 1000ms window, scale 1000 for ms to s. | 32 // 1000ms window, scale 1000 for ms to s. |
33 decode_fps_estimator_(1000, 1000), | 33 decode_fps_estimator_(1000, 1000), |
34 renders_fps_estimator_(1000, 1000), | 34 renders_fps_estimator_(1000, 1000), |
35 render_fps_tracker_(100, 10u), | 35 render_fps_tracker_(100, 10u), |
36 render_pixel_tracker_(100, 10u), | 36 render_pixel_tracker_(100, 10u), |
37 freq_offset_counter_(clock, nullptr, kFreqOffsetProcessIntervalMs) { | 37 freq_offset_counter_(clock, nullptr, kFreqOffsetProcessIntervalMs), |
| 38 first_report_block_time_ms_(-1) { |
38 stats_.ssrc = config_.rtp.remote_ssrc; | 39 stats_.ssrc = config_.rtp.remote_ssrc; |
39 for (auto it : config_.rtp.rtx) | 40 for (auto it : config_.rtp.rtx) |
40 rtx_stats_[it.second.ssrc] = StreamDataCounters(); | 41 rtx_stats_[it.second.ssrc] = StreamDataCounters(); |
41 } | 42 } |
42 | 43 |
43 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { | 44 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { |
44 UpdateHistograms(); | 45 UpdateHistograms(); |
45 } | 46 } |
46 | 47 |
47 void ReceiveStatisticsProxy::UpdateHistograms() { | 48 void ReceiveStatisticsProxy::UpdateHistograms() { |
48 RTC_HISTOGRAM_COUNTS_100000( | 49 RTC_HISTOGRAM_COUNTS_100000( |
49 "WebRTC.Video.ReceiveStreamLifetimeInSeconds", | 50 "WebRTC.Video.ReceiveStreamLifetimeInSeconds", |
50 (clock_->TimeInMilliseconds() - start_ms_) / 1000); | 51 (clock_->TimeInMilliseconds() - start_ms_) / 1000); |
51 | 52 |
52 int fraction_lost = report_block_stats_.FractionLostInPercent(); | 53 if (first_report_block_time_ms_ != -1 && |
53 if (fraction_lost != -1) { | 54 ((clock_->TimeInMilliseconds() - first_report_block_time_ms_) / 1000) >= |
54 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", | 55 metrics::kMinRunTimeInSeconds) { |
55 fraction_lost); | 56 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
| 57 if (fraction_lost != -1) { |
| 58 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", |
| 59 fraction_lost); |
| 60 } |
56 } | 61 } |
| 62 |
57 const int kMinRequiredSamples = 200; | 63 const int kMinRequiredSamples = 200; |
58 int samples = static_cast<int>(render_fps_tracker_.TotalSampleCount()); | 64 int samples = static_cast<int>(render_fps_tracker_.TotalSampleCount()); |
59 if (samples > kMinRequiredSamples) { | 65 if (samples > kMinRequiredSamples) { |
60 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond", | 66 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond", |
61 round(render_fps_tracker_.ComputeTotalRate())); | 67 round(render_fps_tracker_.ComputeTotalRate())); |
62 RTC_HISTOGRAM_COUNTS_100000( | 68 RTC_HISTOGRAM_COUNTS_100000( |
63 "WebRTC.Video.RenderSqrtPixelsPerSecond", | 69 "WebRTC.Video.RenderSqrtPixelsPerSecond", |
64 round(render_pixel_tracker_.ComputeTotalRate())); | 70 round(render_pixel_tracker_.ComputeTotalRate())); |
65 } | 71 } |
66 int width = render_width_counter_.Avg(kMinRequiredSamples); | 72 int width = render_width_counter_.Avg(kMinRequiredSamples); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 void ReceiveStatisticsProxy::StatisticsUpdated( | 227 void ReceiveStatisticsProxy::StatisticsUpdated( |
222 const webrtc::RtcpStatistics& statistics, | 228 const webrtc::RtcpStatistics& statistics, |
223 uint32_t ssrc) { | 229 uint32_t ssrc) { |
224 rtc::CritScope lock(&crit_); | 230 rtc::CritScope lock(&crit_); |
225 // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we | 231 // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we |
226 // receive stats from one of them. | 232 // receive stats from one of them. |
227 if (stats_.ssrc != ssrc) | 233 if (stats_.ssrc != ssrc) |
228 return; | 234 return; |
229 stats_.rtcp_stats = statistics; | 235 stats_.rtcp_stats = statistics; |
230 report_block_stats_.Store(statistics, ssrc, 0); | 236 report_block_stats_.Store(statistics, ssrc, 0); |
| 237 |
| 238 if (first_report_block_time_ms_ == -1) |
| 239 first_report_block_time_ms_ = clock_->TimeInMilliseconds(); |
231 } | 240 } |
232 | 241 |
233 void ReceiveStatisticsProxy::CNameChanged(const char* cname, uint32_t ssrc) { | 242 void ReceiveStatisticsProxy::CNameChanged(const char* cname, uint32_t ssrc) { |
234 rtc::CritScope lock(&crit_); | 243 rtc::CritScope lock(&crit_); |
235 // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we | 244 // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we |
236 // receive stats from one of them. | 245 // receive stats from one of them. |
237 if (stats_.ssrc != ssrc) | 246 if (stats_.ssrc != ssrc) |
238 return; | 247 return; |
239 stats_.c_name = cname; | 248 stats_.c_name = cname; |
240 } | 249 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 ++num_samples; | 343 ++num_samples; |
335 } | 344 } |
336 | 345 |
337 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 346 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
338 if (num_samples < min_required_samples || num_samples == 0) | 347 if (num_samples < min_required_samples || num_samples == 0) |
339 return -1; | 348 return -1; |
340 return sum / num_samples; | 349 return sum / num_samples; |
341 } | 350 } |
342 | 351 |
343 } // namespace webrtc | 352 } // namespace webrtc |
OLD | NEW |