Bug 189239 - [EME][GStreamer] Add support for WebM encrypted caps "application/x-webm-enc"
Summary: [EME][GStreamer] Add support for WebM encrypted caps "application/x-webm-enc"
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: 189238
Blocks:
  Show dependency treegraph
 
Reported: 2018-09-03 03:07 PDT by Yacine Bandou
Modified: 2018-10-08 06:25 PDT (History)
5 users (show)

See Also:


Attachments
Patch (8.48 KB, patch)
2018-09-03 06:48 PDT, Yacine Bandou
no flags Details | Formatted Diff | Diff
Patch (8.58 KB, patch)
2018-10-03 11:33 PDT, Yacine Bandou
no flags Details | Formatted Diff | Diff
Patch (8.48 KB, patch)
2018-10-04 10:12 PDT, Yacine Bandou
no flags Details | Formatted Diff | Diff
Patch (8.31 KB, patch)
2018-10-08 02:49 PDT, Yacine Bandou
no flags Details | Formatted Diff | Diff
Patch (8.31 KB, patch)
2018-10-08 05:39 PDT, Yacine Bandou
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-09-03 03:07:07 PDT
Add the support of WebM encrypted caps "application/x-webm-enc"
Tests:
 media/encrypted-media/clearKey/clearKey-encrypted-webm-event-mse.html
 media/encrypted-media/clearKey/clearKey-webm-video-playback-mse.html
Comment 1 Yacine Bandou 2018-09-03 06:48:42 PDT
Created attachment 348768 [details]
Patch
Comment 2 Xabier Rodríguez Calvar 2018-09-03 08:29:41 PDT
Comment on attachment 348768 [details]
Patch

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

Wrote some comments on https://bugzilla.gnome.org/show_bug.cgi?id=765275 cause I don't like the "UNDEFINED" API.

> Source/WebCore/ChangeLog:11
> +        see https://bugzilla.gnome.org/attachment.cgi?id=365211

Nit: There's a period missing at the end of this line.
Comment 3 Yacine Bandou 2018-10-03 11:33:33 PDT
Created attachment 351539 [details]
Patch
Comment 4 Xabier Rodríguez Calvar 2018-10-04 08:53:07 PDT
Comment on attachment 351539 [details]
Patch

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

> Source/WebCore/ChangeLog:11
> +        in case of WebM, for details, see https://bugzilla.gnome.org/attachment.cgi?id=365211

period at the end.

> Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp:179
> +    return (gst_structure_has_name(structure, "application/x-cenc") || gst_structure_has_name(structure, "application/x-webm-enc"));

You don't need the () enclosing the two checks.

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:1295
> +        if (eventKeySystemUUID == GST_PROTECTION_UNSPECIFIED_SYSTEM_ID)
> +            weakThis->m_player->initializationDataEncountered("webm"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));
> +        else
> +            weakThis->m_player->initializationDataEncountered("cenc"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));

You can use a ? b : c instead of an if.

I have also a concern of what we are considering here: if system id is unspecified then we consider webm, cenc otherwise, which means that cenc needs to enforce a sys id and WebM will never have one. I guess the later is true by per spec but I wonder if that assumtion of cenc is true.

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:1296
> +

This line should be removed.

> Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:61
> +    "application/x-cenc, original-media-type=(string)audio/mpeg, protection-system=(string)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID";"
> +    "application/x-webm-enc, original-media-type=(string)video/x-vp8;"
> +    "application/x-webm-enc, original-media-type=(string)video/x-vp9;"));

Can WebM handle cenc? If it can then we have an issue with this.

> Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:165
> +            if (!g_strcmp0(klass->protectionSystemId, GST_PROTECTION_UNSPECIFIED_SYSTEM_ID))
> +                gst_structure_set_name(outgoingStructure.get(), "application/x-webm-enc");
> +            else
> +                gst_structure_set_name(outgoingStructure.get(), "application/x-cenc");

Ditto for a ? b : c.
Comment 5 Yacine Bandou 2018-10-04 09:47:40 PDT
(In reply to Xabier Rodríguez Calvar from comment #4)
> Comment on attachment 351539 [details]
> Patch
> > Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:1295
> > +        if (eventKeySystemUUID == GST_PROTECTION_UNSPECIFIED_SYSTEM_ID)
> > +            weakThis->m_player->initializationDataEncountered("webm"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));
> > +        else
> > +            weakThis->m_player->initializationDataEncountered("cenc"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));
> 
> You can use a ? b : c instead of an if.
> 
> I have also a concern of what we are considering here: if system id is
> unspecified then we consider webm, cenc otherwise, which means that cenc
> needs to enforce a sys id and WebM will never have one. I guess the later is
> true by per spec but I wonder if that assumtion of cenc is true.
> 

