OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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/base/checks.h" | |
12 #include "webrtc/common_types.h" | 11 #include "webrtc/common_types.h" |
13 | 12 |
14 #include <limits> | 13 #include <limits> |
15 #include <string.h> | 14 #include <string.h> |
16 | 15 |
| 16 #include "webrtc/base/checks.h" |
| 17 #include "webrtc/base/stringutils.h" |
| 18 |
17 namespace webrtc { | 19 namespace webrtc { |
18 | 20 |
19 StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} | 21 StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} |
20 | 22 |
21 RTPHeaderExtension::RTPHeaderExtension() | 23 RTPHeaderExtension::RTPHeaderExtension() |
22 : hasTransmissionTimeOffset(false), | 24 : hasTransmissionTimeOffset(false), |
23 transmissionTimeOffset(0), | 25 transmissionTimeOffset(0), |
24 hasAbsoluteSendTime(false), | 26 hasAbsoluteSendTime(false), |
25 absoluteSendTime(0), | 27 absoluteSendTime(0), |
26 hasTransportSequenceNumber(false), | 28 hasTransportSequenceNumber(false), |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 96 } |
95 | 97 |
96 static const char* kPayloadNameVp8 = "VP8"; | 98 static const char* kPayloadNameVp8 = "VP8"; |
97 static const char* kPayloadNameVp9 = "VP9"; | 99 static const char* kPayloadNameVp9 = "VP9"; |
98 static const char* kPayloadNameH264 = "H264"; | 100 static const char* kPayloadNameH264 = "H264"; |
99 static const char* kPayloadNameI420 = "I420"; | 101 static const char* kPayloadNameI420 = "I420"; |
100 static const char* kPayloadNameRED = "RED"; | 102 static const char* kPayloadNameRED = "RED"; |
101 static const char* kPayloadNameULPFEC = "ULPFEC"; | 103 static const char* kPayloadNameULPFEC = "ULPFEC"; |
102 static const char* kPayloadNameGeneric = "Generic"; | 104 static const char* kPayloadNameGeneric = "Generic"; |
103 | 105 |
104 rtc::Optional<std::string> CodecTypeToPayloadName(VideoCodecType type) { | 106 static bool CodecNamesEq(const char* name1, const char* name2) { |
| 107 return _stricmp(name1, name2) == 0; |
| 108 } |
| 109 |
| 110 rtc::Optional<const char*> CodecTypeToPayloadName(VideoCodecType type) { |
105 switch (type) { | 111 switch (type) { |
106 case kVideoCodecVP8: | 112 case kVideoCodecVP8: |
107 return rtc::Optional<std::string>(kPayloadNameVp8); | 113 return rtc::Optional<const char*>(kPayloadNameVp8); |
108 case kVideoCodecVP9: | 114 case kVideoCodecVP9: |
109 return rtc::Optional<std::string>(kPayloadNameVp9); | 115 return rtc::Optional<const char*>(kPayloadNameVp9); |
110 case kVideoCodecH264: | 116 case kVideoCodecH264: |
111 return rtc::Optional<std::string>(kPayloadNameH264); | 117 return rtc::Optional<const char*>(kPayloadNameH264); |
112 case kVideoCodecI420: | 118 case kVideoCodecI420: |
113 return rtc::Optional<std::string>(kPayloadNameI420); | 119 return rtc::Optional<const char*>(kPayloadNameI420); |
114 case kVideoCodecRED: | 120 case kVideoCodecRED: |
115 return rtc::Optional<std::string>(kPayloadNameRED); | 121 return rtc::Optional<const char*>(kPayloadNameRED); |
116 case kVideoCodecULPFEC: | 122 case kVideoCodecULPFEC: |
117 return rtc::Optional<std::string>(kPayloadNameULPFEC); | 123 return rtc::Optional<const char*>(kPayloadNameULPFEC); |
118 case kVideoCodecGeneric: | 124 case kVideoCodecGeneric: |
119 return rtc::Optional<std::string>(kPayloadNameGeneric); | 125 return rtc::Optional<const char*>(kPayloadNameGeneric); |
120 default: | 126 default: |
121 return rtc::Optional<std::string>(); | 127 return rtc::Optional<const char*>(); |
122 } | 128 } |
123 } | 129 } |
124 | 130 |
125 rtc::Optional<VideoCodecType> PayloadNameToCodecType(const std::string& name) { | 131 rtc::Optional<VideoCodecType> PayloadNameToCodecType(const std::string& name) { |
126 if (name == kPayloadNameVp8) | 132 if (CodecNamesEq(name.c_str(), kPayloadNameVp8)) |
127 return rtc::Optional<VideoCodecType>(kVideoCodecVP8); | 133 return rtc::Optional<VideoCodecType>(kVideoCodecVP8); |
128 if (name == kPayloadNameVp9) | 134 if (CodecNamesEq(name.c_str(), kPayloadNameVp9)) |
129 return rtc::Optional<VideoCodecType>(kVideoCodecVP9); | 135 return rtc::Optional<VideoCodecType>(kVideoCodecVP9); |
130 if (name == kPayloadNameH264) | 136 if (CodecNamesEq(name.c_str(), kPayloadNameH264)) |
131 return rtc::Optional<VideoCodecType>(kVideoCodecH264); | 137 return rtc::Optional<VideoCodecType>(kVideoCodecH264); |
132 if (name == kPayloadNameI420) | 138 if (CodecNamesEq(name.c_str(), kPayloadNameI420)) |
133 return rtc::Optional<VideoCodecType>(kVideoCodecI420); | 139 return rtc::Optional<VideoCodecType>(kVideoCodecI420); |
134 if (name == kPayloadNameRED) | 140 if (CodecNamesEq(name.c_str(), kPayloadNameRED)) |
135 return rtc::Optional<VideoCodecType>(kVideoCodecRED); | 141 return rtc::Optional<VideoCodecType>(kVideoCodecRED); |
136 if (name == kPayloadNameULPFEC) | 142 if (CodecNamesEq(name.c_str(), kPayloadNameULPFEC)) |
137 return rtc::Optional<VideoCodecType>(kVideoCodecULPFEC); | 143 return rtc::Optional<VideoCodecType>(kVideoCodecULPFEC); |
138 if (name == kPayloadNameGeneric) | 144 if (CodecNamesEq(name.c_str(), kPayloadNameGeneric)) |
139 return rtc::Optional<VideoCodecType>(kVideoCodecGeneric); | 145 return rtc::Optional<VideoCodecType>(kVideoCodecGeneric); |
140 return rtc::Optional<VideoCodecType>(); | 146 return rtc::Optional<VideoCodecType>(); |
141 } | 147 } |
142 | 148 |
143 const uint32_t BitrateAllocation::kMaxBitrateBps = | 149 const uint32_t BitrateAllocation::kMaxBitrateBps = |
144 std::numeric_limits<uint32_t>::max(); | 150 std::numeric_limits<uint32_t>::max(); |
145 | 151 |
146 BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{} {} | 152 BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{} {} |
147 | 153 |
148 bool BitrateAllocation::SetBitrate(size_t spatial_index, | 154 bool BitrateAllocation::SetBitrate(size_t spatial_index, |
(...skipping 23 matching lines...) Expand all Loading... |
172 // Get the sum of all the temporal layer for a specific spatial layer. | 178 // Get the sum of all the temporal layer for a specific spatial layer. |
173 uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const { | 179 uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const { |
174 RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers)); | 180 RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers)); |
175 uint32_t sum = 0; | 181 uint32_t sum = 0; |
176 for (int i = 0; i < kMaxTemporalStreams; ++i) | 182 for (int i = 0; i < kMaxTemporalStreams; ++i) |
177 sum += bitrates_[spatial_index][i]; | 183 sum += bitrates_[spatial_index][i]; |
178 return sum; | 184 return sum; |
179 } | 185 } |
180 | 186 |
181 } // namespace webrtc | 187 } // namespace webrtc |
OLD | NEW |