Title: [218417] trunk
Revision
218417
Author
jer.no...@apple.com
Date
2017-06-16 14:59:23 -0700 (Fri, 16 Jun 2017)

Log Message

[iOS] Do not pause playing video when application resigns active state.
https://bugs.webkit.org/show_bug.cgi?id=173474

Reviewed by Tim Horton.

Source/WebCore:

Test: media/video-inactive-playback.html

Separate out the concept of "inactive" playback from "process background" playback.
Move the implementation of applicationDidEnterBackground() from MediaSessionManagerIOS
into it's superclass, PlatformMediaSessionManager, and add a new set of restrictions
for "InactiveProcessPlaybackRestricted" and "SuspendedUnderLockPlaybackRestricted".
Leave the default restriction set for iOS as "BackgroundProcessPlaybackRestricted" and
"SuspendedUnderLockPlaybackRestricted", to preserve the existing behavior of suspending
playback when switching apps or when locking the device.

* platform/audio/PlatformMediaSession.cpp:
(WebCore::interruptionName):
* platform/audio/PlatformMediaSession.h:
* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::applicationWillBecomeInactive):
(WebCore::PlatformMediaSessionManager::applicationDidBecomeActive):
(WebCore::PlatformMediaSessionManager::applicationDidEnterBackground):
(WebCore::PlatformMediaSessionManager::applicationWillEnterForeground):
(WebCore::PlatformMediaSessionManager::applicationWillEnterBackground): Deleted.
(WebCore::PlatformMediaSessionManager::applicationDidEnterForeground): Deleted.
* platform/audio/PlatformMediaSessionManager.h:
* platform/audio/ios/MediaSessionManagerIOS.h:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::resetRestrictions):
(-[WebMediaSessionHelper applicationDidBecomeActive:]):
(-[WebMediaSessionHelper applicationWillResignActive:]):
(WebCore::MediaSessionManageriOS::applicationDidEnterBackground): Deleted.
(WebCore::MediaSessionManageriOS::applicationWillEnterForeground): Deleted.
* testing/Internals.cpp:
(WebCore::Internals::applicationWillBecomeInactive):
(WebCore::Internals::applicationDidBecomeActive):
(WebCore::Internals::applicationWillEnterForeground):
(WebCore::Internals::applicationDidEnterBackground):
(WebCore::Internals::setMediaSessionRestrictions):
(WebCore::Internals::applicationDidEnterForeground): Deleted.
(WebCore::Internals::applicationWillEnterBackground): Deleted.
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* media/video-background-playback-expected.txt:
* media/video-background-playback.html:
* media/video-background-tab-playback-expected.txt:
* media/video-background-tab-playback.html:
* media/video-inactive-playback-expected.txt: Added.
* media/video-inactive-playback.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (218416 => 218417)


--- trunk/LayoutTests/ChangeLog	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/LayoutTests/ChangeLog	2017-06-16 21:59:23 UTC (rev 218417)
@@ -1,3 +1,17 @@
+2017-06-16  Jer Noble  <jer.no...@apple.com>
+
+        [iOS] Do not pause playing video when application resigns active state.
+        https://bugs.webkit.org/show_bug.cgi?id=173474
+
+        Reviewed by Tim Horton.
+
+        * media/video-background-playback-expected.txt:
+        * media/video-background-playback.html:
+        * media/video-background-tab-playback-expected.txt:
+        * media/video-background-tab-playback.html:
+        * media/video-inactive-playback-expected.txt: Added.
+        * media/video-inactive-playback.html: Added.
+
 2017-06-16  Alex Christensen  <achristen...@webkit.org>
 
         REGRESSION (r213126): Sync XHR needs partition for cache and credentials

Modified: trunk/LayoutTests/media/video-background-playback-expected.txt (218416 => 218417)


--- trunk/LayoutTests/media/video-background-playback-expected.txt	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/LayoutTests/media/video-background-playback-expected.txt	2017-06-16 21:59:23 UTC (rev 218417)
@@ -12,7 +12,7 @@
 EVENT(playing)
 
 ** Simulate switch to background, video should pause.
-RUN(internals.applicationWillEnterBackground())
+RUN(internals.applicationDidEnterBackground())
 
 EVENT(pause)
 
@@ -21,7 +21,7 @@
 EXPECTED (audio.paused == 'false') OK
 
 ** Simulate switch back to foreground, video should resume.
-RUN(internals.applicationDidEnterForeground())
+RUN(internals.applicationWillEnterForeground())
 
 EVENT(playing)
 

Modified: trunk/LayoutTests/media/video-background-playback.html (218416 => 218417)


--- trunk/LayoutTests/media/video-background-playback.html	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/LayoutTests/media/video-background-playback.html	2017-06-16 21:59:23 UTC (rev 218417)
@@ -23,7 +23,7 @@
                     testExpected("audio.paused", false);
                     state = "foreground";
                     consoleWrite("<br>** Simulate switch back to foreground, video should resume.");
-                    run("internals.applicationDidEnterForeground()");
+                    run("internals.applicationWillEnterForeground()");
                     setTimeout(checkState, 100);
                     consoleWrite("");
                     break;
@@ -43,7 +43,7 @@
                     return;
 
                 consoleWrite("<br>** Simulate switch to background, video should pause.");
-                run("internals.applicationWillEnterBackground()");
+                run("internals.applicationDidEnterBackground()");
                 setTimeout(checkState, 100);
                 state = "background";
                 consoleWrite("");

Modified: trunk/LayoutTests/media/video-background-tab-playback-expected.txt (218416 => 218417)


--- trunk/LayoutTests/media/video-background-tab-playback-expected.txt	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/LayoutTests/media/video-background-tab-playback-expected.txt	2017-06-16 21:59:23 UTC (rev 218417)
@@ -16,7 +16,7 @@
 EXPECTED (video.paused == 'true') OK
 
 ** Simulate switch back to foreground, video should remain paused.
-RUN(internals.applicationDidEnterForeground())
+RUN(internals.applicationWillEnterForeground())
 
 
 ** 100ms timer fired...

Modified: trunk/LayoutTests/media/video-background-tab-playback.html (218416 => 218417)


--- trunk/LayoutTests/media/video-background-tab-playback.html	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/LayoutTests/media/video-background-tab-playback.html	2017-06-16 21:59:23 UTC (rev 218417)
@@ -13,7 +13,7 @@
                     testExpected("video.paused", true);
                     state = "foreground";
                     consoleWrite("<br>** Simulate switch back to foreground, video should remain paused.");
-                    run("internals.applicationDidEnterForeground()");
+                    run("internals.applicationWillEnterForeground()");
                     setTimeout(checkState, 100);
                     consoleWrite("");
                     break;

Added: trunk/LayoutTests/media/video-inactive-playback-expected.txt (0 => 218417)


--- trunk/LayoutTests/media/video-inactive-playback-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-inactive-playback-expected.txt	2017-06-16 21:59:23 UTC (rev 218417)
@@ -0,0 +1,15 @@
+
+RUN(internals.setMediaSessionRestrictions("videoaudio", ""))
+RUN(video.src = "" "content/test"))
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(playing)
+RUN(internals.applicationWillBecomeInactive())
+EXPECTED (video.paused == 'false') OK
+RUN(internals.setMediaSessionRestrictions("videoaudio", "inactiveprocessplaybackrestricted"))
+RUN(internals.applicationWillBecomeInactive())
+EVENT(pause)
+RUN(internals.applicationDidBecomeActive())
+EVENT(playing)
+END OF TEST
+

Added: trunk/LayoutTests/media/video-inactive-playback.html (0 => 218417)


--- trunk/LayoutTests/media/video-inactive-playback.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-inactive-playback.html	2017-06-16 21:59:23 UTC (rev 218417)
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function go()
+{
+    nextTest();
+}
+
+function nextTest()
+{
+    if (tests.length)
+        tests.shift()();
+    else
+        endTest();
+}
+
+function timeoutFor(time)
+{
+    return new Promise(resolve => {
+        setTimeout(resolve, time);
+    });
+}
+
+function waitFor(eventName)
+{
+    return new Promise(resolve => {
+        waitForEventOnce(eventName, resolve);
+    });
+}
+
+var tests = [
+    function initializeTests() {
+        findMediaElement();
+        run('internals.setMediaSessionRestrictions("videoaudio", "")');
+        run('video.src = "" "content/test")');
+        waitFor('canplaythrough').then(nextTest);
+
+    },
+
+    function testPlaybackContinuesWhenInactive() {
+        run('video.play()');
+        waitFor('playing').then(() => {
+            run("internals.applicationWillBecomeInactive()");
+            timeoutFor(100).then(() => {
+                testExpected('video.paused', false);
+            }).then(nextTest);
+        })
+    },
+
+    function testPlaybackPausesWhenInactive() {
+        run('internals.setMediaSessionRestrictions("videoaudio", "inactiveprocessplaybackrestricted")');
+        run('internals.applicationWillBecomeInactive()');
+        waitFor('pause').then(nextTest);
+    },
+
+    function testPlaybackResumesWhenActive() {
+        run('internals.applicationDidBecomeActive()');
+        waitFor('playing').then(nextTest);
+    },
+];
+
+</script>
+</head>
+<body _onload_="go()">
+    <video controls></video>
+</body>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (218416 => 218417)


