Changeset 191168 in webkit


Ignore:
Timestamp:
Oct 15, 2015 11:28:51 PM (9 years ago)
Author:
matthew_hanson@apple.com
Message:

Merge r190434. rdar://problem/22865007

Location:
branches/safari-601.1.46-branch
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-601.1.46-branch/LayoutTests/ChangeLog

    r191099 r191168  
     12015-10-15  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        Merge r190434. rdar://problem/22865007
     4
     5    2015-10-01  Eric Carlson  <eric.carlson@apple.com>
     6
     7            [iOS] AirPlay should not stop when the screen locks
     8            https://bugs.webkit.org/show_bug.cgi?id=148315
     9            <rdar://problem/22770703>
     10
     11            Reviewed by Jer Noble.
     12
     13            * media/video-interruption-with-resume-allowing-play.html:
     14            * media/video-interruption-with-resume-not-allowing-play.html:
     15
    1162015-10-15  Matthew Hanson  <matthew_hanson@apple.com>
    217
  • branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt

    r190815 r191168  
    77EVENT(playing)
    88EXPECTED (video.paused == 'false') OK
    9 RUN(internals.beginMediaSessionInterruption())
     9RUN(internals.beginMediaSessionInterruption('System'))
    1010
    1111100ms timer fired...
     
    1717
    1818EXPECTED (video.paused == 'false') OK
    19 RUN(internals.beginMediaSessionInterruption())
     19RUN(internals.beginMediaSessionInterruption('System'))
    2020
    2121100ms timer fired...
  • branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play.html

    r190815 r191168  
    1313                    testExpected("video.paused", false);
    1414                    state = "interrupted";
    15                     run("internals.beginMediaSessionInterruption()");;
     15                    run("internals.beginMediaSessionInterruption('System')");;
    1616                    setTimeout(checkState, 100);
    1717                    consoleWrite("");
  • branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt

    r190815 r191168  
    66
    77EVENT(playing)
    8 RUN(internals.beginMediaSessionInterruption())
     8RUN(internals.beginMediaSessionInterruption('System'))
    99
    1010100ms timer fired...
  • branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html

    r190815 r191168  
    88            function playing()
    99            {
    10                 run("internals.beginMediaSessionInterruption()");;
     10                run("internals.beginMediaSessionInterruption('System')");;
    1111                setTimeout(checkState, 100);
    1212            }
  • branches/safari-601.1.46-branch/Source/WebCore/ChangeLog

    r191154 r191168  
     12015-10-15  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        Merge r190434. rdar://problem/22865007
     4
     5    2015-10-01  Eric Carlson  <eric.carlson@apple.com>
     6
     7            [iOS] AirPlay should not stop when the screen locks
     8            https://bugs.webkit.org/show_bug.cgi?id=148315
     9            <rdar://problem/22770703>
     10
     11            Reviewed by Jer Noble.
     12
     13            Tested by media/video-interruption-with-resume-allowing-play.html
     14                      media/video-interruption-with-resume-not-allowing-play.html
     15
     16            * Modules/webaudio/AudioContext.h: overrideBackgroundPlaybackRestriction ->
     17              shouldOverrideBackgroundPlaybackRestriction.
     18
     19            * html/HTMLMediaElement.cpp:
     20            (WebCore::HTMLMediaElement::suspendPlayback): Fix a typo in the logging.
     21            (WebCore::HTMLMediaElement::mayResumePlayback): Ditto.
     22            (WebCore::HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction): Renamed from
     23              overrideBackgroundPlaybackRestriction.
     24            (WebCore::HTMLMediaElement::overrideBackgroundPlaybackRestriction): Deleted.
     25            * html/HTMLMediaElement.h:
     26
     27            * platform/audio/PlatformMediaSession.cpp:
     28            (WebCore::stateName):
     29            (WebCore::interruptionName): New, log the name of the interruption.
     30            (WebCore::PlatformMediaSession::beginInterruption): Log the interruption type. Don't
     31              increment the interruption counter if we are going to ignore it. Incorporate logic
     32              from doInterruption.
     33            (WebCore::PlatformMediaSession::doInterruption): Deleted.
     34            (WebCore::PlatformMediaSession::shouldDoInterruption): Deleted.
     35            (WebCore::PlatformMediaSession::forceInterruption): Deleted.
     36
     37            * platform/audio/PlatformMediaSession.h: Add SuspendedUnderLock interruption type.
     38            * platform/audio/PlatformMediaSessionManager.cpp:
     39            (WebCore::PlatformMediaSessionManager::applicationDidEnterBackground): Deleted.
     40            * platform/audio/PlatformMediaSessionManager.h:
     41
     42            * platform/audio/ios/MediaSessionManagerIOS.h:
     43            * platform/audio/ios/MediaSessionManagerIOS.mm:
     44            (WebCore::MediaSessionManageriOS::applicationDidEnterBackground): Call beginInterruption
     45              when appropriate.
     46
    1472015-10-15  Matthew Hanson  <matthew_hanson@apple.com>
    248
  • branches/safari-601.1.46-branch/Source/WebCore/Modules/webaudio/AudioContext.h

    r190815 r191168  
    323323    virtual bool canReceiveRemoteControlCommands() const override { return false; }
    324324    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override { }
    325     virtual bool overrideBackgroundPlaybackRestriction() const override { return false; }
     325    bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override { return false; }
    326326
    327327    // EventTarget
  • branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp

    r191088 r191168  
    63496349void HTMLMediaElement::suspendPlayback()
    63506350{
    6351     LOG(Media, "HTMLMediaElement::pausePlayback(%p) - paused = %s", this, boolString(paused()));
     6351    LOG(Media, "HTMLMediaElement::suspendPlayback(%p) - paused = %s", this, boolString(paused()));
    63526352    if (!paused())
    63536353        pause();
     
    63566356void HTMLMediaElement::mayResumePlayback(bool shouldResume)
    63576357{
    6358     LOG(Media, "HTMLMediaElement::resumePlayback(%p) - paused = %s", this, boolString(paused()));
     6358    LOG(Media, "HTMLMediaElement::mayResumePlayback(%p) - paused = %s", this, boolString(paused()));
    63596359    if (paused() && shouldResume)
    63606360        play();
     
    63986398}
    63996399
    6400 bool HTMLMediaElement::overrideBackgroundPlaybackRestriction() const
    6401 {
     6400bool HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType type) const
     6401{
     6402    if (type != PlatformMediaSession::EnteringBackground)
     6403        return false;
     6404
    64026405#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    64036406    if (m_player && m_player->isCurrentPlaybackTargetWireless())
  • branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.h

    r191087 r191168  
    726726    virtual bool canReceiveRemoteControlCommands() const override { return true; }
    727727    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override;
    728     virtual bool overrideBackgroundPlaybackRestriction() const override;
     728    bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override;
    729729
    730730    virtual void pageMutedStateDidChange() override;
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp

    r190815 r191168  
    4040static const char* stateName(PlatformMediaSession::State state)
    4141{
    42 #define CASE(state) case PlatformMediaSession::state: return #state
     42#define STATE_CASE(state) case PlatformMediaSession::state: return #state
    4343    switch (state) {
    44     CASE(Idle);
    45     CASE(Playing);
    46     CASE(Paused);
    47     CASE(Interrupted);
    48     }
    49 
     44    STATE_CASE(Idle);
     45    STATE_CASE(Playing);
     46    STATE_CASE(Paused);
     47    STATE_CASE(Interrupted);
     48    }
     49
     50    ASSERT_NOT_REACHED();
     51    return "";
     52}
     53
     54static const char* interruptionName(PlatformMediaSession::InterruptionType type)
     55{
     56#define INTERRUPTION_CASE(type) case PlatformMediaSession::type: return #type
     57    switch (type) {
     58    INTERRUPTION_CASE(SystemSleep);
     59    INTERRUPTION_CASE(EnteringBackground);
     60    INTERRUPTION_CASE(SystemInterruption);
     61    INTERRUPTION_CASE(SuspendedUnderLock);
     62    }
     63   
    5064    ASSERT_NOT_REACHED();
    5165    return "";
     
    8094}
    8195
    82 void PlatformMediaSession::doInterruption()
    83 {
     96void PlatformMediaSession::beginInterruption(InterruptionType type)
     97{
     98    LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption type = %s, interruption count = %i", this, stateName(m_state), interruptionName(type), m_interruptionCount);
     99
     100    if (++m_interruptionCount > 1)
     101        return;
     102
     103    if (client().shouldOverrideBackgroundPlaybackRestriction(type))
     104        return;
     105
    84106    m_stateToRestore = state();
    85107    m_notifyingClient = true;
     
    87109    client().suspendPlayback();
    88110    m_notifyingClient = false;
    89 }
    90 
    91 bool PlatformMediaSession::shouldDoInterruption(InterruptionType type)
    92 {
    93     return type != EnteringBackground || !client().overrideBackgroundPlaybackRestriction();
    94 }
    95 
    96 void PlatformMediaSession::beginInterruption(InterruptionType type)
    97 {
    98     LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption count = %i", this, stateName(m_state), m_interruptionCount);
    99 
    100     if (++m_interruptionCount > 1 || !shouldDoInterruption(type))
    101         return;
    102 
    103     doInterruption();
    104 }
    105 
    106 void PlatformMediaSession::forceInterruption(InterruptionType type)
    107 {
    108     LOG(Media, "PlatformMediaSession::forceInterruption(%p), state = %s, interruption count = %i", this, stateName(m_state), m_interruptionCount);
    109 
    110     // beginInterruption() must have been called before calling this function.
    111     if (!m_interruptionCount) {
    112         ASSERT_NOT_REACHED();
    113         return;
    114     }
    115 
    116     // The purpose of this function is to override the decision which was made by
    117     // beginInterruption(). If it was decided to interrupt the media session there,
    118     // then nothing should be done here.
    119     if (shouldDoInterruption(type))
    120         return;
    121 
    122     doInterruption();
    123111}
    124112
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h

    r190815 r191168  
    7575        EnteringBackground,
    7676        SystemInterruption,
     77        SuspendedUnderLock,
    7778    };
    7879    enum EndInterruptionFlags {
     
    8182    };
    8283
    83     void doInterruption();
    84     bool shouldDoInterruption(InterruptionType);
    8584    void beginInterruption(InterruptionType);
    86     void forceInterruption(InterruptionType);
    8785    void endInterruption(EndInterruptionFlags);
    8886
     
    180178    virtual bool elementIsHidden() const { return false; }
    181179
    182     virtual bool overrideBackgroundPlaybackRestriction() const = 0;
     180    virtual bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const = 0;
    183181
    184182    virtual void wirelessRoutesAvailableDidChange() { }
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp

    r190815 r191168  
    290290}
    291291
    292 void PlatformMediaSessionManager::applicationDidEnterBackground(bool isSuspendedUnderLock) const
    293 {
    294     LOG(Media, "PlatformMediaSessionManager::applicationDidEnterBackground");
    295 
    296     if (!isSuspendedUnderLock)
    297         return;
    298 
    299     Vector<PlatformMediaSession*> sessions = m_sessions;
    300     for (auto* session : sessions) {
    301         if (m_restrictions[session->mediaType()] & BackgroundProcessPlaybackRestricted)
    302             session->forceInterruption(PlatformMediaSession::EnteringBackground);
    303     }
    304 }
    305 
    306292void PlatformMediaSessionManager::applicationWillEnterForeground() const
    307293{
     
    325311        return;
    326312
    327     if (session.state() != PlatformMediaSession::Interrupted && session.shouldDoInterruption(PlatformMediaSession::EnteringBackground))
    328         session.doInterruption();
     313    if (session.state() != PlatformMediaSession::Interrupted)
     314        session.beginInterruption(PlatformMediaSession::EnteringBackground);
    329315}
    330316
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h

    r190815 r191168  
    5757    WEBCORE_EXPORT void applicationWillEnterForeground() const;
    5858    WEBCORE_EXPORT void applicationWillEnterBackground() const;
    59     WEBCORE_EXPORT void applicationDidEnterBackground(bool isSuspendedUnderLock) const;
    6059
    6160    void stopAllMediaPlaybackForDocument(const Document*);
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h

    r190815 r191168  
    4949    void externalOutputDeviceAvailableDidChange();
    5050    virtual bool hasWirelessTargetsAvailable() override;
     51    void applicationDidEnterBackground(bool isSuspendedUnderLock);
    5152
    5253private:
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r190815 r191168  
    249249}
    250250
     251void MediaSessionManageriOS::applicationDidEnterBackground(bool isSuspendedUnderLock)
     252{
     253    LOG(Media, "MediaSessionManageriOS::applicationDidEnterBackground");
     254
     255    if (!isSuspendedUnderLock)
     256        return;
     257
     258    Vector<PlatformMediaSession*> sessions = this->sessions();
     259    for (auto* session : sessions) {
     260        if (restrictions(session->mediaType()) & BackgroundProcessPlaybackRestricted)
     261            session->beginInterruption(PlatformMediaSession::SuspendedUnderLock);
     262    }
     263}
     264
     265
    251266} // namespace WebCore
    252267
  • branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp

    r190815 r191168  
    26152615
    26162616#if ENABLE(VIDEO)
    2617 void Internals::beginMediaSessionInterruption()
    2618 {
     2617void Internals::beginMediaSessionInterruption(const String& interruptionString, ExceptionCode& ec)
     2618{
     2619    PlatformMediaSession::InterruptionType interruption = PlatformMediaSession::SystemInterruption;
     2620
     2621    if (equalIgnoringCase(interruptionString, "System"))
     2622        interruption = PlatformMediaSession::SystemInterruption;
     2623    else if (equalIgnoringCase(interruptionString, "SystemSleep"))
     2624        interruption = PlatformMediaSession::SystemSleep;
     2625    else if (equalIgnoringCase(interruptionString, "EnteringBackground"))
     2626        interruption = PlatformMediaSession::EnteringBackground;
     2627    else {
     2628        ec = INVALID_ACCESS_ERR;
     2629        return;
     2630    }
     2631
    26192632    PlatformMediaSessionManager::sharedManager().beginInterruption(PlatformMediaSession::SystemInterruption);
    26202633}
  • branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.h

    r190815 r191168  
    383383
    384384#if ENABLE(VIDEO)
    385     void beginMediaSessionInterruption();
     385    void beginMediaSessionInterruption(const String&, ExceptionCode&);
    386386    void endMediaSessionInterruption(const String&);
    387387    void applicationWillEnterForeground() const;
  • branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.idl

    r190815 r191168  
    350350    [Conditional=MEDIA_SOURCE] DOMString[] bufferedSamplesForTrackID(SourceBuffer buffer, DOMString trackID);
    351351
    352     [Conditional=VIDEO] void beginMediaSessionInterruption();
     352    [Conditional=VIDEO, RaisesException] void beginMediaSessionInterruption(DOMString interruptionType);
    353353    [Conditional=VIDEO] void endMediaSessionInterruption(DOMString flags);
    354354    [Conditional=VIDEO] void applicationWillEnterForeground();
Note: See TracChangeset for help on using the changeset viewer.