Title: [221718] trunk/Source/WebCore
Revision
221718
Author
zandober...@gmail.com
Date
2017-09-06 22:58:32 -0700 (Wed, 06 Sep 2017)

Log Message

[GStreamer] Implement MediaPlayerPrivateGStreamerMSE::attempToDecryptWithInstance()
https://bugs.webkit.org/show_bug.cgi?id=176445

Reviewed by Xabier Rodriguez-Calvar.

Implement MediaPlayerPrivateGStreamerMSE::attempToDecryptWithInstance(), also
adding support for dispatching ClearKey keys into the append pipelines.

CDMInstanceClearKey::Key is added, containing key ID and value buffers as well
as the key status value. Vector of keys for a specific CDMInstance is
accessible through the CDMInstanceClearKey::keys() getter.

In MediaPlayerPrivateGStreamerMSE, that Vector is retrieved and then iterated
over, constructing corresponding key ID and key value lists that contain
GstBuffer objects into which each key ID and value data is copied. Both lists
are then set on the 'drm-cipher-clearkey' structure before it's dispatched
against each AppendPipeline object.

* platform/encryptedmedia/clearkey/CDMClearKey.h:
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::attemptToDecryptWithInstance):
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221717 => 221718)


--- trunk/Source/WebCore/ChangeLog	2017-09-07 04:23:35 UTC (rev 221717)
+++ trunk/Source/WebCore/ChangeLog	2017-09-07 05:58:32 UTC (rev 221718)
@@ -1,3 +1,28 @@
+2017-09-06  Zan Dobersek  <zdober...@igalia.com>
+
+        [GStreamer] Implement MediaPlayerPrivateGStreamerMSE::attempToDecryptWithInstance()
+        https://bugs.webkit.org/show_bug.cgi?id=176445
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Implement MediaPlayerPrivateGStreamerMSE::attempToDecryptWithInstance(), also
+        adding support for dispatching ClearKey keys into the append pipelines.
+
+        CDMInstanceClearKey::Key is added, containing key ID and value buffers as well
+        as the key status value. Vector of keys for a specific CDMInstance is
+        accessible through the CDMInstanceClearKey::keys() getter.
+
+        In MediaPlayerPrivateGStreamerMSE, that Vector is retrieved and then iterated
+        over, constructing corresponding key ID and key value lists that contain
+        GstBuffer objects into which each key ID and value data is copied. Both lists
+        are then set on the 'drm-cipher-clearkey' structure before it's dispatched
+        against each AppendPipeline object.
+
+        * platform/encryptedmedia/clearkey/CDMClearKey.h:
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerMSE::attemptToDecryptWithInstance):
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
+
 2017-09-06  Joseph Pecoraro  <pecor...@apple.com>
 
         Fetch's Response.statusText is unexpectedly the full http status line for HTTP/2 responses

Modified: trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h (221717 => 221718)


--- trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h	2017-09-07 04:23:35 UTC (rev 221717)
+++ trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h	2017-09-07 05:58:32 UTC (rev 221718)
@@ -33,6 +33,7 @@
 #include "CDMFactory.h"
 #include "CDMInstance.h"
 #include "CDMPrivate.h"
+#include "SharedBuffer.h"
 
 namespace WebCore {
 
@@ -91,6 +92,17 @@
     void storeRecordOfKeyUsage(const String&) override;
 
     const String& keySystem() const final;
+
+    struct Key {
+        KeyStatus status;
+        RefPtr<SharedBuffer> keyIDData;
+        RefPtr<SharedBuffer> keyValueData;
+    };
+
+    const Vector<Key>& keys() const { return m_keys; }
+
+private:
+    Vector<Key> m_keys;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp (221717 => 221718)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2017-09-07 04:23:35 UTC (rev 221717)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2017-09-07 05:58:32 UTC (rev 221718)
@@ -53,6 +53,11 @@
 #include <wtf/text/AtomicString.h>
 #include <wtf/text/AtomicStringHash.h>
 
+#if ENABLE(ENCRYPTED_MEDIA)
+#include "CDMClearKey.h"
+#include "SharedBuffer.h"
+#endif
+
 static const char* dumpReadyState(WebCore::MediaPlayer::ReadyState readyState)
 {
     switch (readyState) {
@@ -927,6 +932,43 @@
     return result;
 }
 
+#if ENABLE(ENCRYPTED_MEDIA)
+void MediaPlayerPrivateGStreamerMSE::attemptToDecryptWithInstance(const CDMInstance& instance)
+{
+    if (is<CDMInstanceClearKey>(instance)) {
+        auto& ckInstance = downcast<CDMInstanceClearKey>(instance);
+        if (ckInstance.keys().isEmpty())
+            return;
+
+        GValue keyIDList = G_VALUE_INIT, keyValueList = G_VALUE_INIT;
+        g_value_init(&keyIDList, GST_TYPE_LIST);
+        g_value_init(&keyValueList, GST_TYPE_LIST);
+
+        auto appendBuffer =
+            [](GValue* valueList, const SharedBuffer& buffer)
+            {
+                GValue* bufferValue = g_new0(GValue, 1);
+                g_value_init(bufferValue, GST_TYPE_BUFFER);
+                gst_value_take_buffer(bufferValue,
+                    gst_buffer_new_wrapped(g_memdup(buffer.data(), buffer.size()), buffer.size()));
+                gst_value_list_append_and_take_value(valueList, bufferValue);
+            };
+
+        for (auto& key : ckInstance.keys()) {
+            appendBuffer(&keyIDList, *key.keyIDData);
+            appendBuffer(&keyValueList, *key.keyValueData);
+        }
+
+        GUniquePtr<GstStructure> structure(gst_structure_new_empty("drm-cipher-clearkey"));
+        gst_structure_set_value(structure.get(), "key-ids", &keyIDList);
+        gst_structure_set_value(structure.get(), "key-values", &keyValueList);
+
+        for (auto it : m_appendPipelinesMap)
+            it.value->dispatchDecryptionStructure(GUniquePtr<GstStructure>(gst_structure_copy(structure.get())));
+    }
+}
+#endif
+
 } // namespace WebCore.
 
 #endif // USE(GSTREAMER)

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h (221717 => 221718)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2017-09-07 04:23:35 UTC (rev 221717)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2017-09-07 05:58:32 UTC (rev 221718)
@@ -85,6 +85,10 @@
 
     static bool supportsCodecs(const String& codecs);
 
+#if ENABLE(ENCRYPTED_MEDIA)
+    void attemptToDecryptWithInstance(const CDMInstance&) final;
+#endif
+
 private:
     static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
     static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to