| 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/codecs/interface/video_codec_interface.h" |
| 16 #include "webrtc/system_wrappers/interface/clock.h" | 17 #include "webrtc/system_wrappers/interface/clock.h" |
| 17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 18 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 18 #include "webrtc/system_wrappers/interface/metrics.h" | 19 #include "webrtc/system_wrappers/interface/metrics.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 | 22 |
| 22 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) | 23 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) |
| 23 : clock_(clock), | 24 : clock_(clock), |
| 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), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 static_cast<int>(render_fps_tracker_.ComputeTotalRate())); | 47 static_cast<int>(render_fps_tracker_.ComputeTotalRate())); |
| 47 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.RenderSqrtPixelsPerSecond", | 48 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.RenderSqrtPixelsPerSecond", |
| 48 static_cast<int>(render_pixel_tracker_.ComputeTotalRate())); | 49 static_cast<int>(render_pixel_tracker_.ComputeTotalRate())); |
| 49 } | 50 } |
| 50 int width = render_width_counter_.Avg(kMinRequiredSamples); | 51 int width = render_width_counter_.Avg(kMinRequiredSamples); |
| 51 int height = render_height_counter_.Avg(kMinRequiredSamples); | 52 int height = render_height_counter_.Avg(kMinRequiredSamples); |
| 52 if (width != -1) { | 53 if (width != -1) { |
| 53 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedWidthInPixels", width); | 54 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedWidthInPixels", width); |
| 54 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedHeightInPixels", height); | 55 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedHeightInPixels", height); |
| 55 } | 56 } |
| 57 int qp = qp_counters_.vp8.Avg(kMinRequiredSamples); |
| 58 if (qp != -1) |
| 59 RTC_HISTOGRAM_COUNTS_200("WebRTC.Video.Decoded.Vp8.Qp", qp); |
| 60 |
| 56 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and | 61 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and |
| 57 // not per frame. Change decode time to include every frame. | 62 // not per frame. Change decode time to include every frame. |
| 58 const int kMinRequiredDecodeSamples = 5; | 63 const int kMinRequiredDecodeSamples = 5; |
| 59 int decode_ms = decode_time_counter_.Avg(kMinRequiredDecodeSamples); | 64 int decode_ms = decode_time_counter_.Avg(kMinRequiredDecodeSamples); |
| 60 if (decode_ms != -1) | 65 if (decode_ms != -1) |
| 61 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms); | 66 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms); |
| 62 | 67 |
| 63 int delay_ms = delay_counter_.Avg(kMinRequiredDecodeSamples); | 68 int delay_ms = delay_counter_.Avg(kMinRequiredDecodeSamples); |
| 64 if (delay_ms != -1) | 69 if (delay_ms != -1) |
| 65 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); | 70 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 const FrameCounts& frame_counts) { | 178 const FrameCounts& frame_counts) { |
| 174 rtc::CritScope lock(&crit_); | 179 rtc::CritScope lock(&crit_); |
| 175 stats_.frame_counts = frame_counts; | 180 stats_.frame_counts = frame_counts; |
| 176 } | 181 } |
| 177 | 182 |
| 178 void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) { | 183 void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) { |
| 179 rtc::CritScope lock(&crit_); | 184 rtc::CritScope lock(&crit_); |
| 180 stats_.discarded_packets = discarded_packets; | 185 stats_.discarded_packets = discarded_packets; |
| 181 } | 186 } |
| 182 | 187 |
| 188 void ReceiveStatisticsProxy::OnPreDecode( |
| 189 const EncodedImage& encoded_image, |
| 190 const CodecSpecificInfo* codec_specific_info) { |
| 191 if (codec_specific_info == nullptr || encoded_image.qp_ == -1) { |
| 192 return; |
| 193 } |
| 194 if (codec_specific_info->codecType == kVideoCodecVP8) { |
| 195 qp_counters_.vp8.Add(encoded_image.qp_); |
| 196 } |
| 197 } |
| 198 |
| 183 void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { | 199 void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { |
| 184 sum += sample; | 200 sum += sample; |
| 185 ++num_samples; | 201 ++num_samples; |
| 186 } | 202 } |
| 187 | 203 |
| 188 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 204 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
| 189 if (num_samples < min_required_samples || num_samples == 0) | 205 if (num_samples < min_required_samples || num_samples == 0) |
| 190 return -1; | 206 return -1; |
| 191 return sum / num_samples; | 207 return sum / num_samples; |
| 192 } | 208 } |
| 193 | 209 |
| 194 } // namespace webrtc | 210 } // namespace webrtc |
| OLD | NEW |