Backed out 3 changesets (bug 1917873) for causing bpnu bustages on MFCDMSession.cpp. CLOSED TREE

Backed out changeset f073db877894 (bug 1917873)
Backed out changeset acf167a789d8 (bug 1917873)
Backed out changeset c82fc68684e4 (bug 1917873)
This commit is contained in:
Tamas Szentpeteri 2024-09-11 01:46:25 +03:00
Родитель b63fcda0f1
Коммит 5c59b80d05
4 изменённых файлов: 8 добавлений и 70 удалений

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

@ -142,7 +142,6 @@ void ClearKeySessionManager::CreateSession(uint32_t aPromiseId,
// request, whether or not another session has sent a request with the same // request, whether or not another session has sent a request with the same
// key ID. Otherwise a script can end up waiting for another script to // key ID. Otherwise a script can end up waiting for another script to
// respond to the request (which may not necessarily happen). // respond to the request (which may not necessarily happen).
CK_LOGARRAY("Key ID: ", it->data(), it->size());
neededKeys.push_back(*it); neededKeys.push_back(*it);
mDecryptionManager->ExpectKeyId(*it); mDecryptionManager->ExpectKeyId(*it);
} }

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

@ -4,19 +4,14 @@
#include "WMFCDMProxyCallback.h" #include "WMFCDMProxyCallback.h"
#include "GMPUtils.h"
#include "mozilla/EMEUtils.h"
#include "mozilla/WMFCDMProxy.h" #include "mozilla/WMFCDMProxy.h"
namespace mozilla {
#define RETURN_IF_NULL(proxy) \ #define RETURN_IF_NULL(proxy) \
if (!proxy) { \ if (!proxy) { \
return; \ return; \
} }
#define LOG(msg, ...) \ namespace mozilla {
EME_LOG("WMFCDMProxyCallback[%p]@%s: " msg, this, __func__, ##__VA_ARGS__)
WMFCDMProxyCallback::WMFCDMProxyCallback(WMFCDMProxy* aProxy) : mProxy(aProxy) { WMFCDMProxyCallback::WMFCDMProxyCallback(WMFCDMProxy* aProxy) : mProxy(aProxy) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -45,14 +40,9 @@ void WMFCDMProxyCallback::OnSessionKeyStatusesChange(
{ {
auto caps = mProxy->Capabilites().Lock(); auto caps = mProxy->Capabilites().Lock();
for (const auto& keyInfo : keyStatuses.keyInfo()) { for (const auto& keyInfo : keyStatuses.keyInfo()) {
bool statusChanged = caps->SetKeyStatus( keyStatusesChange |= caps->SetKeyStatus(
keyInfo.keyId(), keyStatuses.sessionId(), keyInfo.keyId(), keyStatuses.sessionId(),
dom::Optional<dom::MediaKeyStatus>(keyInfo.status())); dom::Optional<dom::MediaKeyStatus>(keyInfo.status()));
keyStatusesChange |= statusChanged;
LOG("Session ID: %s, Key ID: %s, Status changed: %s",
NS_ConvertUTF16toUTF8(keyStatuses.sessionId()).get(),
ToHexString(keyInfo.keyId()).get(),
statusChanged ? "true" : "false");
} }
} }
if (keyStatusesChange) { if (keyStatusesChange) {
@ -79,5 +69,4 @@ void WMFCDMProxyCallback::Shutdown() {
} }
#undef RETURN_IF_NULL #undef RETURN_IF_NULL
#undef LOG
} // namespace mozilla } // namespace mozilla

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

@ -233,21 +233,14 @@ void MFCDMSession::OnSessionKeysChange() {
}; };
CopyableTArray<MFCDMKeyInformation> keyInfos; CopyableTArray<MFCDMKeyInformation> keyInfos;
const bool isInTesting =
StaticPrefs::media_eme_wmf_use_mock_cdm_for_external_cdms();
for (uint32_t idx = 0; idx < count; idx++) { for (uint32_t idx = 0; idx < count; idx++) {
const MFMediaKeyStatus& keyStatus = keyStatuses[idx]; const MFMediaKeyStatus& keyStatus = keyStatuses[idx];
CopyableTArray<uint8_t> keyId; if (keyStatus.cbKeyId != sizeof(GUID)) {
if (isInTesting && keyStatus.cbKeyId != sizeof(GUID)) {
// Not a GUID, no need to convert it from GUID.
keyId.AppendElements(keyStatus.pbKeyId, keyStatus.cbKeyId);
} else if (keyStatus.cbKeyId == sizeof(GUID)) {
ByteArrayFromGUID(*reinterpret_cast<const GUID*>(keyStatus.pbKeyId),
keyId);
} else {
LOG("Key ID with unsupported size ignored"); LOG("Key ID with unsupported size ignored");
continue; continue;
} }
CopyableTArray<uint8_t> keyId;
ByteArrayFromGUID(reinterpret_cast<REFGUID>(keyStatus.pbKeyId), keyId);
nsAutoCString keyIdString(ToHexString(keyId)); nsAutoCString keyIdString(ToHexString(keyId));
LOG("Append keyid-sz=%u, keyid=%s, status=%s", keyStatus.cbKeyId, LOG("Append keyid-sz=%u, keyid=%s, status=%s", keyStatus.cbKeyId,

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

@ -55,10 +55,7 @@ add_task(async function testKeySystemRequestForMFCDMs() {
}); });
async function testKeySystemRequest(keySystem) { async function testKeySystemRequest(keySystem) {
// Create a Uint8Array for the key ID const fakeKID = '{"kids":["a1234567890"]}';
const fakeKID = new Uint8Array([0xa1, 0x23, 0x45, 0x67, 0x89]);
const fakeKIDBase64 = base64UrlEncode(String.fromCharCode.apply(null, fakeKID));
// Mock CDM only supports temporary type. // Mock CDM only supports temporary type.
const sessionType = 'temporary'; const sessionType = 'temporary';
const configs = [{ const configs = [{
@ -77,60 +74,20 @@ async function testKeySystemRequest(keySystem) {
info(`creating a temporary media key session`); info(`creating a temporary media key session`);
let session = mediaKeys.createSession(sessionType); let session = mediaKeys.createSession(sessionType);
let messagePromise = new Promise(r => { let messagePromise = new Promise(r => {
session.addEventListener('message', async event => { session.addEventListener('message', event => {
is(event.messageType, 'license-request', is(event.messageType, 'license-request',
'MediaKeyMessage type should be license-request'); 'MediaKeyMessage type should be license-request');
ok(true, `created request and received message event`); ok(true, `created request and received message event`);
// Simulate license server response in JWK format
const mockLicenseResponse = {
keys: [{
kty: "oct",
kid: fakeKIDBase64,
k: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=" // Base64 encoded 32-byte key
}],
type: "temporary"
};
const encoder = new TextEncoder();
const licenseBuffer = encoder.encode(JSON.stringify(mockLicenseResponse));
await session.update(licenseBuffer)
.catch(e => ok(false, `Failed to update session: ${e}`));
await new Promise(resolve => {
session.addEventListener('keystatuseschange', resolve, { once: true });
});
for (let [keyId, status] of session.keyStatuses) {
const keyIdBase64 = base64UrlEncode(String.fromCharCode.apply(null, new Uint8Array(keyId)));
is(keyIdBase64, fakeKIDBase64, "Key ID should match");
is(status, 'usable', 'Key status should be usable');
}
session.close().then(() => { r(); }); session.close().then(() => { r(); });
}); });
}); });
const initData = {
kids: [fakeKIDBase64], // Base64 encode the KID
type: 'temporary'
};
const initDataString = JSON.stringify(initData);
await session.generateRequest( await session.generateRequest(
'keyids', 'keyids',
new TextEncoder().encode(initDataString)) new TextEncoder().encode(fakeKID))
.catch(() => ok(false, `failed to generate request`)); .catch(() => ok(false, `failed to generate request`));
await messagePromise; await messagePromise;
} }
// Helper function to create a web-safe Base64 encoded string
function base64UrlEncode(str) {
return btoa(str)
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=+$/, '');
}
</script> </script>
</body> </body>
</html> </html>