Bug 185948 - [GStreamer] Handle changes in the "drm-preferred-decryption-system-id" NEED_CONTEXT message.
Summary: [GStreamer] Handle changes in the "drm-preferred-decryption-system-id" NEED_C...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WPE WebKit (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-24 08:07 PDT by Yacine Bandou
Modified: 2018-05-28 01:18 PDT (History)
8 users (show)

See Also:


Attachments
Patch (4.50 KB, patch)
2018-05-24 09:51 PDT, Yacine Bandou
calvaris: review-
calvaris: commit-queue-
Details | Formatted Diff | Diff
[GStreamer] Add qtdemux patches to fix use of NULL pointers (6.12 KB, patch)
2018-05-25 02:13 PDT, Thibault Saunier
no flags Details | Formatted Diff | Diff
Added a new patch to GStreamer (that I will merge once this one is accepted) that moves back to previous behaviour (13.22 KB, patch)
2018-05-25 05:06 PDT, Thibault Saunier
calvaris: review-
calvaris: commit-queue-
Details | Formatted Diff | Diff
Patch. (13.31 KB, patch)
2018-05-25 07:59 PDT, Thibault Saunier
calvaris: review+
calvaris: commit-queue-
Details | Formatted Diff | Diff
Update patches to add a comment about our intention of merging the GStreamer patch (13.36 KB, patch)
2018-05-25 08:50 PDT, Thibault Saunier
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yacine Bandou 2018-05-24 08:07:53 PDT
After updating to GStreamer  1.14 the function "gst_protection_filter_systems_by_available_decryptors" returns NULL, when there is no decryptor plugin that supports any of the systemid, instead of an empty array in Gstreamer-1.12.

Thus, the "gst_qtdemux_request_protection_context" function of qtdemux in the "gst-plugins-good-0002-qtdemux-add-context-for-a-preferred-protection" patch doesn't wait for the function "gst_protection_filter_systems_by_available_decryptors" to return a NULL, and then, it crashes when send the "drm-preferred-decryption-system-id" GstMessage with a NULL value in the field "stream-encryption-systems".
Comment 1 Yacine Bandou 2018-05-24 09:51:39 PDT
Created attachment 341199 [details]
Patch
Comment 2 Michael Catanzaro 2018-05-24 13:18:21 PDT
Comment on attachment 341199 [details]
Patch

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

> Tools/gstreamer/patches/gst-plugins-good-0002-qtdemux-add-context-for-a-preferred-protection.patch:195
> ++  if (!filtered_sys_ids)
> ++    filtered_sys_ids = g_new0 (char *, 1);

Is there an upstream bug report for this? The patch that you are modifying has already gone upstream, and will be dropped when we upgrade to 1.14.1, so your change will be lost then.

Look at https://cgit.freedesktop.org/gstreamer/gst-plugins-good/log/, there's hardly been a better time to upstream some qtdemux changes!
Comment 3 Xabier Rodríguez Calvar 2018-05-24 23:44:41 PDT
Comment on attachment 341199 [details]
Patch

Michael is very right.
Comment 4 Thibault Saunier 2018-05-25 02:13:04 PDT
Created attachment 341264 [details]
[GStreamer] Add qtdemux patches to fix use of NULL pointers
Comment 5 Yacine Bandou 2018-05-25 02:42:03 PDT
Comment on attachment 341264 [details]
[GStreamer] Add qtdemux patches to fix use of NULL pointers

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

> Tools/gstreamer/patches/gst-plugins-good-0001-qtdemux-Do-not-run-the-preferred-decryptor-context-q.patch:27
> ++

You should know that in ClearKey WPT tests the used MP4 media content contains only the PlayReady and Widevine systemids in their PSSH BOX.
If we return with an error when no available decryptor support any of systemids, so all the clearKey tests of WPT fail. 
Did you test this patch with encrypted-media WPT tests ?
Comment 6 Thibault Saunier 2018-05-25 05:06:05 PDT
Created attachment 341271 [details]
Added a new patch to GStreamer (that I will merge once this one is accepted) that moves back to previous behaviour

and clarifies the name of the fields in the REQUEST_CONTEXT message (this hasn't been released yet so it is the
right time to change the API).

Now that new patch still uses a NULL pointer to represent avalaible system IDs, so handle that in WebKit itself.
Comment 7 Xabier Rodríguez Calvar 2018-05-25 06:38:05 PDT
Comment on attachment 341271 [details]
Added a new patch to GStreamer (that I will merge once this one is accepted) that moves back to previous behaviour

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

> Source/WebCore/ChangeLog:3
> +        [GStreamer] Handle changes in the "drm-preferred-decryption-system-id" NEED_CONTEXT message.

This line should reflect the bug title. If you want to keep this informative text I'd suggest to move it down to the long description section.

> Source/WebCore/ChangeLog:12
> +        Some tests already exist and where failling (crashing) without that patch.

I would list the tests here, something like:
Tests: imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-*

Side comment: "where failling"  -> "were failing"

> Tools/ChangeLog:3
> +        [GStreamer] Handle changes in the "drm-preferred-decryption-system-id" NEED_CONTEXT message.

Ditto.

> Tools/ChangeLog:10
> +        properly taken into account in the qtdemux patch that uses it and got upstreamed. Those 3 new patches fixes that and changes the

... Those 3 new patches fix that and change ...

> Tools/gstreamer/jhbuild.modules:73
> +      <patch file="gst-plugins-good-0002-qtdemux-Do-not-unref-a-NULL-stream_tags.patch" strip="1" /> <!-- Merged as 43a540b1cd9f162d3dae5d50e36703dfaf558a3e -->

I don't understand why this patch is needed here. Besides, it looks like we are missing Tools/gstreamer/patches/gst-plugins-good-0003-qtdemux-Clarify-field-name-about-stream-encryption-s.patch
Comment 8 Yacine Bandou 2018-05-25 07:18:40 PDT
IMHO, we don't need to use "gst_protection_filter_systems_by_available_decryptors" when we dispatch the GstContext, we simply send all the systemIDs present in the media to the application and let it select any systemID, the application know if this system is supported or not.
Comment 9 Thibault Saunier 2018-05-25 07:59:45 PDT
Created attachment 341282 [details]
Patch.

> Comment on attachment 341271 [details]
> Added a new patch to GStreamer (that I will merge once this one is accepted)
> that moves back to previous behaviour
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=341271&action=review
> 
> > Source/WebCore/ChangeLog:3
> > +        [GStreamer] Handle changes in the "drm-preferred-decryption-system-id" NEED_CONTEXT message.
> 
> This line should reflect the bug title. If you want to keep this informative
> text I'd suggest to move it down to the long description section.

Updated bug title.

> > Source/WebCore/ChangeLog:12
> > +        Some tests already exist and where failling (crashing) without that patch.
> 
> I would list the tests here, something like:
> Tests: imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-*

Done.
 
> Side comment: "where failling"  -> "were failing"
> 
> > Tools/ChangeLog:3
> > +        [GStreamer] Handle changes in the "drm-preferred-decryption-system-id" NEED_CONTEXT message.
> 
> Ditto.

Done.

> > Tools/ChangeLog:10
> > +        properly taken into account in the qtdemux patch that uses it and got upstreamed. Those 3 new patches fixes that and changes the
> 
> ... Those 3 new patches fix that and change ...
> 
> > Tools/gstreamer/jhbuild.modules:73
> > +      <patch file="gst-plugins-good-0002-qtdemux-Do-not-unref-a-NULL-stream_tags.patch" strip="1" /> <!-- Merged as 43a540b1cd9f162d3dae5d50e36703dfaf558a3e -->
> 
> I don't understand why this patch is needed here. Besides, it looks like we
> are missing
> Tools/gstreamer/patches/gst-plugins-good-0003-qtdemux-Clarify-field-name-
> about-stream-encryption-s.patch

I added the missing one (forgot to `git add` this file, sorry), The second one is needed so that the patches are the same as upstream (this patch has been merged already).
Basically I think that we should try to have exactly the same patches as what is merged upstream to avoid this kind of issues when rebasing ;)

