blob: c36a0e103b150e92d28e7b9e35e9c2856050b15a [file] [log] [blame]
kwibergc01c6a42016-04-28 14:23:32 -07001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
12#define API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
kwibergc01c6a42016-04-28 14:23:32 -070013
14#include <memory>
15#include <vector>
16
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020017#include "absl/types/optional.h"
Karl Wiberg98900742018-03-01 12:03:49 +010018#include "api/audio_codecs/audio_codec_pair_id.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "api/audio_codecs/audio_decoder.h"
20#include "api/audio_codecs/audio_format.h"
Steve Anton10542f22019-01-11 09:11:00 -080021#include "rtc_base/ref_count.h"
kwibergc01c6a42016-04-28 14:23:32 -070022
23namespace webrtc {
24
25// A factory that creates AudioDecoders.
ossue725f7c2016-05-19 10:48:04 -070026class AudioDecoderFactory : public rtc::RefCountInterface {
kwibergc01c6a42016-04-28 14:23:32 -070027 public:
ossud4e9f622016-08-18 02:01:17 -070028 virtual std::vector<AudioCodecSpec> GetSupportedDecoders() = 0;
kwibergc01c6a42016-04-28 14:23:32 -070029
kwibergd32bf752017-01-19 07:03:59 -080030 virtual bool IsSupportedDecoder(const SdpAudioFormat& format) = 0;
31
Karl Wibergad858d12018-12-10 11:50:55 +010032 // Create a new decoder instance. The `codec_pair_id` argument is used to link
33 // encoders and decoders that talk to the same remote entity: if a
34 // AudioEncoderFactory::MakeAudioEncoder() and a
35 // AudioDecoderFactory::MakeAudioDecoder() call receive non-null IDs that
Karl Wiberg98900742018-03-01 12:03:49 +010036 // compare equal, the factory implementations may assume that the encoder and
Karl Wibergad858d12018-12-10 11:50:55 +010037 // decoder form a pair. (The intended use case for this is to set up
38 // communication between the AudioEncoder and AudioDecoder instances, which is
39 // needed for some codecs with built-in bandwidth adaptation.)
Karl Wiberg98900742018-03-01 12:03:49 +010040 //
41 // Note: Implementations need to be robust against combinations other than
42 // one encoder, one decoder getting the same ID; such decoders must still
43 // work.
kwibergc01c6a42016-04-28 14:23:32 -070044 virtual std::unique_ptr<AudioDecoder> MakeAudioDecoder(
Karl Wiberg98900742018-03-01 12:03:49 +010045 const SdpAudioFormat& format,
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020046 absl::optional<AudioCodecPairId> codec_pair_id) = 0;
kwibergc01c6a42016-04-28 14:23:32 -070047};
48
49} // namespace webrtc
50
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020051#endif // API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_