CENC specifies the system ID and it is mandatory in PSSH Box.


Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:61
> > +    "application/x-cenc, original-media-type=(string)audio/mpeg, protection-system=(string)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID";"
> > +    "application/x-webm-enc, original-media-type=(string)video/x-vp8;"
> > +    "application/x-webm-enc, original-media-type=(string)video/x-vp9;"));
> 
> Can WebM handle cenc? If it can then we have an issue with this.
>

Why do you say that? It is "x-webm-enc" not "x-webm-cenc".
Comment 6 Yacine Bandou 2018-10-04 10:12:05 PDT
Created attachment 351599 [details]
Patch
Comment 7 Xabier Rodríguez Calvar 2018-10-07 22:45:53 PDT
Comment on attachment 351599 [details]
Patch

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

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:1292
> +        (eventKeySystemUUID == GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? weakThis->m_player->initializationDataEncountered("webm"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes())) : weakThis->m_player->initializationDataEncountered("cenc"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));

It would be much simpler to write:

weakThis->m_player->initializationDataEncountered(eventKeySystemUUID == GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "webm"_s : "cenc"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));

> Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:162
> +            (!g_strcmp0(klass->protectionSystemId, GST_PROTECTION_UNSPECIFIED_SYSTEM_ID)) ? gst_structure_set_name(outgoingStructure.get(), "application/x-webm-enc") : gst_structure_set_name(outgoingStructure.get(), "application/x-cenc");

gst_structure_set_name(outgoingStructure.get(), g_strcmp0(klass->protectionSystemId, GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "application/x-cenc" : "application/x-webm-enc");
Comment 8 Xabier Rodríguez Calvar 2018-10-07 22:47:36 PDT
(In reply to Yacine Bandou from comment #5)
> Source/WebCore/platform/graphics/gstreamer/eme/
> WebKitClearKeyDecryptorGStreamer.cpp:61
> > > +    "application/x-cenc, original-media-type=(string)audio/mpeg, protection-system=(string)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID";"
> > > +    "application/x-webm-enc, original-media-type=(string)video/x-vp8;"
> > > +    "application/x-webm-enc, original-media-type=(string)video/x-vp9;"));
> > 
> > Can WebM handle cenc? If it can then we have an issue with this.
> >
> 
> Why do you say that? It is "x-webm-enc" not "x-webm-cenc".

What I mean is that if WebM supports cenc, we should provide a media type for application/x-cenc, original-media-type=(string)video/x-vp8 and vp9.
Comment 9 Yacine Bandou 2018-10-08 02:16:35 PDT
(In reply to Xabier Rodríguez Calvar from comment #8)
> (In reply to Yacine Bandou from comment #5)
> > Source/WebCore/platform/graphics/gstreamer/eme/
> > WebKitClearKeyDecryptorGStreamer.cpp:61
> > > > +    "application/x-cenc, original-media-type=(string)audio/mpeg, protection-system=(string)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID";"
> > > > +    "application/x-webm-enc, original-media-type=(string)video/x-vp8;"
> > > > +    "application/x-webm-enc, original-media-type=(string)video/x-vp9;"));
> > > 
> > > Can WebM handle cenc? If it can then we have an issue with this.
> > >
> > 
> > Why do you say that? It is "x-webm-enc" not "x-webm-cenc".
> 
> What I mean is that if WebM supports cenc, we should provide a media type
> for application/x-cenc, original-media-type=(string)video/x-vp8 and vp9.

No, it is not the same thing.

For example: The PSSH box is mandatory in CENC protection scheme.