--- trunk/Source/WebCore/ChangeLog	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/ChangeLog	2017-06-16 21:59:23 UTC (rev 218417)
@@ -1,3 +1,49 @@
+2017-06-16  Jer Noble  <jer.no...@apple.com>
+
+        [iOS] Do not pause playing video when application resigns active state.
+        https://bugs.webkit.org/show_bug.cgi?id=173474
+
+        Reviewed by Tim Horton.
+
+        Test: media/video-inactive-playback.html
+
+        Separate out the concept of "inactive" playback from "process background" playback.
+        Move the implementation of applicationDidEnterBackground() from MediaSessionManagerIOS
+        into it's superclass, PlatformMediaSessionManager, and add a new set of restrictions
+        for "InactiveProcessPlaybackRestricted" and "SuspendedUnderLockPlaybackRestricted".
+        Leave the default restriction set for iOS as "BackgroundProcessPlaybackRestricted" and
+        "SuspendedUnderLockPlaybackRestricted", to preserve the existing behavior of suspending
+        playback when switching apps or when locking the device.
+
+        * platform/audio/PlatformMediaSession.cpp:
+        (WebCore::interruptionName):
+        * platform/audio/PlatformMediaSession.h:
+        * platform/audio/PlatformMediaSessionManager.cpp:
+        (WebCore::PlatformMediaSessionManager::applicationWillBecomeInactive):
+        (WebCore::PlatformMediaSessionManager::applicationDidBecomeActive):
+        (WebCore::PlatformMediaSessionManager::applicationDidEnterBackground):
+        (WebCore::PlatformMediaSessionManager::applicationWillEnterForeground):
+        (WebCore::PlatformMediaSessionManager::applicationWillEnterBackground): Deleted.
+        (WebCore::PlatformMediaSessionManager::applicationDidEnterForeground): Deleted.
+        * platform/audio/PlatformMediaSessionManager.h:
+        * platform/audio/ios/MediaSessionManagerIOS.h:
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::resetRestrictions):
+        (-[WebMediaSessionHelper applicationDidBecomeActive:]):
+        (-[WebMediaSessionHelper applicationWillResignActive:]):
+        (WebCore::MediaSessionManageriOS::applicationDidEnterBackground): Deleted.
+        (WebCore::MediaSessionManageriOS::applicationWillEnterForeground): Deleted.
+        * testing/Internals.cpp:
+        (WebCore::Internals::applicationWillBecomeInactive):
+        (WebCore::Internals::applicationDidBecomeActive):
+        (WebCore::Internals::applicationWillEnterForeground):
+        (WebCore::Internals::applicationDidEnterBackground):
+        (WebCore::Internals::setMediaSessionRestrictions):
+        (WebCore::Internals::applicationDidEnterForeground): Deleted.
+        (WebCore::Internals::applicationWillEnterBackground): Deleted.
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2017-06-16  Alex Christensen  <achristen...@webkit.org>
 
         REGRESSION (r213126): Sync XHR needs partition for cache and credentials

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp (218416 => 218417)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2017-06-16 21:59:23 UTC (rev 218417)
@@ -62,6 +62,7 @@
     INTERRUPTION_CASE(SystemInterruption);
     INTERRUPTION_CASE(SuspendedUnderLock);
     INTERRUPTION_CASE(InvisibleAutoplay);
+    INTERRUPTION_CASE(ProcessInactive);
     }
     
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.h (218416 => 218417)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2017-06-16 21:59:23 UTC (rev 218417)
@@ -80,6 +80,7 @@
         SystemInterruption,
         SuspendedUnderLock,
         InvisibleAutoplay,
+        ProcessInactive,
     };
     InterruptionType interruptionType() const { return m_interruptionType; }
 

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (218416 => 218417)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2017-06-16 21:59:23 UTC (rev 218417)
@@ -294,10 +294,32 @@
     return session.state() == PlatformMediaSession::Playing || !session.isHidden() || session.shouldOverrideBackgroundLoadingRestriction();
 }
 
