audio_decoder_factory.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
  11. #define API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
  12. #include <memory>
  13. #include <vector>
  14. #include "absl/types/optional.h"
  15. #include "api/audio_codecs/audio_codec_pair_id.h"
  16. #include "api/audio_codecs/audio_decoder.h"
  17. #include "api/audio_codecs/audio_format.h"
  18. #include "rtc_base/ref_count.h"
  19. namespace webrtc {
  20. // A factory that creates AudioDecoders.
  21. class AudioDecoderFactory : public rtc::RefCountInterface {
  22. public:
  23. virtual std::vector<AudioCodecSpec> GetSupportedDecoders() = 0;
  24. virtual bool IsSupportedDecoder(const SdpAudioFormat& format) = 0;
  25. // Create a new decoder instance. The `codec_pair_id` argument is used to link
  26. // encoders and decoders that talk to the same remote entity: if a
  27. // AudioEncoderFactory::MakeAudioEncoder() and a
  28. // AudioDecoderFactory::MakeAudioDecoder() call receive non-null IDs that
  29. // compare equal, the factory implementations may assume that the encoder and
  30. // decoder form a pair. (The intended use case for this is to set up
  31. // communication between the AudioEncoder and AudioDecoder instances, which is
  32. // needed for some codecs with built-in bandwidth adaptation.)
  33. //
  34. // Returns null if the format isn't supported.
  35. //
  36. // Note: Implementations need to be robust against combinations other than
  37. // one encoder, one decoder getting the same ID; such decoders must still
  38. // work.
  39. virtual std::unique_ptr<AudioDecoder> MakeAudioDecoder(
  40. const SdpAudioFormat& format,
  41. absl::optional<AudioCodecPairId> codec_pair_id) = 0;
  42. };
  43. } // namespace webrtc
  44. #endif // API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_