haikuwebkit/LayoutTests/webrtc/concurrentVideoPlayback.html

61 lines
2.1 KiB
HTML
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/212256@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245712 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-23 20:56:56 +00:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing concurrent video playing</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../media/media-file.js"></script>
</head>
<body>
<video id="video1" autoplay controls></video>
<video id="video2" autoplay controls></video>
<video id="video3" autoplay controls></video>
<script src ="routines.js"></script>
<script>
promise_test(async (test) => {
if (window.testRunner)
testRunner.setUserMediaPermission(true);
localStream = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
const remoteStream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
firstConnection.addTrack(localStream.getAudioTracks()[0], localStream);
}, (secondConnection) => {
secondConnection.ontrack = (trackEvent) => {
resolve(trackEvent.streams[0]);
};
});
setTimeout(() => reject("Test timed out"), 5000);
});
video1.srcObject = localStream;
video2.srcObject = remoteStream;
}, "Basic audio/video exchange");
promise_test(async (test) => {
await video1.play();
await video2.play();
assert_false(video1.paused, "video1 paused");
assert_false(video2.paused, "video2 paused");
}, "Play MediaStream backed streams concurrently");
promise_test(async (test) => {
if (window.internals)
internals.setMediaSessionRestrictions('videoaudio', 'ConcurrentPlaybackNotPermitted');
video3.src = findMediaFile('video', '../media/content/audio-tracks');
await video3.play();
assert_false(video1.paused, "video1 paused");
assert_false(video2.paused, "video2 paused");
assert_false(video3.paused, "video3 paused");
}, "Play regular video content should not pause MediaStream backed video elements");
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. Canonical link: https://commits.webkit.org/212256@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245712 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-23 20:56:56 +00:00
</script>
</body>
</html>