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_encoder_factory.h" 12 13 #include <memory> 14 #include <vector> 15 16 #include "api/audio_codecs/audio_encoder_factory_template.h" 17 #include "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h" 18 #include "api/audio_codecs/opus/audio_encoder_opus.h" 19 20 namespace webrtc { 21 namespace { 22 23 // Modify an audio encoder to not advertise support for anything. 24 template <typename T> 25 struct NotAdvertised { 26 using Config = typename T::Config; SdpToConfigwebrtc::__anon6c7e7d4a0111::NotAdvertised27 static absl::optional<Config> SdpToConfig( 28 const SdpAudioFormat& audio_format) { 29 return T::SdpToConfig(audio_format); 30 } AppendSupportedEncoderswebrtc::__anon6c7e7d4a0111::NotAdvertised31 static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) { 32 // Don't advertise support for anything. 33 } QueryAudioEncoderwebrtc::__anon6c7e7d4a0111::NotAdvertised34 static AudioCodecInfo QueryAudioEncoder(const Config& config) { 35 return T::QueryAudioEncoder(config); 36 } MakeAudioEncoderwebrtc::__anon6c7e7d4a0111::NotAdvertised37 static std::unique_ptr<AudioEncoder> MakeAudioEncoder( 38 const Config& config, 39 int payload_type, 40 absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) { 41 return T::MakeAudioEncoder(config, payload_type, codec_pair_id); 42 } 43 }; 44 45 } // namespace 46 CreateOpusAudioEncoderFactory()47rtc::scoped_refptr<AudioEncoderFactory> CreateOpusAudioEncoderFactory() { 48 return CreateAudioEncoderFactory< 49 AudioEncoderOpus, NotAdvertised<AudioEncoderMultiChannelOpus>>(); 50 } 51 52 } // namespace webrtc 53