Change AudioDecoderFactory api to provide Environment to construct AudioDecoders
Bug: webrtc:356878416 Change-Id: Id910bef48138b1b659938b1c1a6d23b5634967f5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/359540 Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42781}
This commit is contained in:
parent
2590d1a7d7
commit
ce807810be
@ -14,11 +14,14 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_codec_pair_id.h"
|
||||
#include "api/audio_codecs/audio_decoder.h"
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/ref_count.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -31,12 +34,12 @@ class AudioDecoderFactory : public RefCountInterface {
|
||||
|
||||
// Create a new decoder instance. The `codec_pair_id` argument is used to link
|
||||
// encoders and decoders that talk to the same remote entity: if a
|
||||
// AudioEncoderFactory::MakeAudioEncoder() and a
|
||||
// AudioDecoderFactory::MakeAudioDecoder() 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.)
|
||||
// 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.)
|
||||
//
|
||||
// Returns null if the format isn't supported.
|
||||
//
|
||||
@ -45,7 +48,19 @@ class AudioDecoderFactory : public RefCountInterface {
|
||||
// work.
|
||||
virtual std::unique_ptr<AudioDecoder> MakeAudioDecoder(
|
||||
const SdpAudioFormat& format,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id) = 0;
|
||||
absl::optional<AudioCodecPairId> codec_pair_id) {
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// TODO: bugs.webrtc.org/356878416 - Make pure virtual when implemented by
|
||||
// derived classes instead of the MakeAudioDecoder.
|
||||
virtual absl::Nullable<std::unique_ptr<AudioDecoder>> Create(
|
||||
const Environment& env,
|
||||
const SdpAudioFormat& format,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id) {
|
||||
return MakeAudioDecoder(format, codec_pair_id);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -34,12 +34,12 @@ class AudioEncoderFactory : public RefCountInterface {
|
||||
int payload_type = -1;
|
||||
|
||||
// Links encoders and decoders that talk to the same remote entity: if
|
||||
// a AudioEncoderFactory::Create() and a
|
||||
// AudioDecoderFactory::MakeAudioDecoder() 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.)
|
||||
// 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.)
|
||||
//
|
||||
// Note: Implementations need to be robust against combinations other than
|
||||
// one encoder, one decoder getting the same ID; such encoders must still
|
||||
|
||||
@ -63,7 +63,7 @@ AudioDecoder* DecoderDatabase::DecoderInfo::GetDecoder() const {
|
||||
// TODO(ossu): Keep a check here for now, since a number of tests create
|
||||
// DecoderInfos without factories.
|
||||
RTC_DCHECK(factory_);
|
||||
decoder_ = factory_->MakeAudioDecoder(audio_format_, codec_pair_id_);
|
||||
decoder_ = factory_->Create(env_, audio_format_, codec_pair_id_);
|
||||
}
|
||||
RTC_DCHECK(decoder_) << "Failed to create: " << rtc::ToString(audio_format_);
|
||||
return decoder_.get();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user