supported_video_decoder_config.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2019 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_SUPPORTED_VIDEO_DECODER_CONFIG_H_
  5. #define MEDIA_BASE_SUPPORTED_VIDEO_DECODER_CONFIG_H_
  6. #include <vector>
  7. #include "base/containers/flat_map.h"
  8. #include "media/base/media_export.h"
  9. #include "media/base/video_codecs.h"
  10. #include "media/base/video_decoder_config.h"
  11. #include "ui/gfx/geometry/size.h"
  12. namespace media {
  13. // The min and max resolution used by SW decoders (dav1d, libgav1, libvpx and
  14. // ffmpeg for example) when queried about decoding capabilities. For now match
  15. // the supported resolutions of HW decoders.
  16. constexpr gfx::Size kDefaultSwDecodeSizeMin(8, 8);
  17. constexpr gfx::Size kDefaultSwDecodeSizeMax(8192, 8192);
  18. // Specification of a range of configurations that are supported by a video
  19. // decoder. Also provides the ability to check if a VideoDecoderConfig matches
  20. // the supported range.
  21. struct MEDIA_EXPORT SupportedVideoDecoderConfig {
  22. SupportedVideoDecoderConfig();
  23. SupportedVideoDecoderConfig(VideoCodecProfile profile_min,
  24. VideoCodecProfile profile_max,
  25. const gfx::Size& coded_size_min,
  26. const gfx::Size& coded_size_max,
  27. bool allow_encrypted,
  28. bool require_encrypted);
  29. ~SupportedVideoDecoderConfig();
  30. // Returns true if and only if |config| is a supported config.
  31. bool Matches(const VideoDecoderConfig& config) const;
  32. bool operator==(const SupportedVideoDecoderConfig& other) const {
  33. return profile_min == other.profile_min &&
  34. profile_max == other.profile_max &&
  35. coded_size_min == other.coded_size_min &&
  36. coded_size_max == other.coded_size_max &&
  37. allow_encrypted == other.allow_encrypted &&
  38. require_encrypted == other.require_encrypted;
  39. }
  40. bool operator!=(const SupportedVideoDecoderConfig& other) const {
  41. return !(*this == other);
  42. }
  43. // Range of VideoCodecProfiles to match, inclusive.
  44. VideoCodecProfile profile_min = VIDEO_CODEC_PROFILE_UNKNOWN;
  45. VideoCodecProfile profile_max = VIDEO_CODEC_PROFILE_UNKNOWN;
  46. // Coded size range, inclusive.
  47. gfx::Size coded_size_min;
  48. gfx::Size coded_size_max;
  49. // TODO(liberato): consider switching these to "allow_clear" and
  50. // "allow_encrypted", so that they're orthogonal.
  51. // If true, then this will match encrypted configs.
  52. bool allow_encrypted = true;
  53. // If true, then unencrypted configs will not match.
  54. bool require_encrypted = false;
  55. // Allow copy and assignment.
  56. };
  57. using SupportedVideoDecoderConfigs = std::vector<SupportedVideoDecoderConfig>;
  58. // Helper method to determine if |config| is supported by |supported_configs|.
  59. MEDIA_EXPORT bool IsVideoDecoderConfigSupported(
  60. const SupportedVideoDecoderConfigs& supported_configs,
  61. const VideoDecoderConfig& config);
  62. } // namespace media
  63. #endif // MEDIA_BASE_SUPPORTED_VIDEO_DECODER_CONFIG_H_