зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1057171 - Implement MediaKeySession.getUsableKeyIds. r=bz
This commit is contained in:
Родитель
2e05a3f6ba
Коммит
96c25b7728
|
@ -184,4 +184,16 @@ CDMCaps::AutoLock::CanDecryptVideo()
|
|||
return mData.HasCap(GMP_EME_CAP_DECRYPT_VIDEO);
|
||||
}
|
||||
|
||||
void
|
||||
CDMCaps::AutoLock::GetUsableKeysForSession(const nsAString& aSessionId,
|
||||
nsTArray<CencKeyId>& aOutKeyIds)
|
||||
{
|
||||
for (size_t i = 0; i < mData.mUsableKeyIds.Length(); i++) {
|
||||
const auto& key = mData.mUsableKeyIds[i];
|
||||
if (key.mSessionId.Equals(aSessionId)) {
|
||||
aOutKeyIds.AppendElement(key.mId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -42,6 +42,8 @@ public:
|
|||
void SetKeyUnusable(const CencKeyId& aKeyId, const nsString& aSessionId);
|
||||
|
||||
void DropKeysForSession(const nsAString& aSessionId);
|
||||
void GetUsableKeysForSession(const nsAString& aSessionId,
|
||||
nsTArray<CencKeyId>& aOutKeyIds);
|
||||
|
||||
// Sets the capabilities of the CDM. aCaps is the logical OR of the
|
||||
// GMP_EME_CAP_* flags from gmp-decryption.h.
|
||||
|
|
|
@ -171,6 +171,34 @@ MediaKeySession::Remove(ErrorResult& aRv)
|
|||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
MediaKeySession::GetUsableKeyIds(ErrorResult& aRv)
|
||||
{
|
||||
nsRefPtr<Promise> promise(mKeys->MakePromise(aRv));
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (IsClosed() || !mKeys->GetCDMProxy()) {
|
||||
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
nsTArray<CencKeyId> keyIds;
|
||||
{
|
||||
CDMCaps::AutoLock caps(mKeys->GetCDMProxy()->Capabilites());
|
||||
caps.GetUsableKeysForSession(mSessionId, keyIds);
|
||||
}
|
||||
|
||||
nsTArray<TypedArrayCreator<ArrayBuffer>> array;
|
||||
for (size_t i = 0; i < keyIds.Length(); i++) {
|
||||
array.AppendElement(keyIds[i]);
|
||||
}
|
||||
promise->MaybeResolve(array);
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
void
|
||||
MediaKeySession::DispatchKeyMessage(const nsTArray<uint8_t>& aMessage,
|
||||
const nsAString& aURL)
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
|
||||
already_AddRefed<Promise> Remove(ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> GetUsableKeyIds(ErrorResult& aRv);
|
||||
|
||||
void DispatchKeyMessage(const nsTArray<uint8_t>& aMessage,
|
||||
const nsAString& aURL);
|
||||
|
||||
|
|
|
@ -19,10 +19,6 @@ interface MediaKeySession : EventTarget {
|
|||
readonly attribute DOMString keySystem;
|
||||
readonly attribute DOMString sessionId;
|
||||
|
||||
// Invalid WebIDL, doesn't work.
|
||||
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=25594
|
||||
// readonly attribute Array<Uint8Array> usableKeyIds;
|
||||
|
||||
readonly attribute unrestricted double expiration;
|
||||
|
||||
// void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457
|
||||
|
@ -40,4 +36,7 @@ interface MediaKeySession : EventTarget {
|
|||
// void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457
|
||||
[NewObject, Throws]
|
||||
Promise<void> remove();
|
||||
|
||||
[NewObject, Throws]
|
||||
Promise<sequence<ArrayBuffer>> getUsableKeyIds();
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче