1 /* 2 * Copyright (c) 2019 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/opus_audio_decoder_factory.h" 12 13 #include <memory> 14 #include <vector> 15 16 #include "api/audio_codecs/audio_decoder_factory_template.h" 17 #include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h" 18 #include "api/audio_codecs/opus/audio_decoder_opus.h" 19 20 namespace webrtc { 21 22 namespace { 23 24 // Modify an audio decoder to not advertise support for anything. 25 template <typename T> 26 struct NotAdvertised { 27 using Config = typename T::Config; SdpToConfigwebrtc::__anon54bf69200111::NotAdvertised28 static absl::optional<Config> SdpToConfig( 29 const SdpAudioFormat& audio_format) { 30 return T::SdpToConfig(audio_format); 31 } AppendSupportedDecoderswebrtc::__anon54bf69200111::NotAdvertised32 static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) { 33 // Don't advertise support for anything. 34 } MakeAudioDecoderwebrtc::__anon54bf69200111::NotAdvertised35 static std::unique_ptr<AudioDecoder> MakeAudioDecoder( 36 const Config& config, 37 absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) { 38 return T::MakeAudioDecoder(config, codec_pair_id); 39 } 40 }; 41 42 } // namespace 43 CreateOpusAudioDecoderFactory()44rtc::scoped_refptr<AudioDecoderFactory> CreateOpusAudioDecoderFactory() { 45 return CreateAudioDecoderFactory< 46 AudioDecoderOpus, NotAdvertised<AudioDecoderMultiChannelOpus>>(); 47 } 48 49 } // namespace webrtc 50