-void PlatformMediaSessionManager::applicationWillEnterBackground() const
+void PlatformMediaSessionManager::applicationWillBecomeInactive() const
 {
-    LOG(Media, "PlatformMediaSessionManager::applicationWillEnterBackground");
+    LOG(Media, "PlatformMediaSessionManager::applicationWillBecomeInactive");
 
+    Vector<PlatformMediaSession*> sessions = m_sessions;
+    forEachSession([&] (PlatformMediaSession& session, size_t) {
+        if (m_restrictions[session.mediaType()] & InactiveProcessPlaybackRestricted)
+            session.beginInterruption(PlatformMediaSession::ProcessInactive);
+    });
+}
+
+void PlatformMediaSessionManager::applicationDidBecomeActive() const
+{
+    LOG(Media, "PlatformMediaSessionManager::applicationDidBecomeInactive");
+
+    Vector<PlatformMediaSession*> sessions = m_sessions;
+    forEachSession([&] (PlatformMediaSession& session, size_t) {
+        if (m_restrictions[session.mediaType()] & InactiveProcessPlaybackRestricted)
+            session.endInterruption(PlatformMediaSession::MayResumePlaying);
+    });
+}
+
+void PlatformMediaSessionManager::applicationDidEnterBackground(bool suspendedUnderLock) const
+{
+    LOG(Media, "PlatformMediaSessionManager::applicationDidEnterBackground - suspendedUnderLock(%d)", suspendedUnderLock);
+
     if (m_isApplicationInBackground)
         return;
 
@@ -305,14 +327,16 @@
     
     Vector<PlatformMediaSession*> sessions = m_sessions;
     forEachSession([&] (PlatformMediaSession& session, size_t) {
-        if (m_restrictions[session.mediaType()] & BackgroundProcessPlaybackRestricted)
+        if (suspendedUnderLock && m_restrictions[session.mediaType()] & SuspendedUnderLockPlaybackRestricted)
+            session.beginInterruption(PlatformMediaSession::SuspendedUnderLock);
+        else if (m_restrictions[session.mediaType()] & BackgroundProcessPlaybackRestricted)
             session.beginInterruption(PlatformMediaSession::EnteringBackground);
     });
 }
 
-void PlatformMediaSessionManager::applicationDidEnterForeground() const
+void PlatformMediaSessionManager::applicationWillEnterForeground(bool suspendedUnderLock) const
 {
-    LOG(Media, "PlatformMediaSessionManager::applicationDidEnterForeground");
+    LOG(Media, "PlatformMediaSessionManager::applicationWillEnterForeground - suspendedUnderLock(%d)", suspendedUnderLock);
 
     if (!m_isApplicationInBackground)
         return;
@@ -321,7 +345,7 @@
 
     Vector<PlatformMediaSession*> sessions = m_sessions;
     forEachSession([&] (PlatformMediaSession& session, size_t) {
-        if (m_restrictions[session.mediaType()] & BackgroundProcessPlaybackRestricted)
+        if ((suspendedUnderLock && m_restrictions[session.mediaType()] & SuspendedUnderLockPlaybackRestricted) || m_restrictions[session.mediaType()] & BackgroundProcessPlaybackRestricted)
             session.endInterruption(PlatformMediaSession::MayResumePlaying);
     });
 }

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (218416 => 218417)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2017-06-16 21:59:23 UTC (rev 218417)
@@ -67,8 +67,10 @@
     WEBCORE_EXPORT void beginInterruption(PlatformMediaSession::InterruptionType);
     WEBCORE_EXPORT void endInterruption(PlatformMediaSession::EndInterruptionFlags);
 
-    WEBCORE_EXPORT void applicationDidEnterForeground() const;
-    WEBCORE_EXPORT void applicationWillEnterBackground() const;
+    WEBCORE_EXPORT void applicationWillBecomeInactive() const;
+    WEBCORE_EXPORT void applicationDidBecomeActive() const;
+    WEBCORE_EXPORT void applicationWillEnterForeground(bool suspendedUnderLock) const;
+    WEBCORE_EXPORT void applicationDidEnterBackground(bool suspendedUnderLock) const;
 
     void stopAllMediaPlaybackForDocument(const Document*);
     WEBCORE_EXPORT void stopAllMediaPlaybackForProcess();
