Bug 176445 - [GStreamer] Implement MediaPlayerPrivateGStreamerMSE::attempToDecryptWithInstance()
Summary: [GStreamer] Implement MediaPlayerPrivateGStreamerMSE::attempToDecryptWithInst...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-09-06 02:49 PDT by Zan Dobersek
Modified: 2017-09-27 12:35 PDT (History)
4 users (show)

See Also:


Attachments
Patch (6.31 KB, patch)
2017-09-06 02:56 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (6.23 KB, patch)
2017-09-06 03:23 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (5.89 KB, patch)
2017-09-06 03:38 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch for landing (5.83 KB, patch)
2017-09-06 06:32 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zan Dobersek 2017-09-06 02:49:16 PDT
[GStreamer] Implement MediaPlayerPrivateGStreamerMSE::attempToDecryptWithInstance()
Comment 1 Zan Dobersek 2017-09-06 02:56:11 PDT
Created attachment 319997 [details]
Patch
Comment 2 Build Bot 2017-09-06 02:59:12 PDT
Attachment 319997 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:952:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Charlie Turner 2017-09-06 03:11:58 PDT
Comment on attachment 319997 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=319997&action=review

> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:944
> +        if (keys.isEmpty())

Same check as above?

> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:952
> +            {

Why are the extra scopes used in the loop, is there some problem with have G variables as autos outside the loop?
Comment 4 Zan Dobersek 2017-09-06 03:22:52 PDT
Comment on attachment 319997 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=319997&action=review

>> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:952
>> +            {
> 
> Why are the extra scopes used in the loop, is there some problem with have G variables as autos outside the loop?

It's used for clarity, and to not accidentally access resources across the two GValue constructions.
Comment 5 Zan Dobersek 2017-09-06 03:23:29 PDT
Created attachment 319998 [details]
Patch
Comment 6 Build Bot 2017-09-06 03:26:28 PDT
Attachment 319998 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:948:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Zan Dobersek 2017-09-06 03:38:50 PDT
Created attachment 320000 [details]
Patch

Now uses a functor to group the common code for GStreamer value list appends.
Comment 8 Xabier Rodríguez Calvar 2017-09-06 05:23:35 PDT
Comment on attachment 320000 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=320000&action=review

> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:950
> +                GRefPtr<GstBuffer> gstBuffer(gst_buffer_new_wrapped(

You can use a single line

> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:954
> +                g_value_set_boxed(bufferValue, gstBuffer.get());

Use gst_value_take_buffer or adopt the reference and use set.

> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:968
> +        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())));

I have comments about this code:
* Shouldn't we WTFMove the GUniquePtr as it the method takes a && ?
* Considering that the copy is not shallow and can mean some memory copies, I think it would be interesting to unroll the loop once and copy the the structure in all cases but one, where we'd move.

> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:89
> +    void attemptToDecryptWithInstance(const CDMInstance&) override;

You can go with final here.
Comment 9 Xabier Rodríguez Calvar 2017-09-06 05:24:39 PDT
Comment on attachment 320000 [details]
Patch

Please, have a look at the comments before landing.
Comment 10 Zan Dobersek 2017-09-06 06:31:20 PDT
Comment on attachment 320000 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=320000&action=review

>> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:954
>> +                g_value_set_boxed(bufferValue, gstBuffer.get());
> 
> Use gst_value_take_buffer or adopt the reference and use set.

I'll just inline the gst_buffer_new_wrapped() in the gst_value_take_buffer then.

>> Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:968
>> +            it.value->dispatchDecryptionStructure(GUniquePtr<GstStructure>(gst_structure_copy(structure.get())));
> 
> I have comments about this code:
> * Shouldn't we WTFMove the GUniquePtr as it the method takes a && ?
> * Considering that the copy is not shallow and can mean some memory copies, I think it would be interesting to unroll the loop once and copy the the structure in all cases but one, where we'd move.

* No WTFMove is necessary, GUniquePtr<> as constructed here is an rvalue that binds fine to the GUniquePtr<>&& type used by the callee.
* This isn't worth the complexity. The copied data isn't large in size, and this altogether is not a frequent operation.
Comment 11 Zan Dobersek 2017-09-06 06:32:56 PDT
Created attachment 320015 [details]
Patch for landing
Comment 12 Zan Dobersek 2017-09-06 22:58:34 PDT
Comment on attachment 320015 [details]
Patch for landing

Clearing flags on attachment: 320015

Committed r221718: <http://trac.webkit.org/changeset/221718>
Comment 13 Zan Dobersek 2017-09-06 22:58:38 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 Radar WebKit Bug Importer 2017-09-27 12:35:31 PDT
<rdar://problem/34693553>