blob: e3ca1b0e06d2081b7bc9eb95ef50eb07364b8d1f [file] [log] [blame]
kwiberg087bd342017-02-10 16:15:441/*
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 Bonadei92ea95e2017-09-15 04:47:3111#include "api/audio_codecs/builtin_audio_decoder_factory.h"
kwiberg087bd342017-02-10 16:15:4412
kwiberge5eb7242017-08-25 10:10:5013#include <memory>
14#include <vector>
15
Mirko Bonadei92ea95e2017-09-15 04:47:3116#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 Wibergeb254b42017-11-01 14:08:1219#include "api/audio_codecs/g722/audio_decoder_g722.h"
kwiberge5eb7242017-08-25 10:10:5020#if WEBRTC_USE_BUILTIN_ILBC
Mirko Bonadei92ea95e2017-09-15 04:47:3121#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" // nogncheck
kwiberge5eb7242017-08-25 10:10:5022#endif
Karl Wibergeb254b42017-11-01 14:08:1223#include "api/audio_codecs/isac/audio_decoder_isac.h"
kwiberge5eb7242017-08-25 10:10:5024#if WEBRTC_USE_BUILTIN_OPUS
Mirko Bonadei92ea95e2017-09-15 04:47:3125#include "api/audio_codecs/opus/audio_decoder_opus.h" // nogncheck
kwiberge5eb7242017-08-25 10:10:5026#endif
kwiberg087bd342017-02-10 16:15:4427
28namespace webrtc {
29
kwiberge5eb7242017-08-25 10:10:5030namespace {
31
32// Modify an audio decoder to not advertise support for anything.
33template <typename T>
34struct NotAdvertised {
35 using Config = typename T::Config;
Danil Chapovalov0bc58cf2018-06-21 11:32:5636 static absl::optional<Config> SdpToConfig(
37 const SdpAudioFormat& audio_format) {
kwiberge5eb7242017-08-25 10:10:5038 return T::SdpToConfig(audio_format);
39 }
40 static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) {
41 // Don't advertise support for anything.
42 }
Karl Wiberg17668ec2018-03-01 14:13:2743 static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
44 const Config& config,
Danil Chapovalov0bc58cf2018-06-21 11:32:5645 absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) {
Karl Wiberg17668ec2018-03-01 14:13:2746 return T::MakeAudioDecoder(config, codec_pair_id);
kwiberge5eb7242017-08-25 10:10:5047 }
48};
49
50} // namespace
51
kwiberg087bd342017-02-10 16:15:4452rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() {
kwiberge5eb7242017-08-25 10:10:5053 return CreateAudioDecoderFactory<
54
55#if WEBRTC_USE_BUILTIN_OPUS
56 AudioDecoderOpus,
57#endif
58
Karl Wibergeb254b42017-11-01 14:08:1259 AudioDecoderIsac, AudioDecoderG722,
kwiberge5eb7242017-08-25 10:10:5060
61#if WEBRTC_USE_BUILTIN_ILBC
62 AudioDecoderIlbc,
63#endif
64
65 AudioDecoderG711, NotAdvertised<AudioDecoderL16>>();
kwiberg087bd342017-02-10 16:15:4466}
67
68} // namespace webrtc