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/system_wrappers/interface/clock.h" | 13 #include "webrtc/system_wrappers/interface/clock.h" |
14 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 14 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
15 #include "webrtc/system_wrappers/interface/metrics.h" | 15 #include "webrtc/system_wrappers/interface/metrics.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) | 19 ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock) |
20 : clock_(clock), | 20 : clock_(clock), |
21 // 1000ms window, scale 1000 for ms to s. | 21 // 1000ms window, scale 1000 for ms to s. |
22 decode_fps_estimator_(1000, 1000), | 22 decode_fps_estimator_(1000, 1000), |
23 renders_fps_estimator_(1000, 1000), | 23 renders_fps_estimator_(1000, 1000), |
24 render_fps_tracker_(100u, 10u) { | 24 render_fps_tracker_(100u, 10u), |
25 render_pixel_tracker_(100u, 10u) { | |
25 stats_.ssrc = ssrc; | 26 stats_.ssrc = ssrc; |
26 } | 27 } |
27 | 28 |
28 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { | 29 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { |
29 UpdateHistograms(); | 30 UpdateHistograms(); |
30 } | 31 } |
31 | 32 |
32 void ReceiveStatisticsProxy::UpdateHistograms() { | 33 void ReceiveStatisticsProxy::UpdateHistograms() { |
33 int fraction_lost = report_block_stats_.FractionLostInPercent(); | 34 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
34 if (fraction_lost != -1) { | 35 if (fraction_lost != -1) { |
35 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", | 36 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", |
36 fraction_lost); | 37 fraction_lost); |
37 } | 38 } |
38 | 39 |
39 int render_fps = static_cast<int>(render_fps_tracker_.ComputeTotalRate()); | 40 int render_fps = static_cast<int>(render_fps_tracker_.ComputeTotalRate()); |
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 |
44 int render_pps = static_cast<int>(render_pixel_tracker_.ComputeTotalRate()); | |
45 if (render_pps > 0) { | |
46 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.RenderPixelsPerSecond", | |
47 render_pps); | |
48 } | |
49 | |
43 const int kMinRequiredSamples = 200; | 50 const int kMinRequiredSamples = 200; |
44 int width = render_width_counter_.Avg(kMinRequiredSamples); | 51 int width = render_width_counter_.Avg(kMinRequiredSamples); |
45 int height = render_height_counter_.Avg(kMinRequiredSamples); | 52 int height = render_height_counter_.Avg(kMinRequiredSamples); |
46 if (width != -1) { | 53 if (width != -1) { |
47 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedWidthInPixels", width); | 54 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedWidthInPixels", width); |
48 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedHeightInPixels", height); | 55 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedHeightInPixels", height); |
49 } | 56 } |
50 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and | 57 // TODO(asapersson): DecoderTiming() is call periodically (each 1000ms) and |
51 // not per frame. Change decode time to include every frame. | 58 // not per frame. Change decode time to include every frame. |
52 const int kMinRequiredDecodeSamples = 5; | 59 const int kMinRequiredDecodeSamples = 5; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 | 146 |
140 void ReceiveStatisticsProxy::OnRenderedFrame(int width, int height) { | 147 void ReceiveStatisticsProxy::OnRenderedFrame(int width, int height) { |
141 uint64_t now = clock_->TimeInMilliseconds(); | 148 uint64_t now = clock_->TimeInMilliseconds(); |
142 | 149 |
143 rtc::CritScope lock(&crit_); | 150 rtc::CritScope lock(&crit_); |
144 renders_fps_estimator_.Update(1, now); | 151 renders_fps_estimator_.Update(1, now); |
145 stats_.render_frame_rate = renders_fps_estimator_.Rate(now); | 152 stats_.render_frame_rate = renders_fps_estimator_.Rate(now); |
146 render_width_counter_.Add(width); | 153 render_width_counter_.Add(width); |
147 render_height_counter_.Add(height); | 154 render_height_counter_.Add(height); |
148 render_fps_tracker_.AddSamples(1); | 155 render_fps_tracker_.AddSamples(1); |
156 if (width > 0 && height > 0) | |
pbos-webrtc
2015/09/23 13:39:20
DCHECK width>0 and height>0 instead.
åsapersson
2015/09/23 14:07:53
Done.
| |
157 render_pixel_tracker_.AddSamples(sqrt(width * height)); | |
149 } | 158 } |
150 | 159 |
151 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, | 160 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, |
152 uint32_t frameRate) { | 161 uint32_t frameRate) { |
153 } | 162 } |
154 | 163 |
155 void ReceiveStatisticsProxy::OnFrameCountsUpdated( | 164 void ReceiveStatisticsProxy::OnFrameCountsUpdated( |
156 const FrameCounts& frame_counts) { | 165 const FrameCounts& frame_counts) { |
157 rtc::CritScope lock(&crit_); | 166 rtc::CritScope lock(&crit_); |
158 stats_.frame_counts = frame_counts; | 167 stats_.frame_counts = frame_counts; |
159 } | 168 } |
160 | 169 |
161 void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) { | 170 void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) { |
162 rtc::CritScope lock(&crit_); | 171 rtc::CritScope lock(&crit_); |
163 stats_.discarded_packets = discarded_packets; | 172 stats_.discarded_packets = discarded_packets; |
164 } | 173 } |
165 | 174 |
166 void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { | 175 void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { |
167 sum += sample; | 176 sum += sample; |
168 ++num_samples; | 177 ++num_samples; |
169 } | 178 } |
170 | 179 |
171 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 180 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
172 if (num_samples < min_required_samples || num_samples == 0) | 181 if (num_samples < min_required_samples || num_samples == 0) |
173 return -1; | 182 return -1; |
174 return sum / num_samples; | 183 return sum / num_samples; |
175 } | 184 } |
176 | 185 |
177 } // namespace webrtc | 186 } // namespace webrtc |
OLD | NEW |