Changeset 186123 in webkit


Ignore:
Timestamp:
Jun 30, 2015 11:10:55 AM (9 years ago)
Author:
mrajca@apple.com
Message:

Media Session: implement algorithm for updating a media element's session (6.1)
https://bugs.webkit.org/show_bug.cgi?id=146460

Reviewed by Darin Adler.

In addition to storing a pointer to the new media session, we now:

  • pause the media element if it is 'active' in the current media session
  • remove the media element from the current media session
  • release the current media session if there are no more active media elements
  • set the default media session if the new media session is null
  • update the 'kind' attribute to match the kind of the new media session
  • Modules/mediasession/MediaSession.cpp:

(WebCore::MediaSession::isMediaElementActive):
(WebCore::MediaSession::hasActiveMediaElements):

  • Modules/mediasession/MediaSession.h:
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::setSession):
(WebCore::HTMLMediaElement::setSessionInternal):

  • html/HTMLMediaElement.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r186118 r186123  
     12015-06-30  Matt Rajca  <mrajca@apple.com>
     2
     3        Media Session: implement algorithm for updating a media element's session (6.1)
     4        https://bugs.webkit.org/show_bug.cgi?id=146460
     5
     6        Reviewed by Darin Adler.
     7
     8        In addition to storing a pointer to the new media session, we now:
     9
     10        - pause the media element if it is 'active' in the current media session
     11        - remove the media element from the current media session
     12        - release the current media session if there are no more active media elements
     13        - set the default media session if the new media session is null
     14        - update the 'kind' attribute to match the kind of the new media session
     15
     16        * Modules/mediasession/MediaSession.cpp:
     17        (WebCore::MediaSession::isMediaElementActive):
     18        (WebCore::MediaSession::hasActiveMediaElements):
     19        * Modules/mediasession/MediaSession.h:
     20        * html/HTMLMediaElement.cpp:
     21        (WebCore::HTMLMediaElement::setSession):
     22        (WebCore::HTMLMediaElement::setSessionInternal):
     23        * html/HTMLMediaElement.h:
     24
    1252015-06-29  Anders Carlsson  <andersca@apple.com>
    226
  • trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp

    r186094 r186123  
    126126}
    127127
     128bool MediaSession::isMediaElementActive(HTMLMediaElement& element)
     129{
     130    return m_activeParticipatingElements.contains(&element);
     131}
     132
     133bool MediaSession::hasActiveMediaElements()
     134{
     135    return !m_activeParticipatingElements.isEmpty();
     136}
     137
    128138void MediaSession::setMetadata(const Dictionary& metadata)
    129139{
  • trunk/Source/WebCore/Modules/mediasession/MediaSession.h

    r186084 r186123  
    8989
    9090    void addActiveMediaElement(HTMLMediaElement&);
     91    bool isMediaElementActive(HTMLMediaElement&);
     92    bool hasActiveMediaElements();
    9193
    9294    void releaseInternal();
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r186083 r186123  
    64536453void HTMLMediaElement::setSession(MediaSession* session)
    64546454{
    6455     if (m_session)
     6455    // 6.1
     6456    // 1. Let m be the media element in question.
     6457    // 2. Let old media session be m's current media session, if it has one, and null otherwise.
     6458    // 3. Let new media session be null.
     6459    // 4. Set m's current media session to null, if it currently has one.
     6460    // 5. Let m's current media session be the new value or the top-level browsing context's media session if the new
     6461    //    value is null.
     6462    // 6. If the new value is null, then set the m's kind IDL attribute to the empty string. Otherwise, set m's kind IDL
     6463    //    attribute to the value of current media session's kind attribute.
     6464    // 7. Let new media session be m's current media session.
     6465    // 8. Update media sessions: If old media session and new media session are the same (whether both null or both the
     6466    //    same media session), then terminate these steps.
     6467    // 9. If m is an active audio-producing participant of old media session, then pause m and remove m from old media
     6468    //    session's active audio-producing participants.
     6469    // 10. If old media session is not null and no longer has one or more active audio-producing participants, then run
     6470    //     the media session release algorithm for old media session.
     6471
     6472    if (m_session) {
     6473        if (m_session->isMediaElementActive(*this))
     6474            pause();
     6475
    64566476        m_session->removeMediaElement(*this);
    64576477
    6458     m_session = session;
     6478        if (!m_session->hasActiveMediaElements())
     6479            m_session->releaseSession();
     6480    }
    64596481
    64606482    if (session)
    6461         session->addMediaElement(*this);
    6462 }
    6463 
    6464 #endif
    6465 
    6466 }
    6467 
    6468 #endif
     6483        setSessionInternal(*session);
     6484    else
     6485        setSessionInternal(document().defaultMediaSession());
     6486}
     6487
     6488void HTMLMediaElement::setSessionInternal(MediaSession& session)
     6489{
     6490    m_session = &session;
     6491    session.addMediaElement(*this);
     6492    m_kind = session.kind();
     6493}
     6494
     6495#endif
     6496
     6497}
     6498
     6499#endif
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r186054 r186123  
    557557#endif
    558558
     559#if ENABLE(MEDIA_SESSION)
     560    void setSessionInternal(MediaSession&);
     561#endif
     562
    559563    virtual String mediaPlayerReferrer() const override;
    560564    virtual String mediaPlayerUserAgent() const override;
Note: See TracChangeset for help on using the changeset viewer.