Changeset 236006 in webkit


Ignore:
Timestamp:
Sep 14, 2018 8:37:14 AM (6 years ago)
Author:
calvaris@igalia.com
Message:

[EME] Add support the waitingforkey event
https://bugs.webkit.org/show_bug.cgi?id=189616

Reviewed by Philippe Normand.

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):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r236005 r236006  
     12018-09-14  Xabier Rodriguez Calvar  <calvaris@igalia.com>
     2
     3        [EME] Add support the waitingforkey event
     4        https://bugs.webkit.org/show_bug.cgi?id=189616
     5
     6        Reviewed by Philippe Normand.
     7
     8        Crossplatform support to fire the waitingforkey event from the
     9        player to the element. The element implements the W3C specified
     10        algorithm.
     11
     12        * html/HTMLMediaElement.cpp:
     13        (WebCore::HTMLMediaElement::mediaPlayerWaitingForKey):
     14        (WebCore::HTMLMediaElement::attemptToResumePlaybackIfNecessary):
     15        * html/HTMLMediaElement.h:
     16        * platform/graphics/MediaPlayer.cpp:
     17        (WebCore::MediaPlayer::waitingForKey):
     18        * platform/graphics/MediaPlayer.h:
     19        (WebCore::MediaPlayerClient::mediaPlayerWaitingForKey):
     20
    1212018-09-14  Mike Gorse  <mgorse@suse.com>
    222
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r235752 r236006  
    27882788}
    27892789
     2790void HTMLMediaElement::mediaPlayerWaitingForKey()
     2791{
     2792    // https://www.w3.org/TR/encrypted-media/#wait-for-key
     2793    // W3C Recommendation 18 September 2017
     2794
     2795    // The Wait for Key algorithm queues a waitingforkey event and
     2796    // updates readyState. It should only be called when the
     2797    // HTMLMediaElement object is potentially playing and its
     2798    // readyState is equal to HAVE_FUTURE_DATA or greater. Requests to
     2799    // run this algorithm include a target HTMLMediaElement object.
     2800
     2801    // The following steps are run:
     2802
     2803    // 1. Let the media element be the specified HTMLMediaElement
     2804    // object.
     2805    // 2. If the media element's playback blocked waiting for key
     2806    // value is true, abort these steps.
     2807    if (m_playbackBlockedWaitingForKey)
     2808        return;
     2809
     2810    // 3. Set the media element's playback blocked waiting for key
     2811    // value to true.
     2812    m_playbackBlockedWaitingForKey = true;
     2813
     2814    // NOTE
     2815    // As a result of the above step, the media element will become a
     2816    // blocked media element if it wasn't already. In that case, the
     2817    // media element will stop playback.
     2818
     2819    // 4. Follow the steps for the first matching condition from the
     2820    // following list:
     2821
     2822    // If data for the immediate current playback position is
     2823    // available
     2824    // Set the readyState of media element to HAVE_CURRENT_DATA.
     2825    // Otherwise
     2826    // Set the readyState of media element to HAVE_METADATA.
     2827    ReadyState nextReadyState = buffered()->contain(currentTime()) ? HAVE_CURRENT_DATA : HAVE_METADATA;
     2828    if (nextReadyState < m_readyState)
     2829        setReadyState(static_cast<MediaPlayer::ReadyState>(nextReadyState));
     2830
     2831    // NOTE
     2832    // In other words, if the video frame and audio data for the
     2833    // current playback position have been decoded because they were
     2834    // unencrypted and/or successfully decrypted, set readyState to
     2835    // HAVE_CURRENT_DATA. Otherwise, including if this was previously
     2836    // the case but the data is no longer available, set readyState to
     2837    // HAVE_METADATA.
     2838
     2839    // 5. Queue a task to fire a simple event named waitingforkey at the
     2840    // media element.
     2841    scheduleEvent(eventNames().waitingforkeyEvent);
     2842
     2843    // 6. Suspend playback.
     2844    // GStreamer handles this without suspending explicitly.
     2845}
     2846
    27902847void HTMLMediaElement::attemptToDecrypt()
    27912848{
     
    28282885    // 1. Let the media element be the specified HTMLMediaElement object.
    28292886    // 2. If the media element's playback blocked waiting for key is false, abort these steps.
    2830     // FIXME: ^
     2887    if (!m_playbackBlockedWaitingForKey)
     2888        return;
    28312889
    28322890    // 3. Run the Attempt to Decrypt algorithm on the media element.
     
    28352893    // 4. If the user agent can advance the current playback position in the direction of playback:
    28362894    //   4.1. Set the media element's decryption blocked waiting for key value to false.
     2895    // FIXME: ^
    28372896    //   4.2. Set the media element's playback blocked waiting for key value to false.
     2897    m_playbackBlockedWaitingForKey = false;
     2898
    28382899    //   4.3. Set the media element's readyState value to HAVE_CURRENT_DATA, HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA as appropriate.
    2839     // FIXME: ^
     2900    setReadyState(m_player->readyState());
    28402901}
    28412902
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r235752 r236006  
    674674#if ENABLE(ENCRYPTED_MEDIA)
    675675    void mediaPlayerInitializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&) final;
     676    void mediaPlayerWaitingForKey() final;
    676677
    677678    void attemptToDecrypt();
     
    11491150    RefPtr<MediaKeys> m_mediaKeys;
    11501151    bool m_attachingMediaKeys { false };
     1152    bool m_playbackBlockedWaitingForKey { false };
    11511153    GenericTaskQueue<Timer> m_encryptedMediaQueue;
    11521154#endif
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r234140 r236006  
    12671267}
    12681268
     1269void MediaPlayer::waitingForKey()
     1270{
     1271    client().mediaPlayerWaitingForKey();
     1272}
    12691273#endif
    12701274
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r234055 r236006  
    170170#if ENABLE(ENCRYPTED_MEDIA)
    171171    virtual void mediaPlayerInitializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&) { }
     172    virtual void mediaPlayerWaitingForKey() { }
    172173#endif
    173174   
     
    488489#if ENABLE(ENCRYPTED_MEDIA)
    489490    void initializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&);
     491    void waitingForKey();
    490492#endif
    491493
Note: See TracChangeset for help on using the changeset viewer.