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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); | 58 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); |
59 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); | 59 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); |
60 if (sent_width != -1) { | 60 if (sent_width != -1) { |
61 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width); | 61 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width); |
62 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height); | 62 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height); |
63 } | 63 } |
64 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); | 64 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); |
65 if (encode_ms != -1) | 65 if (encode_ms != -1) |
66 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.EncodeTimeInMs", encode_ms); | 66 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.EncodeTimeInMs", encode_ms); |
| 67 |
| 68 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); |
| 69 if (key_frames_permille != -1) { |
| 70 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesSentInPermille", |
| 71 key_frames_permille); |
| 72 } |
67 } | 73 } |
68 | 74 |
69 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { | 75 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { |
70 rtc::CritScope lock(&crit_); | 76 rtc::CritScope lock(&crit_); |
71 stats_.encode_frame_rate = framerate; | 77 stats_.encode_frame_rate = framerate; |
72 stats_.media_bitrate_bps = bitrate; | 78 stats_.media_bitrate_bps = bitrate; |
73 } | 79 } |
74 | 80 |
75 void SendStatisticsProxy::CpuOveruseMetricsUpdated( | 81 void SendStatisticsProxy::CpuOveruseMetricsUpdated( |
76 const CpuOveruseMetrics& metrics) { | 82 const CpuOveruseMetrics& metrics) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 161 |
156 rtc::CritScope lock(&crit_); | 162 rtc::CritScope lock(&crit_); |
157 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 163 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
158 if (stats == nullptr) | 164 if (stats == nullptr) |
159 return; | 165 return; |
160 | 166 |
161 stats->width = encoded_image._encodedWidth; | 167 stats->width = encoded_image._encodedWidth; |
162 stats->height = encoded_image._encodedHeight; | 168 stats->height = encoded_image._encodedHeight; |
163 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); | 169 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); |
164 | 170 |
| 171 if (encoded_image._frameType != kSkipFrame) |
| 172 key_frame_counter_.Add(encoded_image._frameType == kKeyFrame); |
| 173 |
165 // TODO(asapersson): This is incorrect if simulcast layers are encoded on | 174 // TODO(asapersson): This is incorrect if simulcast layers are encoded on |
166 // different threads and there is no guarantee that one frame of all layers | 175 // different threads and there is no guarantee that one frame of all layers |
167 // are encoded before the next start. | 176 // are encoded before the next start. |
168 if (last_sent_frame_timestamp_ > 0 && | 177 if (last_sent_frame_timestamp_ > 0 && |
169 encoded_image._timeStamp != last_sent_frame_timestamp_) { | 178 encoded_image._timeStamp != last_sent_frame_timestamp_) { |
170 sent_frame_rate_tracker_.AddSamples(1); | 179 sent_frame_rate_tracker_.AddSamples(1); |
171 sent_width_counter_.Add(max_sent_width_per_timestamp_); | 180 sent_width_counter_.Add(max_sent_width_per_timestamp_); |
172 sent_height_counter_.Add(max_sent_height_per_timestamp_); | 181 sent_height_counter_.Add(max_sent_height_per_timestamp_); |
173 max_sent_width_per_timestamp_ = 0; | 182 max_sent_width_per_timestamp_ = 0; |
174 max_sent_height_per_timestamp_ = 0; | 183 max_sent_height_per_timestamp_ = 0; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 sum += sample; | 275 sum += sample; |
267 ++num_samples; | 276 ++num_samples; |
268 } | 277 } |
269 | 278 |
270 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 279 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
271 if (num_samples < min_required_samples || num_samples == 0) | 280 if (num_samples < min_required_samples || num_samples == 0) |
272 return -1; | 281 return -1; |
273 return sum / num_samples; | 282 return sum / num_samples; |
274 } | 283 } |
275 | 284 |
| 285 void SendStatisticsProxy::BoolSampleCounter::Add(bool sample) { |
| 286 if (sample) |
| 287 ++sum; |
| 288 ++num_samples; |
| 289 } |
| 290 |
| 291 int SendStatisticsProxy::BoolSampleCounter::Percent( |
| 292 int min_required_samples) const { |
| 293 return Fraction(min_required_samples, 100.0f); |
| 294 } |
| 295 |
| 296 int SendStatisticsProxy::BoolSampleCounter::Permille( |
| 297 int min_required_samples) const { |
| 298 return Fraction(min_required_samples, 1000.0f); |
| 299 } |
| 300 |
| 301 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 302 int min_required_samples, float multiplier) const { |
| 303 if (num_samples < min_required_samples || num_samples == 0) |
| 304 return -1; |
| 305 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 306 } |
| 307 |
276 } // namespace webrtc | 308 } // namespace webrtc |
OLD | NEW |