webrtc/api/audio_codecs/audio_decoder_factory.h
Harald Alvestrand d39834b911 Make creating decoders without CodecPairId possible
While https://webrtc-review.googlesource.com/c/src/+/440684 addressed
encoders, this CL addresses decoders.

Bug: webrtc:398550915
Change-Id: Ie7b039ca7fb0a63761b404ffd0061408eb04a280
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/440920
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Auto-Submit: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#46596}
2026-01-09 05:39:11 -08:00

57 lines
1.9 KiB
C++

/*
* Copyright (c) 2016 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.
*/
#ifndef API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
#define API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
#include <memory>
#include <optional>
#include <vector>
#include "absl/base/nullability.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"
namespace webrtc {
// A factory that creates AudioDecoders.
class AudioDecoderFactory : public RefCountInterface {
public:
virtual std::vector<AudioCodecSpec> GetSupportedDecoders() = 0;
virtual bool IsSupportedDecoder(const SdpAudioFormat& format) = 0;
// Creates a new decoder instance.
virtual absl_nullable std::unique_ptr<AudioDecoder> Create(
const Environment& env,
const SdpAudioFormat& format) {
return Create(env, format, std::nullopt);
}
// Backwards compatible call format. The "codec_pair_id" refers to deleted
// functionality for linking encoders to decoders; this is no longer used.
// TODO: https://issues.webrtc.org/398550915 - remove when no longer used,
// and make above method pure virtual.
virtual absl_nullable std::unique_ptr<AudioDecoder> Create(
const Environment& env,
const SdpAudioFormat& format,
std::optional<AudioCodecPairId> /* codec_pair_id */) {
// Note: If neither method is implemented, this default implementation
// will result in a stack overflow.
return Create(env, format);
}
};
} // namespace webrtc
#endif // API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_