Title: [222498] trunk
Revision
222498
Author
[email protected]
Date
2017-09-26 02:48:23 -0700 (Tue, 26 Sep 2017)

Log Message

[EME] Add ClearKey support for persistent session data load and removal
https://bugs.webkit.org/show_bug.cgi?id=177442

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

Implement the session data load and removal for persistent sessions
in the ClearKey implementation of the CDMInstance interface.

CDMInstanceClearKey::loadSession() finds data for the specified session
name, if any, and constructs a corresponding KeyStatusVector object that
holds information about all known keys associated with this session before
dispatching the LoadSessionCallback asynchronously.

CDMInstanceClearKey::removeSessionData() similarly finds the session data,
if any, and then removes it from the state tracker. The key data is still
reused to construct the KeyStatusVector object that holds information
about all the keys that were stored for this session. The key information
is also embedded in the 'license release' JSON message. Both key status
vector and message are then used in the RemoveSessionDataCallback dispatch
that is again done asynchronously.

No new tests -- affected tests have their baselines updated.

* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::CDMInstanceClearKey::loadSession):
(WebCore::CDMInstanceClearKey::removeSessionData):

LayoutTests:

Update WPE baselines for EME tests affected by the addition of persistent
session data load and removal in the ClearKey implementation.

All the affected tests progress, but most of them still don't pass
entirely due to missing functionality in the GStreamer pipeline.

* platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-destroy-persistent-license-expected.txt:
* platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-persistent-license-events-expected.txt:
* platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-destroy-persistent-license-expected.txt:
* platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-persistent-license-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222497 => 222498)


--- trunk/LayoutTests/ChangeLog	2017-09-26 08:38:16 UTC (rev 222497)
+++ trunk/LayoutTests/ChangeLog	2017-09-26 09:48:23 UTC (rev 222498)
@@ -1,3 +1,21 @@
+2017-09-26  Zan Dobersek  <[email protected]>
+
+        [EME] Add ClearKey support for persistent session data load and removal
+        https://bugs.webkit.org/show_bug.cgi?id=177442
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Update WPE baselines for EME tests affected by the addition of persistent
+        session data load and removal in the ClearKey implementation.
+
+        All the affected tests progress, but most of them still don't pass
+        entirely due to missing functionality in the GStreamer pipeline.
+
+        * platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-destroy-persistent-license-expected.txt:
+        * platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-persistent-license-events-expected.txt:
+        * platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-destroy-persistent-license-expected.txt:
+        * platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-persistent-license-expected.txt:
+
 2017-09-25  Devin Rousso  <[email protected]>
 
         Web Inspector: move Console.addInspectedNode to DOM.setInspectedNode

Modified: trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-destroy-persistent-license-expected.txt (222497 => 222498)


--- trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-destroy-persistent-license-expected.txt	2017-09-26 08:38:16 UTC (rev 222497)
+++ trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-destroy-persistent-license-expected.txt	2017-09-26 09:48:23 UTC (rev 222498)
@@ -1,3 +1,3 @@
 
-FAIL org.w3.clearkey, persistent-license, mp4, playback, destroy and acknowledge assert_unreached: NotSupportedError: The operation is not supported. Reached unreachable code
+PASS org.w3.clearkey, persistent-license, mp4, playback, destroy and acknowledge 
 

Modified: trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-persistent-license-events-expected.txt (222497 => 222498)


--- trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-persistent-license-events-expected.txt	2017-09-26 08:38:16 UTC (rev 222497)
+++ trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-persistent-license-events-expected.txt	2017-09-26 09:48:23 UTC (rev 222498)
@@ -1,3 +1,3 @@
 
-FAIL org.w3.clearkey, persistent-license, mp4, playback, check events assert_unreached: NotSupportedError: The operation is not supported. Reached unreachable code
+FAIL org.w3.clearkey, persistent-license, mp4, playback, check events assert_equals: Expected 1st event to be 'generaterequest' expected "generaterequest" but got "license-request"
 

Modified: trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-destroy-persistent-license-expected.txt (222497 => 222498)


--- trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-destroy-persistent-license-expected.txt	2017-09-26 08:38:16 UTC (rev 222497)
+++ trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-destroy-persistent-license-expected.txt	2017-09-26 09:48:23 UTC (rev 222498)
@@ -1,3 +1,5 @@
 
-FAIL org.w3.clearkey, persistent-license, mp4, playback, retrieve, playback and destroy assert_equals: NotSupportedError: The operation is not supported. expected true but got false
+Harness Error (TIMEOUT), message = null
 
+TIMEOUT org.w3.clearkey, persistent-license, mp4, playback, retrieve, playback and destroy Test timed out
+

Modified: trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-persistent-license-expected.txt (222497 => 222498)


--- trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-persistent-license-expected.txt	2017-09-26 08:38:16 UTC (rev 222497)
+++ trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-retrieve-persistent-license-expected.txt	2017-09-26 09:48:23 UTC (rev 222498)
@@ -1,3 +1,5 @@
 
-FAIL org.w3.clearkey, persistent-license, mp4, playback, retrieve and playback assert_equals: NotSupportedError: The operation is not supported. expected true but got false
+Harness Error (TIMEOUT), message = null
 
+TIMEOUT org.w3.clearkey, persistent-license, mp4, playback, retrieve and playback Test timed out
+

Modified: trunk/Source/WebCore/ChangeLog (222497 => 222498)


--- trunk/Source/WebCore/ChangeLog	2017-09-26 08:38:16 UTC (rev 222497)
+++ trunk/Source/WebCore/ChangeLog	2017-09-26 09:48:23 UTC (rev 222498)
@@ -1,3 +1,32 @@
+2017-09-26  Zan Dobersek  <[email protected]>
+
+        [EME] Add ClearKey support for persistent session data load and removal
+        https://bugs.webkit.org/show_bug.cgi?id=177442
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Implement the session data load and removal for persistent sessions
+        in the ClearKey implementation of the CDMInstance interface.
+
+        CDMInstanceClearKey::loadSession() finds data for the specified session
+        name, if any, and constructs a corresponding KeyStatusVector object that
+        holds information about all known keys associated with this session before
+        dispatching the LoadSessionCallback asynchronously.
+
+        CDMInstanceClearKey::removeSessionData() similarly finds the session data,
+        if any, and then removes it from the state tracker. The key data is still
+        reused to construct the KeyStatusVector object that holds information
+        about all the keys that were stored for this session. The key information
+        is also embedded in the 'license release' JSON message. Both key status
+        vector and message are then used in the RemoveSessionDataCallback dispatch
+        that is again done asynchronously.
+
+        No new tests -- affected tests have their baselines updated.
+
+        * platform/encryptedmedia/clearkey/CDMClearKey.cpp:
+        (WebCore::CDMInstanceClearKey::loadSession):
+        (WebCore::CDMInstanceClearKey::removeSessionData):
+
 2017-09-26  Ms2ger  <[email protected]>
 
         Update compressedTexImage3D to match the signature in the specification.

Modified: trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp (222497 => 222498)


--- trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp	2017-09-26 08:38:16 UTC (rev 222497)
+++ trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp	2017-09-26 09:48:23 UTC (rev 222498)
@@ -452,15 +452,37 @@
     dispatchCallback(false, std::nullopt, SuccessValue::Failed);
 }
 
