2017-04-06 10:03:21 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_
|
|
|
|
|
#define API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_
|
2017-04-06 10:03:21 -07:00
|
|
|
|
|
|
|
|
#include <memory>
|
2024-08-29 13:00:40 +00:00
|
|
|
#include <optional>
|
2017-04-06 10:03:21 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
2018-03-01 12:03:49 +01:00
|
|
|
#include "api/audio_codecs/audio_codec_pair_id.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/audio_encoder.h"
|
|
|
|
|
#include "api/audio_codecs/audio_format.h"
|
2024-06-07 15:16:04 +02:00
|
|
|
#include "api/environment/environment.h"
|
|
|
|
|
#include "rtc_base/checks.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/ref_count.h"
|
2017-04-06 10:03:21 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// A factory that creates AudioEncoders.
|
2024-06-06 11:01:02 +00:00
|
|
|
class AudioEncoderFactory : public RefCountInterface {
|
2017-04-06 10:03:21 -07:00
|
|
|
public:
|
2024-06-07 15:16:04 +02:00
|
|
|
struct Options {
|
2024-07-15 14:12:43 +02:00
|
|
|
// The encoder will tags its payloads with the specified payload type.
|
2024-06-07 15:16:04 +02:00
|
|
|
// TODO(ossu): Try to avoid audio encoders having to know their payload
|
|
|
|
|
// type.
|
|
|
|
|
int payload_type = -1;
|
2024-07-15 14:12:43 +02:00
|
|
|
|
|
|
|
|
// Links encoders and decoders that talk to the same remote entity: if
|
2024-08-14 12:59:26 +02:00
|
|
|
// a AudioEncoderFactory::Create() and a AudioDecoderFactory::Create() call
|
|
|
|
|
// receive non-null IDs that compare equal, the factory implementations may
|
|
|
|
|
// assume that the encoder and decoder form a pair. (The intended use case
|
|
|
|
|
// for this is to set up communication between the AudioEncoder and
|
|
|
|
|
// AudioDecoder instances, which is needed for some codecs with built-in
|
|
|
|
|
// bandwidth adaptation.)
|
2024-07-15 14:12:43 +02:00
|
|
|
//
|
|
|
|
|
// Note: Implementations need to be robust against combinations other than
|
|
|
|
|
// one encoder, one decoder getting the same ID; such encoders must still
|
|
|
|
|
// work.
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<AudioCodecPairId> codec_pair_id;
|
2024-06-07 15:16:04 +02:00
|
|
|
};
|
|
|
|
|
|
2017-04-06 10:03:21 -07:00
|
|
|
// Returns a prioritized list of audio codecs, to use for signaling etc.
|
|
|
|
|
virtual std::vector<AudioCodecSpec> GetSupportedEncoders() = 0;
|
|
|
|
|
|
|
|
|
|
// Returns information about how this format would be encoded, provided it's
|
|
|
|
|
// supported. More format and format variations may be supported than those
|
|
|
|
|
// returned by GetSupportedEncoders().
|
2024-08-29 13:00:40 +00:00
|
|
|
virtual std::optional<AudioCodecInfo> QueryAudioEncoder(
|
2017-04-06 10:03:21 -07:00
|
|
|
const SdpAudioFormat& format) = 0;
|
|
|
|
|
|
2024-07-15 14:12:43 +02:00
|
|
|
// Creates an AudioEncoder for the specified format.
|
2020-08-26 15:02:58 +02:00
|
|
|
// Returns null if the format isn't supported.
|
2024-07-15 14:12:43 +02:00
|
|
|
virtual absl::Nullable<std::unique_ptr<AudioEncoder>> Create(
|
|
|
|
|
const Environment& env,
|
2018-03-01 12:03:49 +01:00
|
|
|
const SdpAudioFormat& format,
|
2024-07-15 14:12:43 +02:00
|
|
|
Options options) = 0;
|
2017-04-06 10:03:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_
|