decoder.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_BASE_DECODER_H_
  5. #define MEDIA_BASE_DECODER_H_
  6. #include <ostream>
  7. #include <string>
  8. #include "media/base/media_export.h"
  9. #include "media/base/status.h"
  10. namespace media {
  11. // List of known AudioDecoder implementations; recorded to UKM, always add new
  12. // values to the end and do not reorder or delete values from this list.
  13. enum class AudioDecoderType : int {
  14. kUnknown = 0, // Decoder name string is not recognized or n/a.
  15. kFFmpeg = 1, // FFmpegAudioDecoder
  16. kMojo = 2, // MojoAudioDecoder
  17. kDecrypting = 3, // DecryptingAudioDecoder
  18. kMediaCodec = 4, // MediaCodecAudioDecoder (Android)
  19. kBroker = 5, // AudioDecoderBroker
  20. kTesting = 6, // Never send this to UKM, for tests only.
  21. kAudioToolbox = 7, // AudioToolbox (macOS)
  22. kMediaFoundation = 8, // MediaFoundationAudioDecoder
  23. // Keep this at the end and equal to the last entry.
  24. kMaxValue = kMediaFoundation,
  25. };
  26. // List of known VideoDecoder implementations; recorded to UKM, always add new
  27. // values to the end and do not reorder or delete values from this list.
  28. enum class VideoDecoderType : int {
  29. kUnknown = 0, // Decoder name string is not recognized or n/a.
  30. // kGpu = 1, // GpuVideoDecoder (DEPRECATED)
  31. kFFmpeg = 2, // FFmpegVideoDecoder
  32. kVpx = 3, // VpxVideoDecoder
  33. kAom = 4, // AomVideoDecoder
  34. kMojo = 5, // MojoVideoDecoder
  35. kDecrypting = 6, // DecryptingVideoDecoder
  36. kDav1d = 7, // Dav1dVideoDecoder
  37. kFuchsia = 8, // FuchsiaVideoDecoder
  38. kMediaCodec = 9, // MediaCodecVideoDecoder (Android)
  39. kGav1 = 10, // Gav1VideoDecoder
  40. kD3D11 = 11, // D3D11VideoDecoder
  41. kVaapi = 12, // VaapiVideoDecoder
  42. kBroker = 13, // VideoDecoderBroker (Webcodecs)
  43. kVda = 14, // VDAVideoDecoder
  44. // kChromeOs = 15, // DEPRECATED, should be kVaapi or kV4L2 instead.
  45. kV4L2 = 16, // V4L2VideoDecoder
  46. kTesting = 17, // Never send this to UKM, for tests only.
  47. // Keep this at the end and equal to the last entry.
  48. kMaxValue = kTesting
  49. };
  50. MEDIA_EXPORT std::string GetDecoderName(AudioDecoderType type);
  51. MEDIA_EXPORT std::string GetDecoderName(VideoDecoderType type);
  52. MEDIA_EXPORT std::ostream& operator<<(std::ostream& out, AudioDecoderType type);
  53. MEDIA_EXPORT std::ostream& operator<<(std::ostream& out, VideoDecoderType type);
  54. class MEDIA_EXPORT Decoder {
  55. public:
  56. virtual ~Decoder();
  57. // Returns true if the implementation is expected to be implemented by the
  58. // platform. The value should be available immediately after construction and
  59. // should not change within the lifetime of a decoder instance.
  60. virtual bool IsPlatformDecoder() const;
  61. // Returns true if the implementation supports decoding configs with
  62. // encryption.
  63. // TODO(crbug.com/1099488): Sometimes it's not possible to give a definitive
  64. // yes or no answer unless more context is given. While this doesn't pose any
  65. // problems, it does allow incompatible decoders to pass the filtering step in
  66. // |DecoderSelector| potentially slowing down the selection process.
  67. virtual bool SupportsDecryption() const;
  68. protected:
  69. Decoder();
  70. };
  71. } // namespace media
  72. #endif // MEDIA_BASE_DECODER_H_