Chromium Code Reviews| 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/send_statistics_proxy.h" | 11 #include "webrtc/video/send_statistics_proxy.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <map> | 14 #include <map> |
| 15 | 15 |
| 16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
| 17 | 17 |
| 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/logging.h" | 19 #include "webrtc/system_wrappers/interface/logging.h" |
| 20 #include "webrtc/system_wrappers/interface/metrics.h" | 20 #include "webrtc/system_wrappers/interface/metrics.h" |
| 21 | 21 |
| 22 namespace webrtc { | 22 namespace webrtc { |
| 23 namespace { | |
| 24 // Used by histograms. Values of entries should not be changed. | |
| 25 enum HistogramCodecType { | |
| 26 kVideoVp8 = 0, | |
|
pbos-webrtc
2015/10/26 13:19:03
I'd prefer unknown to be zero, and then set explic
åsapersson
2015/10/26 14:19:53
Done.
| |
| 27 kVideoVp9, | |
| 28 kVideoH264, | |
| 29 kVideoUnknown = 19, | |
| 30 kVideoMax = 20, | |
|
pbos-webrtc
2015/10/26 13:19:03
I think you can pick something larger if this isn'
åsapersson
2015/10/26 14:19:53
Done.
| |
| 31 }; | |
| 32 | |
| 33 HistogramCodecType PayloadNameToHistogramCodecType( | |
| 34 const std::string& payload_name) { | |
| 35 if (payload_name == "VP8") { | |
| 36 return kVideoVp8; | |
| 37 } else if (payload_name == "VP9") { | |
| 38 return kVideoVp9; | |
| 39 } else if (payload_name == "H264") { | |
| 40 return kVideoH264; | |
| 41 } else { | |
| 42 return kVideoUnknown; | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 void UpdateCodecTypeHistogram(const std::string& payload_name) { | |
| 47 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.Encoder.CodecType", | |
| 48 PayloadNameToHistogramCodecType(payload_name), kVideoMax); | |
| 49 } | |
| 50 } // namespace | |
| 51 | |
| 23 | 52 |
| 24 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; | 53 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; |
| 25 | 54 |
| 26 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, | 55 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, |
| 27 const VideoSendStream::Config& config) | 56 const VideoSendStream::Config& config) |
| 28 : clock_(clock), | 57 : clock_(clock), |
| 29 config_(config), | 58 config_(config), |
| 30 input_frame_rate_tracker_(100u, 10u), | 59 input_frame_rate_tracker_(100u, 10u), |
| 31 sent_frame_rate_tracker_(100u, 10u), | 60 sent_frame_rate_tracker_(100u, 10u), |
| 32 last_sent_frame_timestamp_(0), | 61 last_sent_frame_timestamp_(0), |
| 33 max_sent_width_per_timestamp_(0), | 62 max_sent_width_per_timestamp_(0), |
| 34 max_sent_height_per_timestamp_(0) { | 63 max_sent_height_per_timestamp_(0) { |
| 64 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); | |
| 35 } | 65 } |
| 36 | 66 |
| 37 SendStatisticsProxy::~SendStatisticsProxy() { | 67 SendStatisticsProxy::~SendStatisticsProxy() { |
| 38 UpdateHistograms(); | 68 UpdateHistograms(); |
| 39 } | 69 } |
| 40 | 70 |
| 41 void SendStatisticsProxy::UpdateHistograms() { | 71 void SendStatisticsProxy::UpdateHistograms() { |
| 42 int input_fps = | 72 int input_fps = |
| 43 static_cast<int>(input_frame_rate_tracker_.ComputeTotalRate()); | 73 static_cast<int>(input_frame_rate_tracker_.ComputeTotalRate()); |
| 44 if (input_fps > 0) | 74 if (input_fps > 0) |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 } | 367 } |
| 338 | 368 |
| 339 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 369 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 340 int min_required_samples, float multiplier) const { | 370 int min_required_samples, float multiplier) const { |
| 341 if (num_samples < min_required_samples || num_samples == 0) | 371 if (num_samples < min_required_samples || num_samples == 0) |
| 342 return -1; | 372 return -1; |
| 343 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 373 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 344 } | 374 } |
| 345 | 375 |
| 346 } // namespace webrtc | 376 } // namespace webrtc |
| OLD | NEW |