kwiberg | c01c6a4 | 2016-04-28 14:23:32 -0700 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_ |
| 12 | #define API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_ |
kwiberg | c01c6a4 | 2016-04-28 14:23:32 -0700 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | #include <vector> |
| 16 | |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame^] | 17 | #include "absl/types/optional.h" |
Karl Wiberg | 9890074 | 2018-03-01 12:03:49 +0100 | [diff] [blame] | 18 | #include "api/audio_codecs/audio_codec_pair_id.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "api/audio_codecs/audio_decoder.h" |
| 20 | #include "api/audio_codecs/audio_format.h" |
| 21 | #include "rtc_base/refcount.h" |
kwiberg | c01c6a4 | 2016-04-28 14:23:32 -0700 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | // A factory that creates AudioDecoders. |
| 26 | // NOTE: This class is still under development and may change without notice. |
ossu | e725f7c | 2016-05-19 10:48:04 -0700 | [diff] [blame] | 27 | class AudioDecoderFactory : public rtc::RefCountInterface { |
kwiberg | c01c6a4 | 2016-04-28 14:23:32 -0700 | [diff] [blame] | 28 | public: |
ossu | d4e9f62 | 2016-08-18 02:01:17 -0700 | [diff] [blame] | 29 | virtual std::vector<AudioCodecSpec> GetSupportedDecoders() = 0; |
kwiberg | c01c6a4 | 2016-04-28 14:23:32 -0700 | [diff] [blame] | 30 | |
kwiberg | d32bf75 | 2017-01-19 07:03:59 -0800 | [diff] [blame] | 31 | virtual bool IsSupportedDecoder(const SdpAudioFormat& format) = 0; |
| 32 | |
Karl Wiberg | 9890074 | 2018-03-01 12:03:49 +0100 | [diff] [blame] | 33 | // Create a new decoder instance. The `codec_pair_id` argument is used to |
| 34 | // link encoders and decoders that talk to the same remote entity; if a |
| 35 | // MakeAudioEncoder() and a MakeAudioDecoder() call receive non-null IDs that |
| 36 | // compare equal, the factory implementations may assume that the encoder and |
| 37 | // decoder form a pair. |
| 38 | // |
| 39 | // Note: Implementations need to be robust against combinations other than |
| 40 | // one encoder, one decoder getting the same ID; such decoders must still |
| 41 | // work. |
kwiberg | c01c6a4 | 2016-04-28 14:23:32 -0700 | [diff] [blame] | 42 | virtual std::unique_ptr<AudioDecoder> MakeAudioDecoder( |
Karl Wiberg | 9890074 | 2018-03-01 12:03:49 +0100 | [diff] [blame] | 43 | const SdpAudioFormat& format, |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame^] | 44 | absl::optional<AudioCodecPairId> codec_pair_id) = 0; |
kwiberg | c01c6a4 | 2016-04-28 14:23:32 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | } // namespace webrtc |
| 48 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 49 | #endif // API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_ |