// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_CDM_SUPPORTED_CDM_VERSIONS_H_ #define MEDIA_CDM_SUPPORTED_CDM_VERSIONS_H_ #include <stddef.h> #include <array> #include "media/base/media_export.h" #include "media/cdm/api/content_decryption_module.h" // A library CDM interface is "supported" if it's implemented by CdmAdapter and // CdmWrapper. Typically multiple CDM interfaces are supported: // - The latest stable CDM interface. // - Previous stable CDM interface(s), for supporting older CDMs. // - Experimental CDM interface(s), for development. // // A library CDM interface is "enabled" if it's enabled at runtime, e.g. being // able to be registered and creating CDM instances. Experimental CDM interfaces // must not be enabled by default. // // Whether a CDM interface is enabled can also be overridden by using command // line switch switches::kOverrideEnabledCdmInterfaceVersion for finer control // in a test environment or for local debugging, including enabling experimental // CDM interfaces. namespace media { struct SupportedVersion { … }; constexpr std::array<SupportedVersion, 2> kSupportedCdmInterfaceVersions = …; // In most cases CdmInterface::kVersion == CdmInterface::Host::kVersion. However // this is not guaranteed. For example, a newer CDM interface may use an // existing CDM host. So we keep CDM host support separate from CDM interface // support. In CdmInterfaceTraits we also static assert that for supported CDM // interface, CdmInterface::Host::kVersion must also be supported. constexpr int kMinSupportedCdmHostVersion = …; constexpr int kMaxSupportedCdmHostVersion = …; constexpr bool IsSupportedCdmModuleVersion(int version) { … } // Returns whether the CDM interface of |version| is supported in the // implementation. constexpr bool IsSupportedCdmInterfaceVersion(int version) { … } // Returns whether the CDM host interface of |version| is supported in the // implementation. Currently there's no way to disable a supported CDM host // interface at run time. constexpr bool IsSupportedCdmHostVersion(int version) { … } // Returns whether the CDM interface of |version| is enabled by default. constexpr bool IsCdmInterfaceVersionEnabledByDefault(int version) { … } // Returns whether the CDM interface of |version| is supported in the // implementation and enabled at runtime. MEDIA_EXPORT bool IsSupportedAndEnabledCdmInterfaceVersion(int version); VersionCheckFunc; // Returns true if all versions in the range [min_version, max_version] and no // versions outside the range are supported, and false otherwise. constexpr bool CheckVersions(VersionCheckFunc check_func, int min_version, int max_version) { … } // Ensures CDM interface versions in and only in the range [min_version, // max_version] are supported in the implementation. constexpr bool CheckSupportedCdmInterfaceVersions(int min_version, int max_version) { … } // Ensures CDM host interface versions in and only in the range [min_version, // max_version] are supported in the implementation. constexpr bool CheckSupportedCdmHostVersions(int min_version, int max_version) { … } // Traits for CDM Interfaces template <int CdmInterfaceVersion> struct CdmInterfaceTraits { … }; // TODO(xhwang): CDM_9 support has been removed; consider to use a macro to // help define CdmInterfaceTraits specializations. template <> struct CdmInterfaceTraits<10> { … }; template <> struct CdmInterfaceTraits<11> { … }; } // namespace media #endif // MEDIA_CDM_SUPPORTED_CDM_VERSIONS_H_