Multiple videos (with audios) with autoplay & playinline not working. Only one video...
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 20:56:56 +0000 (20:56 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 20:56:56 +0000 (20:56 +0000)
commitcf80258878f78ebbba7075bffd2cd180377edf87
treeb2bcd81baf494cb70bc7c2ba53a00a92acd62af2
parent1943f33b723fe3281220351f3514f1e1ea9acdc1
Multiple videos (with audios) with autoplay & playinline not working. Only one video play at a time.
https://bugs.webkit.org/show_bug.cgi?id=193312
<rdar://problem/47189864>

Reviewed by Jer Noble.

Source/WebCore:

Allow all MediaStream backed video elements to play together.
Any non MediaStream backed video will stop all MediaStream backed video elements.
Conversely, all non MediaStream backed videos will stop when playing one MediaStream backed video.

Refactor PlatformMediaSessionManager as the way to iterate through sessions
is not safe when pausing a session: if playing, the session will be moved in the array of sessions.

To handle this, copy the list of sessions before iterating through them.
For extra safety, make sessions WeakPtr.

Add routines for the case of filtering with a predicate taking a const session.
In that case, we do not copy the vector but iterate through it as a small optimization.

Test: webrtc/concurrentVideoPlayback.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::bestMediaElementForShowingPlaybackControlsManager):
(WebCore::HTMLMediaElement::hasMediaStreamSource const):
* html/HTMLMediaElement.h:
* platform/audio/PlatformMediaSession.cpp:
(WebCore::PlatformMediaSession::activeAudioSessionRequired const):
(WebCore::PlatformMediaSession::canPlayConcurrently const):
(WebCore::PlatformMediaSession::activeAudioSessionRequired): Deleted.
* platform/audio/PlatformMediaSession.h:
(WebCore::PlatformMediaSessionClient::hasMediaStreamSource const):
* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::has const):
(WebCore::PlatformMediaSessionManager::activeAudioSessionRequired const):
(WebCore::PlatformMediaSessionManager::canProduceAudio const):
(WebCore::PlatformMediaSessionManager::count const):
(WebCore::PlatformMediaSessionManager::beginInterruption):
(WebCore::PlatformMediaSessionManager::endInterruption):
(WebCore::PlatformMediaSessionManager::addSession):
(WebCore::PlatformMediaSessionManager::removeSession):
(WebCore::PlatformMediaSessionManager::sessionWillBeginPlayback):
(WebCore::PlatformMediaSessionManager::sessionWillEndPlayback):
(WebCore::PlatformMediaSessionManager::setCurrentSession):
(WebCore::PlatformMediaSessionManager::currentSession const):
(WebCore::PlatformMediaSessionManager::applicationWillBecomeInactive):
(WebCore::PlatformMediaSessionManager::applicationDidBecomeActive):
(WebCore::PlatformMediaSessionManager::applicationDidEnterBackground):
(WebCore::PlatformMediaSessionManager::applicationWillEnterForeground):
(WebCore::PlatformMediaSessionManager::systemWillSleep):
(WebCore::PlatformMediaSessionManager::systemDidWake):
(WebCore::PlatformMediaSessionManager::stopAllMediaPlaybackForDocument):
(WebCore::PlatformMediaSessionManager::stopAllMediaPlaybackForProcess):
(WebCore::PlatformMediaSessionManager::suspendAllMediaPlaybackForDocument):
(WebCore::PlatformMediaSessionManager::resumeAllMediaPlaybackForDocument):
(WebCore::PlatformMediaSessionManager::suspendAllMediaBufferingForDocument):
(WebCore::PlatformMediaSessionManager::resumeAllMediaBufferingForDocument):
(WebCore::PlatformMediaSessionManager::currentSessionsMatching const):
(WebCore::PlatformMediaSessionManager::forEachMatchingSession):
(WebCore::PlatformMediaSessionManager::forEachMatchingSession const):
(WebCore::PlatformMediaSessionManager::forEachSession):
(WebCore::PlatformMediaSessionManager::anyOfSessions const):
(): Deleted.
(WebCore::PlatformMediaSessionManager::applicationWillBecomeInactive const): Deleted.
(WebCore::PlatformMediaSessionManager::applicationDidBecomeActive const): Deleted.
(WebCore::PlatformMediaSessionManager::applicationDidEnterBackground const): Deleted.
(WebCore::PlatformMediaSessionManager::applicationWillEnterForeground const): Deleted.
(WebCore::PlatformMediaSessionManager::forEachSession const): Deleted.
(WebCore::PlatformMediaSessionManager::findSession const): Deleted.
* platform/audio/PlatformMediaSessionManager.h:
(WebCore::PlatformMediaSessionManager::anyOfSessions const): Deleted.
* platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(MediaSessionManagerCocoa::updateSessionState):
(MediaSessionManagerCocoa::beginInterruption):
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring):
(WebCore::MediaSessionManageriOS::externalOutputDeviceAvailableDidChange):

LayoutTests:

* webrtc/concurrentVideoPlayback-expected.txt: Added.
* webrtc/concurrentVideoPlayback.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245712 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/webrtc/concurrentVideoPlayback-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/concurrentVideoPlayback.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/audio/PlatformMediaSession.cpp
Source/WebCore/platform/audio/PlatformMediaSession.h
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
Source/WebCore/platform/audio/PlatformMediaSessionManager.h
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm