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_encoder_factory.h"
12
13 #include <memory>
14 #include <vector>
15
16 #include "api/audio_codecs/L16/audio_encoder_L16.h"
17 #include "api/audio_codecs/audio_encoder_factory_template.h"
18 #include "api/audio_codecs/g711/audio_encoder_g711.h"
19 #include "api/audio_codecs/g722/audio_encoder_g722.h"
20 #if WEBRTC_USE_BUILTIN_ILBC
21 #include "api/audio_codecs/ilbc/audio_encoder_ilbc.h" // nogncheck
22 #endif
23 #include "api/audio_codecs/isac/audio_encoder_isac.h"
24 #if WEBRTC_USE_BUILTIN_OPUS
25 #include "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h"
26 #include "api/audio_codecs/opus/audio_encoder_opus.h" // nogncheck
27 #endif
28
29 namespace webrtc {
30
31 namespace {
32
33 // Modify an audio encoder to not advertise support for anything.
34 template <typename T>
35 struct NotAdvertised {
36 using Config = typename T::Config;
SdpToConfigwebrtc::__anon9e8b74fa0111::NotAdvertised37 static absl::optional<Config> SdpToConfig(
38 const SdpAudioFormat& audio_format) {
39 return T::SdpToConfig(audio_format);
40 }
AppendSupportedEncoderswebrtc::__anon9e8b74fa0111::NotAdvertised41 static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) {
42 // Don't advertise support for anything.
43 }
QueryAudioEncoderwebrtc::__anon9e8b74fa0111::NotAdvertised44 static AudioCodecInfo QueryAudioEncoder(const Config& config) {
45 return T::QueryAudioEncoder(config);
46 }
MakeAudioEncoderwebrtc::__anon9e8b74fa0111::NotAdvertised47 static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
48 const Config& config,
49 int payload_type,
50 absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) {
51 return T::MakeAudioEncoder(config, payload_type, codec_pair_id);
52 }
53 };
54
55 } // namespace
56
CreateBuiltinAudioEncoderFactory()57 rtc::scoped_refptr<AudioEncoderFactory> CreateBuiltinAudioEncoderFactory() {
58 return CreateAudioEncoderFactory<
59
60 #if WEBRTC_USE_BUILTIN_OPUS
61 AudioEncoderOpus, NotAdvertised<AudioEncoderMultiChannelOpus>,
62 #endif
63
64 AudioEncoderIsac, AudioEncoderG722,
65
66 #if WEBRTC_USE_BUILTIN_ILBC
67 AudioEncoderIlbc,
68 #endif
69
70 AudioEncoderG711, NotAdvertised<AudioEncoderL16>>();
71 }
72
73 } // namespace webrtc
74