If we set the caps "application/x-cenc, original-media-type=(string)video/x-vp9" for encrypted WebM/VP9. How we can differentiate it from encrypted MP4/VP9 ?
For you information, MP4 supports the VP8 and VP9 codec (http://mp4ra.org/#/codecs).

see also these two links:
https://www.w3.org/TR/eme-stream-webm/
https://www.w3.org/TR/eme-stream-mp4/
Comment 10 Yacine Bandou 2018-10-08 02:23:15 PDT
(In reply to Xabier Rodríguez Calvar from comment #7)
> Comment on attachment 351599 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=351599&action=review
> 
> > Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:1292
> > +        (eventKeySystemUUID == GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? weakThis->m_player->initializationDataEncountered("webm"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes())) : weakThis->m_player->initializationDataEncountered("cenc"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));
> 
> It would be much simpler to write:
> 
> weakThis->m_player->initializationDataEncountered(eventKeySystemUUID ==
> GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "webm"_s : "cenc"_s,
> ArrayBuffer::create(reinterpret_cast<const
> uint8_t*>(initData.characters8()), initData.sizeInBytes()));
> 

Absolutely.
Comment 11 Yacine Bandou 2018-10-08 02:49:20 PDT
Created attachment 351765 [details]
Patch
Comment 12 Xabier Rodríguez Calvar 2018-10-08 03:06:16 PDT
(In reply to Yacine Bandou from comment #9)
> > What I mean is that if WebM supports cenc, we should provide a media type
> > for application/x-cenc, original-media-type=(string)video/x-vp8 and vp9.
> 
> No, it is not the same thing.
> 
> For example: The PSSH box is mandatory in CENC protection scheme.
> 
> If we set the caps "application/x-cenc,
> original-media-type=(string)video/x-vp9" for encrypted WebM/VP9. How we can
> differentiate it from encrypted MP4/VP9 ?
> For you information, MP4 supports the VP8 and VP9 codec
> (http://mp4ra.org/#/codecs).

This is exactly my question, how can we differentiate them. I guess you're assuming that in the case of mp4 with VP8/9 what the demuxer would report would be application/x-cenc, original-media-type=(string)video/mpeg ?
Comment 13 Xabier Rodríguez Calvar 2018-10-08 03:07:24 PDT
Comment on attachment 351765 [details]
Patch

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

> Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:163
> +                (!g_strcmp0(klass->protectionSystemId, GST_PROTECTION_UNSPECIFIED_SYSTEM_ID)) ? "application/x-webm-enc" : "application/x-cenc");

You don't need the () around g_strcmp0.
Comment 14 Yacine Bandou 2018-10-08 04:59:24 PDT
(In reply to Xabier Rodríguez Calvar from comment #12)
> (In reply to Yacine Bandou from comment #9)
> > > What I mean is that if WebM supports cenc, we should provide a media type
> > > for application/x-cenc, original-media-type=(string)video/x-vp8 and vp9.
> > 
> > No, it is not the same thing.
> > 
> > For example: The PSSH box is mandatory in CENC protection scheme.
> > 
> > If we set the caps "application/x-cenc,
> > original-media-type=(string)video/x-vp9" for encrypted WebM/VP9. How we can
> > differentiate it from encrypted MP4/VP9 ?
> > For you information, MP4 supports the VP8 and VP9 codec
> > (http://mp4ra.org/#/codecs).
> 
> This is exactly my question, how can we differentiate them. I guess you're
> assuming that in the case of mp4 with VP8/9 what the demuxer would report
> would be application/x-cenc, original-media-type=(string)video/mpeg ?

Encrypted MP4/VP9 --> qtdemux with src caps "application/x-cenc, original-media-type=(string)video/VP9".
Encrypted WebM/VP9 --> Matroskademux with src caps "application/x-webm-enc, original-media-type=(string)video/VP9".
Comment 15 Yacine Bandou 2018-10-08 05:39:25 PDT
Created attachment 351771 [details]
Patch
Comment 16 Xabier Rodríguez Calvar 2018-10-08 05:58:49 PDT
Comment on attachment 351771 [details]
Patch

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

> Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:61
>      GST_STATIC_CAPS("application/x-cenc, original-media-type=(string)video/x-h264, protection-system=(string)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID "; "
> -    "application/x-cenc, original-media-type=(string)audio/mpeg, protection-system=(string)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID));
> +    "application/x-cenc, original-media-type=(string)audio/mpeg, protection-system=(string)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID";"
> +    "application/x-webm-enc, original-media-type=(string)video/x-vp8;"
> +    "application/x-webm-enc, original-media-type=(string)video/x-vp9;"));

(In reply to Yacine Bandou from comment #14)
> Encrypted MP4/VP9 --> qtdemux with src caps "application/x-cenc,
> original-media-type=(string)video/VP9".

Again, why did  you decide to leave outside the question "application/x-cenc, original-media-type=(string)video/VP9"  cause from current code I see it is not supported. Well, anyway, this would not belong to this patch, so I'll r+ it.
Comment 17 WebKit Commit Bot 2018-10-08 06:25:09 PDT
Comment on attachment 351771 [details]
Patch

Clearing flags on attachment: 351771

Committed r236912: <https://trac.webkit.org/changeset/236912>
Comment 18 WebKit Commit Bot 2018-10-08 06:25:11 PDT
All reviewed patches have been landed.  Closing bug.