• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #ifndef API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
12 #define API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
13 
14 #include <memory>
15 #include <vector>
16 
17 #include "absl/types/optional.h"
18 #include "api/audio_codecs/audio_codec_pair_id.h"
19 #include "api/audio_codecs/audio_decoder.h"
20 #include "api/audio_codecs/audio_format.h"
21 #include "rtc_base/ref_count.h"
22 
23 namespace webrtc {
24 
25 // A factory that creates AudioDecoders.
26 class AudioDecoderFactory : public rtc::RefCountInterface {
27  public:
28   virtual std::vector<AudioCodecSpec> GetSupportedDecoders() = 0;
29 
30   virtual bool IsSupportedDecoder(const SdpAudioFormat& format) = 0;
31 
32   // 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
36   // compare equal, the factory implementations may assume that the encoder and
37   // 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.)
40   //
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.
44   virtual std::unique_ptr<AudioDecoder> MakeAudioDecoder(
45       const SdpAudioFormat& format,
46       absl::optional<AudioCodecPairId> codec_pair_id) = 0;
47 };
48 
49 }  // namespace webrtc
50 
51 #endif  // API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
52