haikuwebkit/LayoutTests/media/media-session/mock-coordinator.html

243 lines
9.2 KiB
HTML
Raw Permalink Normal View History

[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
<!-- webkit-test-runner [ MediaSessionCoordinatorEnabled=true ] -->
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
<!DOCTYPE html>
<html>
<head>
<title>mock-mediasession-coordinator</title>
<script src="../video-test.js"></script>
<script>
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
let waiting = false;
async function waitForDebugger()
{
let counter = 0;
while (waiting) {
await sleepFor(100);
counter++;
}
}
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
function changeHandler(change)
{
window.latestChange = change;
}
window.addEventListener('load', async event => {
window.latestAction = '';
window.latestChange = '';
if (!window.internals) {
failTest('This test requires Internals');
return;
}
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
let changePromise = () => {
return new Promise(resolve => {
LayoutTests/imported/w3c: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * web-platform-tests/mediasession/idlharness.window-expected.txt: Source/WebCore: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. The coordinator was a read-only optional attribute of the MediaSession element. Testing if the attribute was to be used to determine if a MediaSessionCoordinator was now available and for the MediaSession to join it. This made the use of an external polyfill difficult and enforcing the validity of an user created custom MediaSessionCoordinator due to IDL semantics limitations hard. We instead always create a MediaSessionCoordinator which in its default state is Closed. Once this state is changed to Waiting and an event is fire the MediaSession can now join it. * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event. Remove no longer necessary inheritance and async event queue. (WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor. (WebCore::MediaSession::createCoordinator): Make method private. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead. * Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate): (WebCore::MediaSessionCoordinator::virtualHasPendingActivity const): (WebCore::MediaSessionCoordinator::join): (WebCore::MediaSessionCoordinator::close): (WebCore::MediaSessionCoordinator::coordinatorStateChanged): * Modules/mediasession/MediaSessionCoordinator.h: * Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute. * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition. * dom/EventNames.h: * dom/EventTargetFactory.in: * page/Page.cpp: (WebCore::Page::setMediaSessionCoordinator): (WebCore::Page::invalidateMediaSessionCoordinator): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Tools: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm: (TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API, using coordinatorstatechange event instead. * TestWebKitAPI/Tests/WebKitCocoa/media-remote.html: LayoutTests: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: Change test to match new API. Canonical link: https://commits.webkit.org/238369@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
navigator.mediaSession.coordinator.addEventListener('coordinatorstatechange', (event) => {
consoleWrite(`EVENT(${event.type} STATE(${navigator.mediaSession.coordinator.state})`);
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
resolve();
LayoutTests/imported/w3c: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * web-platform-tests/mediasession/idlharness.window-expected.txt: Source/WebCore: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. The coordinator was a read-only optional attribute of the MediaSession element. Testing if the attribute was to be used to determine if a MediaSessionCoordinator was now available and for the MediaSession to join it. This made the use of an external polyfill difficult and enforcing the validity of an user created custom MediaSessionCoordinator due to IDL semantics limitations hard. We instead always create a MediaSessionCoordinator which in its default state is Closed. Once this state is changed to Waiting and an event is fire the MediaSession can now join it. * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event. Remove no longer necessary inheritance and async event queue. (WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor. (WebCore::MediaSession::createCoordinator): Make method private. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead. * Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate): (WebCore::MediaSessionCoordinator::virtualHasPendingActivity const): (WebCore::MediaSessionCoordinator::join): (WebCore::MediaSessionCoordinator::close): (WebCore::MediaSessionCoordinator::coordinatorStateChanged): * Modules/mediasession/MediaSessionCoordinator.h: * Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute. * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition. * dom/EventNames.h: * dom/EventTargetFactory.in: * page/Page.cpp: (WebCore::Page::setMediaSessionCoordinator): (WebCore::Page::invalidateMediaSessionCoordinator): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Tools: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm: (TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API, using coordinatorstatechange event instead. * TestWebKitAPI/Tests/WebKitCocoa/media-remote.html: LayoutTests: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: Change test to match new API. Canonical link: https://commits.webkit.org/238369@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
}, { once: true });
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
});
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
}
await waitForDebugger();
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
consoleWrite('');
LayoutTests/imported/w3c: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * web-platform-tests/mediasession/idlharness.window-expected.txt: Source/WebCore: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. The coordinator was a read-only optional attribute of the MediaSession element. Testing if the attribute was to be used to determine if a MediaSessionCoordinator was now available and for the MediaSession to join it. This made the use of an external polyfill difficult and enforcing the validity of an user created custom MediaSessionCoordinator due to IDL semantics limitations hard. We instead always create a MediaSessionCoordinator which in its default state is Closed. Once this state is changed to Waiting and an event is fire the MediaSession can now join it. * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event. Remove no longer necessary inheritance and async event queue. (WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor. (WebCore::MediaSession::createCoordinator): Make method private. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead. * Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate): (WebCore::MediaSessionCoordinator::virtualHasPendingActivity const): (WebCore::MediaSessionCoordinator::join): (WebCore::MediaSessionCoordinator::close): (WebCore::MediaSessionCoordinator::coordinatorStateChanged): * Modules/mediasession/MediaSessionCoordinator.h: * Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute. * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition. * dom/EventNames.h: * dom/EventTargetFactory.in: * page/Page.cpp: (WebCore::Page::setMediaSessionCoordinator): (WebCore::Page::invalidateMediaSessionCoordinator): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Tools: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm: (TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API, using coordinatorstatechange event instead. * TestWebKitAPI/Tests/WebKitCocoa/media-remote.html: LayoutTests: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: Change test to match new API. Canonical link: https://commits.webkit.org/238369@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
consoleWrite('** There mediaSession.coordinator.state should be closed initially.');
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
LayoutTests/imported/w3c: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * web-platform-tests/mediasession/idlharness.window-expected.txt: Source/WebCore: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. The coordinator was a read-only optional attribute of the MediaSession element. Testing if the attribute was to be used to determine if a MediaSessionCoordinator was now available and for the MediaSession to join it. This made the use of an external polyfill difficult and enforcing the validity of an user created custom MediaSessionCoordinator due to IDL semantics limitations hard. We instead always create a MediaSessionCoordinator which in its default state is Closed. Once this state is changed to Waiting and an event is fire the MediaSession can now join it. * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event. Remove no longer necessary inheritance and async event queue. (WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor. (WebCore::MediaSession::createCoordinator): Make method private. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead. * Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate): (WebCore::MediaSessionCoordinator::virtualHasPendingActivity const): (WebCore::MediaSessionCoordinator::join): (WebCore::MediaSessionCoordinator::close): (WebCore::MediaSessionCoordinator::coordinatorStateChanged): * Modules/mediasession/MediaSessionCoordinator.h: * Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute. * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition. * dom/EventNames.h: * dom/EventTargetFactory.in: * page/Page.cpp: (WebCore::Page::setMediaSessionCoordinator): (WebCore::Page::invalidateMediaSessionCoordinator): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Tools: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm: (TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API, using coordinatorstatechange event instead. * TestWebKitAPI/Tests/WebKitCocoa/media-remote.html: LayoutTests: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: Change test to match new API. Canonical link: https://commits.webkit.org/238369@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
testExpected('navigator.mediaSession.coordinator.state', "closed");
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
consoleWrite('');
LayoutTests/imported/w3c: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * web-platform-tests/mediasession/idlharness.window-expected.txt: Source/WebCore: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. The coordinator was a read-only optional attribute of the MediaSession element. Testing if the attribute was to be used to determine if a MediaSessionCoordinator was now available and for the MediaSession to join it. This made the use of an external polyfill difficult and enforcing the validity of an user created custom MediaSessionCoordinator due to IDL semantics limitations hard. We instead always create a MediaSessionCoordinator which in its default state is Closed. Once this state is changed to Waiting and an event is fire the MediaSession can now join it. * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event. Remove no longer necessary inheritance and async event queue. (WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor. (WebCore::MediaSession::createCoordinator): Make method private. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead. * Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate): (WebCore::MediaSessionCoordinator::virtualHasPendingActivity const): (WebCore::MediaSessionCoordinator::join): (WebCore::MediaSessionCoordinator::close): (WebCore::MediaSessionCoordinator::coordinatorStateChanged): * Modules/mediasession/MediaSessionCoordinator.h: * Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute. * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition. * dom/EventNames.h: * dom/EventTargetFactory.in: * page/Page.cpp: (WebCore::Page::setMediaSessionCoordinator): (WebCore::Page::invalidateMediaSessionCoordinator): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Tools: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm: (TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API, using coordinatorstatechange event instead. * TestWebKitAPI/Tests/WebKitCocoa/media-remote.html: LayoutTests: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: Change test to match new API. Canonical link: https://commits.webkit.org/238369@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
consoleWrite('** Test that mediaSession.coordinator.coordinatorstatechange event is fired when it changes.');
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
run('internals.registerMockMediaSessionCoordinator(changeHandler)');
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
await changePromise();
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
['play', 'pause', 'seekto'].forEach(action => {
navigator.mediaSession.setActionHandler(action, actionDetails => {
consoleWrite(`ACTION(${actionDetails.action})`);
latestAction = actionDetails.action;
});
});
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
let testAction = async (action, func, expectFailure) => {
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
latestAction = '';
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
run(`promise = ${func.toString()}`);
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
try {
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
if (expectFailure)
await shouldReject(promise);
else
await shouldResolve(promise);
} catch(ex) {}
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
consoleWrite('');
};
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
let testReadyStates = async (testCallback) => {
let previousState = 'havenothing';
navigator.mediaSession.readyState = 'havenothing';
for (let state of ['havemetadata', 'havecurrentdata', 'havefuturedata', 'haveenoughdata', 'havenothing']) {
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
testExpected('navigator.mediaSession.readyState', previousState);
latestChange = '';
run(`navigator.mediaSession.readyState = '${state}'`);
await testCallback()
testExpected('navigator.mediaSession.readyState', state);
previousState = state;
consoleWrite('');
};
}
let testPlaybackStates = async (testCallback) => {
let previousState = 'none';
navigator.mediaSession.playbackState = 'none';
for (let state of ['paused', 'playing', 'none']) {
testExpected('navigator.mediaSession.playbackState', previousState);
latestChange = '';
run(`navigator.mediaSession.playbackState = '${state}'`);
await testCallback()
testExpected('navigator.mediaSession.playbackState', state);
previousState = state;
consoleWrite('');
};
}
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
let actions = [
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
{ action: 'play', func : 'navigator.mediaSession.coordinator.play()' },
{ action: 'pause', func : 'navigator.mediaSession.coordinator.pause()' },
{ action: 'seekto', func : 'navigator.mediaSession.coordinator.seekTo(10)' },
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
];
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
// Before joining
consoleWrite('');
LayoutTests/imported/w3c: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * web-platform-tests/mediasession/idlharness.window-expected.txt: Source/WebCore: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. The coordinator was a read-only optional attribute of the MediaSession element. Testing if the attribute was to be used to determine if a MediaSessionCoordinator was now available and for the MediaSession to join it. This made the use of an external polyfill difficult and enforcing the validity of an user created custom MediaSessionCoordinator due to IDL semantics limitations hard. We instead always create a MediaSessionCoordinator which in its default state is Closed. Once this state is changed to Waiting and an event is fire the MediaSession can now join it. * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event. Remove no longer necessary inheritance and async event queue. (WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor. (WebCore::MediaSession::createCoordinator): Make method private. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead. * Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate): (WebCore::MediaSessionCoordinator::virtualHasPendingActivity const): (WebCore::MediaSessionCoordinator::join): (WebCore::MediaSessionCoordinator::close): (WebCore::MediaSessionCoordinator::coordinatorStateChanged): * Modules/mediasession/MediaSessionCoordinator.h: * Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute. * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition. * dom/EventNames.h: * dom/EventTargetFactory.in: * page/Page.cpp: (WebCore::Page::setMediaSessionCoordinator): (WebCore::Page::invalidateMediaSessionCoordinator): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Tools: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm: (TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API, using coordinatorstatechange event instead. * TestWebKitAPI/Tests/WebKitCocoa/media-remote.html: LayoutTests: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: Change test to match new API. Canonical link: https://commits.webkit.org/238369@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
consoleWrite('** navigator.mediaSession.coordinator.state should be "waiting" initially')
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
testExpected('navigator.mediaSession.coordinator.state', 'waiting');
consoleWrite('');
consoleWrite('** Test that when coordinator methods fail and promises reject before mediaSession.join() is called.')
for (let action of actions)
await testAction(action.action, action.func, true);
consoleWrite(`** Test that mediaSession does not notify coordinator when states change before mediaSession.join() is called.`)
consoleWrite('* PositionState');
latestChange = '';
run('navigator.mediaSession.setPositionState({ duration: 1, playbackRate: 1, position: 0 })');
await sleepFor(20);
testExpected('latestChange', '');
consoleWrite('');
consoleWrite('* ReadyState');
await testReadyStates(async () => {
await sleepFor(20);
testExpected('latestChange', '');
});
consoleWrite('* PlaybackState');
await testPlaybackStates(async () => {
await sleepFor(20);
testExpected('latestChange', '');
});
consoleWrite('<br>');
consoleWrite('** session.join() should reject on failure');
run('internals.setMockMediaSessionCoordinatorCommandsShouldFail(true)');
run('promise = navigator.mediaSession.coordinator.join()');
await shouldReject(promise).then(() => { }).catch(() => { });
testExpected('navigator.mediaSession.coordinator.state', 'waiting');
testExpected('latestChange', '');
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
consoleWrite('');
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
run('internals.setMockMediaSessionCoordinatorCommandsShouldFail(false)');
run('promise = navigator.mediaSession.coordinator.join()');
LayoutTests/imported/w3c: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * web-platform-tests/mediasession/idlharness.window-expected.txt: Source/WebCore: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. The coordinator was a read-only optional attribute of the MediaSession element. Testing if the attribute was to be used to determine if a MediaSessionCoordinator was now available and for the MediaSession to join it. This made the use of an external polyfill difficult and enforcing the validity of an user created custom MediaSessionCoordinator due to IDL semantics limitations hard. We instead always create a MediaSessionCoordinator which in its default state is Closed. Once this state is changed to Waiting and an event is fire the MediaSession can now join it. * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event. Remove no longer necessary inheritance and async event queue. (WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor. (WebCore::MediaSession::createCoordinator): Make method private. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead. * Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate): (WebCore::MediaSessionCoordinator::virtualHasPendingActivity const): (WebCore::MediaSessionCoordinator::join): (WebCore::MediaSessionCoordinator::close): (WebCore::MediaSessionCoordinator::coordinatorStateChanged): * Modules/mediasession/MediaSessionCoordinator.h: * Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute. * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition. * dom/EventNames.h: * dom/EventTargetFactory.in: * page/Page.cpp: (WebCore::Page::setMediaSessionCoordinator): (WebCore::Page::invalidateMediaSessionCoordinator): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Tools: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm: (TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API, using coordinatorstatechange event instead. * TestWebKitAPI/Tests/WebKitCocoa/media-remote.html: LayoutTests: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: Change test to match new API. Canonical link: https://commits.webkit.org/238369@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
await changePromise();
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
await shouldResolve(promise).then(() => { }).catch(() => { });
testExpected('navigator.mediaSession.coordinator.state', 'joined');
consoleWrite('');
consoleWrite('** Test that when coordinator methods succeed, promises resolve and mediaSession action handlers are called.')
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
internals.setMockMediaSessionCoordinatorCommandsShouldFail(false);
for (let action of actions)
await testAction(action.action, action.func, false);
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
consoleWrite('** Test that when coordinator methods fail, promises reject and mediaSession action handlers are not called.')
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
internals.setMockMediaSessionCoordinatorCommandsShouldFail(true);
for (let action of actions)
await testAction(action.action, action.func, true);
consoleWrite(`** Test that mediaSession notifies coordinator when positionState changes.`)
run('navigator.mediaSession.setPositionState({ duration: 1, playbackRate: 1, position: 0 })');
await testExpectedEventually('latestChange', 'positionStateChanged', '==', 100);
consoleWrite('');
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
consoleWrite('** Test that mediaSession notifies coordinator when readyState changes.');
await testReadyStates(async () => { await testExpectedEventually('latestChange', 'readyStateChanged', '==', 100); })
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
consoleWrite('** Test that mediaSession notifies coordinator when playbackState changes.')
await testPlaybackStates(async () => { testExpectedEventually('latestChange', 'playbackStateChanged', '==', 100); });
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
// After leaving
consoleWrite('<br>');
consoleWrite('** Leave the session')
run('navigator.mediaSession.coordinator.leave()');
LayoutTests/imported/w3c: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * web-platform-tests/mediasession/idlharness.window-expected.txt: Source/WebCore: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. The coordinator was a read-only optional attribute of the MediaSession element. Testing if the attribute was to be used to determine if a MediaSessionCoordinator was now available and for the MediaSession to join it. This made the use of an external polyfill difficult and enforcing the validity of an user created custom MediaSessionCoordinator due to IDL semantics limitations hard. We instead always create a MediaSessionCoordinator which in its default state is Closed. Once this state is changed to Waiting and an event is fire the MediaSession can now join it. * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event. Remove no longer necessary inheritance and async event queue. (WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor. (WebCore::MediaSession::createCoordinator): Make method private. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead. * Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate): (WebCore::MediaSessionCoordinator::virtualHasPendingActivity const): (WebCore::MediaSessionCoordinator::join): (WebCore::MediaSessionCoordinator::close): (WebCore::MediaSessionCoordinator::coordinatorStateChanged): * Modules/mediasession/MediaSessionCoordinator.h: * Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute. * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition. * dom/EventNames.h: * dom/EventTargetFactory.in: * page/Page.cpp: (WebCore::Page::setMediaSessionCoordinator): (WebCore::Page::invalidateMediaSessionCoordinator): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Tools: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm: (TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API, using coordinatorstatechange event instead. * TestWebKitAPI/Tests/WebKitCocoa/media-remote.html: LayoutTests: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: Change test to match new API. Canonical link: https://commits.webkit.org/238369@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
await changePromise();
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
testExpected('navigator.mediaSession.coordinator.state', 'closed');
LayoutTests/imported/w3c: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * web-platform-tests/mediasession/idlharness.window-expected.txt: Source/WebCore: MediaSession.coordinator should not be optional, relying on coordinator state change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. The coordinator was a read-only optional attribute of the MediaSession element. Testing if the attribute was to be used to determine if a MediaSessionCoordinator was now available and for the MediaSession to join it. This made the use of an external polyfill difficult and enforcing the validity of an user created custom MediaSessionCoordinator due to IDL semantics limitations hard. We instead always create a MediaSessionCoordinator which in its default state is Closed. Once this state is changed to Waiting and an event is fire the MediaSession can now join it. * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): MediaSession no longer needs to fire event. Remove no longer necessary inheritance and async event queue. (WebCore::MediaSession::create): Drive-by fix, don't call suspendIfNeeded() in the constructor. (WebCore::MediaSession::createCoordinator): Make method private. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): MediaSessionCoordinator always exists. Return reference instead. * Modules/mediasession/MediaSession.idl: Amend definition, remove EventHandler * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::setMediaSessionCoordinatorPrivate): (WebCore::MediaSessionCoordinator::virtualHasPendingActivity const): (WebCore::MediaSessionCoordinator::join): (WebCore::MediaSessionCoordinator::close): (WebCore::MediaSessionCoordinator::coordinatorStateChanged): * Modules/mediasession/MediaSessionCoordinator.h: * Modules/mediasession/MediaSessionCoordinator.idl: Added new EventHandler attribute. * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Update for new API definition. * dom/EventNames.h: * dom/EventTargetFactory.in: * page/Page.cpp: (WebCore::Page::setMediaSessionCoordinator): (WebCore::Page::invalidateMediaSessionCoordinator): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Tools: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/MediaSessionCoordinatorTest.mm: (TestWebKitAPI::MediaSessionCoordinatorTest::createCoordinator): Change test to match new API, using coordinatorstatechange event instead. * TestWebKitAPI/Tests/WebKitCocoa/media-remote.html: LayoutTests: MediaSession.coordinator should not be optional, relying on coordinator readyState change instead https://bugs.webkit.org/show_bug.cgi?id=226328 rdar://77461335 Reviewed by Eric Carlson. * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: Change test to match new API. Canonical link: https://commits.webkit.org/238369@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:20:38 +00:00
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
latestChange = '';
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
consoleWrite('');
consoleWrite('** Test that when coordinator methods fail and promises reject after mediaSession.leave() has been called.')
for (let action of actions)
await testAction(action.action, action.func, true);
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
consoleWrite(`** Test that mediaSession does not notify coordinator when states change after mediaSession.leave() has been called.`)
consoleWrite('* PositionState');
latestChange = '';
run('navigator.mediaSession.setPositionState({ duration: 1, playbackRate: 1, position: 0 })');
await sleepFor(20);
testExpected('latestChange', '');
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
consoleWrite('');
consoleWrite('* ReadyState');
await testReadyStates(async () => {
await sleepFor(20);
testExpected('latestChange', '');
});
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
consoleWrite('* PlaybackState');
await testPlaybackStates(async () => {
await sleepFor(20);
testExpected('latestChange', '');
});
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
[macOS] MediaSessionCoordinator should have join and leave methods https://bugs.webkit.org/show_bug.cgi?id=223955 <rdar://problem/76021588> Reviewed by Jer Noble. Source/WebCore: Add 'join' and 'leave' methods to MediaSessionCoordinator so a page has to opt-in to participating in a coordinated session and can leave at any time. Don't have the coordinator automatically call session methods when the private coordinator finishes, just signal the promise and let the page handle it. No new tests, updated media/media-session/mock-coordinator.html. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Modules/mediasession/MediaMetadata.idl: Fix Conditional. * Modules/mediasession/MediaMetadataPlaylistMixin.idl: Ditto. * Modules/mediasession/MediaPositionState.h: Add logging template. (WTF::LogArgument<WebCore::MediaPositionState>::toString): * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Switch from beging a ContextDestructionObserver to an ActiveDOMObject to the wrapper won't be collected while an event dispatch is pending. (WebCore::MediaSession::virtualHasPendingActivity const): Prevent collection while event dispatch is pending. (WebCore::MediaSession::setPositionState): Improve logging. (WebCore::MediaPositionState::toJSONString const): * Modules/mediasession/MediaSession.h: * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionCoordinator.cpp: (WebCore::MediaSessionCoordinator::join): New. (WebCore::MediaSessionCoordinator::leave): New. (WebCore::MediaSessionCoordinator::seekTo): Reject unless state is 'joined'. Don't call session method. (WebCore::MediaSessionCoordinator::play): Ditto. (WebCore::MediaSessionCoordinator::pause): Ditto. (WebCore::MediaSessionCoordinator::setTrack): Ditto. (WebCore::MediaSessionCoordinator::positionStateChanged): (WebCore::MediaSessionCoordinator::playbackStateChanged): (WebCore::MediaSessionCoordinator::readyStateChanged): Do nothing unless state is 'joined'. Improve logging. (WebCore::MediaSessionCoordinator::seekSessionToTime): Ditto. (WebCore::MediaSessionCoordinator::playSession): Ditto. (WebCore::MediaSessionCoordinator::pauseSession): Ditto. (WebCore::MediaSessionCoordinator::setSessionTrack): Ditto. * Modules/mediasession/MediaSessionCoordinator.h: (WebCore::MediaSessionCoordinator::identifier const): (WebCore::MediaSessionCoordinator::state const): * Modules/mediasession/MediaSessionCoordinator.idl: * Modules/mediasession/MediaSessionCoordinatorMixin.idl: Fix Conditional. * Modules/mediasession/MediaSessionCoordinatorPrivate.h: Declare new required methods. * Modules/mediasession/MediaSessionCoordinatorState.h: Define states. * Modules/mediasession/MediaSessionCoordinatorState.idl: * Modules/mediasession/MediaSessionPlaylistMixin.idl: Fix Conditional. * Sources.txt: Add JSMediaSessionCoordinatorState.cpp. * WebCore.xcodeproj/project.pbxproj: * testing/MockMediaSessionCoordinator.cpp: (WebCore::MockMediaSessionCoordinator::join): (WebCore::MockMediaSessionCoordinator::leave): (WebCore::MockMediaSessionCoordinator::coordinatorStateChanged): * testing/MockMediaSessionCoordinator.h: Source/WebKit: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::join): (WebKit::RemoteMediaSessionCoordinatorProxy::leave): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::join): (WebKit::RemoteMediaSessionCoordinator::leave): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: * UIProcess/Media/MediaSessionCoordinatorProxyPrivate.h: Renamed from Source/WebKit/UIProcess/Media/MediaSessionCoordinatorPrivateProxy.h. * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp: (WebKit::RemoteMediaSessionCoordinatorProxy::create): (WebKit::RemoteMediaSessionCoordinatorProxy::RemoteMediaSessionCoordinatorProxy): (WebKit::RemoteMediaSessionCoordinatorProxy::coordinatorStateChanged): * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h: * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.messages.in: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::createMediaSessionCoordinator): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp: (WebKit::RemoteMediaSessionCoordinator::create): (WebKit::RemoteMediaSessionCoordinator::RemoteMediaSessionCoordinator): (WebKit::RemoteMediaSessionCoordinator::coordinatorStateChanged): * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::createMediaSessionCoordinator): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: LayoutTests: * media/media-session/mock-coordinator-expected.txt: * media/media-session/mock-coordinator.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275314 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235995@main
2021-03-31 23:11:14 +00:00
consoleWrite('<br>');
consoleWrite('** It should not be possible to join or leave a closed session');
run('promise = navigator.mediaSession.coordinator.join()');
await shouldReject(promise).then(() => { }).catch(() => { });
let exception;
try {
navigator.mediaSession.coordinator.leave();
} catch (ex) {
exception = ex;
}
let expected = 'InvalidStateError: Unable to leave when state is closed';
logResult(exception.toString() == expected, `TEST(navigator.mediaSession.coordinator.leave()) THROWS(${expected})`);
[Cocoa] Add Experimental MediaSession coordinator https://bugs.webkit.org/show_bug.cgi?id=222158 <rdar://problem/74508862> Reviewed by Jer Noble. Source/WebCore: Add an experimental MediaSession coordinator, an object that provides an interface that allows script to coordinate changes to MediaSession with the User Agent. Also add an experimental MediaSession playlist interface. The changes are behind new experimental feature flags, MediaSessionCoordinatorEnabled and MediaSessionPlaylistEnabled. Test: media/media-session/mock-coordinator.html * DerivedSources-input.xcfilelist: Add new IDL files. * DerivedSources-output.xcfilelist: Add new derived sources. * DerivedSources.make: Add new IDL. * Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::create): Set trackIdentifier from init data. (WebCore::MediaMetadata::setTrackIdentifier): trackIdentifier setter. * Modules/mediasession/MediaMetadata.h: (WebCore::MediaMetadata::trackIdentifier const): * Modules/mediasession/MediaMetadata.idl: * Modules/mediasession/MediaMetadataInit.h: Add trackIdentifier. (WebCore::MediaMetadataInit::encode const): (WebCore::MediaMetadataInit::decode): * Modules/mediasession/MediaMetadataInit.idl: * Modules/mediasession/MediaSession.cpp: (WebCore::MediaSession::MediaSession): Initialize MainThreadGenericEventQueue. (WebCore::MediaSession::setMetadata): metadataUpdated -> notifyMetadataObservers. (WebCore::MediaSession::setReadyState): Session readyState setter. (WebCore::MediaSession::setCoordinator): Coordinator setter. Post 'coordinatorchange' event after change. (WebCore::MediaSession::setPlaylist): Playlist setter. (WebCore::MediaSession::setActionHandler): Call notifyActionHandlerObservers. (WebCore::MediaSession::setPositionState): Call notifyPositionStateObservers. (WebCore::MediaSession::metadataUpdated): Call notifyMetadataObservers. (WebCore::MediaSession::addObserver): New. (WebCore::MediaSession::removeObserver): New. (WebCore::MediaSession::forEachObserver): New. (WebCore::MediaSession::notifyMetadataObservers): New. (WebCore::MediaSession::notifyPositionStateObservers): New. (WebCore::MediaSession::notifyPlaybackStateObservers): New. (WebCore::MediaSession::notifyActionHandlerObservers): New. (WebCore::MediaSession::notifyReadyStateObservers): New. * Modules/mediasession/MediaSession.h: (WebCore::MediaSession::coordinator const): (WebCore::MediaSession::playlist const): (WebCore::MediaSession::logger const): * Modules/mediasession/MediaSession.idl: * Modules/mediasession/MediaSessionAction.h: * Modules/mediasession/MediaSessionAction.idl: * Modules/mediasession/MediaSessionActionDetails.h: * Modules/mediasession/MediaSessionActionDetails.idl: MediaSessionCoordinator proxies calls through the PlatformMediaSessionCoordinator, and then calls the equivalent MediaSession methode if the platform coordinator is successful. * Modules/mediasession/MediaSessionCoordinator.cpp: Added. (WebCore::nextCoordinatorLogIdentifier): (WebCore::MediaSessionCoordinator::create): (WebCore::MediaSessionCoordinator::MediaSessionCoordinator): (WebCore::MediaSessionCoordinator::seekTo): (WebCore::MediaSessionCoordinator::play): (WebCore::MediaSessionCoordinator::pause): (WebCore::MediaSessionCoordinator::setTrack): (WebCore::MediaSessionCoordinator::setMediaSession): (WebCore::MediaSessionCoordinator::logChannel): * Modules/mediasession/MediaSessionCoordinator.h: New. (WebCore::MediaSessionCoordinator::logger const): (WebCore::MediaSessionCoordinator::logIdentifier const): (WebCore::MediaSessionCoordinator::logClassName): * Modules/mediasession/MediaSessionCoordinator.idl: New. * Modules/mediasession/NavigatorMediaSession.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/EventNames.h: * dom/EventTargetFactory.in: * platform/graphics/PlatformMediaSessionCoordinator.h: Added. (WebCore::PlatformMediaSessionCoordinator::setLogger): (WebCore::PlatformMediaSessionCoordinator::loggerPtr const): (WebCore::PlatformMediaSessionCoordinator::logIdentifier const): (WebCore::PlatformMediaSessionCoordinator::logClassName const): (WebCore::PlatformMediaSessionCoordinator::logChannel const): * testing/Internals.cpp: (WebCore::Internals::registerMockMediaSessionCoordinator): Register the mock media session coordinator for testing. * testing/Internals.h: * testing/Internals.idl: * testing/MockMediaSessionCoordinator.cpp: Added. (WebCore::MockMediaSessionCoordinator::create): (WebCore::MockMediaSessionCoordinator::MockMediaSessionCoordinator): (WebCore::MockMediaSessionCoordinator::seekTo): (WebCore::MockMediaSessionCoordinator::play): (WebCore::MockMediaSessionCoordinator::pause): (WebCore::MockMediaSessionCoordinator::setTrack): * testing/MockMediaSessionCoordinator.h: New. Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: * wtf/PlatformEnableCocoa.h: LayoutTests: * platform/TestExpectations: * media/media-session/mock-coordinator-expected.txt: Added. * media/media-session/mock-coordinator.html: Added. Canonical link: https://commits.webkit.org/235728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 23:14:51 +00:00
consoleWrite('');
endTest();
}, {once: true});
</script>
</head>
<body>
</body>
</html>