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 <cmath> | 14 #include <cmath> |
15 #include <map> | 15 #include <map> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
20 #include "webrtc/base/trace_event.h" | 20 #include "webrtc/base/trace_event.h" |
| 21 #include "webrtc/common_types.h" |
21 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 22 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
22 #include "webrtc/system_wrappers/include/metrics.h" | 23 #include "webrtc/system_wrappers/include/metrics.h" |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 namespace { | 26 namespace { |
26 const float kEncodeTimeWeigthFactor = 0.5f; | 27 const float kEncodeTimeWeigthFactor = 0.5f; |
27 | 28 |
28 // Used by histograms. Values of entries should not be changed. | 29 // Used by histograms. Values of entries should not be changed. |
29 enum HistogramCodecType { | 30 enum HistogramCodecType { |
30 kVideoUnknown = 0, | 31 kVideoUnknown = 0, |
(...skipping 12 matching lines...) Expand all Loading... |
43 return kRealtimePrefix; | 44 return kRealtimePrefix; |
44 case VideoEncoderConfig::ContentType::kScreen: | 45 case VideoEncoderConfig::ContentType::kScreen: |
45 return kScreenPrefix; | 46 return kScreenPrefix; |
46 } | 47 } |
47 RTC_NOTREACHED(); | 48 RTC_NOTREACHED(); |
48 return nullptr; | 49 return nullptr; |
49 } | 50 } |
50 | 51 |
51 HistogramCodecType PayloadNameToHistogramCodecType( | 52 HistogramCodecType PayloadNameToHistogramCodecType( |
52 const std::string& payload_name) { | 53 const std::string& payload_name) { |
53 if (payload_name == "VP8") { | 54 rtc::Optional<VideoCodecType> codecType = |
54 return kVideoVp8; | 55 PayloadNameToCodecType(payload_name); |
55 } else if (payload_name == "VP9") { | 56 if (!codecType) { |
56 return kVideoVp9; | |
57 } else if (payload_name == "H264") { | |
58 return kVideoH264; | |
59 } else { | |
60 return kVideoUnknown; | 57 return kVideoUnknown; |
61 } | 58 } |
| 59 switch (*codecType) { |
| 60 case kVideoCodecVP8: |
| 61 return kVideoVp8; |
| 62 case kVideoCodecVP9: |
| 63 return kVideoVp9; |
| 64 case kVideoCodecH264: |
| 65 return kVideoH264; |
| 66 default: |
| 67 return kVideoUnknown; |
| 68 } |
62 } | 69 } |
63 | 70 |
64 void UpdateCodecTypeHistogram(const std::string& payload_name) { | 71 void UpdateCodecTypeHistogram(const std::string& payload_name) { |
65 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.Encoder.CodecType", | 72 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.Encoder.CodecType", |
66 PayloadNameToHistogramCodecType(payload_name), | 73 PayloadNameToHistogramCodecType(payload_name), |
67 kVideoMax); | 74 kVideoMax); |
68 } | 75 } |
69 } // namespace | 76 } // namespace |
70 | 77 |
71 | 78 |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 } | 856 } |
850 | 857 |
851 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 858 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
852 int64_t min_required_samples, | 859 int64_t min_required_samples, |
853 float multiplier) const { | 860 float multiplier) const { |
854 if (num_samples < min_required_samples || num_samples == 0) | 861 if (num_samples < min_required_samples || num_samples == 0) |
855 return -1; | 862 return -1; |
856 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 863 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
857 } | 864 } |
858 } // namespace webrtc | 865 } // namespace webrtc |
OLD | NEW |