1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "WMFClearKeyCDMFactory.h"
11 #include "WMFClearKeyCDMAccess.h"
12 #include "WMFClearKeyUtils.h"
16 using Microsoft::WRL::MakeAndInitialize
;
18 ActivatableClass(WMFClearKeyCDMFactory
);
20 bool isRequiringHDCP22OrAbove(LPCWSTR aType
) {
21 if (aType
== nullptr || *aType
== L
'\0') {
25 // The HDCP value follows the feature value in
26 // https://docs.microsoft.com/en-us/uwp/api/windows.media.protection.protectioncapabilities.istypesupported?view=winrt-19041
27 // - 1 (on without HDCP 2.2 Type 1 restriction)
28 // - 2 (on with HDCP 2.2 Type 1 restriction)
29 std::wstring
wstr(aType
);
30 std::string
hdcpStr(wstr
.begin(), wstr
.end());
31 return wstr
.find(L
"hdcp=2") != std::string::npos
;
35 WMFClearKeyCDMFactory::IsTypeSupported(_In_ LPCWSTR aKeySystem
,
36 _In_opt_ LPCWSTR aContentType
) {
37 // For testing, return support for most of cases. Only returns false for some
40 bool needHDCP22OrAbove
= isRequiringHDCP22OrAbove(aContentType
);
41 ENTRY_LOG_ARGS("Need-HDCP2.2+=%d", needHDCP22OrAbove
);
43 // As the API design of the Media Foundation, we can only know whether the
44 // requester is asking for HDCP 2.2+ or not, we can't know the exact HDCP
45 // version which is used in getStatusPolicy web api. Therefore, we pretend
46 // ourselves only having HDCP 2.1 compliant.
47 if (needHDCP22OrAbove
) {
54 WMFClearKeyCDMFactory::CreateContentDecryptionModuleAccess(
55 LPCWSTR aKeySystem
, IPropertyStore
** aConfigurations
,
56 DWORD aNumConfigurations
, IMFContentDecryptionModuleAccess
** aCdmAccess
) {
58 if (aKeySystem
== nullptr || aKeySystem
[0] == L
'\0') {
59 ENTRY_LOG_ARGS("Key system is null or empty");
63 if (aNumConfigurations
== 0) {
64 ENTRY_LOG_ARGS("No available configration");
68 if (!IsTypeSupported(aKeySystem
, nullptr)) {
69 ENTRY_LOG_ARGS("Not supported type");
70 return MF_NOT_SUPPORTED_ERR
;
74 MakeAndInitialize
<WMFClearKeyCDMAccess
, IMFContentDecryptionModuleAccess
>(
76 ENTRY_LOG_ARGS("Created CDM access!");
82 } // namespace mozilla