@@ -79,6 +81,8 @@
         BackgroundProcessPlaybackRestricted = 1 << 1,
         BackgroundTabPlaybackRestricted = 1 << 2,
         InterruptedPlaybackNotPermitted = 1 << 3,
+        InactiveProcessPlaybackRestricted = 1 << 4,
+        SuspendedUnderLockPlaybackRestricted = 1 << 5,
     };
     typedef unsigned SessionRestrictions;
 

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (218416 => 218417)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2017-06-16 21:59:23 UTC (rev 218417)
@@ -48,8 +48,6 @@
 
     void externalOutputDeviceAvailableDidChange();
     bool hasWirelessTargetsAvailable() override;
-    void applicationDidEnterBackground(bool isSuspendedUnderLock);
-    void applicationWillEnterForeground(bool isSuspendedUnderLock);
 
 private:
     friend class PlatformMediaSessionManager;
@@ -83,7 +81,6 @@
     double m_reportedCurrentTime { 0 };
     String m_reportedTitle;
     bool m_nowPlayingActive { false };
-    bool m_isInBackground { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (218416 => 218417)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2017-06-16 21:59:23 UTC (rev 218417)
@@ -153,17 +153,8 @@
         addRestriction(PlatformMediaSession::Video, BackgroundTabPlaybackRestricted);
     }
 
-    removeRestriction(PlatformMediaSession::Video, ConcurrentPlaybackNotPermitted);
     addRestriction(PlatformMediaSession::Video, BackgroundProcessPlaybackRestricted);
-
-    addRestriction(PlatformMediaSession::VideoAudio, ConcurrentPlaybackNotPermitted);
-    addRestriction(PlatformMediaSession::VideoAudio, BackgroundProcessPlaybackRestricted);
-
-    removeRestriction(PlatformMediaSession::Audio, ConcurrentPlaybackNotPermitted);
-    removeRestriction(PlatformMediaSession::Audio, BackgroundProcessPlaybackRestricted);
-
-    removeRestriction(PlatformMediaSession::WebAudio, ConcurrentPlaybackNotPermitted);
-    removeRestriction(PlatformMediaSession::WebAudio, BackgroundProcessPlaybackRestricted);
+    addRestriction(PlatformMediaSession::VideoAudio, ConcurrentPlaybackNotPermitted | BackgroundProcessPlaybackRestricted | SuspendedUnderLockPlaybackRestricted);
 }
 
 bool MediaSessionManageriOS::hasWirelessTargetsAvailable()
@@ -292,40 +283,6 @@
     });
 }
 
-void MediaSessionManageriOS::applicationDidEnterBackground(bool isSuspendedUnderLock)
-{
-    LOG(Media, "MediaSessionManageriOS::applicationDidEnterBackground");
-
-    if (m_isInBackground)
-        return;
-    m_isInBackground = true;
-
-    if (!isSuspendedUnderLock)
-        return;
-
-    forEachSession([this] (PlatformMediaSession& session, size_t) {
-        if (restrictions(session.mediaType()) & BackgroundProcessPlaybackRestricted)
-            session.beginInterruption(PlatformMediaSession::SuspendedUnderLock);
-    });
-}
-
-void MediaSessionManageriOS::applicationWillEnterForeground(bool isSuspendedUnderLock)
-{
-    LOG(Media, "MediaSessionManageriOS::applicationWillEnterForeground");
-
-    if (!m_isInBackground)
-        return;
-    m_isInBackground = false;
-
-    if (!isSuspendedUnderLock)
-        return;
-
-    forEachSession([this] (PlatformMediaSession& session, size_t) {
-        if (restrictions(session.mediaType()) & BackgroundProcessPlaybackRestricted)
-            session.endInterruption(PlatformMediaSession::MayResumePlaying);
-    });
-}
-
 } // namespace WebCore
 
 @implementation WebMediaSessionHelper
@@ -513,7 +470,7 @@
         if (!_callback)
             return;
 
-        _callback->applicationDidEnterForeground();
+        _callback->applicationDidBecomeActive();
     });
 }
 
@@ -530,7 +487,7 @@
         if (!_callback)
             return;
 
-        _callback->applicationWillEnterBackground();
+        _callback->applicationWillBecomeInactive();
     });
 }
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (218416 => 218417)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-06-16 21:59:23 UTC (rev 218417)
@@ -3237,16 +3237,26 @@
     PlatformMediaSessionManager::sharedManager().endInterruption(flags);
 }
 
