kwiberg | 087bd34 | 2017-02-10 16:15:44 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #include "api/audio_codecs/builtin_audio_decoder_factory.h" |
kwiberg | 087bd34 | 2017-02-10 16:15:44 | [diff] [blame] | 12 | |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 13 | #include <memory> |
| 14 | #include <vector> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 16 | #include "api/audio_codecs/L16/audio_decoder_L16.h" |
| 17 | #include "api/audio_codecs/audio_decoder_factory_template.h" |
| 18 | #include "api/audio_codecs/g711/audio_decoder_g711.h" |
Karl Wiberg | eb254b4 | 2017-11-01 14:08:12 | [diff] [blame] | 19 | #include "api/audio_codecs/g722/audio_decoder_g722.h" |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 20 | #if WEBRTC_USE_BUILTIN_ILBC |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 21 | #include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" // nogncheck |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 22 | #endif |
Karl Wiberg | eb254b4 | 2017-11-01 14:08:12 | [diff] [blame] | 23 | #include "api/audio_codecs/isac/audio_decoder_isac.h" |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 24 | #if WEBRTC_USE_BUILTIN_OPUS |
Alex Loiko | e5b9416 | 2019-04-08 15:19:41 | [diff] [blame] | 25 | #include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 26 | #include "api/audio_codecs/opus/audio_decoder_opus.h" // nogncheck |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 27 | #endif |
kwiberg | 087bd34 | 2017-02-10 16:15:44 | [diff] [blame] | 28 | |
| 29 | namespace webrtc { |
| 30 | |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 31 | namespace { |
| 32 | |
| 33 | // Modify an audio decoder to not advertise support for anything. |
| 34 | template <typename T> |
| 35 | struct NotAdvertised { |
| 36 | using Config = typename T::Config; |
Danil Chapovalov | 0bc58cf | 2018-06-21 11:32:56 | [diff] [blame] | 37 | static absl::optional<Config> SdpToConfig( |
| 38 | const SdpAudioFormat& audio_format) { |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 39 | return T::SdpToConfig(audio_format); |
| 40 | } |
| 41 | static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) { |
| 42 | // Don't advertise support for anything. |
| 43 | } |
Karl Wiberg | 17668ec | 2018-03-01 14:13:27 | [diff] [blame] | 44 | static std::unique_ptr<AudioDecoder> MakeAudioDecoder( |
| 45 | const Config& config, |
Danil Chapovalov | 0bc58cf | 2018-06-21 11:32:56 | [diff] [blame] | 46 | absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) { |
Karl Wiberg | 17668ec | 2018-03-01 14:13:27 | [diff] [blame] | 47 | return T::MakeAudioDecoder(config, codec_pair_id); |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 48 | } |
| 49 | }; |
| 50 | |
| 51 | } // namespace |
| 52 | |
kwiberg | 087bd34 | 2017-02-10 16:15:44 | [diff] [blame] | 53 | rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() { |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 54 | return CreateAudioDecoderFactory< |
| 55 | |
| 56 | #if WEBRTC_USE_BUILTIN_OPUS |
Alex Loiko | e5b9416 | 2019-04-08 15:19:41 | [diff] [blame] | 57 | AudioDecoderOpus, NotAdvertised<AudioDecoderMultiChannelOpus>, |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 58 | #endif |
| 59 | |
Karl Wiberg | eb254b4 | 2017-11-01 14:08:12 | [diff] [blame] | 60 | AudioDecoderIsac, AudioDecoderG722, |
kwiberg | e5eb724 | 2017-08-25 10:10:50 | [diff] [blame] | 61 | |
| 62 | #if WEBRTC_USE_BUILTIN_ILBC |
| 63 | AudioDecoderIlbc, |
| 64 | #endif |
| 65 | |
| 66 | AudioDecoderG711, NotAdvertised<AudioDecoderL16>>(); |
kwiberg | 087bd34 | 2017-02-10 16:15:44 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | } // namespace webrtc |