| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 stats_.ssrc = ssrc; | 24 stats_.ssrc = ssrc; |
| 25 } | 25 } |
| 26 | 26 |
| 27 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { | 27 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { |
| 28 UpdateHistograms(); | 28 UpdateHistograms(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void ReceiveStatisticsProxy::UpdateHistograms() const { | 31 void ReceiveStatisticsProxy::UpdateHistograms() { |
| 32 int fraction_lost; | 32 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
| 33 { | |
| 34 rtc::CritScope lock(&crit_); | |
| 35 fraction_lost = report_block_stats_.FractionLostInPercent(); | |
| 36 } | |
| 37 if (fraction_lost != -1) { | 33 if (fraction_lost != -1) { |
| 38 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", | 34 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", |
| 39 fraction_lost); | 35 fraction_lost); |
| 40 } | 36 } |
| 37 |
| 38 int render_fps = static_cast<int>(render_fps_tracker_total_.units_second()); |
| 39 if (render_fps > 0) |
| 40 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond", render_fps); |
| 41 |
| 42 const int kMinRequiredSamples = 100; |
| 43 int width = render_width_counter_.Avg(kMinRequiredSamples); |
| 44 int height = render_height_counter_.Avg(kMinRequiredSamples); |
| 45 if (width != -1) { |
| 46 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedWidthInPixels", width); |
| 47 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.ReceivedHeightInPixels", height); |
| 48 } |
| 41 } | 49 } |
| 42 | 50 |
| 43 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { | 51 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { |
| 44 rtc::CritScope lock(&crit_); | 52 rtc::CritScope lock(&crit_); |
| 45 return stats_; | 53 return stats_; |
| 46 } | 54 } |
| 47 | 55 |
| 48 void ReceiveStatisticsProxy::IncomingRate(const int video_channel, | 56 void ReceiveStatisticsProxy::IncomingRate(const int video_channel, |
| 49 const unsigned int framerate, | 57 const unsigned int framerate, |
| 50 const unsigned int bitrate_bps) { | 58 const unsigned int bitrate_bps) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 118 } |
| 111 | 119 |
| 112 void ReceiveStatisticsProxy::OnDecodedFrame() { | 120 void ReceiveStatisticsProxy::OnDecodedFrame() { |
| 113 uint64_t now = clock_->TimeInMilliseconds(); | 121 uint64_t now = clock_->TimeInMilliseconds(); |
| 114 | 122 |
| 115 rtc::CritScope lock(&crit_); | 123 rtc::CritScope lock(&crit_); |
| 116 decode_fps_estimator_.Update(1, now); | 124 decode_fps_estimator_.Update(1, now); |
| 117 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now); | 125 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now); |
| 118 } | 126 } |
| 119 | 127 |
| 120 void ReceiveStatisticsProxy::OnRenderedFrame() { | 128 void ReceiveStatisticsProxy::OnRenderedFrame(int width, int height) { |
| 121 uint64_t now = clock_->TimeInMilliseconds(); | 129 uint64_t now = clock_->TimeInMilliseconds(); |
| 122 | 130 |
| 123 rtc::CritScope lock(&crit_); | 131 rtc::CritScope lock(&crit_); |
| 124 renders_fps_estimator_.Update(1, now); | 132 renders_fps_estimator_.Update(1, now); |
| 125 stats_.render_frame_rate = renders_fps_estimator_.Rate(now); | 133 stats_.render_frame_rate = renders_fps_estimator_.Rate(now); |
| 134 render_width_counter_.Add(width); |
| 135 render_height_counter_.Add(height); |
| 136 render_fps_tracker_total_.Update(1); |
| 126 } | 137 } |
| 127 | 138 |
| 128 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, | 139 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, |
| 129 uint32_t frameRate) { | 140 uint32_t frameRate) { |
| 130 } | 141 } |
| 131 | 142 |
| 132 void ReceiveStatisticsProxy::OnFrameCountsUpdated( | 143 void ReceiveStatisticsProxy::OnFrameCountsUpdated( |
| 133 const FrameCounts& frame_counts) { | 144 const FrameCounts& frame_counts) { |
| 134 rtc::CritScope lock(&crit_); | 145 rtc::CritScope lock(&crit_); |
| 135 stats_.frame_counts = frame_counts; | 146 stats_.frame_counts = frame_counts; |
| 136 } | 147 } |
| 137 | 148 |
| 138 void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) { | 149 void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) { |
| 139 rtc::CritScope lock(&crit_); | 150 rtc::CritScope lock(&crit_); |
| 140 stats_.discarded_packets = discarded_packets; | 151 stats_.discarded_packets = discarded_packets; |
| 141 } | 152 } |
| 142 | 153 |
| 154 void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { |
| 155 sum += sample; |
| 156 ++num_samples; |
| 157 } |
| 158 |
| 159 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
| 160 if (num_samples < min_required_samples || num_samples == 0) |
| 161 return -1; |
| 162 return sum / num_samples; |
| 163 } |
| 164 |
| 143 } // namespace webrtc | 165 } // namespace webrtc |
| OLD | NEW |