-void Internals::applicationDidEnterForeground() const
+void Internals::applicationWillBecomeInactive()
 {
-    PlatformMediaSessionManager::sharedManager().applicationDidEnterForeground();
+    PlatformMediaSessionManager::sharedManager().applicationWillBecomeInactive();
 }
 
-void Internals::applicationWillEnterBackground() const
+void Internals::applicationDidBecomeActive()
 {
-    PlatformMediaSessionManager::sharedManager().applicationWillEnterBackground();
+    PlatformMediaSessionManager::sharedManager().applicationDidBecomeActive();
 }
 
+void Internals::applicationWillEnterForeground(bool suspendedUnderLock) const
+{
+    PlatformMediaSessionManager::sharedManager().applicationWillEnterForeground(suspendedUnderLock);
+}
+
+void Internals::applicationDidEnterBackground(bool suspendedUnderLock) const
+{
+    PlatformMediaSessionManager::sharedManager().applicationDidEnterBackground(suspendedUnderLock);
+}
+
 static PlatformMediaSession::MediaType mediaTypeFromString(const String& mediaTypeString)
 {
     if (equalLettersIgnoringASCIICase(mediaTypeString, "video"))
@@ -3283,6 +3293,10 @@
             restrictions |= PlatformMediaSessionManager::BackgroundTabPlaybackRestricted;
         if (equalLettersIgnoringASCIICase(restrictionString, "interruptedplaybacknotpermitted"))
             restrictions |= PlatformMediaSessionManager::InterruptedPlaybackNotPermitted;
+        if (equalLettersIgnoringASCIICase(restrictionString, "inactiveprocessplaybackrestricted"))
+            restrictions |= PlatformMediaSessionManager::InactiveProcessPlaybackRestricted;
+        if (equalLettersIgnoringASCIICase(restrictionString, "suspendedunderlockplaybackrestricted"))
+            restrictions |= PlatformMediaSessionManager::SuspendedUnderLockPlaybackRestricted;
     }
     PlatformMediaSessionManager::sharedManager().addRestriction(mediaType, restrictions);
     return { };

Modified: trunk/Source/WebCore/testing/Internals.h (218416 => 218417)


--- trunk/Source/WebCore/testing/Internals.h	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/testing/Internals.h	2017-06-16 21:59:23 UTC (rev 218417)
@@ -473,8 +473,10 @@
 #if ENABLE(VIDEO)
     ExceptionOr<void> beginMediaSessionInterruption(const String&);
     void endMediaSessionInterruption(const String&);
-    void applicationDidEnterForeground() const;
-    void applicationWillEnterBackground() const;
+    void applicationWillBecomeInactive();
+    void applicationDidBecomeActive();
+    void applicationWillEnterForeground(bool suspendedUnderLock) const;
+    void applicationDidEnterBackground(bool suspendedUnderLock) const;
     ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString);
     ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const;
     void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString);

Modified: trunk/Source/WebCore/testing/Internals.idl (218416 => 218417)


--- trunk/Source/WebCore/testing/Internals.idl	2017-06-16 21:43:00 UTC (rev 218416)
+++ trunk/Source/WebCore/testing/Internals.idl	2017-06-16 21:59:23 UTC (rev 218417)
@@ -446,8 +446,10 @@
     [Conditional=MEDIA_SESSION] DOMString mediaSessionCurrentState(MediaSession session);
     [Conditional=MEDIA_SESSION] double mediaElementPlayerVolume(HTMLMediaElement element);
     [Conditional=MEDIA_SESSION] void sendMediaControlEvent(MediaControlEvent event);
-    [Conditional=VIDEO] void applicationDidEnterForeground();
-    [Conditional=VIDEO] void applicationWillEnterBackground();
+    [Conditional=VIDEO] void applicationWillBecomeInactive();
+    [Conditional=VIDEO] void applicationDidBecomeActive();
+    [Conditional=VIDEO] void applicationWillEnterForeground(optional boolean suspendedUnderLock = false);
+    [Conditional=VIDEO] void applicationDidEnterBackground(optional boolean suspendedUnderLock = false);
     [Conditional=VIDEO, MayThrowException] void setMediaSessionRestrictions(DOMString mediaType, DOMString restrictions);
     [Conditional=VIDEO, MayThrowException] DOMString mediaSessionRestrictions(DOMString mediaType);
     [Conditional=VIDEO] void setMediaElementRestrictions(HTMLMediaElement element, DOMString restrictions);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to