Bug 1868482 - part3 : ensure HDCP2.2 compatible would be vaild when the flag contains 'CapabilitesFlag::NeedHDCPCheck'. r=jolin

Differential Revision: https://phabricator.services.mozilla.com/D205394
This commit is contained in:
alwu 2024-03-26 01:28:30 +00:00
parent e4cc9a1487
commit c560dfa1f4
4 changed files with 21 additions and 12 deletions

View file

@ -199,7 +199,9 @@ void MFCDMCapabilitiesIPDLToKeySystemConfig(
aKeySystemConfig.mEncryptionSchemes.AppendElement(
NS_ConvertUTF8toUTF16(EncryptionSchemeStr(scheme)));
}
aKeySystemConfig.mIsHDCP22Compatible = aCDMConfig.isHDCP22Compatible();
aKeySystemConfig.mIsHDCP22Compatible = aCDMConfig.isHDCP22Compatible()
? *aCDMConfig.isHDCP22Compatible()
: false;
EME_LOG("New Capabilities=%s",
NS_ConvertUTF16toUTF8(aKeySystemConfig.GetDebugInfo()).get());
}

View file

@ -773,15 +773,26 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
return;
}
ComPtr<IMFContentDecryptionModuleFactory> factory = aFactory;
if (!factory) {
RETURN_VOID_IF_FAILED(GetOrCreateFactory(aKeySystem, factory));
}
StaticMutexAutoLock lock(sCapabilitesMutex);
// TODO : handle HDCP check properly, current implmentation won't be able to
// force calculating HDCP.
for (const auto& capabilities : sCapabilities) {
for (auto& capabilities : sCapabilities) {
if (capabilities.keySystem().Equals(aKeySystem) &&
capabilities.isHardwareDecryption() == isHardwareDecryption) {
MFCDM_PARENT_SLOG(
"Return cached capabilities for %s (hardwareDecryption=%d)",
NS_ConvertUTF16toUTF8(aKeySystem).get(), isHardwareDecryption);
if (capabilities.isHDCP22Compatible().isNothing() &&
aFlags.contains(CapabilitesFlag::NeedHDCPCheck)) {
const bool rv = IsHDCPVersionSupported(factory, aKeySystem,
dom::HDCPVersion::_2_2) == NS_OK;
MFCDM_PARENT_SLOG(
"Check HDCP 2.2 compatible (%d) for the cached capabilites", rv);
capabilities.isHDCP22Compatible() = Some(rv);
}
aCapabilitiesOut = capabilities;
return;
}
@ -791,11 +802,6 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
"Query capabilities for %s from the factory (hardwareDecryption=%d)",
NS_ConvertUTF16toUTF8(aKeySystem).get(), isHardwareDecryption);
ComPtr<IMFContentDecryptionModuleFactory> factory = aFactory;
if (!factory) {
RETURN_VOID_IF_FAILED(GetOrCreateFactory(aKeySystem, factory));
}
// Widevine requires codec type to be four CC, PlayReady is fine with both.
static auto convertCodecToFourCC =
[](const KeySystemConfig::EMECodecString& aCodec) {
@ -970,7 +976,8 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
if (aFlags.contains(CapabilitesFlag::NeedHDCPCheck) &&
IsHDCPVersionSupported(factory, aKeySystem, dom::HDCPVersion::_2_2) ==
NS_OK) {
aCapabilitiesOut.isHDCP22Compatible() = true;
MFCDM_PARENT_SLOG("Capabilites is compatible with HDCP 2.2");
aCapabilitiesOut.isHDCP22Compatible() = Some(true);
}
// TODO: don't hardcode

View file

@ -57,7 +57,7 @@ struct MFCDMCapabilitiesIPDL {
CryptoScheme[] encryptionSchemes;
Requirement distinctiveID;
Requirement persistentState;
bool isHDCP22Compatible;
bool? isHDCP22Compatible;
bool isHardwareDecryption;
};

View file

@ -246,7 +246,7 @@ void UtilityAudioDecoderChild::GetKeySystemCapabilities(
info->mClearlead =
DoesKeySystemSupportClearLead(info->mKeySystemName);
if (capabilities.isHDCP22Compatible()) {
info->mIsHDCP22Compatible = true;
info->mIsHDCP22Compatible = *capabilities.isHDCP22Compatible();
}
}
promise->MaybeResolve(cdmInfo);