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/modules/video_coding/codecs/interface/video_codec_interface.h" |
17 #include "webrtc/system_wrappers/interface/clock.h" | 17 #include "webrtc/system_wrappers/interface/clock.h" |
18 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 18 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
19 #include "webrtc/system_wrappers/interface/metrics.h" | 19 #include "webrtc/system_wrappers/interface/metrics.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
| 22 namespace { |
| 23 const float kQpWeigthFactor = 0.97f; |
| 24 } // namespace |
22 | 25 |
23 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) | 26 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) |
24 : clock_(clock), | 27 : clock_(clock), |
25 // 1000ms window, scale 1000 for ms to s. | 28 // 1000ms window, scale 1000 for ms to s. |
26 decode_fps_estimator_(1000, 1000), | 29 decode_fps_estimator_(1000, 1000), |
27 renders_fps_estimator_(1000, 1000), | 30 renders_fps_estimator_(1000, 1000), |
28 render_fps_tracker_(100u, 10u), | 31 render_fps_tracker_(100u, 10u), |
29 render_pixel_tracker_(100u, 10u) { | 32 render_pixel_tracker_(100u, 10u), |
| 33 qp_(kQpWeigthFactor) { |
30 stats_.ssrc = ssrc; | 34 stats_.ssrc = ssrc; |
31 } | 35 } |
32 | 36 |
33 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { | 37 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { |
34 UpdateHistograms(); | 38 UpdateHistograms(); |
35 } | 39 } |
36 | 40 |
37 void ReceiveStatisticsProxy::UpdateHistograms() { | 41 void ReceiveStatisticsProxy::UpdateHistograms() { |
38 int fraction_lost = report_block_stats_.FractionLostInPercent(); | 42 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
39 if (fraction_lost != -1) { | 43 if (fraction_lost != -1) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 191 |
188 void ReceiveStatisticsProxy::OnPreDecode( | 192 void ReceiveStatisticsProxy::OnPreDecode( |
189 const EncodedImage& encoded_image, | 193 const EncodedImage& encoded_image, |
190 const CodecSpecificInfo* codec_specific_info) { | 194 const CodecSpecificInfo* codec_specific_info) { |
191 if (codec_specific_info == nullptr || encoded_image.qp_ == -1) { | 195 if (codec_specific_info == nullptr || encoded_image.qp_ == -1) { |
192 return; | 196 return; |
193 } | 197 } |
194 if (codec_specific_info->codecType == kVideoCodecVP8) { | 198 if (codec_specific_info->codecType == kVideoCodecVP8) { |
195 qp_counters_.vp8.Add(encoded_image.qp_); | 199 qp_counters_.vp8.Add(encoded_image.qp_); |
196 } | 200 } |
| 201 qp_.Apply(1.0f, encoded_image.qp_); |
| 202 |
| 203 rtc::CritScope lock(&crit_); |
| 204 stats_.qp = round(qp_.filtered()); |
197 } | 205 } |
198 | 206 |
199 void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { | 207 void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { |
200 sum += sample; | 208 sum += sample; |
201 ++num_samples; | 209 ++num_samples; |
202 } | 210 } |
203 | 211 |
204 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 212 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
205 if (num_samples < min_required_samples || num_samples == 0) | 213 if (num_samples < min_required_samples || num_samples == 0) |
206 return -1; | 214 return -1; |
207 return sum / num_samples; | 215 return sum / num_samples; |
208 } | 216 } |
209 | 217 |
210 } // namespace webrtc | 218 } // namespace webrtc |
OLD | NEW |