зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 8 changesets (bug 1883784, bug 1868482) for causing bc failures in /ipc/EnumSerializer.h CLOSED TREE
Backed out changeset 38d3d0010972 (bug 1868482) Backed out changeset 72de2a649e60 (bug 1868482) Backed out changeset 5849055ce485 (bug 1868482) Backed out changeset 396b76ded255 (bug 1883784) Backed out changeset 3974723c71be (bug 1883784) Backed out changeset c569adae327d (bug 1883784) Backed out changeset 8f1acf9322b9 (bug 1883784) Backed out changeset e112d7db9cbb (bug 1883784)
This commit is contained in:
Родитель
c2f36e9b38
Коммит
0186696113
|
@ -199,9 +199,7 @@ void MFCDMCapabilitiesIPDLToKeySystemConfig(
|
|||
aKeySystemConfig.mEncryptionSchemes.AppendElement(
|
||||
NS_ConvertUTF8toUTF16(EncryptionSchemeStr(scheme)));
|
||||
}
|
||||
aKeySystemConfig.mIsHDCP22Compatible = aCDMConfig.isHDCP22Compatible()
|
||||
? *aCDMConfig.isHDCP22Compatible()
|
||||
: false;
|
||||
aKeySystemConfig.mIsHDCP22Compatible = aCDMConfig.isHDCP22Compatible();
|
||||
EME_LOG("New Capabilities=%s",
|
||||
NS_ConvertUTF16toUTF8(aKeySystemConfig.GetDebugInfo()).get());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,36 @@ bool WMFCDMImpl::GetCapabilities(bool aIsHardwareDecryption,
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO : remove media::await to make this async
|
||||
static std::unordered_map<std::string, nsTArray<KeySystemConfig>>
|
||||
sKeySystemConfigs{};
|
||||
static bool sSetRunOnShutdown = false;
|
||||
if (!sSetRunOnShutdown) {
|
||||
GetMainThreadSerialEventTarget()->Dispatch(
|
||||
NS_NewRunnableFunction("WMFCDMImpl::GetCapabilities", [&] {
|
||||
RunOnShutdown([&] { sKeySystemConfigs.clear(); },
|
||||
ShutdownPhase::XPCOMShutdown);
|
||||
}));
|
||||
sSetRunOnShutdown = true;
|
||||
}
|
||||
|
||||
// Retrieve result from our cached key system
|
||||
auto keySystem = std::string{NS_ConvertUTF16toUTF8(mKeySystem).get()};
|
||||
const bool isKeySystemSupportedHarewareDecryption =
|
||||
DoesKeySystemSupportHardwareDecryption(mKeySystem);
|
||||
if (auto rv = sKeySystemConfigs.find(keySystem);
|
||||
rv != sKeySystemConfigs.end()) {
|
||||
for (const auto& config : rv->second) {
|
||||
if ((IsHardwareDecryptionSupported(config) ||
|
||||
isKeySystemSupportedHarewareDecryption) == aIsHardwareDecryption) {
|
||||
EME_LOG("Return cached capabilities for %s (%s)", keySystem.c_str(),
|
||||
NS_ConvertUTF16toUTF8(config.GetDebugInfo()).get());
|
||||
aOutConfigs.AppendElement(config);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not cached result, ask the remote process.
|
||||
nsCOMPtr<nsISerialEventTarget> backgroundTaskQueue;
|
||||
NS_CreateBackgroundTaskQueue(__func__, getter_AddRefs(backgroundTaskQueue));
|
||||
if (!mCDM) {
|
||||
|
@ -32,13 +61,10 @@ bool WMFCDMImpl::GetCapabilities(bool aIsHardwareDecryption,
|
|||
media::Await(
|
||||
do_AddRef(backgroundTaskQueue),
|
||||
mCDM->GetCapabilities(aIsHardwareDecryption),
|
||||
[&ok, &aOutConfigs,
|
||||
[&ok, &aOutConfigs, keySystem,
|
||||
aIsHardwareDecryption](const MFCDMCapabilitiesIPDL& capabilities) {
|
||||
EME_LOG("capabilities: keySystem=%s (hw-secure=%d)",
|
||||
NS_ConvertUTF16toUTF8(capabilities.keySystem()).get(),
|
||||
EME_LOG("capabilities: keySystem=%s (hw-secure=%d)", keySystem.c_str(),
|
||||
aIsHardwareDecryption);
|
||||
MOZ_ASSERT(aIsHardwareDecryption ==
|
||||
capabilities.isHardwareDecryption());
|
||||
for (const auto& v : capabilities.videoCapabilities()) {
|
||||
EME_LOG("capabilities: video=%s",
|
||||
NS_ConvertUTF16toUTF8(v.contentType()).get());
|
||||
|
@ -52,11 +78,13 @@ bool WMFCDMImpl::GetCapabilities(bool aIsHardwareDecryption,
|
|||
}
|
||||
KeySystemConfig* config = aOutConfigs.AppendElement();
|
||||
MFCDMCapabilitiesIPDLToKeySystemConfig(capabilities, *config);
|
||||
sKeySystemConfigs[keySystem].AppendElement(*config);
|
||||
ok = true;
|
||||
},
|
||||
[](nsresult rv) {
|
||||
EME_LOG("Fail to get key system capabilities. rv=%x", uint32_t(rv));
|
||||
});
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "MFCDMParent.h"
|
||||
|
||||
#include <mfmediaengine.h>
|
||||
#include <unknwnbase.h>
|
||||
#include <wtypes.h>
|
||||
#define INITGUID // Enable DEFINE_PROPERTYKEY()
|
||||
#include <propkeydef.h> // For DEFINE_PROPERTYKEY() definition
|
||||
|
@ -93,8 +92,6 @@ StaticMutex sFactoryMutex;
|
|||
static nsTHashMap<nsStringHashKey, ComPtr<IMFContentDecryptionModuleFactory>>
|
||||
sFactoryMap;
|
||||
static CopyableTArray<MFCDMCapabilitiesIPDL> sCapabilities;
|
||||
StaticMutex sCapabilitesMutex;
|
||||
static ComPtr<IUnknown> sMediaEngineClassFactory;
|
||||
|
||||
// RAIIized PROPVARIANT. See
|
||||
// third_party/libwebrtc/modules/audio_device/win/core_audio_utility_win.h
|
||||
|
@ -169,11 +166,6 @@ static nsString GetHdcpPolicy(const dom::HDCPVersion& aMinHdcpVersion) {
|
|||
return nsString(u"hdcp=1");
|
||||
}
|
||||
|
||||
static bool RequireClearLead(const nsString& aKeySystem) {
|
||||
return aKeySystem.EqualsLiteral(kWidevineExperiment2KeySystemName) ||
|
||||
aKeySystem.EqualsLiteral(kPlayReadyHardwareClearLeadKeySystemName);
|
||||
}
|
||||
|
||||
static void BuildCapabilitiesArray(
|
||||
const nsTArray<MFCDMMediaCapability>& aCapabilities,
|
||||
AutoPropVar& capabilitiesPropOut) {
|
||||
|
@ -472,10 +464,8 @@ LPCWSTR MFCDMParent::GetCDMLibraryName(const nsString& aKeySystem) {
|
|||
|
||||
/* static */
|
||||
void MFCDMParent::Shutdown() {
|
||||
StaticMutexAutoLock lock(sCapabilitesMutex);
|
||||
sFactoryMap.Clear();
|
||||
sCapabilities.Clear();
|
||||
sMediaEngineClassFactory.Reset();
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -510,13 +500,10 @@ HRESULT MFCDMParent::LoadFactory(
|
|||
NS_ConvertUTF16toUTF8(aKeySystem).get());
|
||||
ComPtr<IMFContentDecryptionModuleFactory> cdmFactory;
|
||||
if (loadFromPlatform) {
|
||||
if (!sMediaEngineClassFactory) {
|
||||
MFCDM_RETURN_IF_FAILED(CoCreateInstance(
|
||||
CLSID_MFMediaEngineClassFactory, nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&sMediaEngineClassFactory)));
|
||||
}
|
||||
ComPtr<IMFMediaEngineClassFactory4> clsFactory;
|
||||
MFCDM_RETURN_IF_FAILED(sMediaEngineClassFactory.As(&clsFactory));
|
||||
MFCDM_RETURN_IF_FAILED(CoCreateInstance(CLSID_MFMediaEngineClassFactory,
|
||||
nullptr, CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&clsFactory)));
|
||||
MFCDM_RETURN_IF_FAILED(clsFactory->CreateContentDecryptionModuleFactory(
|
||||
MapKeySystem(aKeySystem).get(), IID_PPV_ARGS(&cdmFactory)));
|
||||
aFactoryOut.Swap(cdmFactory);
|
||||
|
@ -630,8 +617,12 @@ static bool FactorySupports(ComPtr<IMFContentDecryptionModuleFactory>& aFactory,
|
|||
// use another way to check the capabilities.
|
||||
if (IsPlayReadyKeySystemAndSupported(aKeySystem) &&
|
||||
StaticPrefs::media_eme_playready_istypesupportedex()) {
|
||||
ComPtr<IMFMediaEngineClassFactory> spFactory;
|
||||
ComPtr<IMFExtendedDRMTypeSupport> spDrmTypeSupport;
|
||||
MFCDM_RETURN_BOOL_IF_FAILED(sMediaEngineClassFactory.As(&spDrmTypeSupport));
|
||||
MFCDM_RETURN_BOOL_IF_FAILED(
|
||||
CoCreateInstance(CLSID_MFMediaEngineClassFactory, NULL,
|
||||
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&spFactory)));
|
||||
MFCDM_RETURN_BOOL_IF_FAILED(spFactory.As(&spDrmTypeSupport));
|
||||
BSTR keySystem = aIsHWSecure
|
||||
? CreateBSTRFromConstChar(kPlayReadyKeySystemHardware)
|
||||
: CreateBSTRFromConstChar(kPlayReadyKeySystemName);
|
||||
|
@ -708,62 +699,57 @@ MFCDMParent::GetAllKeySystemsCapabilities() {
|
|||
new CapabilitiesPromise::Private(__func__);
|
||||
Unused << backgroundTaskQueue->Dispatch(NS_NewRunnableFunction(__func__, [p] {
|
||||
MFCDM_PARENT_SLOG("GetAllKeySystemsCapabilities");
|
||||
enum SecureLevel : bool {
|
||||
Software = false,
|
||||
Hardware = true,
|
||||
};
|
||||
const nsTArray<std::pair<nsString, SecureLevel>> kKeySystems{
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kPlayReadyKeySystemName),
|
||||
SecureLevel::Software),
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kPlayReadyKeySystemHardware),
|
||||
SecureLevel::Hardware),
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kPlayReadyHardwareClearLeadKeySystemName),
|
||||
SecureLevel::Hardware),
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kWidevineExperimentKeySystemName),
|
||||
SecureLevel::Hardware),
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kWidevineExperiment2KeySystemName),
|
||||
SecureLevel::Hardware),
|
||||
};
|
||||
|
||||
CopyableTArray<MFCDMCapabilitiesIPDL> capabilitiesArr;
|
||||
for (const auto& keySystem : kKeySystems) {
|
||||
// Only check the capabilites if the relative prefs for the key system
|
||||
// are ON.
|
||||
if (IsPlayReadyKeySystemAndSupported(keySystem.first) ||
|
||||
IsWidevineExperimentKeySystemAndSupported(keySystem.first)) {
|
||||
MFCDMCapabilitiesIPDL* c = capabilitiesArr.AppendElement();
|
||||
CapabilitesFlagSet flags;
|
||||
if (keySystem.second == SecureLevel::Hardware) {
|
||||
flags += CapabilitesFlag::HarewareDecryption;
|
||||
if (sCapabilities.IsEmpty()) {
|
||||
enum SecureLevel : bool {
|
||||
Software = false,
|
||||
Hardware = true,
|
||||
};
|
||||
const nsTArray<std::pair<nsString, SecureLevel>> kKeySystems{
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kPlayReadyKeySystemName),
|
||||
SecureLevel::Software),
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kPlayReadyKeySystemHardware),
|
||||
SecureLevel::Hardware),
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kPlayReadyHardwareClearLeadKeySystemName),
|
||||
SecureLevel::Hardware),
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kWidevineExperimentKeySystemName),
|
||||
SecureLevel::Hardware),
|
||||
std::pair<nsString, SecureLevel>(
|
||||
NS_ConvertUTF8toUTF16(kWidevineExperiment2KeySystemName),
|
||||
SecureLevel::Hardware),
|
||||
};
|
||||
for (const auto& keySystem : kKeySystems) {
|
||||
// Only check the capabilites if the relative prefs for the key system
|
||||
// are ON.
|
||||
if (IsPlayReadyKeySystemAndSupported(keySystem.first) ||
|
||||
IsWidevineExperimentKeySystemAndSupported(keySystem.first)) {
|
||||
MFCDMCapabilitiesIPDL* c = sCapabilities.AppendElement();
|
||||
GetCapabilities(keySystem.first, keySystem.second, nullptr, *c);
|
||||
}
|
||||
flags += CapabilitesFlag::NeedHDCPCheck;
|
||||
if (RequireClearLead(keySystem.first)) {
|
||||
flags += CapabilitesFlag::NeedClearLeadCheck;
|
||||
}
|
||||
GetCapabilities(keySystem.first, flags, nullptr, *c);
|
||||
}
|
||||
}
|
||||
|
||||
p->Resolve(std::move(capabilitiesArr), __func__);
|
||||
p->Resolve(sCapabilities, __func__);
|
||||
}));
|
||||
return p;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
|
||||
const CapabilitesFlagSet& aFlags,
|
||||
const bool aIsHWSecure,
|
||||
IMFContentDecryptionModuleFactory* aFactory,
|
||||
MFCDMCapabilitiesIPDL& aCapabilitiesOut) {
|
||||
const bool isHardwareDecryption =
|
||||
aFlags.contains(CapabilitesFlag::HarewareDecryption);
|
||||
aCapabilitiesOut.keySystem() = aKeySystem;
|
||||
// WMF CDMs usually require these. See
|
||||
// https://source.chromium.org/chromium/chromium/src/+/main:media/cdm/win/media_foundation_cdm_factory.cc;l=69-73;drc=b3ca5c09fa0aa07b7f9921501f75e43d80f3ba48
|
||||
aCapabilitiesOut.persistentState() = KeySystemConfig::Requirement::Required;
|
||||
aCapabilitiesOut.distinctiveID() = KeySystemConfig::Requirement::Required;
|
||||
|
||||
// Return empty capabilites for SWDRM on Windows 10 because it has the process
|
||||
// leaking problem.
|
||||
if (!IsWin11OrLater() && !isHardwareDecryption) {
|
||||
if (!IsWin11OrLater() && !aIsHWSecure) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -772,36 +758,6 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
|
|||
RETURN_VOID_IF_FAILED(GetOrCreateFactory(aKeySystem, factory));
|
||||
}
|
||||
|
||||
StaticMutexAutoLock lock(sCapabilitesMutex);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
MFCDM_PARENT_SLOG(
|
||||
"Query capabilities for %s from the factory (hardwareDecryption=%d)",
|
||||
NS_ConvertUTF16toUTF8(aKeySystem).get(), isHardwareDecryption);
|
||||
|
||||
aCapabilitiesOut.keySystem() = aKeySystem;
|
||||
// WMF CDMs usually require these. See
|
||||
// https://source.chromium.org/chromium/chromium/src/+/main:media/cdm/win/media_foundation_cdm_factory.cc;l=69-73;drc=b3ca5c09fa0aa07b7f9921501f75e43d80f3ba48
|
||||
aCapabilitiesOut.persistentState() = KeySystemConfig::Requirement::Required;
|
||||
aCapabilitiesOut.distinctiveID() = KeySystemConfig::Requirement::Required;
|
||||
|
||||
// Widevine requires codec type to be four CC, PlayReady is fine with both.
|
||||
static auto convertCodecToFourCC =
|
||||
[](const KeySystemConfig::EMECodecString& aCodec) {
|
||||
|
@ -853,12 +809,12 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
|
|||
}
|
||||
if (FactorySupports(factory, aKeySystem, convertCodecToFourCC(codec),
|
||||
KeySystemConfig::EMECodecString(""), nsString(u""),
|
||||
isHardwareDecryption)) {
|
||||
aIsHWSecure)) {
|
||||
MFCDMMediaCapability* c =
|
||||
aCapabilitiesOut.videoCapabilities().AppendElement();
|
||||
c->contentType() = NS_ConvertUTF8toUTF16(codec);
|
||||
c->robustness() =
|
||||
GetRobustnessStringForKeySystem(aKeySystem, isHardwareDecryption);
|
||||
GetRobustnessStringForKeySystem(aKeySystem, aIsHWSecure);
|
||||
MFCDM_PARENT_SLOG("%s: +video:%s", __func__, codec.get());
|
||||
supportedVideoCodecs.AppendElement(codec);
|
||||
}
|
||||
|
@ -875,51 +831,52 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
|
|||
KeySystemConfig::EME_CODEC_VORBIS,
|
||||
});
|
||||
for (const auto& codec : kAudioCodecs) {
|
||||
// Hardware decryption is usually only used for video, so we can just check
|
||||
// the software capabilities for audio in order to save some time. As the
|
||||
// media foundation would create a new D3D device everytime when we check
|
||||
// hardware decryption, which takes way longer time.
|
||||
if (FactorySupports(factory, aKeySystem,
|
||||
convertCodecToFourCC(supportedVideoCodecs[0]),
|
||||
convertCodecToFourCC(codec), nsString(u""),
|
||||
false /* aIsHWSecure */)) {
|
||||
if (FactorySupports(
|
||||
factory, aKeySystem, convertCodecToFourCC(supportedVideoCodecs[0]),
|
||||
convertCodecToFourCC(codec), nsString(u""), aIsHWSecure)) {
|
||||
MFCDMMediaCapability* c =
|
||||
aCapabilitiesOut.audioCapabilities().AppendElement();
|
||||
c->contentType() = NS_ConvertUTF8toUTF16(codec);
|
||||
c->robustness() = GetRobustnessStringForKeySystem(
|
||||
aKeySystem, false /* aIsHWSecure */, false /* isVideo */);
|
||||
c->robustness() = GetRobustnessStringForKeySystem(aKeySystem, aIsHWSecure,
|
||||
false /* isVideo */);
|
||||
MFCDM_PARENT_SLOG("%s: +audio:%s", __func__, codec.get());
|
||||
}
|
||||
}
|
||||
|
||||
// 'If value is unspecified, default value of "cenc" is used.' See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/mfmediaengine/nf-mfmediaengine-imfextendeddrmtypesupport-istypesupportedex
|
||||
if (!supportedVideoCodecs.IsEmpty()) {
|
||||
aCapabilitiesOut.encryptionSchemes().AppendElement(CryptoScheme::Cenc);
|
||||
MFCDM_PARENT_SLOG("%s: +scheme:cenc", __func__);
|
||||
}
|
||||
|
||||
// Check another scheme "cbcs"
|
||||
static std::pair<CryptoScheme, nsDependentString> kCbcs =
|
||||
// Collect schemes supported by all video codecs.
|
||||
static nsTArray<std::pair<CryptoScheme, nsDependentString>> kSchemes = {
|
||||
std::pair<CryptoScheme, nsDependentString>(
|
||||
CryptoScheme::Cbcs, u"encryption-type=cbcs,encryption-iv-size=16,");
|
||||
bool ok = true;
|
||||
for (const auto& codec : supportedVideoCodecs) {
|
||||
ok &= FactorySupports(factory, aKeySystem, convertCodecToFourCC(codec),
|
||||
nsCString(""), kCbcs.second /* additional feature */,
|
||||
isHardwareDecryption);
|
||||
if (!ok) {
|
||||
break;
|
||||
CryptoScheme::Cenc, u"encryption-type=cenc,encryption-iv-size=8,"),
|
||||
std::pair<CryptoScheme, nsDependentString>(
|
||||
CryptoScheme::Cbcs, u"encryption-type=cbcs,encryption-iv-size=16,")};
|
||||
for (auto& scheme : kSchemes) {
|
||||
bool ok = true;
|
||||
for (auto& codec : supportedVideoCodecs) {
|
||||
ok &= FactorySupports(
|
||||
factory, aKeySystem, convertCodecToFourCC(codec), nsCString(""),
|
||||
scheme.second /* additional feature */, aIsHWSecure);
|
||||
if (!ok) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
aCapabilitiesOut.encryptionSchemes().AppendElement(scheme.first);
|
||||
MFCDM_PARENT_SLOG("%s: +scheme:%s", __func__,
|
||||
scheme.first == CryptoScheme::Cenc ? "cenc" : "cbcs");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
aCapabilitiesOut.encryptionSchemes().AppendElement(kCbcs.first);
|
||||
MFCDM_PARENT_SLOG("%s: +scheme:cbcs", __func__);
|
||||
}
|
||||
|
||||
static auto RequireClearLead = [](const nsString& aKeySystem) {
|
||||
if (aKeySystem.EqualsLiteral(kWidevineExperiment2KeySystemName) ||
|
||||
aKeySystem.EqualsLiteral(kPlayReadyHardwareClearLeadKeySystemName)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// For key system requires clearlead, every codec needs to have clear support.
|
||||
// If not, then we will remove the codec from supported codec.
|
||||
if (aFlags.contains(CapabilitesFlag::NeedClearLeadCheck)) {
|
||||
if (RequireClearLead(aKeySystem)) {
|
||||
for (const auto& scheme : aCapabilitiesOut.encryptionSchemes()) {
|
||||
nsTArray<KeySystemConfig::EMECodecString> noClearLeadCodecs;
|
||||
for (const auto& codec : supportedVideoCodecs) {
|
||||
|
@ -937,9 +894,9 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
|
|||
} else {
|
||||
additionalFeature.AppendLiteral(u"cbcs-clearlead,");
|
||||
}
|
||||
bool rv = FactorySupports(factory, aKeySystem,
|
||||
convertCodecToFourCC(codec), nsCString(""),
|
||||
additionalFeature, isHardwareDecryption);
|
||||
bool rv =
|
||||
FactorySupports(factory, aKeySystem, convertCodecToFourCC(codec),
|
||||
nsCString(""), additionalFeature, aIsHWSecure);
|
||||
MFCDM_PARENT_SLOG("clearlead %s IV 8 bytes %s %s",
|
||||
CryptoSchemeToString(scheme), codec.get(),
|
||||
rv ? "supported" : "not supported");
|
||||
|
@ -949,8 +906,7 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
|
|||
// Try 16 bytes IV.
|
||||
additionalFeature.AppendLiteral(u"encryption-iv-size=16,");
|
||||
rv = FactorySupports(factory, aKeySystem, convertCodecToFourCC(codec),
|
||||
nsCString(""), additionalFeature,
|
||||
isHardwareDecryption);
|
||||
nsCString(""), additionalFeature, aIsHWSecure);
|
||||
MFCDM_PARENT_SLOG("clearlead %s IV 16 bytes %s %s",
|
||||
CryptoSchemeToString(scheme), codec.get(),
|
||||
rv ? "supported" : "not supported");
|
||||
|
@ -970,14 +926,9 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
|
|||
}
|
||||
}
|
||||
|
||||
// Only perform HDCP if necessary, "The hdcp query (item 4) has a
|
||||
// computationally expensive first invocation cost". See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/mfmediaengine/nf-mfmediaengine-imfextendeddrmtypesupport-istypesupportedex
|
||||
if (aFlags.contains(CapabilitesFlag::NeedHDCPCheck) &&
|
||||
IsHDCPVersionSupported(factory, aKeySystem, dom::HDCPVersion::_2_2) ==
|
||||
NS_OK) {
|
||||
MFCDM_PARENT_SLOG("Capabilites is compatible with HDCP 2.2");
|
||||
aCapabilitiesOut.isHDCP22Compatible() = Some(true);
|
||||
if (IsHDCPVersionSupported(factory, aKeySystem, dom::HDCPVersion::_2_2) ==
|
||||
NS_OK) {
|
||||
aCapabilitiesOut.isHDCP22Compatible() = true;
|
||||
}
|
||||
|
||||
// TODO: don't hardcode
|
||||
|
@ -987,24 +938,13 @@ void MFCDMParent::GetCapabilities(const nsString& aKeySystem,
|
|||
KeySystemConfig::SessionType::Temporary);
|
||||
aCapabilitiesOut.sessionTypes().AppendElement(
|
||||
KeySystemConfig::SessionType::PersistentLicense);
|
||||
aCapabilitiesOut.isHardwareDecryption() = isHardwareDecryption;
|
||||
|
||||
// Cache capabilities for reuse.
|
||||
sCapabilities.AppendElement(aCapabilitiesOut);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult MFCDMParent::RecvGetCapabilities(
|
||||
const bool aIsHWSecure, GetCapabilitiesResolver&& aResolver) {
|
||||
MFCDM_REJECT_IF(!mFactory, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
MFCDMCapabilitiesIPDL capabilities;
|
||||
CapabilitesFlagSet flags;
|
||||
if (aIsHWSecure) {
|
||||
flags += CapabilitesFlag::HarewareDecryption;
|
||||
}
|
||||
if (RequireClearLead(mKeySystem)) {
|
||||
flags += CapabilitesFlag::NeedClearLeadCheck;
|
||||
}
|
||||
GetCapabilities(mKeySystem, flags, mFactory.Get(), capabilities);
|
||||
GetCapabilities(mKeySystem, aIsHWSecure, mFactory.Get(), capabilities);
|
||||
aResolver(std::move(capabilities));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
|
|
@ -97,13 +97,6 @@ class MFCDMParent final : public PMFCDMParent {
|
|||
private:
|
||||
~MFCDMParent();
|
||||
|
||||
enum class CapabilitesFlag {
|
||||
HarewareDecryption,
|
||||
NeedHDCPCheck,
|
||||
NeedClearLeadCheck,
|
||||
};
|
||||
using CapabilitesFlagSet = EnumSet<CapabilitesFlag, uint8_t>;
|
||||
|
||||
static LPCWSTR GetCDMLibraryName(const nsString& aKeySystem);
|
||||
|
||||
static HRESULT GetOrCreateFactory(
|
||||
|
@ -115,7 +108,7 @@ class MFCDMParent final : public PMFCDMParent {
|
|||
Microsoft::WRL::ComPtr<IMFContentDecryptionModuleFactory>& aFactoryOut);
|
||||
|
||||
static void GetCapabilities(const nsString& aKeySystem,
|
||||
const CapabilitesFlagSet& aFlags,
|
||||
const bool aIsHWSecure,
|
||||
IMFContentDecryptionModuleFactory* aFactory,
|
||||
MFCDMCapabilitiesIPDL& aCapabilitiesOut);
|
||||
|
||||
|
|
|
@ -57,8 +57,7 @@ struct MFCDMCapabilitiesIPDL {
|
|||
CryptoScheme[] encryptionSchemes;
|
||||
Requirement distinctiveID;
|
||||
Requirement persistentState;
|
||||
bool? isHDCP22Compatible;
|
||||
bool isHardwareDecryption;
|
||||
bool isHDCP22Compatible;
|
||||
};
|
||||
|
||||
union MFCDMCapabilitiesResult {
|
||||
|
|
|
@ -246,7 +246,7 @@ void UtilityAudioDecoderChild::GetKeySystemCapabilities(
|
|||
info->mClearlead =
|
||||
DoesKeySystemSupportClearLead(info->mKeySystemName);
|
||||
if (capabilities.isHDCP22Compatible()) {
|
||||
info->mIsHDCP22Compatible = *capabilities.isHDCP22Compatible();
|
||||
info->mIsHDCP22Compatible = true;
|
||||
}
|
||||
}
|
||||
promise->MaybeResolve(cdmInfo);
|
||||
|
|
Загрузка…
Ссылка в новой задаче