Changeset 190434 in webkit
- Timestamp:
- Oct 1, 2015 3:32:56 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r190430 r190434 1 2015-10-01 Eric Carlson <eric.carlson@apple.com> 2 3 [iOS] AirPlay should not stop when the screen locks 4 https://bugs.webkit.org/show_bug.cgi?id=148315 5 <rdar://problem/22770703> 6 7 Reviewed by Jer Noble. 8 9 * media/video-interruption-with-resume-allowing-play.html: 10 * media/video-interruption-with-resume-not-allowing-play.html: 11 1 12 2015-10-01 Ryosuke Niwa <rniwa@webkit.org> 2 13 -
trunk/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt
r179869 r190434 7 7 EVENT(playing) 8 8 EXPECTED (video.paused == 'false') OK 9 RUN(internals.beginMediaSessionInterruption( ))9 RUN(internals.beginMediaSessionInterruption('System')) 10 10 11 11 100ms timer fired... … … 17 17 18 18 EXPECTED (video.paused == 'false') OK 19 RUN(internals.beginMediaSessionInterruption( ))19 RUN(internals.beginMediaSessionInterruption('System')) 20 20 21 21 100ms timer fired... -
trunk/LayoutTests/media/video-interruption-with-resume-allowing-play.html
r179869 r190434 13 13 testExpected("video.paused", false); 14 14 state = "interrupted"; 15 run("internals.beginMediaSessionInterruption( )");;15 run("internals.beginMediaSessionInterruption('System')");; 16 16 setTimeout(checkState, 100); 17 17 consoleWrite(""); -
trunk/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt
r163390 r190434 6 6 7 7 EVENT(playing) 8 RUN(internals.beginMediaSessionInterruption( ))8 RUN(internals.beginMediaSessionInterruption('System')) 9 9 10 10 100ms timer fired... -
trunk/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html
r163390 r190434 8 8 function playing() 9 9 { 10 run("internals.beginMediaSessionInterruption( )");;10 run("internals.beginMediaSessionInterruption('System')");; 11 11 setTimeout(checkState, 100); 12 12 } -
trunk/Source/WebCore/ChangeLog
r190430 r190434 1 2015-10-01 Eric Carlson <eric.carlson@apple.com> 2 3 [iOS] AirPlay should not stop when the screen locks 4 https://bugs.webkit.org/show_bug.cgi?id=148315 5 <rdar://problem/22770703> 6 7 Reviewed by Jer Noble. 8 9 Tested by media/video-interruption-with-resume-allowing-play.html 10 media/video-interruption-with-resume-not-allowing-play.html 11 12 * Modules/webaudio/AudioContext.h: overrideBackgroundPlaybackRestriction -> 13 shouldOverrideBackgroundPlaybackRestriction. 14 15 * html/HTMLMediaElement.cpp: 16 (WebCore::HTMLMediaElement::suspendPlayback): Fix a typo in the logging. 17 (WebCore::HTMLMediaElement::mayResumePlayback): Ditto. 18 (WebCore::HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction): Renamed from 19 overrideBackgroundPlaybackRestriction. 20 (WebCore::HTMLMediaElement::overrideBackgroundPlaybackRestriction): Deleted. 21 * html/HTMLMediaElement.h: 22 23 * platform/audio/PlatformMediaSession.cpp: 24 (WebCore::stateName): 25 (WebCore::interruptionName): New, log the name of the interruption. 26 (WebCore::PlatformMediaSession::beginInterruption): Log the interruption type. Don't 27 increment the interruption counter if we are going to ignore it. Incorporate logic 28 from doInterruption. 29 (WebCore::PlatformMediaSession::doInterruption): Deleted. 30 (WebCore::PlatformMediaSession::shouldDoInterruption): Deleted. 31 (WebCore::PlatformMediaSession::forceInterruption): Deleted. 32 33 * platform/audio/PlatformMediaSession.h: Add SuspendedUnderLock interruption type. 34 * platform/audio/PlatformMediaSessionManager.cpp: 35 (WebCore::PlatformMediaSessionManager::applicationDidEnterBackground): Deleted. 36 * platform/audio/PlatformMediaSessionManager.h: 37 38 * platform/audio/ios/MediaSessionManagerIOS.h: 39 * platform/audio/ios/MediaSessionManagerIOS.mm: 40 (WebCore::MediaSessionManageriOS::applicationDidEnterBackground): Call beginInterruption 41 when appropriate. 42 1 43 2015-10-01 Ryosuke Niwa <rniwa@webkit.org> 2 44 -
trunk/Source/WebCore/Modules/webaudio/AudioContext.h
r188594 r190434 323 323 virtual bool canReceiveRemoteControlCommands() const override { return false; } 324 324 virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override { } 325 virtual bool overrideBackgroundPlaybackRestriction() const override { return false; }325 bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override { return false; } 326 326 327 327 // EventTarget -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r190020 r190434 6376 6376 void HTMLMediaElement::suspendPlayback() 6377 6377 { 6378 LOG(Media, "HTMLMediaElement:: pausePlayback(%p) - paused = %s", this, boolString(paused()));6378 LOG(Media, "HTMLMediaElement::suspendPlayback(%p) - paused = %s", this, boolString(paused())); 6379 6379 if (!paused()) 6380 6380 pause(); … … 6383 6383 void HTMLMediaElement::mayResumePlayback(bool shouldResume) 6384 6384 { 6385 LOG(Media, "HTMLMediaElement:: resumePlayback(%p) - paused = %s", this, boolString(paused()));6385 LOG(Media, "HTMLMediaElement::mayResumePlayback(%p) - paused = %s", this, boolString(paused())); 6386 6386 if (paused() && shouldResume) 6387 6387 play(); … … 6425 6425 } 6426 6426 6427 bool HTMLMediaElement::overrideBackgroundPlaybackRestriction() const 6428 { 6427 bool HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType type) const 6428 { 6429 if (type != PlatformMediaSession::EnteringBackground) 6430 return false; 6431 6429 6432 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 6430 6433 if (m_player && m_player->isCurrentPlaybackTargetWireless()) -
trunk/Source/WebCore/html/HTMLMediaElement.h
r189841 r190434 736 736 virtual bool canReceiveRemoteControlCommands() const override { return true; } 737 737 virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override; 738 virtual bool overrideBackgroundPlaybackRestriction() const override;738 bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override; 739 739 740 740 virtual void pageMutedStateDidChange() override; -
trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp
r189322 r190434 40 40 static const char* stateName(PlatformMediaSession::State state) 41 41 { 42 #define CASE(state) case PlatformMediaSession::state: return #state42 #define STATE_CASE(state) case PlatformMediaSession::state: return #state 43 43 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 54 static 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 50 64 ASSERT_NOT_REACHED(); 51 65 return ""; … … 80 94 } 81 95 82 void PlatformMediaSession::doInterruption() 83 { 96 void 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 84 106 m_stateToRestore = state(); 85 107 m_notifyingClient = true; … … 87 109 client().suspendPlayback(); 88 110 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 by117 // 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();123 111 } 124 112 -
trunk/Source/WebCore/platform/audio/PlatformMediaSession.h
r189322 r190434 75 75 EnteringBackground, 76 76 SystemInterruption, 77 SuspendedUnderLock, 77 78 }; 78 79 enum EndInterruptionFlags { … … 81 82 }; 82 83 83 void doInterruption();84 bool shouldDoInterruption(InterruptionType);85 84 void beginInterruption(InterruptionType); 86 void forceInterruption(InterruptionType);87 85 void endInterruption(EndInterruptionFlags); 88 86 … … 180 178 virtual bool elementIsHidden() const { return false; } 181 179 182 virtual bool overrideBackgroundPlaybackRestriction() const = 0;180 virtual bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const = 0; 183 181 184 182 virtual void wirelessRoutesAvailableDidChange() { } -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
r189322 r190434 289 289 } 290 290 291 void PlatformMediaSessionManager::applicationDidEnterBackground(bool isSuspendedUnderLock) const292 {293 LOG(Media, "PlatformMediaSessionManager::applicationDidEnterBackground");294 295 if (!isSuspendedUnderLock)296 return;297 298 Vector<PlatformMediaSession*> sessions = m_sessions;299 for (auto* session : sessions) {300 if (m_restrictions[session->mediaType()] & BackgroundProcessPlaybackRestricted)301 session->forceInterruption(PlatformMediaSession::EnteringBackground);302 }303 }304 305 291 void PlatformMediaSessionManager::applicationWillEnterForeground() const 306 292 { … … 324 310 return; 325 311 326 if (session.state() != PlatformMediaSession::Interrupted && session.shouldDoInterruption(PlatformMediaSession::EnteringBackground))327 session. doInterruption();312 if (session.state() != PlatformMediaSession::Interrupted) 313 session.beginInterruption(PlatformMediaSession::EnteringBackground); 328 314 } 329 315 -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h
r189369 r190434 61 61 WEBCORE_EXPORT void applicationWillEnterForeground() const; 62 62 WEBCORE_EXPORT void applicationWillEnterBackground() const; 63 WEBCORE_EXPORT void applicationDidEnterBackground(bool isSuspendedUnderLock) const;64 63 65 64 void stopAllMediaPlaybackForDocument(const Document*); -
trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h
r187522 r190434 49 49 void externalOutputDeviceAvailableDidChange(); 50 50 virtual bool hasWirelessTargetsAvailable() override; 51 void applicationDidEnterBackground(bool isSuspendedUnderLock); 51 52 52 53 private: -
trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm
r189369 r190434 249 249 } 250 250 251 void 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 251 266 } // namespace WebCore 252 267 -
trunk/Source/WebCore/testing/Internals.cpp
r190363 r190434 2703 2703 2704 2704 #if ENABLE(VIDEO) 2705 void Internals::beginMediaSessionInterruption() 2706 { 2705 void Internals::beginMediaSessionInterruption(const String& interruptionString, ExceptionCode& ec) 2706 { 2707 PlatformMediaSession::InterruptionType interruption = PlatformMediaSession::SystemInterruption; 2708 2709 if (equalIgnoringCase(interruptionString, "System")) 2710 interruption = PlatformMediaSession::SystemInterruption; 2711 else if (equalIgnoringCase(interruptionString, "SystemSleep")) 2712 interruption = PlatformMediaSession::SystemSleep; 2713 else if (equalIgnoringCase(interruptionString, "EnteringBackground")) 2714 interruption = PlatformMediaSession::EnteringBackground; 2715 else { 2716 ec = INVALID_ACCESS_ERR; 2717 return; 2718 } 2719 2707 2720 PlatformMediaSessionManager::sharedManager().beginInterruption(PlatformMediaSession::SystemInterruption); 2708 2721 } -
trunk/Source/WebCore/testing/Internals.h
r190363 r190434 387 387 388 388 #if ENABLE(VIDEO) 389 void beginMediaSessionInterruption( );389 void beginMediaSessionInterruption(const String&, ExceptionCode&); 390 390 void endMediaSessionInterruption(const String&); 391 391 void applicationWillEnterForeground() const; -
trunk/Source/WebCore/testing/Internals.idl
r190363 r190434 366 366 [Conditional=MEDIA_SOURCE] void setShouldGenerateTimestamps(SourceBuffer buffer, boolean flag); 367 367 368 [Conditional=VIDEO ] void beginMediaSessionInterruption();368 [Conditional=VIDEO, RaisesException] void beginMediaSessionInterruption(DOMString interruptionType); 369 369 [Conditional=VIDEO] void endMediaSessionInterruption(DOMString flags); 370 370 [Conditional=MEDIA_SESSION] void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory category);
Note: See TracChangeset
for help on using the changeset viewer.