<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[237921] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/237921">237921</a></dd>
<dt>Author</dt> <dd>cturner@igalia.com</dd>
<dt>Date</dt> <dd>2018-11-07 03:50:30 -0800 (Wed, 07 Nov 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>[EME][GStreamer] Ensure key id buffers are present and simplify lifetime management of ClearKey class.
https://bugs.webkit.org/show_bug.cgi?id=191157

Reviewed by Xabier Rodriguez-Calvar.

This is in preparation for moving the clearkey decryptor behind a
new decrypt API in CDMInstance, which will be sent into the
pipeline to handle key management and decryption. This is for a
later patch.

Covered by existing clear key tests in media/encrypted-media.

* platform/graphics/gstreamer/GStreamerCommon.h:
(WebCore::GstMappedBuffer::data const): Add a const data accessor,
since we are now providing operator=='s on const objects of this
class that need const access to the data pointer.
(WebCore::GstMappedBuffer::operator==): Add a swap of the new
equality operator so you don't have to remember to have the
GstBuffer on the RHS of the equality all the time.
(WebCore::operator==): Define an equality operator between Gst
buffers and WebCore's mapped buffers. Gst creates a ref and a
separate read view under the covers in the memcmp call, so we do
not need to map the buffer ourselves.
* platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
(webkit_media_clear_key_decrypt_class_init): Remove setup/release
bindings.
(webkit_media_clear_key_decrypt_init): Initialize gcrypt cipher
here once instead of for every buffer to be decrypted.
(webKitMediaClearKeyDecryptorFinalize): And destroy the cipher
context when the decryptor is destroyed.
(webKitMediaClearKeyDecryptorFindAndSetKey): Factor out the key
retrieval and context setting in this method, call it for each
sample.
(webKitMediaClearKeyDecryptorDecrypt): Base key id buffer into
this function, and remove cipher creation / destroy methods.
* platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:
(webkit_media_common_encryption_decrypt_class_init): Remove
setup/release bindings.
(webkitMediaCommonEncryptionDecryptTransformInPlace): Ensure a key
id is present and pass it to the decrypt class method.
(webKitMediaCommonEncryptionDecryptDefaultSetupCipher): Deleted.
(webKitMediaCommonEncryptionDecryptDefaultReleaseCipher): Deleted.
* platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerGStreamerCommonh">trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreameremeWebKitClearKeyDecryptorGStreamercpp">trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreameremeWebKitCommonEncryptionDecryptorGStreamercpp">trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreameremeWebKitCommonEncryptionDecryptorGStreamerh">trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (237920 => 237921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-11-07 11:29:27 UTC (rev 237920)
+++ trunk/Source/WebCore/ChangeLog      2018-11-07 11:50:30 UTC (rev 237921)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2018-11-07  Charlie Turner  <cturner@igalia.com>
+
+        [EME][GStreamer] Ensure key id buffers are present and simplify lifetime management of ClearKey class.
+        https://bugs.webkit.org/show_bug.cgi?id=191157
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        This is in preparation for moving the clearkey decryptor behind a
+        new decrypt API in CDMInstance, which will be sent into the
+        pipeline to handle key management and decryption. This is for a
+        later patch.
+
+        Covered by existing clear key tests in media/encrypted-media.
+
+        * platform/graphics/gstreamer/GStreamerCommon.h:
+        (WebCore::GstMappedBuffer::data const): Add a const data accessor,
+        since we are now providing operator=='s on const objects of this
+        class that need const access to the data pointer.
+        (WebCore::GstMappedBuffer::operator==): Add a swap of the new
+        equality operator so you don't have to remember to have the
+        GstBuffer on the RHS of the equality all the time.
+        (WebCore::operator==): Define an equality operator between Gst
+        buffers and WebCore's mapped buffers. Gst creates a ref and a
+        separate read view under the covers in the memcmp call, so we do
+        not need to map the buffer ourselves.
+        * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
+        (webkit_media_clear_key_decrypt_class_init): Remove setup/release
+        bindings.
+        (webkit_media_clear_key_decrypt_init): Initialize gcrypt cipher
+        here once instead of for every buffer to be decrypted.
+        (webKitMediaClearKeyDecryptorFinalize): And destroy the cipher
+        context when the decryptor is destroyed.
+        (webKitMediaClearKeyDecryptorFindAndSetKey): Factor out the key
+        retrieval and context setting in this method, call it for each
+        sample.
+        (webKitMediaClearKeyDecryptorDecrypt): Base key id buffer into
+        this function, and remove cipher creation / destroy methods.
+        * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:
+        (webkit_media_common_encryption_decrypt_class_init): Remove
+        setup/release bindings.
+        (webkitMediaCommonEncryptionDecryptTransformInPlace): Ensure a key
+        id is present and pass it to the decrypt class method.
+        (webKitMediaCommonEncryptionDecryptDefaultSetupCipher): Deleted.
+        (webKitMediaCommonEncryptionDecryptDefaultReleaseCipher): Deleted.
+        * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h:
+
</ins><span class="cx"> 2018-11-07  Frederic Wang  <fwang@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [Cairo] Move state change operations from GraphicsContextCairo to CairoOperations
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerGStreamerCommonh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h (237920 => 237921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h       2018-11-07 11:29:27 UTC (rev 237920)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h  2018-11-07 11:50:30 UTC (rev 237921)
</span><span class="lines">@@ -108,15 +108,33 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     uint8_t* data() { ASSERT(m_isValid); return static_cast<uint8_t*>(m_info.data); }
</span><ins>+    const uint8_t* data() const { ASSERT(m_isValid); return static_cast<uint8_t*>(m_info.data); }
+
</ins><span class="cx">     size_t size() const { ASSERT(m_isValid); return static_cast<size_t>(m_info.size); }
</span><span class="cx"> 
</span><span class="cx">     explicit operator bool() const { return m_isValid; }
</span><ins>+
</ins><span class="cx"> private:
</span><ins>+    friend bool operator==(const GstMappedBuffer&, const GstMappedBuffer&);
+    friend bool operator==(const GstMappedBuffer&, const GstBuffer*);
+    friend bool operator==(const GstBuffer* a, const GstMappedBuffer& b) { return operator==(b, a); }
+
</ins><span class="cx">     GstBuffer* m_buffer { nullptr };
</span><span class="cx">     GstMapInfo m_info;
</span><span class="cx">     bool m_isValid { false };
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+inline bool operator==(const GstMappedBuffer& a, const GstMappedBuffer& b)
+{
+    return a.size() == b.size() && !gst_buffer_memcmp(a.m_buffer, 0, b.data(), b.size());
+}
+
+inline bool operator==(const GstMappedBuffer& a, const GstBuffer* b)
+{
+    GstBuffer* nonConstB = const_cast<GstBuffer*>(b);
+    return a.size() == gst_buffer_get_size(nonConstB) && !gst_buffer_memcmp(nonConstB, 0, a.data(), a.size());
+}
+
</ins><span class="cx"> bool gstRegistryHasElementForMediaType(GList* elementFactories, const char* capsString);
</span><span class="cx"> void connectSimpleBusMessageCallback(GstElement *pipeline);
</span><span class="cx"> void disconnectSimpleBusMessageCallback(GstElement *pipeline);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreameremeWebKitClearKeyDecryptorGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp (237920 => 237921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp        2018-11-07 11:29:27 UTC (rev 237920)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp   2018-11-07 11:50:30 UTC (rev 237921)
</span><span class="lines">@@ -45,9 +45,7 @@
</span><span class="cx"> 
</span><span class="cx"> static void webKitMediaClearKeyDecryptorFinalize(GObject*);
</span><span class="cx"> static gboolean webKitMediaClearKeyDecryptorHandleKeyResponse(WebKitMediaCommonEncryptionDecrypt* self, GstEvent*);
</span><del>-static gboolean webKitMediaClearKeyDecryptorSetupCipher(WebKitMediaCommonEncryptionDecrypt*, GstBuffer*);
-static gboolean webKitMediaClearKeyDecryptorDecrypt(WebKitMediaCommonEncryptionDecrypt*, GstBuffer* iv, GstBuffer* sample, unsigned subSamplesCount, GstBuffer* subSamples);
-static void webKitMediaClearKeyDecryptorReleaseCipher(WebKitMediaCommonEncryptionDecrypt*);
</del><ins>+static gboolean webKitMediaClearKeyDecryptorDecrypt(WebKitMediaCommonEncryptionDecrypt*, GstBuffer* iv, GstBuffer* keyid, GstBuffer* sample, unsigned subSamplesCount, GstBuffer* subSamples);
</ins><span class="cx"> 
</span><span class="cx"> GST_DEBUG_CATEGORY_STATIC(webkit_media_clear_key_decrypt_debug_category);
</span><span class="cx"> #define GST_CAT_DEFAULT webkit_media_clear_key_decrypt_debug_category
</span><span class="lines">@@ -89,9 +87,7 @@
</span><span class="cx">     WebKitMediaCommonEncryptionDecryptClass* cencClass = WEBKIT_MEDIA_CENC_DECRYPT_CLASS(klass);
</span><span class="cx">     cencClass->protectionSystemId = WebCore::GStreamerEMEUtilities::s_ClearKeyUUID;
</span><span class="cx">     cencClass->handleKeyResponse = GST_DEBUG_FUNCPTR(webKitMediaClearKeyDecryptorHandleKeyResponse);
</span><del>-    cencClass->setupCipher = GST_DEBUG_FUNCPTR(webKitMediaClearKeyDecryptorSetupCipher);
</del><span class="cx">     cencClass->decrypt = GST_DEBUG_FUNCPTR(webKitMediaClearKeyDecryptorDecrypt);
</span><del>-    cencClass->releaseCipher = GST_DEBUG_FUNCPTR(webKitMediaClearKeyDecryptorReleaseCipher);
</del><span class="cx"> 
</span><span class="cx">     g_type_class_add_private(klass, sizeof(WebKitMediaClearKeyDecryptPrivate));
</span><span class="cx"> }
</span><span class="lines">@@ -102,6 +98,10 @@
</span><span class="cx"> 
</span><span class="cx">     self->priv = priv;
</span><span class="cx">     new (priv) WebKitMediaClearKeyDecryptPrivate();
</span><ins>+    if (gcry_error_t error = gcry_cipher_open(&(priv->handle), GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR, GCRY_CIPHER_SECURE)) {
+        GST_ERROR_OBJECT(self, "Failed to create AES 128 CTR cipher handle: %s", gpg_strerror(error));
+        ASSERT(!error);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void webKitMediaClearKeyDecryptorFinalize(GObject* object)
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx"> {
</span><span class="cx">     WebKitMediaClearKeyDecrypt* self = WEBKIT_MEDIA_CK_DECRYPT(object);
</span><span class="cx">     WebKitMediaClearKeyDecryptPrivate* priv = self->priv;
</span><del>-
</del><ins>+    gcry_cipher_close(priv->handle);
</ins><span class="cx">     priv->~WebKitMediaClearKeyDecryptPrivate();
</span><span class="cx"> 
</span><span class="cx">     GST_CALL_PARENT(G_OBJECT_CLASS, finalize, (object));
</span><span class="lines">@@ -150,25 +150,11 @@
</span><span class="cx">     return TRUE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static gboolean webKitMediaClearKeyDecryptorSetupCipher(WebKitMediaCommonEncryptionDecrypt* self, GstBuffer* keyIDBuffer)
</del><ins>+static gboolean webKitMediaClearKeyDecryptorFindAndSetKey(WebKitMediaClearKeyDecryptPrivate* priv, const WebCore::GstMappedBuffer& keyIDBuffer)
</ins><span class="cx"> {
</span><del>-    if (!keyIDBuffer) {
-        GST_ERROR_OBJECT(self, "got no key id buffer");
-        return false;
-    }
-
-    WebKitMediaClearKeyDecryptPrivate* priv = WEBKIT_MEDIA_CK_DECRYPT_GET_PRIVATE(WEBKIT_MEDIA_CK_DECRYPT(self));
-    gcry_error_t error;
-
</del><span class="cx">     GRefPtr<GstBuffer> keyBuffer;
</span><del>-    WebCore::GstMappedBuffer mappedKeyIdBuffer(keyIDBuffer, GST_MAP_READ);
-    if (!mappedKeyIdBuffer) {
-        GST_ERROR_OBJECT(self, "Failed to map key ID buffer");
-        return false;
-    }
-
</del><span class="cx">     for (auto& key : priv->keys) {
</span><del>-        if (!gst_buffer_memcmp(key.keyID.get(), 0, mappedKeyIdBuffer.data(), mappedKeyIdBuffer.size())) {
</del><ins>+        if (key.keyID.get() == keyIDBuffer) {
</ins><span class="cx">             keyBuffer = key.keyValue;
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="lines">@@ -175,33 +161,26 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!keyBuffer) {
</span><del>-        GST_ERROR_OBJECT(self, "Failed to find an appropriate key buffer");
</del><ins>+        GST_ERROR_OBJECT(priv, "Failed to find an appropriate key buffer");
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    error = gcry_cipher_open(&(priv->handle), GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CTR, GCRY_CIPHER_SECURE);
-    if (error) {
-        GST_ERROR_OBJECT(self, "Failed to create AES 128 CTR cipher handle: %s", gpg_strerror(error));
</del><ins>+    WebCore::GstMappedBuffer mappedKeyValueBuffer(keyBuffer.get(), GST_MAP_READ);
+    if (!mappedKeyValueBuffer) {
+        GST_ERROR_OBJECT(priv, "Failed to map decryption key");
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    WebCore::GstMappedBuffer mappedKeyBuffer(keyBuffer.get(), GST_MAP_READ);
-    if (!mappedKeyBuffer) {
-        GST_ERROR_OBJECT(self, "Failed to map decryption key");
</del><ins>+    ASSERT(mappedKeyValueBuffer.size() == CLEARKEY_SIZE);
+    if (gcry_error_t error = gcry_cipher_setkey(priv->handle, mappedKeyValueBuffer.data(), mappedKeyValueBuffer.size())) {
+        GST_ERROR_OBJECT(priv, "gcry_cipher_setkey failed: %s", gpg_strerror(error));
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ASSERT(mappedKeyBuffer.size() == CLEARKEY_SIZE);
-    error = gcry_cipher_setkey(priv->handle, mappedKeyBuffer.data(), mappedKeyBuffer.size());
-    if (error) {
-        GST_ERROR_OBJECT(self, "gcry_cipher_setkey failed: %s", gpg_strerror(error));
-        return false;
-    }
-
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static gboolean webKitMediaClearKeyDecryptorDecrypt(WebKitMediaCommonEncryptionDecrypt* self, GstBuffer* ivBuffer, GstBuffer* buffer, unsigned subSampleCount, GstBuffer* subSamplesBuffer)
</del><ins>+static gboolean webKitMediaClearKeyDecryptorDecrypt(WebKitMediaCommonEncryptionDecrypt* self, GstBuffer* ivBuffer, GstBuffer* keyIDBuffer, GstBuffer* buffer, unsigned subSampleCount, GstBuffer* subSamplesBuffer)
</ins><span class="cx"> {
</span><span class="cx">     // Check ivBuffer isn't null.
</span><span class="cx">     if (!ivBuffer) {
</span><span class="lines">@@ -233,10 +212,16 @@
</span><span class="cx"> 
</span><span class="cx">     // Check buffer isn't null.
</span><span class="cx">     if (!buffer) {
</span><del>-        GST_ERROR_OBJECT(self, "Error, the buffer is null");
</del><ins>+        GST_ERROR_OBJECT(self, "No buffer to decrypt");
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    WebCore::GstMappedBuffer mappedKeyIdBuffer(keyIDBuffer, GST_MAP_READ);
+    if (!mappedKeyIdBuffer) {
+        GST_ERROR_OBJECT(self, "Failed to map key id buffer");
+        return false;
+    }
+
</ins><span class="cx">     WebCore::GstMappedBuffer mappedBuffer(buffer, GST_MAP_READWRITE);
</span><span class="cx">     if (!mappedBuffer) {
</span><span class="cx">         GST_ERROR_OBJECT(self, "Failed to map buffer");
</span><span class="lines">@@ -243,6 +228,8 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    webKitMediaClearKeyDecryptorFindAndSetKey(priv, mappedKeyIdBuffer);
+
</ins><span class="cx">     unsigned position = 0;
</span><span class="cx">     unsigned sampleIndex = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -309,10 +296,4 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void webKitMediaClearKeyDecryptorReleaseCipher(WebKitMediaCommonEncryptionDecrypt* self)
-{
-    WebKitMediaClearKeyDecryptPrivate* priv = WEBKIT_MEDIA_CK_DECRYPT_GET_PRIVATE(WEBKIT_MEDIA_CK_DECRYPT(self));
-    gcry_cipher_close(priv->handle);
-}
-
</del><span class="cx"> #endif // ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreameremeWebKitCommonEncryptionDecryptorGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp (237920 => 237921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp        2018-11-07 11:29:27 UTC (rev 237920)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp   2018-11-07 11:50:30 UTC (rev 237921)
</span><span class="lines">@@ -45,8 +45,6 @@
</span><span class="cx"> static GstFlowReturn webkitMediaCommonEncryptionDecryptTransformInPlace(GstBaseTransform*, GstBuffer*);
</span><span class="cx"> static gboolean webkitMediaCommonEncryptionDecryptSinkEventHandler(GstBaseTransform*, GstEvent*);
</span><span class="cx"> 
</span><del>-static gboolean webKitMediaCommonEncryptionDecryptDefaultSetupCipher(WebKitMediaCommonEncryptionDecrypt*, GstBuffer*);
-static void webKitMediaCommonEncryptionDecryptDefaultReleaseCipher(WebKitMediaCommonEncryptionDecrypt*);
</del><span class="cx"> 
</span><span class="cx"> GST_DEBUG_CATEGORY_STATIC(webkit_media_common_encryption_decrypt_debug_category);
</span><span class="cx"> #define GST_CAT_DEFAULT webkit_media_common_encryption_decrypt_debug_category
</span><span class="lines">@@ -71,9 +69,6 @@
</span><span class="cx">     baseTransformClass->transform_ip_on_passthrough = FALSE;
</span><span class="cx">     baseTransformClass->sink_event = GST_DEBUG_FUNCPTR(webkitMediaCommonEncryptionDecryptSinkEventHandler);
</span><span class="cx"> 
</span><del>-    klass->setupCipher = GST_DEBUG_FUNCPTR(webKitMediaCommonEncryptionDecryptDefaultSetupCipher);
-    klass->releaseCipher = GST_DEBUG_FUNCPTR(webKitMediaCommonEncryptionDecryptDefaultReleaseCipher);
-
</del><span class="cx">     g_type_class_add_private(klass, sizeof(WebKitMediaCommonEncryptionDecryptPrivate));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -269,35 +264,31 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     value = gst_structure_get_value(protectionMeta->info, "kid");
</span><del>-    GstBuffer* keyIDBuffer = nullptr;
-    if (value)
-        keyIDBuffer = gst_value_get_buffer(value);
</del><span class="cx"> 
</span><del>-    WebKitMediaCommonEncryptionDecryptClass* klass = WEBKIT_MEDIA_CENC_DECRYPT_GET_CLASS(self);
-    if (!klass->setupCipher(self, keyIDBuffer)) {
-        GST_ERROR_OBJECT(self, "Failed to configure cipher");
</del><ins>+    if (!value) {
+        GST_ERROR_OBJECT(self, "Failed to get key id for buffer");
</ins><span class="cx">         gst_buffer_remove_meta(buffer, reinterpret_cast<GstMeta*>(protectionMeta));
</span><span class="cx">         return GST_FLOW_NOT_SUPPORTED;
</span><span class="cx">     }
</span><ins>+    GstBuffer* keyIDBuffer = gst_value_get_buffer(value);
</ins><span class="cx"> 
</span><span class="cx">     value = gst_structure_get_value(protectionMeta->info, "iv");
</span><span class="cx">     if (!value) {
</span><span class="cx">         GST_ERROR_OBJECT(self, "Failed to get IV for sample");
</span><del>-        klass->releaseCipher(self);
</del><span class="cx">         gst_buffer_remove_meta(buffer, reinterpret_cast<GstMeta*>(protectionMeta));
</span><span class="cx">         return GST_FLOW_NOT_SUPPORTED;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     GstBuffer* ivBuffer = gst_value_get_buffer(value);
</span><ins>+    WebKitMediaCommonEncryptionDecryptClass* klass = WEBKIT_MEDIA_CENC_DECRYPT_GET_CLASS(self);
+
</ins><span class="cx">     GST_TRACE_OBJECT(self, "decrypting");
</span><del>-    if (!klass->decrypt(self, ivBuffer, buffer, subSampleCount, subSamplesBuffer)) {
</del><ins>+    if (!klass->decrypt(self, ivBuffer, keyIDBuffer, buffer, subSampleCount, subSamplesBuffer)) {
</ins><span class="cx">         GST_ERROR_OBJECT(self, "Decryption failed");
</span><del>-        klass->releaseCipher(self);
</del><span class="cx">         gst_buffer_remove_meta(buffer, reinterpret_cast<GstMeta*>(protectionMeta));
</span><span class="cx">         return GST_FLOW_NOT_SUPPORTED;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    klass->releaseCipher(self);
</del><span class="cx">     gst_buffer_remove_meta(buffer, reinterpret_cast<GstMeta*>(protectionMeta));
</span><span class="cx">     return GST_FLOW_OK;
</span><span class="cx"> }
</span><span class="lines">@@ -356,15 +347,4 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
-static gboolean webKitMediaCommonEncryptionDecryptDefaultSetupCipher(WebKitMediaCommonEncryptionDecrypt*, GstBuffer*)
-{
-    return true;
-}
-
-
-static void webKitMediaCommonEncryptionDecryptDefaultReleaseCipher(WebKitMediaCommonEncryptionDecrypt*)
-{
-}
-
</del><span class="cx"> #endif // ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreameremeWebKitCommonEncryptionDecryptorGStreamerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h (237920 => 237921)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h  2018-11-07 11:29:27 UTC (rev 237920)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h     2018-11-07 11:50:30 UTC (rev 237921)
</span><span class="lines">@@ -54,9 +54,7 @@
</span><span class="cx"> 
</span><span class="cx">     const char* protectionSystemId;
</span><span class="cx">     gboolean (*handleKeyResponse)(WebKitMediaCommonEncryptionDecrypt*, GstEvent* event);
</span><del>-    gboolean (*setupCipher)(WebKitMediaCommonEncryptionDecrypt*, GstBuffer*);
-    gboolean (*decrypt)(WebKitMediaCommonEncryptionDecrypt*, GstBuffer* ivBuffer, GstBuffer* buffer, unsigned subSamplesCount, GstBuffer* subSamplesBuffer);
-    void (*releaseCipher)(WebKitMediaCommonEncryptionDecrypt*);
</del><ins>+    gboolean (*decrypt)(WebKitMediaCommonEncryptionDecrypt*, GstBuffer* ivBuffer, GstBuffer* keyIDBuffer, GstBuffer* buffer, unsigned subSamplesCount, GstBuffer* subSamplesBuffer);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> G_END_DECLS
</span></span></pre>
</div>
</div>

</body>
</html>