| 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 |
| 11 #include "webrtc/video/receive_statistics_proxy.h" | 11 #include "webrtc/video/receive_statistics_proxy.h" |
| 12 | 12 |
| 13 #include <cmath> | 13 #include <cmath> |
| 14 | 14 |
| 15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
| 16 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 16 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| 17 #include "webrtc/system_wrappers/include/clock.h" | 17 #include "webrtc/system_wrappers/include/clock.h" |
| 18 #include "webrtc/system_wrappers/include/metrics.h" | 18 #include "webrtc/system_wrappers/include/metrics.h" |
| 19 | 19 |
| 20 namespace webrtc { | 20 namespace webrtc { |
| 21 | 21 |
| 22 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) | 22 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) |
| 23 : clock_(clock), | 23 : clock_(clock), |
| 24 start_time_ms_(clock->TimeInMilliseconds()), |
| 24 // 1000ms window, scale 1000 for ms to s. | 25 // 1000ms window, scale 1000 for ms to s. |
| 25 decode_fps_estimator_(1000, 1000), | 26 decode_fps_estimator_(1000, 1000), |
| 26 renders_fps_estimator_(1000, 1000), | 27 renders_fps_estimator_(1000, 1000), |
| 27 render_fps_tracker_(100u, 10u), | 28 render_fps_tracker_(100u, 10u), |
| 28 render_pixel_tracker_(100u, 10u) { | 29 render_pixel_tracker_(100u, 10u) { |
| 29 stats_.ssrc = ssrc; | 30 stats_.ssrc = ssrc; |
| 30 } | 31 } |
| 31 | 32 |
| 32 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { | 33 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { |
| 33 UpdateHistograms(); | 34 UpdateHistograms(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 61 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and | 62 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and |
| 62 // not per frame. Change decode time to include every frame. | 63 // not per frame. Change decode time to include every frame. |
| 63 const int kMinRequiredDecodeSamples = 5; | 64 const int kMinRequiredDecodeSamples = 5; |
| 64 int decode_ms = decode_time_counter_.Avg(kMinRequiredDecodeSamples); | 65 int decode_ms = decode_time_counter_.Avg(kMinRequiredDecodeSamples); |
| 65 if (decode_ms != -1) | 66 if (decode_ms != -1) |
| 66 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms); | 67 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms); |
| 67 | 68 |
| 68 int delay_ms = delay_counter_.Avg(kMinRequiredDecodeSamples); | 69 int delay_ms = delay_counter_.Avg(kMinRequiredDecodeSamples); |
| 69 if (delay_ms != -1) | 70 if (delay_ms != -1) |
| 70 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); | 71 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); |
| 72 |
| 73 int64_t elapsed_sec = (clock_->TimeInMilliseconds() - start_time_ms_) / 1000; |
| 74 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
| 75 const RtcpPacketTypeCounter& counters = stats_.rtcp_packet_type_counts; |
| 76 |
| 77 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.NackPacketsSentPerMinute", |
| 78 counters.nack_packets * 60 / elapsed_sec); |
| 79 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FirPacketsSentPerMinute", |
| 80 counters.fir_packets * 60 / elapsed_sec); |
| 81 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PliPacketsSentPerMinute", |
| 82 counters.pli_packets * 60 / elapsed_sec); |
| 83 if (counters.nack_requests > 0) { |
| 84 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.UniqueNackRequestsSentInPercent", |
| 85 counters.UniqueNackRequestsInPercent()); |
| 86 } |
| 87 } |
| 71 } | 88 } |
| 72 | 89 |
| 73 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { | 90 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { |
| 74 rtc::CritScope lock(&crit_); | 91 rtc::CritScope lock(&crit_); |
| 75 return stats_; | 92 return stats_; |
| 76 } | 93 } |
| 77 | 94 |
| 78 void ReceiveStatisticsProxy::OnIncomingPayloadType(int payload_type) { | 95 void ReceiveStatisticsProxy::OnIncomingPayloadType(int payload_type) { |
| 79 rtc::CritScope lock(&crit_); | 96 rtc::CritScope lock(&crit_); |
| 80 stats_.current_payload_type = payload_type; | 97 stats_.current_payload_type = payload_type; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 ++num_samples; | 223 ++num_samples; |
| 207 } | 224 } |
| 208 | 225 |
| 209 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 226 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
| 210 if (num_samples < min_required_samples || num_samples == 0) | 227 if (num_samples < min_required_samples || num_samples == 0) |
| 211 return -1; | 228 return -1; |
| 212 return sum / num_samples; | 229 return sum / num_samples; |
| 213 } | 230 } |
| 214 | 231 |
| 215 } // namespace webrtc | 232 } // namespace webrtc |
| OLD | NEW |