2019-11-26 14:00:41 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "api/audio_codecs/opus_audio_decoder_factory.h"
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
2024-08-29 13:00:40 +00:00
|
|
|
#include <optional>
|
2019-11-26 14:00:41 +01:00
|
|
|
#include <vector>
|
|
|
|
|
|
2024-06-17 12:27:24 +00:00
|
|
|
#include "api/audio_codecs/audio_codec_pair_id.h"
|
|
|
|
|
#include "api/audio_codecs/audio_decoder.h"
|
|
|
|
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
2019-11-26 14:00:41 +01:00
|
|
|
#include "api/audio_codecs/audio_decoder_factory_template.h"
|
2024-06-17 12:27:24 +00:00
|
|
|
#include "api/audio_codecs/audio_format.h"
|
2019-11-26 14:00:41 +01:00
|
|
|
#include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h"
|
|
|
|
|
#include "api/audio_codecs/opus/audio_decoder_opus.h"
|
2024-06-17 12:27:24 +00:00
|
|
|
#include "api/scoped_refptr.h"
|
2019-11-26 14:00:41 +01:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
// Modify an audio decoder to not advertise support for anything.
|
|
|
|
|
template <typename T>
|
|
|
|
|
struct NotAdvertised {
|
|
|
|
|
using Config = typename T::Config;
|
2024-08-29 13:00:40 +00:00
|
|
|
static std::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format) {
|
2019-11-26 14:00:41 +01:00
|
|
|
return T::SdpToConfig(audio_format);
|
|
|
|
|
}
|
2024-10-27 14:24:44 +02:00
|
|
|
static void AppendSupportedDecoders(
|
|
|
|
|
std::vector<AudioCodecSpec>* /* specs */) {
|
2019-11-26 14:00:41 +01:00
|
|
|
// Don't advertise support for anything.
|
|
|
|
|
}
|
|
|
|
|
static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
|
|
|
|
|
const Config& config,
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<AudioCodecPairId> codec_pair_id = std::nullopt) {
|
2019-11-26 14:00:41 +01:00
|
|
|
return T::MakeAudioDecoder(config, codec_pair_id);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<AudioDecoderFactory> CreateOpusAudioDecoderFactory() {
|
|
|
|
|
return CreateAudioDecoderFactory<
|
|
|
|
|
AudioDecoderOpus, NotAdvertised<AudioDecoderMultiChannelOpus>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|