<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:calvaris&#64;igalia.com" title="Xabier Rodríguez Calvar &lt;calvaris&#64;igalia.com&gt;"> <span class="fn">Xabier Rodríguez Calvar</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK][GStreamer] ClearKey EME v1 decryption support"
   href="https://bugs.webkit.org/show_bug.cgi?id=154235">bug 154235</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #272321 Flags</td>
           <td>review+
           </td>
           <td>review-
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK][GStreamer] ClearKey EME v1 decryption support"
   href="https://bugs.webkit.org/show_bug.cgi?id=154235#c43">Comment # 43</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK][GStreamer] ClearKey EME v1 decryption support"
   href="https://bugs.webkit.org/show_bug.cgi?id=154235">bug 154235</a>
              from <span class="vcard"><a class="email" href="mailto:calvaris&#64;igalia.com" title="Xabier Rodríguez Calvar &lt;calvaris&#64;igalia.com&gt;"> <span class="fn">Xabier Rodríguez Calvar</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=272321&amp;action=diff" name="attach_272321" title="patch">attachment 272321</a> <a href="attachment.cgi?id=272321&amp;action=edit" title="patch">[details]</a></span>
patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=272321&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=272321&amp;action=review</a>

To complement a bit more what Carlos said, some more comments. Most of them are nits. The important thing here is the test. I do think it is needed.

<span class="quote">&gt; Source/WebCore/ChangeLog:24
&gt; +        There are no layout tests unskipped because this feature is
&gt; +        disabled by default.</span >

If there is none, I think we should add some test to ensure at least the basic functionality is not broken, even when this is not active by default. This would be important specially if you honor Michael's comment later.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:878
&gt; +MediaPlayer::MediaKeyException MediaPlayerPrivateGStreamerBase::addKey(const String&amp; keySystem, const unsigned char* keyData, unsigned keyLength, const unsigned char* /* initData */, unsigned /* initDataLength */ , const String&amp; sessionId)</span >

Remove the comment marks, leave the parameters. They are meaningful though unused.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:901
&gt; +MediaPlayer::MediaKeyException MediaPlayerPrivateGStreamerBase::cancelKeyRequest(const String&amp; /* keySystem */ , const String&amp; /* sessionId */)</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:133
&gt; +    MediaPlayer::MediaKeyException addKey(const String&amp;, const unsigned char*, unsigned, const unsigned char*, unsigned, const String&amp;) override;
&gt; +    MediaPlayer::MediaKeyException generateKeyRequest(const String&amp;, const unsigned char*, unsigned) override;
&gt; +    MediaPlayer::MediaKeyException cancelKeyRequest(const String&amp;, const String&amp;) override;
&gt; +    void needKey(const String&amp;, const String&amp;, const unsigned char*, unsigned);</span >

Parameters seem meaningful here. I wouldn't omit them.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitClearKeyDecryptorGStreamer.cpp:41
&gt; +#define CLEAR_KEY_PROTECTION_SYSTEM_ID &quot;58147ec8-0423-4659-92e6-f52c5ce8c3cc&quot;</span >

Where does this come from? Maybe a comment?

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitClearKeyDecryptorGStreamer.cpp:70
&gt; +                &quot;key-system-id&quot;, G_TYPE_STRING, &quot;org.w3.clearkey&quot;, nullptr)));</span >

nullptr -&gt; NULL

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitClearKeyDecryptorGStreamer.cpp:155
&gt; +        gst_buffer_unmap(buffer, &amp;map);
&gt; +        return FALSE;</span >

We could do this GStreamer style, with a goto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitClearKeyDecryptorGStreamer.cpp:170
&gt; +                gst_byte_reader_free(reader);
&gt; +                gst_buffer_unmap(buffer, &amp;map);
&gt; +                gst_buffer_unmap(subSamplesBuffer, &amp;subSamplesMap);</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitClearKeyDecryptorGStreamer.cpp:189
&gt; +                gst_byte_reader_free(reader);
&gt; +                gst_buffer_unmap(buffer, &amp;map);
&gt; +                gst_buffer_unmap(subSamplesBuffer, &amp;subSamplesMap);</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:96
&gt; +    unsigned size = gst_caps_get_size(caps);</span >

guint?

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:99
&gt; +        GstStructure* in = gst_caps_get_structure(caps, i);
&gt; +        GUniquePtr&lt;GstStructure&gt; out;</span >

I prefer more meaningful names, inputStructure/outputStructure

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:121
&gt; +            for (int index = gst_structure_n_fields(tmp.get()) - 1; index &gt;= 0; --index) {</span >

gint?

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:147
&gt; +        unsigned size = gst_caps_get_size(transformedCaps);</span >

guint?

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:154
&gt; +        for (unsigned index = 0; index &lt; size; ++index) {
&gt; +            GstStructure* item = gst_caps_get_structure(transformedCaps, index);
&gt; +            if (gst_structure_is_equal(item, out.get())) {
&gt; +                isDuplicated = true;
&gt; +                break;
&gt; +            }
&gt; +        }</span >

Not strong preference, but:

for (unsigned index = 0; index &lt; size &amp;&amp; !isDuplicated; ++index) {
    GstStructure* item = gst_caps_get_structure(transformedCaps, index);
    isDuplicated = gst_structure_is_equal(item, out.get());
}

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:194
&gt; +        gst_buffer_remove_meta(buffer, meta);
&gt; +        return GST_FLOW_NOT_SUPPORTED;</span >

We can go GStreamer style with gotos.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:201
&gt; +        gst_buffer_remove_meta(buffer, meta);
&gt; +        return GST_FLOW_NOT_SUPPORTED;</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:206
&gt; +        gst_buffer_remove_meta(buffer, meta);
&gt; +        return GST_FLOW_OK;</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:214
&gt; +        GST_ERROR_OBJECT(self, &quot;Failed to get subsample_count&quot;);
&gt; +        gst_buffer_remove_meta(buffer, meta);
&gt; +        return GST_FLOW_NOT_SUPPORTED;</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:224
&gt; +            GST_ERROR_OBJECT(self, &quot;Failed to get subsamples&quot;);
&gt; +            gst_buffer_remove_meta(buffer, meta);
&gt; +            return GST_FLOW_NOT_SUPPORTED;</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:232
&gt; +        GST_ERROR_OBJECT(self, &quot;Failed to configure cipher&quot;);
&gt; +        gst_buffer_remove_meta(buffer, meta);
&gt; +        return GST_FLOW_NOT_SUPPORTED;</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:240
&gt; +        webkitCommonEncryptionDecryptorReleaseCipher(self);
&gt; +        gst_buffer_remove_meta(buffer, meta);
&gt; +        return GST_FLOW_NOT_SUPPORTED;</span >

Ditto.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:248
&gt; +        webkitCommonEncryptionDecryptorReleaseCipher(self);
&gt; +        gst_buffer_remove_meta(buffer, meta);
&gt; +        return GST_FLOW_NOT_SUPPORTED;</span >

Ditto.

<span class="quote">&gt;&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.cpp:276
&gt;&gt; +        RunLoop::main().dispatch([protectedThis, protectedEvent, initDataBuffer] {
&gt; 
&gt; I would add a comment here, explaining that we capture the event because it's the owner of the buffer, otherwise it looks weird to capture something that is not used in the lambda.</span >

I don't know what the spec says about this, but I even wonder if this could even get compiled out at some degree of automatic compiler optimization.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitCommonEncryptionDecryptorGStreamer.h:57
&gt; +    gboolean (*handleKeyResponse) (WebKitCommonEncryptionDecryptor*, GstEvent* event);</span >

Remove the event parameter name here. Not meaningful

<span class="quote">&gt; Source/cmake/FindLibGcrypt.cmake:18
&gt; +# Copyright 2014 Nicolás Alvarez &lt;<a href="mailto:nicolas.alvarez&#64;gmail.com">nicolas.alvarez&#64;gmail.com</a>&gt;</span >

Fix enconding

<span class="quote">&gt; Source/cmake/FindLibGpgError.cmake:19
&gt; +# Copyright 2014 Nicolás Alvarez &lt;<a href="mailto:nicolas.alvarez&#64;gmail.com">nicolas.alvarez&#64;gmail.com</a>&gt;</span >

Ditto.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>