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 11 #include "api/audio_codecs/builtin_audio_decoder_factory.h" 12 13 #include <memory> 14 #include <vector> 15 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" 19 #include "api/audio_codecs/g722/audio_decoder_g722.h" 20 #if WEBRTC_USE_BUILTIN_ILBC 21 #include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" // nogncheck 22 #endif 23 #if WEBRTC_USE_BUILTIN_OPUS 24 #include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h" 25 #include "api/audio_codecs/opus/audio_decoder_opus.h" // nogncheck 26 #endif 27 28 namespace webrtc { 29 30 namespace { 31 32 // Modify an audio decoder to not advertise support for anything. 33 template <typename T> 34 struct NotAdvertised { 35 using Config = typename T::Config; SdpToConfigwebrtc::__anonb11bc8ff0111::NotAdvertised36 static absl::optional<Config> SdpToConfig( 37 const SdpAudioFormat& audio_format) { 38 return T::SdpToConfig(audio_format); 39 } AppendSupportedDecoderswebrtc::__anonb11bc8ff0111::NotAdvertised40 static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) { 41 // Don't advertise support for anything. 42 } MakeAudioDecoderwebrtc::__anonb11bc8ff0111::NotAdvertised43 static std::unique_ptr<AudioDecoder> MakeAudioDecoder( 44 const Config& config, 45 absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) { 46 return T::MakeAudioDecoder(config, codec_pair_id); 47 } 48 }; 49 50 } // namespace 51 CreateBuiltinAudioDecoderFactory()52rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() { 53 return CreateAudioDecoderFactory< 54 55 #if WEBRTC_USE_BUILTIN_OPUS 56 AudioDecoderOpus, NotAdvertised<AudioDecoderMultiChannelOpus>, 57 #endif 58 59 AudioDecoderG722, 60 61 #if WEBRTC_USE_BUILTIN_ILBC 62 AudioDecoderIlbc, 63 #endif 64 65 AudioDecoderG711, NotAdvertised<AudioDecoderL16>>(); 66 } 67 68 } // namespace webrtc 69