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_encoder_factory.h"
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2024-06-17 12:27:24 +00:00
|
|
|
#include "absl/types/optional.h"
|
|
|
|
|
#include "api/audio_codecs/audio_codec_pair_id.h"
|
|
|
|
|
#include "api/audio_codecs/audio_encoder.h"
|
|
|
|
|
#include "api/audio_codecs/audio_encoder_factory.h"
|
2019-11-26 14:00:41 +01:00
|
|
|
#include "api/audio_codecs/audio_encoder_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_encoder_multi_channel_opus.h"
|
|
|
|
|
#include "api/audio_codecs/opus/audio_encoder_opus.h"
|
2024-06-17 12:27:24 +00:00
|
|
|
#include "api/field_trials_view.h"
|
|
|
|
|
#include "api/scoped_refptr.h"
|
2019-11-26 14:00:41 +01:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
// Modify an audio encoder to not advertise support for anything.
|
|
|
|
|
template <typename T>
|
|
|
|
|
struct NotAdvertised {
|
|
|
|
|
using Config = typename T::Config;
|
|
|
|
|
static absl::optional<Config> SdpToConfig(
|
|
|
|
|
const SdpAudioFormat& audio_format) {
|
|
|
|
|
return T::SdpToConfig(audio_format);
|
|
|
|
|
}
|
|
|
|
|
static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) {
|
|
|
|
|
// Don't advertise support for anything.
|
|
|
|
|
}
|
|
|
|
|
static AudioCodecInfo QueryAudioEncoder(const Config& config) {
|
|
|
|
|
return T::QueryAudioEncoder(config);
|
|
|
|
|
}
|
|
|
|
|
static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
|
|
|
|
|
const Config& config,
|
|
|
|
|
int payload_type,
|
2022-03-15 14:29:00 +01:00
|
|
|
absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
|
2022-03-29 11:04:48 +02:00
|
|
|
const FieldTrialsView* field_trials = nullptr) {
|
2022-03-15 14:29:00 +01:00
|
|
|
return T::MakeAudioEncoder(config, payload_type, codec_pair_id,
|
|
|
|
|
field_trials);
|
2019-11-26 14:00:41 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<AudioEncoderFactory> CreateOpusAudioEncoderFactory() {
|
|
|
|
|
return CreateAudioEncoderFactory<
|
|
|
|
|
AudioEncoderOpus, NotAdvertised<AudioEncoderMultiChannelOpus>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|