Title: [221131] trunk/Source/WebCore
Revision
221131
Author
zandober...@gmail.com
Date
2017-08-24 01:07:38 -0700 (Thu, 24 Aug 2017)

Log Message

[EME] Implement HTMLMediaElement dispatch of the onencrypted event
https://bugs.webkit.org/show_bug.cgi?id=175927

Reviewed by Xabier Rodriguez-Calvar.

Add the MediaPlayerClient::mediaPlayerInitializationDataEncountered()
method that the platform-layer media pipeline can invoke when it hits
encrypted content in the media data. The initialization data and its type
are passed by the caller, allowing the HTMLMediaElement override to
process it further.

This is done in the mediaPlayerInitializationDataEncountered() override
in the HTMLMediaElement class. Partially implementing the 'Initialization
Data Encountered' algorithm, the 'encrypted' event is dispatched, with the
MediaEncryptedEvent interface being leveraged to embed init data and init
data type information. CORS and mixed-content validation of the media data
is skipped for now.

MediaPlayer::initializationDataEncountered() method should be used to
dispatch the corresponding method on the client, passing on the given init
data and init data type values.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerInitializationDataEncountered):
* html/HTMLMediaElement.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::initializationDataEncountered):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerInitializationDataEncountered):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221130 => 221131)


--- trunk/Source/WebCore/ChangeLog	2017-08-24 06:17:22 UTC (rev 221130)
+++ trunk/Source/WebCore/ChangeLog	2017-08-24 08:07:38 UTC (rev 221131)
@@ -1,3 +1,35 @@
+2017-08-24  Zan Dobersek  <zdober...@igalia.com>
+
+        [EME] Implement HTMLMediaElement dispatch of the onencrypted event
+        https://bugs.webkit.org/show_bug.cgi?id=175927
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Add the MediaPlayerClient::mediaPlayerInitializationDataEncountered()
+        method that the platform-layer media pipeline can invoke when it hits
+        encrypted content in the media data. The initialization data and its type
+        are passed by the caller, allowing the HTMLMediaElement override to
+        process it further.
+
+        This is done in the mediaPlayerInitializationDataEncountered() override
+        in the HTMLMediaElement class. Partially implementing the 'Initialization
+        Data Encountered' algorithm, the 'encrypted' event is dispatched, with the
+        MediaEncryptedEvent interface being leveraged to embed init data and init
+        data type information. CORS and mixed-content validation of the media data
+        is skipped for now.
+
+        MediaPlayer::initializationDataEncountered() method should be used to
+        dispatch the corresponding method on the client, passing on the given init
+        data and init data type values.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerInitializationDataEncountered):
+        * html/HTMLMediaElement.h:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::initializationDataEncountered):
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerInitializationDataEncountered):
+
 2017-08-23  Wenson Hsieh  <wenson_hs...@apple.com>
 
         DeleteSelectionCommand should be robust when starting and ending editable positions cannot be found

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (221130 => 221131)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-08-24 06:17:22 UTC (rev 221130)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-08-24 08:07:38 UTC (rev 221131)
@@ -146,6 +146,7 @@
 #endif
 
 #if ENABLE(ENCRYPTED_MEDIA)
+#include "MediaEncryptedEvent.h"
 #include "MediaKeys.h"
 #endif
 
@@ -2652,6 +2653,29 @@
     // 6. Return promise.
 }
 
+void HTMLMediaElement::mediaPlayerInitializationDataEncountered(const String& initDataType, RefPtr<ArrayBuffer>&& initData)
+{
+    // https://w3c.github.io/encrypted-media/#initdata-encountered
+    // W3C Editor's Draft 23 June 2017
+
+    // 1. Let the media element be the specified HTMLMediaElement object.
+    // 2. Let initDataType be the empty string.
+    // 3. Let initData be null.
+    // 4. If the media data is CORS-same-origin and not mixed content, run the following steps:
+    //   4.1. Let initDataType be the string representing the Initialization Data Type of the Initialization Data.
+    //   4.2. Let initData be the Initialization Data.
+    // FIXME: ^
+
+    // 5. Queue a task to create an event named encrypted that does not bubble and is not cancellable using the
+    //    MediaEncryptedEvent interface with its type attribute set to encrypted and its isTrusted attribute
+    //    initialized to true, and dispatch it at the media element.
+    //    The event interface MediaEncryptedEvent has:
+    //      initDataType = initDataType
+    //      initData = initData
+    MediaEncryptedEventInit initializer { initDataType, WTFMove(initData) };
+    m_asyncEventQueue.enqueueEvent(MediaEncryptedEvent::create(eventNames().encryptedEvent, initializer, Event::IsTrusted::Yes));
+}
+
 void HTMLMediaElement::attemptToDecrypt()
 {
     // https://w3c.github.io/encrypted-media/#attempt-to-decrypt

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (221130 => 221131)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2017-08-24 06:17:22 UTC (rev 221130)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2017-08-24 08:07:38 UTC (rev 221131)
@@ -636,6 +636,8 @@
 #endif
 
 #if ENABLE(ENCRYPTED_MEDIA)
+    void mediaPlayerInitializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&) final;
+
     void attemptToDecrypt();
     void attemptToResumePlaybackIfNecessary();
 

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (221130 => 221131)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2017-08-24 06:17:22 UTC (rev 221130)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2017-08-24 08:07:38 UTC (rev 221131)
@@ -1248,6 +1248,13 @@
 }
 #endif
 
+#if ENABLE(ENCRYPTED_MEDIA)
+void MediaPlayer::initializationDataEncountered(const String& initDataType, RefPtr<ArrayBuffer>&& initData)
+{
+    client().mediaPlayerInitializationDataEncountered(initDataType, WTFMove(initData));
+}
+#endif
+
 String MediaPlayer::referrer() const
 {
     return client().mediaPlayerReferrer();

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (221130 => 221131)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2017-08-24 06:17:22 UTC (rev 221130)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2017-08-24 08:07:38 UTC (rev 221131)
@@ -231,6 +231,10 @@
     virtual bool mediaPlayerKeyNeeded(MediaPlayer*, Uint8Array*) { return false; }
     virtual String mediaPlayerMediaKeysStorageDirectory() const { return emptyString(); }
 #endif
+
+#if ENABLE(ENCRYPTED_MEDIA)
+    virtual void mediaPlayerInitializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&) { }
+#endif
     
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     virtual void mediaPlayerCurrentPlaybackTargetIsWirelessChanged(MediaPlayer*) { };
@@ -553,6 +557,10 @@
     String mediaKeysStorageDirectory() const;
 #endif
 
+#if ENABLE(ENCRYPTED_MEDIA)
+    void initializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&);
+#endif
+
     String referrer() const;
     String userAgent() const;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to