(In reply to Yacine Bandou from comment #8)
> IMHO, we don't need to use
> "gst_protection_filter_systems_by_available_decryptors" when we dispatch the
> GstContext, we simply send all the systemIDs present in the media to the
> application and let it select any systemID, the application know if this
> system is supported or not.

The thing is that maybe in WebKit we know but it might not be the case in other apps, I think it makes the API sensibly simpler to use.
Comment 10 Xabier Rodríguez Calvar 2018-05-25 08:39:12 PDT
Comment on attachment 341282 [details]
Patch.

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

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:319
> +    if (streamEncryptionAllowedSystems) {
> +        for (i = 0; streamEncryptionAllowedSystems[i]; ++i)
> +            streamEncryptionAllowedSystemsVector.append(streamEncryptionAllowedSystems[i]);
> +    }

We don't need the brackets here, I think.

> Tools/gstreamer/jhbuild.modules:74
> +      <patch file="gst-plugins-good-0003-qtdemux-Clarify-field-name-about-stream-encryption-s.patch" strip="1" />

You can add a comment <!-- Merged in master, scheduled for 1.16.0 --> because we don't have the commit id yet but we will and we want to ensure that it is clear where it is now and will be release. Actually, the information about the patches scheduled for 1.16 should be in the others too.
Comment 11 Carlos Garcia Campos 2018-05-25 08:45:47 PDT
(In reply to Xabier Rodríguez Calvar from comment #10)
> Comment on attachment 341282 [details]
> Patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=341282&action=review
> 
> > Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:319
> > +    if (streamEncryptionAllowedSystems) {
> > +        for (i = 0; streamEncryptionAllowedSystems[i]; ++i)
> > +            streamEncryptionAllowedSystemsVector.append(streamEncryptionAllowedSystems[i]);
> > +    }
> 
> We don't need the brackets here, I think.

https://webkit.org/code-style-guidelines/#braces-one-line

> > Tools/gstreamer/jhbuild.modules:74
> > +      <patch file="gst-plugins-good-0003-qtdemux-Clarify-field-name-about-stream-encryption-s.patch" strip="1" />
> 
> You can add a comment <!-- Merged in master, scheduled for 1.16.0 -->
> because we don't have the commit id yet but we will and we want to ensure
> that it is clear where it is now and will be release. Actually, the
> information about the patches scheduled for 1.16 should be in the others too.
Comment 12 Thibault Saunier 2018-05-25 08:50:17 PDT
Created attachment 341290 [details]
Update patches to add a comment about our intention of merging the GStreamer patch

(not that I particularly agree it should be neede at all).
Comment 13 Yacine Bandou 2018-05-25 09:13:38 PDT
> (In reply to Yacine Bandou from comment #8)
> > IMHO, we don't need to use
> > "gst_protection_filter_systems_by_available_decryptors" when we dispatch the
> > GstContext, we simply send all the systemIDs present in the media to the
> > application and let it select any systemID, the application know if this
> > system is supported or not.
> 
> The thing is that maybe in WebKit we know but it might not be the case in
> other apps, I think it makes the API sensibly simpler to use.

This API simply used in order to set the "protection-system" field in padsrc caps of qtdemux.

There are 3 cases : 
1.The application knows the supported systems. 
2.The application doesn't know.
3.The application doesn't respond to the GstContext.

For 1 and 3 there is no problem to dispatch all systemIds, no change. 
For 2 the risk that we can set caps with a default systemID which isn't supported, but in this case the pipeline send an error that no plugin supports these caps and I don't see the problem with this behavior.
Comment 14 WebKit Commit Bot 2018-05-28 01:18:41 PDT
Comment on attachment 341290 [details]
Update patches to add a comment about our intention of merging the GStreamer patch

Clearing flags on attachment: 341290

Committed r232240: <https://trac.webkit.org/changeset/232240>
Comment 15 WebKit Commit Bot 2018-05-28 01:18:43 PDT
All reviewed patches have been landed.  Closing bug.