[iOS] AirPlay should not stop when the screen locks
https://bugs.webkit.org/show_bug.cgi?id=148315
<rdar://problem/22770703>

Patch by Eric Carlson <eric.carlson@apple.com> on 2015-10-01
Reviewed by Jer Noble.

Source/WebCore:

Tested by media/video-interruption-with-resume-allowing-play.html
          media/video-interruption-with-resume-not-allowing-play.html

* Modules/webaudio/AudioContext.h: overrideBackgroundPlaybackRestriction -> 
  shouldOverrideBackgroundPlaybackRestriction.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::suspendPlayback): Fix a typo in the logging.
(WebCore::HTMLMediaElement::mayResumePlayback): Ditto.
(WebCore::HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction): Renamed from
  overrideBackgroundPlaybackRestriction.
(WebCore::HTMLMediaElement::overrideBackgroundPlaybackRestriction): Deleted.
* html/HTMLMediaElement.h:

* platform/audio/PlatformMediaSession.cpp:
(WebCore::stateName):
(WebCore::interruptionName): New, log the name of the interruption.
(WebCore::PlatformMediaSession::beginInterruption): Log the interruption type. Don't
  increment the interruption counter if we are going to ignore it. Incorporate logic
  from doInterruption.
(WebCore::PlatformMediaSession::doInterruption): Deleted.
(WebCore::PlatformMediaSession::shouldDoInterruption): Deleted.
(WebCore::PlatformMediaSession::forceInterruption): Deleted.

* platform/audio/PlatformMediaSession.h: Add SuspendedUnderLock interruption type.
* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::applicationDidEnterBackground): Deleted.
* platform/audio/PlatformMediaSessionManager.h:

* platform/audio/ios/MediaSessionManagerIOS.h:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::applicationDidEnterBackground): Call beginInterruption
  when appropriate.

LayoutTests:

* media/video-interruption-with-resume-allowing-play.html:
* media/video-interruption-with-resume-not-allowing-play.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@190434 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index d3a9816..93ca66c 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2015-10-01  Eric Carlson  <eric.carlson@apple.com>
+
+        [iOS] AirPlay should not stop when the screen locks
+        https://bugs.webkit.org/show_bug.cgi?id=148315
+        <rdar://problem/22770703>
+
+        Reviewed by Jer Noble.
+
+        * media/video-interruption-with-resume-allowing-play.html:
+        * media/video-interruption-with-resume-not-allowing-play.html:
+
 2015-10-01  Ryosuke Niwa  <rniwa@webkit.org>
 
         Slot elements should support fallback contents
diff --git a/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt b/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt
index 9518a46..a31d173 100644
--- a/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt
+++ b/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt
@@ -6,7 +6,7 @@
 
 EVENT(playing)
 EXPECTED (video.paused == 'false') OK
-RUN(internals.beginMediaSessionInterruption())
+RUN(internals.beginMediaSessionInterruption('System'))
 
 100ms timer fired...
 EXPECTED (video.paused == 'true') OK
@@ -16,7 +16,7 @@
 EXPECTED (video.paused == 'false') OK
 
 EXPECTED (video.paused == 'false') OK
-RUN(internals.beginMediaSessionInterruption())
+RUN(internals.beginMediaSessionInterruption('System'))
 
 100ms timer fired...
 EXPECTED (video.paused == 'true') OK
diff --git a/LayoutTests/media/video-interruption-with-resume-allowing-play.html b/LayoutTests/media/video-interruption-with-resume-allowing-play.html
index 6b53702..c5cb4dc 100644
--- a/LayoutTests/media/video-interruption-with-resume-allowing-play.html
+++ b/LayoutTests/media/video-interruption-with-resume-allowing-play.html
@@ -12,7 +12,7 @@
                 case "playing":
                     testExpected("video.paused", false);
                     state = "interrupted";
-                    run("internals.beginMediaSessionInterruption()");;
+                    run("internals.beginMediaSessionInterruption('System')");;
                     setTimeout(checkState, 100);
                     consoleWrite("");
                     break;
diff --git a/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt b/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt
index f927697..c9dd8cd 100644
--- a/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt
+++ b/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt
@@ -5,7 +5,7 @@
 RUN(video.play())
 
 EVENT(playing)
-RUN(internals.beginMediaSessionInterruption())
+RUN(internals.beginMediaSessionInterruption('System'))
 
 100ms timer fired...
 EXPECTED (video.paused == 'true') OK
diff --git a/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html b/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html
index a250bee..d64e5ae 100644
--- a/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html
+++ b/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html
@@ -7,7 +7,7 @@
 
             function playing()
             {
-                run("internals.beginMediaSessionInterruption()");;
+                run("internals.beginMediaSessionInterruption('System')");;
                 setTimeout(checkState, 100);
             }