-void CDMInstanceClearKey::loadSession(LicenseType, const String&, const String&, LoadSessionCallback callback)
+void CDMInstanceClearKey::loadSession(LicenseType, const String& sessionId, const String&, LoadSessionCallback callback)
 {
-    callOnMainThread(
-        [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback)] {
-            if (!weakThis)
-                return;
+    // Use a helper functor that schedules the callback dispatch, avoiding duplicated callOnMainThread() calls.
+    auto dispatchCallback =
+        [this, &callback](std::optional<KeyStatusVector>&& existingKeys, SuccessValue success, SessionLoadFailure loadFailure) {
+            callOnMainThread(
+                [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback), existingKeys = WTFMove(existingKeys), success, loadFailure]() mutable {
+                    if (!weakThis)
+                        return;
 
-            callback(std::nullopt, std::nullopt, std::nullopt, Failed, SessionLoadFailure::Other);
-        });
+                    callback(WTFMove(existingKeys), std::nullopt, std::nullopt, success, loadFailure);
+                });
+        };
+
+    // Construct the KeyStatusVector object, representing all the known keys for this session.
+    KeyStatusVector keyStatusVector;
+    {
+        auto& keys = ClearKeyState::singleton().keys();
+        auto it = keys.find(sessionId);
+        if (it == keys.end()) {
+            dispatchCallback(std::nullopt, Failed, SessionLoadFailure::NoSessionData);
+            return;
+        }
+
+        auto& keyVector = it->value;
+        keyStatusVector.reserveInitialCapacity(keyVector.size());
+        for (auto& key : keyVector)
+            keyStatusVector.uncheckedAppend(std::pair<Ref<SharedBuffer>, KeyStatus> { *key.keyIDData, key.status });
+    }
+
+    dispatchCallback(WTFMove(keyStatusVector), Succeeded, SessionLoadFailure::None);
 }
 
 void CDMInstanceClearKey::closeSession(const String&, CloseSessionCallback callback)
@@ -474,15 +496,62 @@
         });
 }
 
-void CDMInstanceClearKey::removeSessionData(const String&, LicenseType, RemoveSessionDataCallback callback)
+void CDMInstanceClearKey::removeSessionData(const String& sessionId, LicenseType, RemoveSessionDataCallback callback)
 {
-    callOnMainThread(
-        [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback)] {
-            if (!weakThis)
-                return;
+    // Use a helper functor that schedules the callback dispatch, avoiding duplicated callOnMainThread() calls.
+    auto dispatchCallback =
+        [this, &callback](KeyStatusVector&& keyStatusVector, std::optional<Ref<SharedBuffer>>&& message, SuccessValue success) {
+            callOnMainThread(
+                [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback), keyStatusVector = WTFMove(keyStatusVector), message = WTFMove(message), success]() mutable {
+                    if (!weakThis)
+                        return;
 
-            callback({ }, std::nullopt, Failed);
-        });
+                    callback(WTFMove(keyStatusVector), WTFMove(message), success);
+                });
+        };
+
+    // Construct the KeyStatusVector object, representing released keys, and the message in the
+    // 'license release' format.
+    KeyStatusVector keyStatusVector;
+    RefPtr<SharedBuffer> message;
+    {
+        // Retrieve information for the given session ID, bailing if none is found.
+        auto& keys = ClearKeyState::singleton().keys();
+        auto it = keys.find(sessionId);
+        if (it == keys.end()) {
+            dispatchCallback(KeyStatusVector { }, std::nullopt, SuccessValue::Failed);
+            return;
+        }
+
+        // Retrieve the Key vector, containing all the keys for this session, and
+        // then remove the key map entry for this session.
+        auto keyVector = WTFMove(it->value);
+        keys.remove(it);
+
+        // Construct the KeyStatusVector object, pairing key IDs with the 'released' status.
+        keyStatusVector.reserveInitialCapacity(keyVector.size());
+        for (auto& key : keyVector)
+            keyStatusVector.uncheckedAppend(std::pair<Ref<SharedBuffer>, KeyStatus> { *key.keyIDData, KeyStatus::Released });
+
+        // Construct JSON that represents the 'license release' format, creating a 'kids' array
+        // of base64URL-encoded key IDs for all keys that were associated with this session.
+        auto rootObject = InspectorObject::create();
+        {
+            auto array = InspectorArray::create();
+            for (auto& key : keyVector) {
+                ASSERT(key.keyIDData->size() <= std::numeric_limits<unsigned>::max());
+                array->pushString(WTF::base64URLEncode(key.keyIDData->data(), static_cast<unsigned>(key.keyIDData->size())));
+            }
+            rootObject->setArray("kids", WTFMove(array));
+        }
+
+        // Copy the JSON data into a SharedBuffer object.
+        String messageString = rootObject->toJSONString();
+        CString messageCString = messageString.utf8();
+        message = SharedBuffer::create(messageCString.data(), messageCString.length());
+    }
+
+    dispatchCallback(WTFMove(keyStatusVector), Ref<SharedBuffer>(*message), SuccessValue::Succeeded);
 }
 
 void CDMInstanceClearKey::storeRecordOfKeyUsage(const String&)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to