| 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 "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" |
| 13 #include "webrtc/system_wrappers/interface/clock.h" | 14 #include "webrtc/system_wrappers/interface/clock.h" |
| 14 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 15 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 15 #include "webrtc/system_wrappers/interface/metrics.h" | 16 #include "webrtc/system_wrappers/interface/metrics.h" |
| 16 | 17 |
| 17 namespace webrtc { | 18 namespace webrtc { |
| 18 | 19 |
| 19 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) | 20 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) |
| 20 : clock_(clock), | 21 : clock_(clock), |
| 21 // 1000ms window, scale 1000 for ms to s. | 22 // 1000ms window, scale 1000 for ms to s. |
| 22 decode_fps_estimator_(1000, 1000), | 23 decode_fps_estimator_(1000, 1000), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 if (render_fps > 0) | 41 if (render_fps > 0) |
| 41 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond", render_fps); | 42 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond", render_fps); |
| 42 | 43 |
| 43 const int kMinRequiredSamples = 200; | 44 const int kMinRequiredSamples = 200; |
| 44 int width = render_width_counter_.Avg(kMinRequiredSamples); | 45 int width = render_width_counter_.Avg(kMinRequiredSamples); |
| 45 int height = render_height_counter_.Avg(kMinRequiredSamples); | 46 int height = render_height_counter_.Avg(kMinRequiredSamples); |
| 46 if (width != -1) { | 47 if (width != -1) { |
| 47 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedWidthInPixels", width); | 48 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedWidthInPixels", width); |
| 48 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedHeightInPixels", height); | 49 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedHeightInPixels", height); |
| 49 } | 50 } |
| 51 int qp = qp_counters_.vp8.Avg(kMinRequiredSamples); |
| 52 if (qp != -1) |
| 53 RTC_HISTOGRAM_COUNTS_200("WebRTC.Video.Decoded.Vp8.Qp", qp); |
| 54 |
| 50 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and | 55 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and |
| 51 // not per frame. Change decode time to include every frame. | 56 // not per frame. Change decode time to include every frame. |
| 52 const int kMinRequiredDecodeSamples = 5; | 57 const int kMinRequiredDecodeSamples = 5; |
| 53 int decode_ms = decode_time_counter_.Avg(kMinRequiredDecodeSamples); | 58 int decode_ms = decode_time_counter_.Avg(kMinRequiredDecodeSamples); |
| 54 if (decode_ms != -1) | 59 if (decode_ms != -1) |
| 55 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms); | 60 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms); |
| 56 } | 61 } |
| 57 | 62 |
| 58 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { | 63 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { |
| 59 rtc::CritScope lock(&crit_); | 64 rtc::CritScope lock(&crit_); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 const FrameCounts& frame_counts) { | 161 const FrameCounts& frame_counts) { |
| 157 rtc::CritScope lock(&crit_); | 162 rtc::CritScope lock(&crit_); |
| 158 stats_.frame_counts = frame_counts; | 163 stats_.frame_counts = frame_counts; |
| 159 } | 164 } |
| 160 | 165 |
| 161 void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) { | 166 void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) { |
| 162 rtc::CritScope lock(&crit_); | 167 rtc::CritScope lock(&crit_); |
| 163 stats_.discarded_packets = discarded_packets; | 168 stats_.discarded_packets = discarded_packets; |
| 164 } | 169 } |
| 165 | 170 |
| 171 void ReceiveStatisticsProxy::Encoded( |
| 172 const EncodedImage& encoded_image, |
| 173 const CodecSpecificInfo* codec_specific_info) { |
| 174 if (codec_specific_info == nullptr || encoded_image.qp_ == -1) { |
| 175 return; |
| 176 } |
| 177 if (codec_specific_info->codecType == kVideoCodecVP8) { |
| 178 qp_counters_.vp8.Add(encoded_image.qp_); |
| 179 } |
| 180 } |
| 181 |
| 166 void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { | 182 void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { |
| 167 sum += sample; | 183 sum += sample; |
| 168 ++num_samples; | 184 ++num_samples; |
| 169 } | 185 } |
| 170 | 186 |
| 171 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 187 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
| 172 if (num_samples < min_required_samples || num_samples == 0) | 188 if (num_samples < min_required_samples || num_samples == 0) |
| 173 return -1; | 189 return -1; |
| 174 return sum / num_samples; | 190 return sum / num_samples; |
| 175 } | 191 } |
| 176 | 192 |
| 177 } // namespace webrtc | 193 } // namespace webrtc |
| OLD | NEW |