Backed out 6 changesets (bug 1711912) for causing build bustages on MediaKeySystemAccessManager.cpp. CLOSED TREE

Backed out changeset b07f45562c35 (bug 1711912)
Backed out changeset 3e825fc0f7d3 (bug 1711912)
Backed out changeset 964d14b3352e (bug 1711912)
Backed out changeset b941cfb1f5ae (bug 1711912)
Backed out changeset fde1d605fce1 (bug 1711912)
Backed out changeset b135eb6bb7db (bug 1711912)
This commit is contained in:
Marian-Vasile Laza 2021-08-19 01:46:57 +03:00
Родитель 58d94ab547
Коммит d479928bd4
18 изменённых файлов: 44 добавлений и 341 удалений

Просмотреть файл

@ -44,6 +44,12 @@ namespace mozilla {
class MediaContainerType;
// EME Key System String.
#define EME_KEY_SYSTEM_CLEARKEY "org.w3.clearkey"
#define EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY \
"org.mozilla.clearkey_with_protection_query"
#define EME_KEY_SYSTEM_WIDEVINE "com.widevine.alpha"
/**
* ReentrantMonitorConditionallyEnter
*

Просмотреть файл

@ -5,8 +5,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DetailedPromise.h"
#include "VideoUtils.h"
#include "mozilla/dom/DOMException.h"
#include "nsPrintfCString.h"

Просмотреть файл

@ -8,7 +8,6 @@
#include "jsfriendapi.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/dom/KeySystemNames.h"
#include "mozilla/dom/UnionTypes.h"
namespace mozilla {
@ -55,14 +54,15 @@ void CopyArrayBufferViewOrArrayBufferData(
bool IsClearkeyKeySystem(const nsAString& aKeySystem) {
if (StaticPrefs::media_clearkey_test_key_systems_enabled()) {
return aKeySystem.EqualsLiteral(kClearKeyKeySystemName) ||
aKeySystem.EqualsLiteral(kClearKeyWithProtectionQueryKeySystemName);
return aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_CLEARKEY) ||
aKeySystem.EqualsLiteral(
EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY);
}
return aKeySystem.EqualsLiteral(kClearKeyKeySystemName);
return aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_CLEARKEY);
}
bool IsWidevineKeySystem(const nsAString& aKeySystem) {
return aKeySystem.EqualsLiteral(kWidevineKeySystemName);
return aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_WIDEVINE);
}
nsString KeySystemToGMPName(const nsAString& aKeySystem) {

Просмотреть файл

@ -7,6 +7,7 @@
#ifndef EME_LOG_H_
#define EME_LOG_H_
#include "VideoUtils.h"
#include "mozilla/Logging.h"
#include "nsString.h"
#include "nsTArray.h"

Просмотреть файл

@ -1,26 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_MEDIA_EME_KEY_SYSTEM_NAMES_H_
#define DOM_MEDIA_EME_KEY_SYSTEM_NAMES_H_
// Header for key system names. Keep these separate from some of our other
// EME utils because want to use these strings in contexts where other utils
// may not build correctly. Specifically at time of writing:
// - The GMP doesn't have prefs available, so we want to avoid utils that
// touch the pref service.
// - The clear key CDM links a limited subset of what normal Fx does, so we
// need to avoid any utils that touch things like XUL.
namespace mozilla {
// EME Key System Strings.
inline constexpr char kClearKeyKeySystemName[] = "org.w3.clearkey";
inline constexpr char kClearKeyWithProtectionQueryKeySystemName[] =
"org.mozilla.clearkey_with_protection_query";
inline constexpr char kWidevineKeySystemName[] = "com.widevine.alpha";
} // namespace mozilla
#endif // DOM_MEDIA_EME_KEY_SYSTEM_NAMES_H_

Просмотреть файл

@ -13,7 +13,6 @@
#include "GMPUtils.h"
#include "MediaContainerType.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/KeySystemNames.h"
#include "mozilla/dom/MediaKeySystemAccessBinding.h"
#include "mozilla/dom/MediaKeySession.h"
#include "mozilla/dom/MediaSource.h"
@ -294,10 +293,10 @@ static nsTArray<KeySystemConfig> GetSupportedKeySystems() {
nsTArray<KeySystemConfig> keySystemConfigs;
{
const nsCString keySystem = nsLiteralCString(kClearKeyKeySystemName);
const nsCString keySystem = nsLiteralCString(EME_KEY_SYSTEM_CLEARKEY);
if (HavePluginForKeySystem(keySystem)) {
KeySystemConfig clearkey;
clearkey.mKeySystem.AssignLiteral(kClearKeyKeySystemName);
clearkey.mKeySystem.AssignLiteral(EME_KEY_SYSTEM_CLEARKEY);
clearkey.mInitDataTypes.AppendElement(u"cenc"_ns);
clearkey.mInitDataTypes.AppendElement(u"keyids"_ns);
clearkey.mInitDataTypes.AppendElement(u"webm"_ns);
@ -335,7 +334,7 @@ static nsTArray<KeySystemConfig> GetSupportedKeySystems() {
// base clearkey system, so just clone clearkey and change the name.
KeySystemConfig clearkeyWithProtectionQuery{clearkey};
clearkeyWithProtectionQuery.mKeySystem.AssignLiteral(
kClearKeyWithProtectionQueryKeySystemName);
EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY);
keySystemConfigs.AppendElement(std::move(clearkeyWithProtectionQuery));
}
@ -343,10 +342,10 @@ static nsTArray<KeySystemConfig> GetSupportedKeySystems() {
}
}
{
const nsCString keySystem = nsLiteralCString(kWidevineKeySystemName);
const nsCString keySystem = nsLiteralCString(EME_KEY_SYSTEM_WIDEVINE);
if (HavePluginForKeySystem(keySystem)) {
KeySystemConfig widevine;
widevine.mKeySystem.AssignLiteral(kWidevineKeySystemName);
widevine.mKeySystem.AssignLiteral(EME_KEY_SYSTEM_WIDEVINE);
widevine.mInitDataTypes.AppendElement(u"cenc"_ns);
widevine.mInitDataTypes.AppendElement(u"keyids"_ns);
widevine.mInitDataTypes.AppendElement(u"webm"_ns);
@ -399,8 +398,8 @@ static nsTArray<KeySystemConfig> GetSupportedKeySystems() {
};
for (const auto& data : validationList) {
if (java::MediaDrmProxy::IsCryptoSchemeSupported(kWidevineKeySystemName,
data.mMimeType)) {
if (java::MediaDrmProxy::IsCryptoSchemeSupported(
EME_KEY_SYSTEM_WIDEVINE, data.mMimeType)) {
if (AndroidDecoderModule::SupportsMimeType(data.mMimeType)) {
data.mSupportType->SetCanDecryptAndDecode(data.mEMECodecType);
} else {

Просмотреть файл

@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS.mozilla.dom += [
"KeySystemNames.h",
"MediaEncryptedEvent.h",
"MediaKeyError.h",
"MediaKeyMessageEvent.h",

Просмотреть файл

@ -8,6 +8,7 @@
#include <utility>
#include "GMPLog.h"
#include "VideoUtils.h"
#include "WidevineUtils.h"
#include "content_decryption_module.h"
#include "content_decryption_module_ext.h"
@ -15,7 +16,6 @@
#include "gmp-api/gmp-video-codec.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/HelperMacros.h"
#include "mozilla/dom/KeySystemNames.h"
#ifdef XP_WIN
# include "WinUtils.h"
@ -103,13 +103,13 @@ GMPErr ChromiumCDMAdapter::GMPInit(const GMPPlatformAPI* aPlatformAPI) {
GMPErr ChromiumCDMAdapter::GMPGetAPI(const char* aAPIName, void* aHostAPI,
void** aPluginAPI,
const nsCString& aKeySystem) {
MOZ_ASSERT(
aKeySystem.EqualsLiteral(kWidevineKeySystemName) ||
aKeySystem.EqualsLiteral(kClearKeyKeySystemName) ||
aKeySystem.EqualsLiteral(kClearKeyWithProtectionQueryKeySystemName) ||
aKeySystem.EqualsLiteral("fake"),
"Should not get an unrecognized key system. Why didn't it get "
"blocked by MediaKeySystemAccess?");
MOZ_ASSERT(aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_WIDEVINE) ||
aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_CLEARKEY) ||
aKeySystem.EqualsLiteral(
EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY) ||
aKeySystem.EqualsLiteral("fake"),
"Should not get an unrecognized key system. Why didn't it get "
"blocked by MediaKeySystemAccess?");
GMP_LOG_DEBUG("ChromiumCDMAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %s) this=0x%p",
aAPIName, aHostAPI, aPluginAPI, aKeySystem.get(), this);
bool isCdm10 = !strcmp(aAPIName, CHROMIUM_CDM_API);

Просмотреть файл

@ -14,7 +14,6 @@
#include "GMPLog.h"
#include "GMPService.h"
#include "GMPUtils.h"
#include "VideoUtils.h"
#include "mozilla/dom/MediaKeyMessageEventBinding.h"
#include "mozilla/gmp/GMPTypes.h"
#include "mozilla/ScopeExit.h"

Просмотреть файл

@ -12,7 +12,6 @@
#include "GMPTimerParent.h"
#include "MediaResult.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/dom/KeySystemNames.h"
#include "mozilla/dom/WidevineCDMManifestBinding.h"
#include "mozilla/ipc/CrashReporterHost.h"
#include "mozilla/ipc/Endpoint.h"
@ -32,6 +31,7 @@
#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
#include "runnable_utils.h"
#include "VideoUtils.h"
#ifdef XP_WIN
# include "WMFDecoderModule.h"
#endif
@ -539,7 +539,7 @@ bool GMPCapability::Supports(const nsTArray<GMPCapability>& aCapabilities,
// file, but uses Windows Media Foundation to decode. That's not present
// on Windows XP, and on some Vista, Windows N, and KN variants without
// certain services packs.
if (tag.EqualsLiteral(kClearKeyKeySystemName)) {
if (tag.EqualsLiteral(EME_KEY_SYSTEM_CLEARKEY)) {
if (capabilities.mAPIName.EqualsLiteral(GMP_API_VIDEO_DECODER)) {
if (!WMFDecoderModule::HasH264()) {
continue;
@ -847,9 +847,9 @@ RefPtr<GenericPromise> GMPParent::ParseChromiumManifest(
// We hard code a few of the settings because they can't be stored in the
// widevine manifest without making our API different to widevine's.
if (mDisplayName.EqualsASCII("clearkey")) {
video.mAPITags.AppendElement(nsCString{kClearKeyKeySystemName});
video.mAPITags.AppendElement(nsCString{EME_KEY_SYSTEM_CLEARKEY});
video.mAPITags.AppendElement(
nsCString{kClearKeyWithProtectionQueryKeySystemName});
nsCString{EME_KEY_SYSTEM_CLEARKEY_WITH_PROTECTION_QUERY});
#if XP_WIN
mLibs = nsLiteralCString(
"dxva2.dll, evr.dll, freebl3.dll, mfh264dec.dll, mfplat.dll, "
@ -858,7 +858,7 @@ RefPtr<GenericPromise> GMPParent::ParseChromiumManifest(
mLibs = "libfreeblpriv3.so, libsoftokn3.so"_ns;
#endif
} else if (mDisplayName.EqualsASCII("WidevineCdm")) {
video.mAPITags.AppendElement(nsCString{kWidevineKeySystemName});
video.mAPITags.AppendElement(nsCString{EME_KEY_SYSTEM_WIDEVINE});
#if XP_WIN
// psapi.dll added for GetMappedFileNameW, which could possibly be avoided
// in future versions, see bug 1383611 for details.

Просмотреть файл

@ -856,9 +856,6 @@ scheme=https
[test_eme_setMediaKeys_before_attach_MediaSource.html]
skip-if = toolkit == 'android' # bug 1149374
scheme=https
[test_eme_special_key_system.html]
skip-if = toolkit == 'android' # bug 1149374
scheme=https
[test_eme_stream_capture_blocked_case1.html]
tags=mtg capturestream
skip-if = toolkit == 'android' # bug 1149374

Просмотреть файл

@ -1,63 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Test Encrypted Media Extensions - Special key system</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
function requestProtectionQueryKeySystemAccess() {
const kKeySystemOptions = [
{
initDataTypes: ["cenc"],
videoCapabilities: [{ contentType: 'video/mp4; codecs="avc1.4d4015"' }],
},
];
const kClearKeyWithProtectionQuery =
"org.mozilla.clearkey_with_protection_query";
return navigator.requestMediaKeySystemAccess(
kClearKeyWithProtectionQuery,
kKeySystemOptions
);
}
// Tests that org.mozilla.clearkey_with_protection_query cannot be accessed from JS if not preffed on.
add_task(async function protectionQueryKeySystemShouldBeHidden() {
try {
// Should throw since special key systems are not enabled.
await requestProtectionQueryKeySystemAccess();
ok(
false,
"Test should have thrown by default because media.clearkey.test-key-systems.enabled should not be set"
);
} catch (e) {
is(e.name, "NotSupportedError", "Should get not supported error");
is(
e.message,
"Key system is unsupported",
"Should get message that key system is unsupported"
);
}
});
// Tests that org.mozilla.clearkey_with_protection_query can be accessed from JS if preffed on.
add_task(async function protectionQueryKeySystemShouldBeExposed() {
await SpecialPowers.pushPrefEnv({
set: [["media.clearkey.test-key-systems.enabled", true]],
});
try {
// Should not throw since special key systems are enabled.
let access = await requestProtectionQueryKeySystemAccess();
ok(
access,
"Should get access to protection query key system when preffed on"
);
} catch (e) {
ok(false, "Test should not have thrown and key system should be available");
}
});
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -7,7 +7,6 @@
#include <cmath>
#include "FrameStatistics.h"
#include "VideoUtils.h"
#include "mozilla/EMEUtils.h"
#include "mozilla/Logging.h"
#include "mozilla/Telemetry.h"

Просмотреть файл

@ -77,12 +77,6 @@ void ClearKeyCDM::TimerExpired(void* aContext) {
Status ClearKeyCDM::Decrypt(const InputBuffer_2& aEncryptedBuffer,
DecryptedBlock* aDecryptedBuffer) {
if (mIsProtectionQueryEnabled) {
// Piggyback this check onto Decrypt calls. If Clearkey implements a timer
// based approach for firing events, we could instead trigger the check
// using that mechanism.
mSessionManager->QueryOutputProtectionStatusIfNeeded();
}
return mSessionManager->Decrypt(aEncryptedBuffer, aDecryptedBuffer);
}
@ -124,12 +118,6 @@ void ClearKeyCDM::ResetDecoder(StreamType aDecoderType) {
Status ClearKeyCDM::DecryptAndDecodeFrame(const InputBuffer_2& aEncryptedBuffer,
VideoFrame* aVideoFrame) {
#ifdef ENABLE_WMF
if (mIsProtectionQueryEnabled) {
// Piggyback this check onto Decrypt + Decode. If Clearkey implements a
// timer based approach for firing events, we could instead trigger the
// check using that mechanism.
mSessionManager->QueryOutputProtectionStatusIfNeeded();
}
return mVideoDecoder->Decode(aEncryptedBuffer, aVideoFrame);
#else
return Status::kDecodeError;
@ -152,16 +140,8 @@ void ClearKeyCDM::OnPlatformChallengeResponse(
void ClearKeyCDM::OnQueryOutputProtectionStatus(
QueryResult aResult, uint32_t aLinkMask, uint32_t aOutputProtectionMask) {
// The higher level GMP machinery should not forward us query information
// unless we've requested it (even if mutiple CDMs exist at once and some
// others are reqeusting this info). If this assert fires we're violating
// that.
MOZ_ASSERT(mIsProtectionQueryEnabled,
"Should only receive a protection status "
"mIsProtectionQueryEnabled is true");
// The session manager handles the guts of this for ClearKey.
mSessionManager->OnQueryOutputProtectionStatus(aResult, aLinkMask,
aOutputProtectionMask);
// This function should never be called and is not supported.
assert(false);
}
void ClearKeyCDM::OnStorageId(uint32_t aVersion, const uint8_t* aStorageId,
@ -180,9 +160,3 @@ void ClearKeyCDM::Destroy() {
#endif
delete this;
}
void ClearKeyCDM::EnableProtectionQuery() {
MOZ_ASSERT(!mIsProtectionQueryEnabled,
"Should not be called more than once per CDM");
mIsProtectionQueryEnabled = true;
}

Просмотреть файл

@ -25,7 +25,6 @@ class ClearKeyCDM : public cdm::ContentDecryptionModule_10 {
#ifdef ENABLE_WMF
RefPtr<VideoDecoder> mVideoDecoder;
#endif
bool mIsProtectionQueryEnabled = false;
protected:
cdm::Host_10* mHost;
@ -95,8 +94,6 @@ class ClearKeyCDM : public cdm::ContentDecryptionModule_10 {
uint32_t aStorageIdSize) override;
void Destroy() override;
void EnableProtectionQuery();
};
#endif

Просмотреть файл

@ -133,7 +133,6 @@ void ClearKeySessionManager::CreateSession(uint32_t aPromiseId,
}
mSessions[sessionId] = session;
mLastSessionId = sessionId;
const vector<KeyId>& sessionKeys = session->GetKeyIds();
vector<KeyId> neededKeys;
@ -239,7 +238,6 @@ void ClearKeySessionManager::PersistentSessionDataLoaded(
new ClearKeySession(aSessionId, SessionType::kPersistentLicense);
mSessions[aSessionId] = session;
mLastSessionId = aSessionId;
uint32_t numKeys = aKeyDataSize / (2 * CENC_KEY_LEN);
@ -573,7 +571,6 @@ void ClearKeySessionManager::DecryptingComplete() {
delete it->second;
}
mSessions.clear();
mLastSessionId = std::nullopt;
mDecryptionManager = nullptr;
mHost = nullptr;
@ -590,124 +587,3 @@ bool ClearKeySessionManager::MaybeDeferTillInitialized(
mDeferredInitialize.emplace(move(aMaybeDefer));
return true;
}
void ClearKeySessionManager::OnQueryOutputProtectionStatus(
QueryResult aResult, uint32_t aLinkMask, uint32_t aOutputProtectionMask) {
MOZ_ASSERT(mHasOutstandingOutputProtectionQuery,
"Should only be called if a query is outstanding");
CK_LOGD("ClearKeySessionManager::OnQueryOutputProtectionStatus");
mHasOutstandingOutputProtectionQuery = false;
if (aResult == QueryResult::kQueryFailed) {
// Indicate the query failed. This can happen if we're in shutdown.
NotifyOutputProtectionStatus(KeyStatus::kInternalError);
return;
}
if (aLinkMask & OutputLinkTypes::kLinkTypeNetwork) {
NotifyOutputProtectionStatus(KeyStatus::kOutputRestricted);
return;
}
NotifyOutputProtectionStatus(KeyStatus::kUsable);
}
void ClearKeySessionManager::QueryOutputProtectionStatusIfNeeded() {
MOZ_ASSERT(
mHost,
"Should not query protection status if we're shutdown (mHost == null)!");
CK_LOGD(
"ClearKeySessionManager::UpdateOutputProtectionStatusAndQueryIfNeeded");
if (mLastOutputProtectionQueryTime.IsNull()) {
// We haven't perfomed a check yet, get a query going.
MOZ_ASSERT(
!mHasOutstandingOutputProtectionQuery,
"Shouldn't have an outstanding query if we haven't recorded a time");
QueryOutputProtectionStatusFromHost();
return;
}
MOZ_ASSERT(!mLastOutputProtectionQueryTime.IsNull(),
"Should have already handled the case where we don't yet have a "
"previous check time");
const mozilla::TimeStamp now = mozilla::TimeStamp::NowLoRes();
const mozilla::TimeDuration timeSinceQuery =
now - mLastOutputProtectionQueryTime;
// The time between output protection checks to the host. I.e. if this amount
// of time has passed since the last check with the host, another should be
// performed (provided the first check has been handled).
static const mozilla::TimeDuration kOutputProtectionQueryInterval =
mozilla::TimeDuration::FromSeconds(0.2);
// The number of kOutputProtectionQueryInterval intervals we can miss before
// we decide a check has failed. I.e. if this value is 2, if we have not
// received a reply to a check after kOutputProtectionQueryInterval * 2
// time, we consider the check failed.
constexpr uint32_t kMissedIntervalsBeforeFailure = 2;
// The length of time after which we will restrict output until we get a
// query response.
static const mozilla::TimeDuration kTimeToWaitBeforeFailure =
kOutputProtectionQueryInterval * kMissedIntervalsBeforeFailure;
if ((timeSinceQuery > kOutputProtectionQueryInterval) &&
!mHasOutstandingOutputProtectionQuery) {
// We don't have an outstanding query and enough time has passed we should
// query again.
QueryOutputProtectionStatusFromHost();
return;
}
if ((timeSinceQuery > kTimeToWaitBeforeFailure) &&
mHasOutstandingOutputProtectionQuery) {
// A reponse was not received fast enough, notify.
NotifyOutputProtectionStatus(KeyStatus::kInternalError);
}
}
void ClearKeySessionManager::QueryOutputProtectionStatusFromHost() {
MOZ_ASSERT(
mHost,
"Should not query protection status if we're shutdown (mHost == null)!");
CK_LOGD("ClearKeySessionManager::QueryOutputProtectionStatusFromHost");
if (mHost) {
mLastOutputProtectionQueryTime = mozilla::TimeStamp::NowLoRes();
mHost->QueryOutputProtectionStatus();
mHasOutstandingOutputProtectionQuery = true;
}
}
void ClearKeySessionManager::NotifyOutputProtectionStatus(KeyStatus aStatus) {
MOZ_ASSERT(aStatus == KeyStatus::kUsable ||
aStatus == KeyStatus::kOutputRestricted ||
aStatus == KeyStatus::kInternalError,
"aStatus should have an expected value");
CK_LOGD("ClearKeySessionManager::NotifyOutputProtectionStatus");
if (!mLastSessionId.has_value()) {
// If we don't have a session id, either because we're too early, or are
// shutting down, don't notify.
return;
}
string& lastSessionId = mLastSessionId.value();
// Use 'output-protection' as the key ID. This helps tests disambiguate key
// status updates related to this.
const uint8_t kKeyId[] = {'o', 'u', 't', 'p', 'u', 't', '-', 'p', 'r',
'o', 't', 'e', 'c', 't', 'i', 'o', 'n'};
KeyInformation keyInfo = {};
keyInfo.key_id = kKeyId;
keyInfo.key_id_size = std::size(kKeyId);
keyInfo.status = aStatus;
vector<KeyInformation> keyInfos;
keyInfos.push_back(keyInfo);
// At time of writing, Gecko's higher level handling doesn't use this arg.
// However, we set it to false to mimic Chromium's similar case. Since
// Clearkey is used to test the Chromium CDM path, it doesn't hurt to try
// and mimic their behaviour.
bool hasAdditionalUseableKey = false;
mHost->OnSessionKeysChange(lastSessionId.c_str(), lastSessionId.size(),
hasAdditionalUseableKey, keyInfos.data(),
keyInfos.size());
}

Просмотреть файл

@ -17,24 +17,21 @@
#ifndef __ClearKeyDecryptor_h__
#define __ClearKeyDecryptor_h__
// This include is required in order for content_decryption_module to work
// on Unix systems.
#include <stddef.h>
#include <functional>
#include <map>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include "ClearKeyDecryptionManager.h"
#include "ClearKeyPersistence.h"
#include "ClearKeySession.h"
#include "ClearKeyUtils.h"
#include "RefCounted.h"
// This include is required in order for content_decryption_module to work
// on Unix systems.
#include "stddef.h"
#include "content_decryption_module.h"
#include "mozilla/TimeStamp.h"
#include "RefCounted.h"
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <string>
class ClearKeySessionManager final : public RefCounted {
public:
@ -72,23 +69,6 @@ class ClearKeySessionManager final : public RefCounted {
const uint8_t* aKeyData,
uint32_t aKeyDataSize);
// Receives the result of an output protection query from the user agent.
// This may trigger a key status change.
// @param aResult indicates if the query succeeded or not. If a query did
// not succeed then that other arguments are ignored.
// @param aLinkMask is used to indicate if output could be captured by the
// user agent. It should be set to `kLinkTypeNetwork` if capture is possible,
// otherwise it should be zero.
// @param aOutputProtectionMask this argument is unused.
void OnQueryOutputProtectionStatus(cdm::QueryResult aResult,
uint32_t aLinkMask,
uint32_t aOutputProtectionMask);
// Prompts the session manager to query the output protection status if we
// haven't yet, or if enough time has passed since the last check. Will also
// notify if a check has not been responded to on time.
void QueryOutputProtectionStatusIfNeeded();
private:
~ClearKeySessionManager();
@ -97,21 +77,6 @@ class ClearKeySessionManager final : public RefCounted {
void Serialize(const ClearKeySession* aSession,
std::vector<uint8_t>& aOutKeyData);
// Signals the host to perform an output protection check.
void QueryOutputProtectionStatusFromHost();
// Called to notify the result of an output protection status call. The
// following arguments are expected, along with their intended use:
// - KeyStatus::kUsable indicates that the query was responded to and the
// response showed output is protected.
// - KeyStatus::kOutputRestricted indicates that the query was responded to
// and the response showed output is not protected.
// - KeyStatus::kInternalError indicates a query was not repsonded to on
// time, or that a query was responded to with a failed cdm::QueryResult.
// The status passed to this function will be used to update the status of
// the keyId "output-protection", which tests an observe.
void NotifyOutputProtectionStatus(cdm::KeyStatus aStatus);
RefPtr<ClearKeyDecryptionManager> mDecryptionManager;
RefPtr<ClearKeyPersistence> mPersistence;
@ -120,18 +85,7 @@ class ClearKeySessionManager final : public RefCounted {
std::set<KeyId> mKeyIds;
std::map<std::string, ClearKeySession*> mSessions;
// The session id of the last session created or loaded from persistent
// storage. Used to fire test messages at that session.
std::optional<std::string> mLastSessionId;
std::queue<std::function<void()>> mDeferredInitialize;
// If there is an inflight query to the host to check the output protection
// status. Multiple in flight queries should not be allowed, avoid firing
// more if this is true.
bool mHasOutstandingOutputProtectionQuery = false;
// The last time the manager called QueryOutputProtectionStatus on the host.
mozilla::TimeStamp mLastOutputProtectionQueryTime;
};
#endif // __ClearKeyDecryptor_h__

Просмотреть файл

@ -22,7 +22,6 @@
#include "ClearKeyCDM.h"
#include "ClearKeySessionManager.h"
#include "mozilla/dom/KeySystemNames.h"
// This include is required in order for content_decryption_module to work
// on Unix systems.
#include "stddef.h"
@ -85,12 +84,6 @@ void* CreateCdmInstance(int cdm_interface_version, const char* key_system,
CK_LOGE("Created ClearKeyCDM instance!");
if (strncmp(key_system, mozilla::kClearKeyWithProtectionQueryKeySystemName,
key_system_size) == 0) {
CK_LOGE("Enabling protection query on ClearKeyCDM instance!");
clearKey->EnableProtectionQuery();
}
return clearKey;
}