WebKit Bugzilla
Attachment 349751 Details for
Bug 189616
: [EME] Add support the waitingforkey event
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189616-20180914103647.patch (text/plain), 7.28 KB, created by
Xabier RodrÃguez Calvar
on 2018-09-14 01:36:48 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Xabier RodrÃguez Calvar
Created:
2018-09-14 01:36:48 PDT
Size:
7.28 KB
patch
obsolete
>Subversion Revision: 235971 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 88320c4bcbd18747d145ec17242163c27b11a2b3..789331eabca2938898f349189537cebb193cde90 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,23 @@ >+2018-09-14 Xabier Rodriguez Calvar <calvaris@igalia.com> >+ >+ [EME] Add support the waitingforkey event >+ https://bugs.webkit.org/show_bug.cgi?id=189616 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Crossplatform support to fire the waitingforkey event from the >+ player to the element. The element implements the W3C specified >+ algorithm. >+ >+ * html/HTMLMediaElement.cpp: >+ (WebCore::HTMLMediaElement::mediaPlayerWaitingForKey): >+ (WebCore::HTMLMediaElement::attemptToResumePlaybackIfNecessary): >+ * html/HTMLMediaElement.h: >+ * platform/graphics/MediaPlayer.cpp: >+ (WebCore::MediaPlayer::waitingForKey): >+ * platform/graphics/MediaPlayer.h: >+ (WebCore::MediaPlayerClient::mediaPlayerWaitingForKey): >+ > 2018-09-13 Xabier Rodriguez Calvar <calvaris@igalia.com> > > [GStreamer][EME] decrypt-key-needed message renamed to drm-cdm-instance-needed >diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp >index 27d4aaba4204cdf3e16c34a57fbedfa44d7fd8ef..0a1650baa434bafae5b869c187389ed3aea03bcd 100644 >--- a/Source/WebCore/html/HTMLMediaElement.cpp >+++ b/Source/WebCore/html/HTMLMediaElement.cpp >@@ -2787,6 +2787,64 @@ void HTMLMediaElement::mediaPlayerInitializationDataEncountered(const String& in > m_asyncEventQueue.enqueueEvent(MediaEncryptedEvent::create(eventNames().encryptedEvent, initializer, Event::IsTrusted::Yes)); > } > >+void HTMLMediaElement::mediaPlayerWaitingForKey() >+{ >+ // https://www.w3.org/TR/encrypted-media/#wait-for-key >+ // W3C Recommendation 18 September 2017 >+ >+ // The Wait for Key algorithm queues a waitingforkey event and >+ // updates readyState. It should only be called when the >+ // HTMLMediaElement object is potentially playing and its >+ // readyState is equal to HAVE_FUTURE_DATA or greater. Requests to >+ // run this algorithm include a target HTMLMediaElement object. >+ >+ // The following steps are run: >+ >+ // 1. Let the media element be the specified HTMLMediaElement >+ // object. >+ // 2. If the media element's playback blocked waiting for key >+ // value is true, abort these steps. >+ if (m_playbackBlockedWaitingForKey) >+ return; >+ >+ // 3. Set the media element's playback blocked waiting for key >+ // value to true. >+ m_playbackBlockedWaitingForKey = true; >+ >+ // NOTE >+ // As a result of the above step, the media element will become a >+ // blocked media element if it wasn't already. In that case, the >+ // media element will stop playback. >+ >+ // 4. Follow the steps for the first matching condition from the >+ // following list: >+ >+ // If data for the immediate current playback position is >+ // available >+ // Set the readyState of media element to HAVE_CURRENT_DATA. >+ // Otherwise >+ // Set the readyState of media element to HAVE_METADATA. >+ ReadyState nextReadyState = buffered()->contain(currentTime()) ? HAVE_CURRENT_DATA : HAVE_METADATA; >+ if (nextReadyState < m_readyState) >+ setReadyState(static_cast<MediaPlayer::ReadyState>(nextReadyState)); >+ >+ // NOTE >+ // In other words, if the video frame and audio data for the >+ // current playback position have been decoded because they were >+ // unencrypted and/or successfully decrypted, set readyState to >+ // HAVE_CURRENT_DATA. Otherwise, including if this was previously >+ // the case but the data is no longer available, set readyState to >+ // HAVE_METADATA. >+ >+ // 5. Queue a task to fire a simple event named waitingforkey at the >+ // media element. >+ scheduleEvent(eventNames().waitingforkeyEvent); >+ >+ // 6. Suspend playback. >+ // The platform already suspends and resumes playback >+ // automagically. >+} >+ > void HTMLMediaElement::attemptToDecrypt() > { > // https://w3c.github.io/encrypted-media/#attempt-to-decrypt >@@ -2827,16 +2885,20 @@ void HTMLMediaElement::attemptToResumePlaybackIfNecessary() > > // 1. Let the media element be the specified HTMLMediaElement object. > // 2. If the media element's playback blocked waiting for key is false, abort these steps. >- // FIXME: ^ >+ if (!m_playbackBlockedWaitingForKey) >+ return; > > // 3. Run the Attempt to Decrypt algorithm on the media element. > attemptToDecrypt(); > > // 4. If the user agent can advance the current playback position in the direction of playback: > // 4.1. Set the media element's decryption blocked waiting for key value to false. >+ // FIXME: ^ > // 4.2. Set the media element's playback blocked waiting for key value to false. >+ m_playbackBlockedWaitingForKey = false; >+ > // 4.3. Set the media element's readyState value to HAVE_CURRENT_DATA, HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA as appropriate. >- // FIXME: ^ >+ setReadyState(m_player->readyState()); > } > > void HTMLMediaElement::cdmClientAttemptToResumePlaybackIfNecessary() >diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h >index 572c189537e9b4c37a3a8a5e82b8672f2186aa8a..9c8d541b80f932c3087035d43df558ea703cd204 100644 >--- a/Source/WebCore/html/HTMLMediaElement.h >+++ b/Source/WebCore/html/HTMLMediaElement.h >@@ -673,6 +673,7 @@ private: > > #if ENABLE(ENCRYPTED_MEDIA) > void mediaPlayerInitializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&) final; >+ void mediaPlayerWaitingForKey() final; > > void attemptToDecrypt(); > void attemptToResumePlaybackIfNecessary(); >@@ -1148,6 +1149,7 @@ private: > #if ENABLE(ENCRYPTED_MEDIA) > RefPtr<MediaKeys> m_mediaKeys; > bool m_attachingMediaKeys { false }; >+ bool m_playbackBlockedWaitingForKey { false }; > GenericTaskQueue<Timer> m_encryptedMediaQueue; > #endif > >diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp b/Source/WebCore/platform/graphics/MediaPlayer.cpp >index 506aee3dc64f6e758d6576998c7012601455713d..c2e80d62fa5ab451c71604811a37da7ab9b02c13 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayer.cpp >+++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp >@@ -1266,6 +1266,10 @@ void MediaPlayer::initializationDataEncountered(const String& initDataType, RefP > client().mediaPlayerInitializationDataEncountered(initDataType, WTFMove(initData)); > } > >+void MediaPlayer::waitingForKey() >+{ >+ client().mediaPlayerWaitingForKey(); >+} > #endif > > String MediaPlayer::referrer() const >diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h >index 97c68e2b29fcd5cebe7db0e72253d8f5fd42ea19..760f0e43848719f1d3d49ed135148c3f88f68d8d 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayer.h >+++ b/Source/WebCore/platform/graphics/MediaPlayer.h >@@ -169,6 +169,7 @@ public: > > #if ENABLE(ENCRYPTED_MEDIA) > virtual void mediaPlayerInitializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&) { } >+ virtual void mediaPlayerWaitingForKey() { } > #endif > > #if ENABLE(WIRELESS_PLAYBACK_TARGET) >@@ -487,6 +488,7 @@ public: > > #if ENABLE(ENCRYPTED_MEDIA) > void initializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&); >+ void waitingForKey(); > #endif > > String referrer() const;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189616
:
349751
|
349760