OLD | NEW |
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 |
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_ |
13 | 13 |
14 #include <stddef.h> | 14 #include <stddef.h> |
15 | 15 |
16 #include "webrtc/base/array_view.h" | 16 #include "webrtc/base/array_view.h" |
17 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
18 #include "webrtc/base/maybe.h" | 18 #include "webrtc/base/optional.h" |
19 #include "webrtc/base/scoped_ptr.h" | 19 #include "webrtc/base/scoped_ptr.h" |
20 #include "webrtc/typedefs.h" | 20 #include "webrtc/typedefs.h" |
21 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | 21 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" |
22 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" | 22 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" |
23 | 23 |
24 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) | 24 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
25 #include "webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h" | 25 #include "webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h" |
26 #else | 26 #else |
27 // Dummy implementation, for when we don't have iSAC. | 27 // Dummy implementation, for when we don't have iSAC. |
28 namespace webrtc { | 28 namespace webrtc { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 kDecoderCNGswb48kHz, | 137 kDecoderCNGswb48kHz, |
138 kDecoderArbitrary, | 138 kDecoderArbitrary, |
139 kDecoderOpus, | 139 kDecoderOpus, |
140 kDecoderOpus_2ch, | 140 kDecoderOpus_2ch, |
141 }; | 141 }; |
142 | 142 |
143 static inline size_t NumberOfCodecs() { | 143 static inline size_t NumberOfCodecs() { |
144 return static_cast<size_t>(CodecId::kNumCodecs); | 144 return static_cast<size_t>(CodecId::kNumCodecs); |
145 } | 145 } |
146 | 146 |
147 static inline rtc::Maybe<int> CodecIndexFromId(CodecId codec_id) { | 147 static inline rtc::Optional<int> CodecIndexFromId(CodecId codec_id) { |
148 const int i = static_cast<int>(codec_id); | 148 const int i = static_cast<int>(codec_id); |
149 return i >= 0 && i < static_cast<int>(NumberOfCodecs()) ? rtc::Maybe<int>(i) | 149 return i >= 0 && i < static_cast<int>(NumberOfCodecs()) |
150 : rtc::Maybe<int>(); | 150 ? rtc::Optional<int>(i) |
| 151 : rtc::Optional<int>(); |
151 } | 152 } |
152 | 153 |
153 static inline rtc::Maybe<CodecId> CodecIdFromIndex(int codec_index) { | 154 static inline rtc::Optional<CodecId> CodecIdFromIndex(int codec_index) { |
154 return static_cast<size_t>(codec_index) < NumberOfCodecs() | 155 return static_cast<size_t>(codec_index) < NumberOfCodecs() |
155 ? rtc::Maybe<RentACodec::CodecId>( | 156 ? rtc::Optional<RentACodec::CodecId>( |
156 static_cast<RentACodec::CodecId>(codec_index)) | 157 static_cast<RentACodec::CodecId>(codec_index)) |
157 : rtc::Maybe<RentACodec::CodecId>(); | 158 : rtc::Optional<RentACodec::CodecId>(); |
158 } | 159 } |
159 | 160 |
160 static rtc::Maybe<CodecId> CodecIdByParams(const char* payload_name, | 161 static rtc::Optional<CodecId> CodecIdByParams(const char* payload_name, |
161 int sampling_freq_hz, | 162 int sampling_freq_hz, |
162 int channels); | 163 int channels); |
163 static rtc::Maybe<CodecInst> CodecInstById(CodecId codec_id); | 164 static rtc::Optional<CodecInst> CodecInstById(CodecId codec_id); |
164 static rtc::Maybe<CodecId> CodecIdByInst(const CodecInst& codec_inst); | 165 static rtc::Optional<CodecId> CodecIdByInst(const CodecInst& codec_inst); |
165 static rtc::Maybe<CodecInst> CodecInstByParams(const char* payload_name, | 166 static rtc::Optional<CodecInst> CodecInstByParams(const char* payload_name, |
166 int sampling_freq_hz, | 167 int sampling_freq_hz, |
167 int channels); | 168 int channels); |
168 static bool IsCodecValid(const CodecInst& codec_inst); | 169 static bool IsCodecValid(const CodecInst& codec_inst); |
169 | 170 |
170 static inline bool IsPayloadTypeValid(int payload_type) { | 171 static inline bool IsPayloadTypeValid(int payload_type) { |
171 return payload_type >= 0 && payload_type <= 127; | 172 return payload_type >= 0 && payload_type <= 127; |
172 } | 173 } |
173 | 174 |
174 static rtc::ArrayView<const CodecInst> Database(); | 175 static rtc::ArrayView<const CodecInst> Database(); |
175 | 176 |
176 static rtc::Maybe<bool> IsSupportedNumChannels(CodecId codec_id, | 177 static rtc::Optional<bool> IsSupportedNumChannels(CodecId codec_id, |
177 int num_channels); | 178 int num_channels); |
178 | 179 |
179 static rtc::Maybe<NetEqDecoder> NetEqDecoderFromCodecId(CodecId codec_id, | 180 static rtc::Optional<NetEqDecoder> NetEqDecoderFromCodecId(CodecId codec_id, |
180 int num_channels); | 181 int num_channels); |
181 | 182 |
182 RentACodec(); | 183 RentACodec(); |
183 ~RentACodec(); | 184 ~RentACodec(); |
184 | 185 |
185 // Creates and returns an audio encoder built to the given specification. | 186 // Creates and returns an audio encoder built to the given specification. |
186 // Returns null in case of error. The returned encoder is live until the next | 187 // Returns null in case of error. The returned encoder is live until the next |
187 // successful call to this function, or until the Rent-A-Codec is destroyed. | 188 // successful call to this function, or until the Rent-A-Codec is destroyed. |
188 AudioEncoder* RentEncoder(const CodecInst& codec_inst); | 189 AudioEncoder* RentEncoder(const CodecInst& codec_inst); |
189 | 190 |
190 // Creates and returns an iSAC decoder, which will remain live until the | 191 // Creates and returns an iSAC decoder, which will remain live until the |
191 // Rent-A-Codec is destroyed. Subsequent calls will simply return the same | 192 // Rent-A-Codec is destroyed. Subsequent calls will simply return the same |
192 // object. | 193 // object. |
193 AudioDecoder* RentIsacDecoder(); | 194 AudioDecoder* RentIsacDecoder(); |
194 | 195 |
195 private: | 196 private: |
196 rtc::scoped_ptr<AudioEncoder> encoder_; | 197 rtc::scoped_ptr<AudioEncoder> encoder_; |
197 rtc::scoped_ptr<AudioDecoder> isac_decoder_; | 198 rtc::scoped_ptr<AudioDecoder> isac_decoder_; |
198 LockedIsacBandwidthInfo isac_bandwidth_info_; | 199 LockedIsacBandwidthInfo isac_bandwidth_info_; |
199 | 200 |
200 RTC_DISALLOW_COPY_AND_ASSIGN(RentACodec); | 201 RTC_DISALLOW_COPY_AND_ASSIGN(RentACodec); |
201 }; | 202 }; |
202 | 203 |
203 } // namespace acm2 | 204 } // namespace acm2 |
204 } // namespace webrtc | 205 } // namespace webrtc |
205 | 206 |
206 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_ | 207 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_ |
OLD | NEW |