| 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 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } else { | 167 } else { |
| 168 return false; | 168 return false; |
| 169 } | 169 } |
| 170 }}, | 170 }}, |
| 171 #endif | 171 #endif |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 class BuiltinAudioDecoderFactory : public AudioDecoderFactory { | 174 class BuiltinAudioDecoderFactory : public AudioDecoderFactory { |
| 175 public: | 175 public: |
| 176 std::vector<AudioCodecSpec> GetSupportedDecoders() override { | 176 std::vector<AudioCodecSpec> GetSupportedDecoders() override { |
| 177 static std::vector<AudioCodecSpec> specs = { | 177 // Although this looks a bit strange, it means specs need only be initalized |
| 178 // once, and that that initialization is thread-safe. |
| 179 static std::vector<AudioCodecSpec> specs = |
| 180 []{ |
| 181 std::vector<AudioCodecSpec> specs; |
| 178 #ifdef WEBRTC_CODEC_OPUS | 182 #ifdef WEBRTC_CODEC_OPUS |
| 179 { { "opus", 48000, 2, { | 183 AudioCodecSpec opus({"opus", 48000, 2, { |
| 180 {"minptime", "10" }, | 184 {"minptime", "10"}, |
| 181 {"useinbandfec", "1" } | 185 {"useinbandfec", "1"} |
| 182 } | 186 }}); |
| 183 }, false | 187 opus.allow_comfort_noise = false; |
| 184 }, | 188 opus.supports_network_adaption = true; |
| 189 specs.push_back(opus); |
| 185 #endif | 190 #endif |
| 186 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) | 191 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) |
| 187 {{"isac", 16000, 1}, true}, | 192 specs.push_back(AudioCodecSpec({"isac", 16000, 1})); |
| 188 #endif | 193 #endif |
| 189 #if (defined(WEBRTC_CODEC_ISAC)) | 194 #if (defined(WEBRTC_CODEC_ISAC)) |
| 190 {{"isac", 32000, 1}, true}, | 195 specs.push_back(AudioCodecSpec({"isac", 32000, 1})); |
| 191 #endif | 196 #endif |
| 192 #ifdef WEBRTC_CODEC_G722 | 197 #ifdef WEBRTC_CODEC_G722 |
| 193 {{"G722", 8000, 1}, true}, | 198 specs.push_back(AudioCodecSpec({"G722", 8000, 1})); |
| 194 #endif | 199 #endif |
| 195 #ifdef WEBRTC_CODEC_ILBC | 200 #ifdef WEBRTC_CODEC_ILBC |
| 196 {{"iLBC", 8000, 1}, true}, | 201 specs.push_back(AudioCodecSpec({"iLBC", 8000, 1})); |
| 197 #endif | 202 #endif |
| 198 {{"PCMU", 8000, 1}, true}, | 203 specs.push_back(AudioCodecSpec({"PCMU", 8000, 1})); |
| 199 {{"PCMA", 8000, 1}, true} | 204 specs.push_back(AudioCodecSpec({"PCMA", 8000, 1})); |
| 200 }; | 205 return specs; |
| 201 | 206 }(); |
| 202 return specs; | 207 return specs; |
| 203 } | 208 } |
| 204 | 209 |
| 205 bool IsSupportedDecoder(const SdpAudioFormat& format) override { | 210 bool IsSupportedDecoder(const SdpAudioFormat& format) override { |
| 206 for (const auto& dc : decoder_constructors) { | 211 for (const auto& dc : decoder_constructors) { |
| 207 if (STR_CASE_CMP(format.name.c_str(), dc.name) == 0) { | 212 if (STR_CASE_CMP(format.name.c_str(), dc.name) == 0) { |
| 208 return dc.constructor(format, nullptr); | 213 return dc.constructor(format, nullptr); |
| 209 } | 214 } |
| 210 } | 215 } |
| 211 return false; | 216 return false; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 233 }; | 238 }; |
| 234 | 239 |
| 235 } // namespace | 240 } // namespace |
| 236 | 241 |
| 237 rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() { | 242 rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() { |
| 238 return rtc::scoped_refptr<AudioDecoderFactory>( | 243 return rtc::scoped_refptr<AudioDecoderFactory>( |
| 239 new rtc::RefCountedObject<BuiltinAudioDecoderFactory>); | 244 new rtc::RefCountedObject<BuiltinAudioDecoderFactory>); |
| 240 } | 245 } |
| 241 | 246 |
| 242 } // namespace webrtc | 247 } // namespace webrtc |
| OLD | NEW |