Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: webrtc/common_types.cc

Issue 2998293002: Make CodecType conversion functions non-optional. (Closed)
Patch Set: Keep old functions for backwards-compat Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/common_types.h ('k') | webrtc/media/engine/internalencoderfactory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 static const char* kPayloadNameH264 = "H264"; 125 static const char* kPayloadNameH264 = "H264";
126 static const char* kPayloadNameI420 = "I420"; 126 static const char* kPayloadNameI420 = "I420";
127 static const char* kPayloadNameRED = "RED"; 127 static const char* kPayloadNameRED = "RED";
128 static const char* kPayloadNameULPFEC = "ULPFEC"; 128 static const char* kPayloadNameULPFEC = "ULPFEC";
129 static const char* kPayloadNameGeneric = "Generic"; 129 static const char* kPayloadNameGeneric = "Generic";
130 130
131 static bool CodecNamesEq(const char* name1, const char* name2) { 131 static bool CodecNamesEq(const char* name1, const char* name2) {
132 return _stricmp(name1, name2) == 0; 132 return _stricmp(name1, name2) == 0;
133 } 133 }
134 134
135 rtc::Optional<const char*> CodecTypeToPayloadName(VideoCodecType type) { 135 const char* CodecTypeToPayloadString(VideoCodecType type) {
136 switch (type) { 136 switch (type) {
137 case kVideoCodecVP8: 137 case kVideoCodecVP8:
138 return rtc::Optional<const char*>(kPayloadNameVp8); 138 return kPayloadNameVp8;
139 case kVideoCodecVP9: 139 case kVideoCodecVP9:
140 return rtc::Optional<const char*>(kPayloadNameVp9); 140 return kPayloadNameVp9;
141 case kVideoCodecH264: 141 case kVideoCodecH264:
142 return rtc::Optional<const char*>(kPayloadNameH264); 142 return kPayloadNameH264;
143 case kVideoCodecI420: 143 case kVideoCodecI420:
144 return rtc::Optional<const char*>(kPayloadNameI420); 144 return kPayloadNameI420;
145 case kVideoCodecRED: 145 case kVideoCodecRED:
146 return rtc::Optional<const char*>(kPayloadNameRED); 146 return kPayloadNameRED;
147 case kVideoCodecULPFEC: 147 case kVideoCodecULPFEC:
148 return rtc::Optional<const char*>(kPayloadNameULPFEC); 148 return kPayloadNameULPFEC;
149 case kVideoCodecGeneric:
150 return rtc::Optional<const char*>(kPayloadNameGeneric);
151 default: 149 default:
152 return rtc::Optional<const char*>(); 150 // Unrecognized codecs default to generic.
151 return kPayloadNameGeneric;
153 } 152 }
154 } 153 }
155 154
155 VideoCodecType PayloadStringToCodecType(const std::string& name) {
156 if (CodecNamesEq(name.c_str(), kPayloadNameVp8))
157 return kVideoCodecVP8;
158 if (CodecNamesEq(name.c_str(), kPayloadNameVp9))
159 return kVideoCodecVP9;
160 if (CodecNamesEq(name.c_str(), kPayloadNameH264))
161 return kVideoCodecH264;
162 if (CodecNamesEq(name.c_str(), kPayloadNameI420))
163 return kVideoCodecI420;
164 if (CodecNamesEq(name.c_str(), kPayloadNameRED))
165 return kVideoCodecRED;
166 if (CodecNamesEq(name.c_str(), kPayloadNameULPFEC))
167 return kVideoCodecULPFEC;
168 return kVideoCodecGeneric;
169 }
170
171 // TODO(kthelgason): Remove these methods once upstream projects
172 // have been updated.
173 rtc::Optional<const char*> CodecTypeToPayloadName(VideoCodecType type) {
174 return rtc::Optional<const char*>(CodecTypeToPayloadString(type));
175 }
176
156 rtc::Optional<VideoCodecType> PayloadNameToCodecType(const std::string& name) { 177 rtc::Optional<VideoCodecType> PayloadNameToCodecType(const std::string& name) {
157 if (CodecNamesEq(name.c_str(), kPayloadNameVp8)) 178 return rtc::Optional<VideoCodecType>(PayloadStringToCodecType(name));
158 return rtc::Optional<VideoCodecType>(kVideoCodecVP8);
159 if (CodecNamesEq(name.c_str(), kPayloadNameVp9))
160 return rtc::Optional<VideoCodecType>(kVideoCodecVP9);
161 if (CodecNamesEq(name.c_str(), kPayloadNameH264))
162 return rtc::Optional<VideoCodecType>(kVideoCodecH264);
163 if (CodecNamesEq(name.c_str(), kPayloadNameI420))
164 return rtc::Optional<VideoCodecType>(kVideoCodecI420);
165 if (CodecNamesEq(name.c_str(), kPayloadNameRED))
166 return rtc::Optional<VideoCodecType>(kVideoCodecRED);
167 if (CodecNamesEq(name.c_str(), kPayloadNameULPFEC))
168 return rtc::Optional<VideoCodecType>(kVideoCodecULPFEC);
169 if (CodecNamesEq(name.c_str(), kPayloadNameGeneric))
170 return rtc::Optional<VideoCodecType>(kVideoCodecGeneric);
171 return rtc::Optional<VideoCodecType>();
172 } 179 }
173 180
174 const uint32_t BitrateAllocation::kMaxBitrateBps = 181 const uint32_t BitrateAllocation::kMaxBitrateBps =
175 std::numeric_limits<uint32_t>::max(); 182 std::numeric_limits<uint32_t>::max();
176 183
177 BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{} {} 184 BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{} {}
178 185
179 bool BitrateAllocation::SetBitrate(size_t spatial_index, 186 bool BitrateAllocation::SetBitrate(size_t spatial_index,
180 size_t temporal_index, 187 size_t temporal_index,
181 uint32_t bitrate_bps) { 188 uint32_t bitrate_bps) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 oss << " ]"; 259 oss << " ]";
253 return oss.str(); 260 return oss.str();
254 } 261 }
255 262
256 std::ostream& BitrateAllocation::operator<<(std::ostream& os) const { 263 std::ostream& BitrateAllocation::operator<<(std::ostream& os) const {
257 os << ToString(); 264 os << ToString();
258 return os; 265 return os;
259 } 266 }
260 267
261 } // namespace webrtc 268 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_types.h ('k') | webrtc/media/engine/internalencoderfactory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698