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

Side by Side Diff: webrtc/modules/audio_coding/main/acm2/rent_a_codec.h

Issue 1407383010: Correctly handle the error case where the CodecId has a negative value (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | no next file » | 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 kDecoderArbitrary, 125 kDecoderArbitrary,
126 kDecoderOpus, 126 kDecoderOpus,
127 kDecoderOpus_2ch, 127 kDecoderOpus_2ch,
128 }; 128 };
129 129
130 static inline size_t NumberOfCodecs() { 130 static inline size_t NumberOfCodecs() {
131 return static_cast<size_t>(CodecId::kNumCodecs); 131 return static_cast<size_t>(CodecId::kNumCodecs);
132 } 132 }
133 133
134 static inline rtc::Maybe<int> CodecIndexFromId(CodecId codec_id) { 134 static inline rtc::Maybe<int> CodecIndexFromId(CodecId codec_id) {
135 const int i = static_cast<int>(codec_id); 135 const size_t i = static_cast<size_t>(codec_id);
hlundin-webrtc 2015/11/04 11:03:42 No sir, I didn't like it. I prefer augmenting the
kwiberg-webrtc 2015/11/04 14:27:59 Done.
136 return i < static_cast<int>(NumberOfCodecs()) ? rtc::Maybe<int>(i) 136 return i < NumberOfCodecs() ? rtc::Maybe<int>(static_cast<int>(i))
137 : rtc::Maybe<int>(); 137 : rtc::Maybe<int>();
138 } 138 }
139 139
140 static inline rtc::Maybe<CodecId> CodecIdFromIndex(int codec_index) { 140 static inline rtc::Maybe<CodecId> CodecIdFromIndex(int codec_index) {
141 return static_cast<size_t>(codec_index) < NumberOfCodecs() 141 return static_cast<size_t>(codec_index) < NumberOfCodecs()
142 ? rtc::Maybe<RentACodec::CodecId>( 142 ? rtc::Maybe<RentACodec::CodecId>(
143 static_cast<RentACodec::CodecId>(codec_index)) 143 static_cast<RentACodec::CodecId>(codec_index))
144 : rtc::Maybe<RentACodec::CodecId>(); 144 : rtc::Maybe<RentACodec::CodecId>();
145 } 145 }
146 146
147 static rtc::Maybe<CodecId> CodecIdByParams(const char* payload_name, 147 static rtc::Maybe<CodecId> CodecIdByParams(const char* payload_name,
(...skipping 10 matching lines...) Expand all
158 int num_channels); 158 int num_channels);
159 159
160 static rtc::Maybe<NetEqDecoder> NetEqDecoderFromCodecId(CodecId codec_id, 160 static rtc::Maybe<NetEqDecoder> NetEqDecoderFromCodecId(CodecId codec_id,
161 int num_channels); 161 int num_channels);
162 }; 162 };
163 163
164 } // namespace acm2 164 } // namespace acm2
165 } // namespace webrtc 165 } // namespace webrtc
166 166
167 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_ 167 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698