OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" | 11 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory_inter
nal.h" |
12 | 12 |
| 13 #include <memory> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/optional.h" | 17 #include "webrtc/base/optional.h" |
17 #include "webrtc/common_types.h" | 18 #include "webrtc/common_types.h" |
18 #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" | 19 #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" |
19 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" | 20 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" |
20 #ifdef WEBRTC_CODEC_G722 | 21 #ifdef WEBRTC_CODEC_G722 |
21 #include "webrtc/modules/audio_coding/codecs/g722/audio_decoder_g722.h" | 22 #include "webrtc/modules/audio_coding/codecs/g722/audio_decoder_g722.h" |
22 #endif | 23 #endif |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 170 } |
170 }}, | 171 }}, |
171 #endif | 172 #endif |
172 }; | 173 }; |
173 | 174 |
174 class BuiltinAudioDecoderFactory : public AudioDecoderFactory { | 175 class BuiltinAudioDecoderFactory : public AudioDecoderFactory { |
175 public: | 176 public: |
176 std::vector<AudioCodecSpec> GetSupportedDecoders() override { | 177 std::vector<AudioCodecSpec> GetSupportedDecoders() override { |
177 // Although this looks a bit strange, it means specs need only be initalized | 178 // Although this looks a bit strange, it means specs need only be initalized |
178 // once, and that that initialization is thread-safe. | 179 // once, and that that initialization is thread-safe. |
179 static std::vector<AudioCodecSpec> specs = | 180 static std::vector<AudioCodecSpec> specs = [] { |
180 []{ | 181 std::vector<AudioCodecSpec> specs; |
181 std::vector<AudioCodecSpec> specs; | |
182 #ifdef WEBRTC_CODEC_OPUS | 182 #ifdef WEBRTC_CODEC_OPUS |
183 AudioCodecSpec opus({"opus", 48000, 2, { | 183 // clang-format off |
184 {"minptime", "10"}, | 184 AudioCodecSpec opus({"opus", 48000, 2, { |
185 {"useinbandfec", "1"} | 185 {"minptime", "10"}, |
186 }}); | 186 {"useinbandfec", "1"} |
187 opus.allow_comfort_noise = false; | 187 }}); |
188 opus.supports_network_adaption = true; | 188 // clang-format on |
189 specs.push_back(opus); | 189 opus.allow_comfort_noise = false; |
| 190 opus.supports_network_adaption = true; |
| 191 specs.push_back(opus); |
190 #endif | 192 #endif |
191 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) | 193 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) |
192 specs.push_back(AudioCodecSpec({"isac", 16000, 1})); | 194 specs.push_back(AudioCodecSpec({"isac", 16000, 1})); |
193 #endif | 195 #endif |
194 #if (defined(WEBRTC_CODEC_ISAC)) | 196 #if (defined(WEBRTC_CODEC_ISAC)) |
195 specs.push_back(AudioCodecSpec({"isac", 32000, 1})); | 197 specs.push_back(AudioCodecSpec({"isac", 32000, 1})); |
196 #endif | 198 #endif |
197 #ifdef WEBRTC_CODEC_G722 | 199 #ifdef WEBRTC_CODEC_G722 |
198 specs.push_back(AudioCodecSpec({"G722", 8000, 1})); | 200 specs.push_back(AudioCodecSpec({"G722", 8000, 1})); |
199 #endif | 201 #endif |
200 #ifdef WEBRTC_CODEC_ILBC | 202 #ifdef WEBRTC_CODEC_ILBC |
201 specs.push_back(AudioCodecSpec({"iLBC", 8000, 1})); | 203 specs.push_back(AudioCodecSpec({"iLBC", 8000, 1})); |
202 #endif | 204 #endif |
203 specs.push_back(AudioCodecSpec({"PCMU", 8000, 1})); | 205 specs.push_back(AudioCodecSpec({"PCMU", 8000, 1})); |
204 specs.push_back(AudioCodecSpec({"PCMA", 8000, 1})); | 206 specs.push_back(AudioCodecSpec({"PCMA", 8000, 1})); |
205 return specs; | 207 return specs; |
206 }(); | 208 }(); |
207 return specs; | 209 return specs; |
208 } | 210 } |
209 | 211 |
210 bool IsSupportedDecoder(const SdpAudioFormat& format) override { | 212 bool IsSupportedDecoder(const SdpAudioFormat& format) override { |
211 for (const auto& dc : decoder_constructors) { | 213 for (const auto& dc : decoder_constructors) { |
212 if (STR_CASE_CMP(format.name.c_str(), dc.name) == 0) { | 214 if (STR_CASE_CMP(format.name.c_str(), dc.name) == 0) { |
213 return dc.constructor(format, nullptr); | 215 return dc.constructor(format, nullptr); |
214 } | 216 } |
215 } | 217 } |
216 return false; | 218 return false; |
(...skipping 15 matching lines...) Expand all Loading... |
232 } | 234 } |
233 return decoder; | 235 return decoder; |
234 } | 236 } |
235 } | 237 } |
236 return nullptr; | 238 return nullptr; |
237 } | 239 } |
238 }; | 240 }; |
239 | 241 |
240 } // namespace | 242 } // namespace |
241 | 243 |
242 rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() { | 244 rtc::scoped_refptr<AudioDecoderFactory> |
| 245 CreateBuiltinAudioDecoderFactoryInternal() { |
243 return rtc::scoped_refptr<AudioDecoderFactory>( | 246 return rtc::scoped_refptr<AudioDecoderFactory>( |
244 new rtc::RefCountedObject<BuiltinAudioDecoderFactory>); | 247 new rtc::RefCountedObject<BuiltinAudioDecoderFactory>); |
245 } | 248 } |
246 | 249 |
247 } // namespace webrtc | 250 } // namespace webrtc |
OLD | NEW |