Title: [272748] trunk/Source
Revision
272748
Author
[email protected]
Date
2021-02-11 13:49:12 -0800 (Thu, 11 Feb 2021)

Log Message

[Cocoa][GPUP] Move RemoteCommandListener into the GPU Process
https://bugs.webkit.org/show_bug.cgi?id=221732

Reviewed by Eric Carlson.

Source/WebCore:

Refactor RemoteCommandListener to allow its methods to work over XPC:

- Rather than having a synchronous client method to query whether seeking is
  supported, require clients to set seekability explicitly.
- Change the RemoteCommandArgument from a union to an Optional<double>.
- Allow clients to query the MediaPlaybackTarget through the session rather
  than wait for a notification that the playback target changed.

Additionally, add a mini-factory functionality to RemoteCommandListener to allow
clients to specify a different subclass to be created at runtime.

* Modules/webaudio/AudioContext.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::didReceiveRemoteControlCommand):
* html/HTMLMediaElement.h:
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::didReceiveRemoteControlCommand):
* html/MediaElementSession.h:
* platform/NowPlayingManager.cpp:
(WebCore::NowPlayingManager::didReceiveRemoteControlCommand):
(WebCore::NowPlayingManager::setNowPlayingInfo):
(WebCore::NowPlayingManager::supportsSeeking const): Deleted.
* platform/NowPlayingManager.h:
* platform/RemoteCommandListener.cpp:
(WebCore::remoteCommandListenerCreationFunction):
(WebCore::RemoteCommandListener::setCreationFunction):
(WebCore::RemoteCommandListener::resetCreationFunction):
(WebCore::RemoteCommandListener::create):
(WebCore::RemoteCommandListener::RemoteCommandListener):
(WebCore::RemoteCommandListener::setSupportsSeeking):
* platform/RemoteCommandListener.h:
(WebCore::RemoteCommandListener::RemoteCommandListener): Deleted.
(WebCore::RemoteCommandListener::updateSupportedCommands): Deleted.
(WebCore::RemoteCommandListener::client const): Deleted.
* platform/audio/PlatformMediaSession.cpp:
(WebCore::PlatformMediaSession::didReceiveRemoteControlCommand):
* platform/audio/PlatformMediaSession.h:
* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::processDidReceiveRemoteControlCommand):
* platform/audio/PlatformMediaSessionManager.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::scheduleSessionStatusUpdate):
* platform/audio/ios/MediaSessionHelperIOS.h:
* platform/audio/ios/MediaSessionHelperIOS.mm:
(MediaSessionHelperiOS::activeVideoRouteDidChange):
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::sessionWillBeginPlayback):
* platform/ios/RemoteCommandListenerIOS.h:
* platform/ios/RemoteCommandListenerIOS.mm:
(WebCore::RemoteCommandListenerIOS::create):
(WebCore::RemoteCommandListenerIOS::RemoteCommandListenerIOS):
(WebCore::RemoteCommandListenerIOS::updateSupportedCommands):
(WebCore::RemoteCommandListener::create): Deleted.
* platform/mac/RemoteCommandListenerMac.h:
* platform/mac/RemoteCommandListenerMac.mm:
(WebCore::RemoteCommandListenerMac::create):
(WebCore::RemoteCommandListenerMac::updateSupportedCommands):
(WebCore::RemoteCommandListenerMac::RemoteCommandListenerMac):
(WebCore::RemoteCommandListener::create): Deleted.
* testing/Internals.cpp:
(WebCore::Internals::postRemoteControlCommand):

Source/WebKit:

Add a new Remote/Proxy class pair to facilitate RemoteCommandListener being
created in the GPU Process.

* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::createRemoteCommandListener):
(WebKit::GPUConnectionToWebProcess::releaseRemoteCommandListener):
* GPUProcess/GPUConnectionToWebProcess.h:
* GPUProcess/GPUConnectionToWebProcess.messages.in:
* GPUProcess/media/RemoteRemoteCommandListenerProxy.cpp:
(WebKit::RemoteRemoteCommandListenerProxy::RemoteRemoteCommandListenerProxy):
(WebKit::RemoteRemoteCommandListenerProxy::didReceiveRemoteControlCommand):
(WebKit::RemoteRemoteCommandListenerProxy::updateSupportedCommands):
* GPUProcess/media/RemoteRemoteCommandListenerProxy.h:
* GPUProcess/media/RemoteRemoteCommandListenerProxy.messages.in:
* Scripts/webkit/messages.py:
* Sources.txt:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/GPU/GPUProcessConnection.cpp:
(WebKit::GPUProcessConnection::didReceiveRemoteCommand):
* WebProcess/GPU/media/RemoteRemoteCommandListener.cpp: Added.
(WebKit::RemoteRemoteCommandListener::create):
(WebKit::RemoteRemoteCommandListener::RemoteRemoteCommandListener):
(WebKit::RemoteRemoteCommandListener::~RemoteRemoteCommandListener):
(WebKit::RemoteRemoteCommandListener::gpuProcessConnectionDidClose):
(WebKit::RemoteRemoteCommandListener::didReceiveRemoteControlCommand):
* WebProcess/GPU/media/RemoteRemoteCommandListener.h:
* WebProcess/GPU/media/RemoteRemoteCommandListener.messages.in:
* WebProcess/GPU/media/RemoteRemoteCommandListenerIdentifier.h:
* WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp:
(WebKit::RemoteMediaSessionHelper::activeVideoRouteDidChange):
* WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::setUseGPUProcessForMedia):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (272747 => 272748)


--- trunk/Source/WebCore/ChangeLog	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/ChangeLog	2021-02-11 21:49:12 UTC (rev 272748)
@@ -1,3 +1,73 @@
+2021-02-11  Jer Noble  <[email protected]>
+
+        [Cocoa][GPUP] Move RemoteCommandListener into the GPU Process
+        https://bugs.webkit.org/show_bug.cgi?id=221732
+
+        Reviewed by Eric Carlson.
+
+        Refactor RemoteCommandListener to allow its methods to work over XPC:
+
+        - Rather than having a synchronous client method to query whether seeking is
+          supported, require clients to set seekability explicitly.
+        - Change the RemoteCommandArgument from a union to an Optional<double>.
+        - Allow clients to query the MediaPlaybackTarget through the session rather
+          than wait for a notification that the playback target changed.
+
+        Additionally, add a mini-factory functionality to RemoteCommandListener to allow
+        clients to specify a different subclass to be created at runtime.
+
+        * Modules/webaudio/AudioContext.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::didReceiveRemoteControlCommand):
+        * html/HTMLMediaElement.h:
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::didReceiveRemoteControlCommand):
+        * html/MediaElementSession.h:
+        * platform/NowPlayingManager.cpp:
+        (WebCore::NowPlayingManager::didReceiveRemoteControlCommand):
+        (WebCore::NowPlayingManager::setNowPlayingInfo):
+        (WebCore::NowPlayingManager::supportsSeeking const): Deleted.
+        * platform/NowPlayingManager.h:
+        * platform/RemoteCommandListener.cpp:
+        (WebCore::remoteCommandListenerCreationFunction):
+        (WebCore::RemoteCommandListener::setCreationFunction):
+        (WebCore::RemoteCommandListener::resetCreationFunction):
+        (WebCore::RemoteCommandListener::create):
+        (WebCore::RemoteCommandListener::RemoteCommandListener):
+        (WebCore::RemoteCommandListener::setSupportsSeeking):
+        * platform/RemoteCommandListener.h:
+        (WebCore::RemoteCommandListener::RemoteCommandListener): Deleted.
+        (WebCore::RemoteCommandListener::updateSupportedCommands): Deleted.
+        (WebCore::RemoteCommandListener::client const): Deleted.
+        * platform/audio/PlatformMediaSession.cpp:
+        (WebCore::PlatformMediaSession::didReceiveRemoteControlCommand):
+        * platform/audio/PlatformMediaSession.h:
+        * platform/audio/PlatformMediaSessionManager.cpp:
+        (WebCore::PlatformMediaSessionManager::processDidReceiveRemoteControlCommand):
+        * platform/audio/PlatformMediaSessionManager.h:
+        * platform/audio/cocoa/MediaSessionManagerCocoa.h:
+        * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+        (WebCore::MediaSessionManagerCocoa::scheduleSessionStatusUpdate):
+        * platform/audio/ios/MediaSessionHelperIOS.h:
+        * platform/audio/ios/MediaSessionHelperIOS.mm:
+        (MediaSessionHelperiOS::activeVideoRouteDidChange):
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::sessionWillBeginPlayback):
+        * platform/ios/RemoteCommandListenerIOS.h:
+        * platform/ios/RemoteCommandListenerIOS.mm:
+        (WebCore::RemoteCommandListenerIOS::create):
+        (WebCore::RemoteCommandListenerIOS::RemoteCommandListenerIOS):
+        (WebCore::RemoteCommandListenerIOS::updateSupportedCommands):
+        (WebCore::RemoteCommandListener::create): Deleted.
+        * platform/mac/RemoteCommandListenerMac.h:
+        * platform/mac/RemoteCommandListenerMac.mm:
+        (WebCore::RemoteCommandListenerMac::create):
+        (WebCore::RemoteCommandListenerMac::updateSupportedCommands):
+        (WebCore::RemoteCommandListenerMac::RemoteCommandListenerMac):
+        (WebCore::RemoteCommandListener::create): Deleted.
+        * testing/Internals.cpp:
+        (WebCore::Internals::postRemoteControlCommand):
+
 2021-02-11  Darin Adler  <[email protected]>
 
         Use a template to simplify repetitive code in ColorSpaceCG.cpp

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.h (272747 => 272748)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -115,7 +115,7 @@
     void mayResumePlayback(bool shouldResume) override;
     void suspendPlayback() override;
     bool canReceiveRemoteControlCommands() const override { return false; }
-    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) override { }
+    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument&) override { }
     bool supportsSeeking() const override { return false; }
     bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override { return false; }
     bool canProduceAudio() const final { return true; }

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (272747 => 272748)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -7515,7 +7515,7 @@
     return m_mediaSession->mediaSessionIdentifier();
 }
 
-void HTMLMediaElement::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument* argument)
+void HTMLMediaElement::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument& argument)
 {
     ALWAYS_LOG(LOGIDENTIFIER, command);
 
@@ -7544,18 +7544,18 @@
         break;
     case PlatformMediaSession::SkipForwardCommand:
         if (argument)
-            offset = argument->asDouble;
+            offset = *argument;
         handleSeekToPlaybackPosition(offset);
         break;
     case PlatformMediaSession::SkipBackwardCommand:
         if (argument)
-            offset = argument->asDouble;
+            offset = *argument;
         handleSeekToPlaybackPosition(0 - offset);
         break;
     case PlatformMediaSession::SeekToPlaybackPositionCommand:
         ASSERT(argument);
         if (argument)
-            handleSeekToPlaybackPosition(argument->asDouble);
+            handleSeekToPlaybackPosition(*argument);
         break;
     default:
         { } // Do nothing

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (272747 => 272748)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -863,7 +863,7 @@
     void resumeAutoplaying() override;
     void mayResumePlayback(bool shouldResume) override;
     bool canReceiveRemoteControlCommands() const override { return true; }
-    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) override;
+    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument&) override;
     bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override;
     bool shouldOverrideBackgroundLoadingRestriction() const override;
     bool canProduceAudio() const final;

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (272747 => 272748)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -1026,7 +1026,7 @@
 }
 
 #if ENABLE(MEDIA_SESSION)
-void MediaElementSession::didReceiveRemoteControlCommand(RemoteControlCommandType commandType, const RemoteCommandArgument* argument)
+void MediaElementSession::didReceiveRemoteControlCommand(RemoteControlCommandType commandType, const RemoteCommandArgument& argument)
 {
     auto* window = m_element.document().domWindow();
     auto* session = window ? &NavigatorMediaSession::mediaSession(window->navigator()) : nullptr;
@@ -1056,16 +1056,16 @@
         if (!argument)
             return;
         actionDetails.action = ""
-        actionDetails.seekTime = argument->asDouble;
+        actionDetails.seekTime = *argument;
         break;
     case SkipForwardCommand:
         if (argument)
-            actionDetails.seekOffset = argument->asDouble;
+            actionDetails.seekOffset = *argument;
         actionDetails.action = ""
         break;
     case SkipBackwardCommand:
         if (argument)
-            actionDetails.seekOffset = argument->asDouble;
+            actionDetails.seekOffset = *argument;
         actionDetails.action = ""
         break;
     case NextTrackCommand:

Modified: trunk/Source/WebCore/html/MediaElementSession.h (272747 => 272748)


--- trunk/Source/WebCore/html/MediaElementSession.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/html/MediaElementSession.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -175,7 +175,7 @@
 #endif
 
 #if ENABLE(MEDIA_SESSION)
-    void didReceiveRemoteControlCommand(RemoteControlCommandType, const RemoteCommandArgument* = nullptr) final;
+    void didReceiveRemoteControlCommand(RemoteControlCommandType, const RemoteCommandArgument& = WTF::nullopt) final;
 #endif
 
 private:

Modified: trunk/Source/WebCore/platform/NowPlayingManager.cpp (272747 => 272748)


--- trunk/Source/WebCore/platform/NowPlayingManager.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/NowPlayingManager.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -35,24 +35,14 @@
 NowPlayingManager::NowPlayingManager() = default;
 NowPlayingManager::~NowPlayingManager() = default;
 
-void NowPlayingManager::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType type, const PlatformMediaSession::RemoteCommandArgument* argument)
+void NowPlayingManager::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType type, const PlatformMediaSession::RemoteCommandArgument& argument)
 {
     ASSERT(m_nowPlayingInfo);
 
-    if (!m_client)
-        return;
-
-    Optional<double> value;
-    if (argument)
-        value = argument->asDouble;
-    m_client->didReceiveRemoteControlCommand(type, value);
+    if (m_client)
+        m_client->didReceiveRemoteControlCommand(type, argument);
 }
 
-bool NowPlayingManager::supportsSeeking() const
-{
-    return m_nowPlayingInfo && m_nowPlayingInfo->supportsSeeking;
-}
-
 void NowPlayingManager::clearNowPlayingInfoClient(Client& client)
 {
     if (m_client.get() != &client)
@@ -72,6 +62,7 @@
     if (!m_remoteCommandListener)
         m_remoteCommandListener = RemoteCommandListener::create(*this);
 
+    m_remoteCommandListener->setSupportsSeeking(nowPlayingInfo.supportsSeeking);
     m_client = makeWeakPtr(client);
     m_nowPlayingInfo = WTFMove(nowPlayingInfo);
 

Modified: trunk/Source/WebCore/platform/NowPlayingManager.h (272747 => 272748)


--- trunk/Source/WebCore/platform/NowPlayingManager.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/NowPlayingManager.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -40,8 +40,7 @@
     NowPlayingManager();
     ~NowPlayingManager();
 
-    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) final;
-    bool supportsSeeking() const final;
+    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument&) final;
 
     class Client : public CanMakeWeakPtr<Client> {
     public:

Modified: trunk/Source/WebCore/platform/RemoteCommandListener.cpp (272747 => 272748)


--- trunk/Source/WebCore/platform/RemoteCommandListener.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/RemoteCommandListener.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -26,17 +26,55 @@
 #include "config.h"
 #include "RemoteCommandListener.h"
 
+#if PLATFORM(MAC)
+#include "RemoteCommandListenerMac.h"
+#endif
+
+#if PLATFORM(IOS_FAMILY)
+#include "RemoteCommandListenerIOS.h"
+#endif
+
 namespace WebCore {
 
-#if !PLATFORM(COCOA)
+static RemoteCommandListener::CreationFunction& remoteCommandListenerCreationFunction()
+{
+    static NeverDestroyed<RemoteCommandListener::CreationFunction> creationFunction;
+    return creationFunction;
+}
 
-std::unique_ptr<RemoteCommandListener> RemoteCommandListener::create(RemoteCommandListenerClient& client)
+void RemoteCommandListener::setCreationFunction(CreationFunction&& function)
 {
-    return makeUnique<RemoteCommandListener>(client);
+    remoteCommandListenerCreationFunction() = WTFMove(function);
 }
 
+void RemoteCommandListener::resetCreationFunction()
+{
+    remoteCommandListenerCreationFunction() = [] (RemoteCommandListenerClient& client) {
+#if PLATFORM(MAC)
+        return RemoteCommandListenerMac::create(client);
+#elif PLATFORM(IOS_FAMILY)
+        return RemoteCommandListenerIOS::create(client);
+#else
+        return RemoteCommandListener::create(client);
 #endif
+    };
+}
 
+std::unique_ptr<RemoteCommandListener> RemoteCommandListener::create(RemoteCommandListenerClient& client)
+{
+    if (!remoteCommandListenerCreationFunction())
+        resetCreationFunction();
+    return remoteCommandListenerCreationFunction()(client);
+}
+
+RemoteCommandListener::RemoteCommandListener(RemoteCommandListenerClient& client)
+    : m_client(client)
+{
+}
+
+RemoteCommandListener::~RemoteCommandListener() = default;
+
+
 void RemoteCommandListener::scheduleSupportedCommandsUpdate()
 {
     if (!m_updateCommandsTask.hasPendingTask()) {
@@ -46,6 +84,15 @@
     }
 }
 
+void RemoteCommandListener::setSupportsSeeking(bool supports)
+{
+    if (m_supportsSeeking == supports)
+        return;
+
+    m_supportsSeeking = supports;
+    scheduleSupportedCommandsUpdate();
+}
+
 void RemoteCommandListener::addSupportedCommand(PlatformMediaSession::RemoteControlCommandType command)
 {
     m_registeredCommands.add(command);

Modified: trunk/Source/WebCore/platform/RemoteCommandListener.h (272747 => 272748)


--- trunk/Source/WebCore/platform/RemoteCommandListener.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/RemoteCommandListener.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -35,21 +35,25 @@
     WTF_MAKE_FAST_ALLOCATED;
 public:
     virtual ~RemoteCommandListenerClient() = default;
-    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) = 0;
-    virtual bool supportsSeeking() const = 0;
+    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument&) = 0;
 };
 
-class RemoteCommandListener {
+class WEBCORE_EXPORT RemoteCommandListener {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    WEBCORE_EXPORT static std::unique_ptr<RemoteCommandListener> create(RemoteCommandListenerClient&);
-    RemoteCommandListener(RemoteCommandListenerClient& client) : m_client(client) { }
-    virtual ~RemoteCommandListener() = default;
+    static std::unique_ptr<RemoteCommandListener> create(RemoteCommandListenerClient&);
+    RemoteCommandListener(RemoteCommandListenerClient&);
+    virtual ~RemoteCommandListener();
 
+    using CreationFunction = Function<std::unique_ptr<RemoteCommandListener>(RemoteCommandListenerClient&)>;
+    static void setCreationFunction(CreationFunction&&);
+    static void resetCreationFunction();
+
     void addSupportedCommand(PlatformMediaSession::RemoteControlCommandType);
     void removeSupportedCommand(PlatformMediaSession::RemoteControlCommandType);
     virtual void updateSupportedCommands() { }
     void scheduleSupportedCommandsUpdate();
+    void setSupportsSeeking(bool);
 
     RemoteCommandListenerClient& client() const { return m_client; }
 
@@ -58,6 +62,7 @@
 
     using RemoteCommandsSet = HashSet<PlatformMediaSession::RemoteControlCommandType, WTF::IntHash<PlatformMediaSession::RemoteControlCommandType>, WTF::StrongEnumHashTraits<PlatformMediaSession::RemoteControlCommandType>>;
     RemoteCommandsSet m_registeredCommands;
+    bool m_supportsSeeking { false };
 
     DeferrableTask<Timer> m_updateCommandsTask;
 };

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp (272747 => 272748)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -291,7 +291,7 @@
     return m_client.canReceiveRemoteControlCommands();
 }
 
-void PlatformMediaSession::didReceiveRemoteControlCommand(RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument* argument)
+void PlatformMediaSession::didReceiveRemoteControlCommand(RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument& argument)
 {
     ALWAYS_LOG(LOGIDENTIFIER, command);
 

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.h (272747 => 272748)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -114,11 +114,9 @@
 
     virtual void suspendBuffering() { }
     virtual void resumeBuffering() { }
-    
-    typedef union {
-        double asDouble;
-    } RemoteCommandArgument;
 
+    using RemoteCommandArgument = Optional<double>;
+
     enum RemoteControlCommandType : uint8_t {
         NoCommand,
         PlayCommand,
@@ -136,7 +134,7 @@
         PreviousTrackCommand,
     };
     bool canReceiveRemoteControlCommands() const;
-    virtual void didReceiveRemoteControlCommand(RemoteControlCommandType, const RemoteCommandArgument* = nullptr);
+    virtual void didReceiveRemoteControlCommand(RemoteControlCommandType, const RemoteCommandArgument& = WTF::nullopt);
     bool supportsSeeking() const;
 
     enum DisplayType : uint8_t {
@@ -239,7 +237,7 @@
     virtual void suspendPlayback() = 0;
 
     virtual bool canReceiveRemoteControlCommands() const = 0;
-    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) = 0;
+    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument&) = 0;
     virtual bool supportsSeeking() const = 0;
 
     virtual bool canProduceAudio() const { return false; }

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (272747 => 272748)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -430,7 +430,7 @@
     updateSessionState();
 }
 
-void PlatformMediaSessionManager::processDidReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument* argument)
+void PlatformMediaSessionManager::processDidReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument& argument)
 {
     PlatformMediaSession* activeSession = currentSession();
     if (!activeSession || !activeSession->canReceiveRemoteControlCommands())

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (272747 => 272748)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -147,7 +147,7 @@
     WEBCORE_EXPORT void removeAudioCaptureSource(PlatformMediaSession::AudioCaptureSource&);
     bool hasAudioCaptureSource(PlatformMediaSession::AudioCaptureSource& source) const { return m_audioCaptureSources.contains(source); }
 
-    WEBCORE_EXPORT void processDidReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*);
+    WEBCORE_EXPORT void processDidReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument&);
 
     bool isInterrupted() const { return m_interrupted; }
     bool hasNoSession() const;

Modified: trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h (272747 => 272748)


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -93,8 +93,7 @@
 #endif
 
     // RemoteCommandListenerClient
-    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType type, const PlatformMediaSession::RemoteCommandArgument* argument) final { processDidReceiveRemoteControlCommand(type, argument); }
-    bool supportsSeeking() const final { return computeSupportsSeeking(); }
+    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType type, const PlatformMediaSession::RemoteCommandArgument& argument) final { processDidReceiveRemoteControlCommand(type, argument); }
 
     // AudioHardwareListenerClient
     void audioHardwareDidBecomeActive() final { }

Modified: trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm (272747 => 272748)


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-02-11 21:49:12 UTC (rev 272748)
@@ -153,8 +153,10 @@
 void MediaSessionManagerCocoa::scheduleSessionStatusUpdate()
 {
     m_taskQueue.enqueueTask([this] () mutable {
-        if (m_remoteCommandListener)
+        if (m_remoteCommandListener) {
+            m_remoteCommandListener->setSupportsSeeking(computeSupportsSeeking());
             m_remoteCommandListener->updateSupportedCommands();
+        }
 
         updateNowPlayingInfo();
 

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.h (272747 => 272748)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -79,6 +79,8 @@
     bool activeVideoRouteSupportsAirPlayVideo() const { return m_activeVideoRouteSupportsAirPlayVideo; }
     bool isPlayingToAutomotiveHeadUnit() const { return m_isPlayingToAutomotiveHeadUnit; }
 
+    MediaPlaybackTarget* playbackTarget() const { return m_playbackTarget.get(); }
+
 protected:
     WeakHashSet<MediaSessionHelperClient> m_clients;
     uint32_t m_monitoringWirelessRoutesCount { 0 };
@@ -85,6 +87,7 @@
     bool m_isExternalOutputDeviceAvailable { false };
     bool m_activeVideoRouteSupportsAirPlayVideo { false };
     bool m_isPlayingToAutomotiveHeadUnit { false };
+    RefPtr<MediaPlaybackTarget> m_playbackTarget;
 };
 
 }

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm (272747 => 272748)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm	2021-02-11 21:49:12 UTC (rev 272748)
@@ -288,10 +288,10 @@
 
 void MediaSessionHelperiOS::activeVideoRouteDidChange()
 {
-    auto playbackTarget = MediaPlaybackTargetCocoa::create();
-    m_activeVideoRouteSupportsAirPlayVideo = playbackTarget->supportsRemoteVideoPlayback();
+    m_playbackTarget = MediaPlaybackTargetCocoa::create();
+    m_activeVideoRouteSupportsAirPlayVideo = m_playbackTarget->supportsRemoteVideoPlayback();
     for (auto& client : m_clients)
-        client.activeVideoRouteDidChange(m_activeVideoRouteSupportsAirPlayVideo ? SupportsAirPlayVideo::Yes : SupportsAirPlayVideo::No, playbackTarget.copyRef());
+        client.activeVideoRouteDidChange(m_activeVideoRouteSupportsAirPlayVideo ? SupportsAirPlayVideo::Yes : SupportsAirPlayVideo::No, *m_playbackTarget);
 }
 #endif
 

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (272747 => 272748)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2021-02-11 21:49:12 UTC (rev 272748)
@@ -142,15 +142,11 @@
         return false;
 
 #if PLATFORM(IOS_FAMILY) && !PLATFORM(IOS_FAMILY_SIMULATOR) && !PLATFORM(MACCATALYST) && !PLATFORM(WATCHOS)
-    if (!m_playbackTarget) {
-        m_playbackTarget = MediaPlaybackTargetCocoa::create();
-        m_playbackTargetSupportsAirPlayVideo = m_playbackTarget->supportsRemoteVideoPlayback();
-    }
-
-    ALWAYS_LOG(LOGIDENTIFIER, "Playback Target Supports AirPlay Video = ", m_playbackTargetSupportsAirPlayVideo);
-    if (m_playbackTargetSupportsAirPlayVideo)
-        session.setPlaybackTarget(*m_playbackTarget.copyRef());
-    session.setShouldPlayToPlaybackTarget(m_playbackTargetSupportsAirPlayVideo);
+    auto playbackTargetSupportsAirPlayVideo = MediaSessionHelper::sharedHelper().activeVideoRouteSupportsAirPlayVideo();
+    ALWAYS_LOG(LOGIDENTIFIER, "Playback Target Supports AirPlay Video = ", playbackTargetSupportsAirPlayVideo);
+    if (auto target = MediaSessionHelper::sharedHelper().playbackTarget(); target && playbackTargetSupportsAirPlayVideo)
+        session.setPlaybackTarget(*target);
+    session.setShouldPlayToPlaybackTarget(playbackTargetSupportsAirPlayVideo);
 #endif
 
     providePresentingApplicationPIDIfNecessary();

Modified: trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h (272747 => 272748)


--- trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -33,6 +33,7 @@
 
 class RemoteCommandListenerIOS final : public RemoteCommandListener, public CanMakeWeakPtr<RemoteCommandListenerIOS> {
 public:
+    static std::unique_ptr<RemoteCommandListenerIOS> create(RemoteCommandListenerClient&);
     RemoteCommandListenerIOS(RemoteCommandListenerClient&);
     virtual ~RemoteCommandListenerIOS();
 

Modified: trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm (272747 => 272748)


--- trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm	2021-02-11 21:49:12 UTC (rev 272748)
@@ -40,7 +40,7 @@
 
 namespace WebCore {
 
-std::unique_ptr<RemoteCommandListener> RemoteCommandListener::create(RemoteCommandListenerClient& client)
+std::unique_ptr<RemoteCommandListenerIOS> RemoteCommandListenerIOS::create(RemoteCommandListenerClient& client)
 {
     if (!MediaPlayerLibrary())
         return nullptr;
@@ -58,7 +58,7 @@
         callOnMainThread([weakThis] {
             if (!weakThis)
                 return;
-            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PauseCommand, nullptr);
+            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PauseCommand, WTF::nullopt);
         });
 
         return MPRemoteCommandHandlerStatusSuccess;
@@ -68,7 +68,7 @@
         callOnMainThread([weakThis] {
             if (!weakThis)
                 return;
-            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PlayCommand, nullptr);
+            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PlayCommand, WTF::nullopt);
         });
 
         return MPRemoteCommandHandlerStatusSuccess;
@@ -78,7 +78,7 @@
         callOnMainThread([weakThis] {
             if (!weakThis)
                 return;
-            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::TogglePlayPauseCommand, nullptr);
+            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::TogglePlayPauseCommand, WTF::nullopt);
         });
 
         return MPRemoteCommandHandlerStatusSuccess;
@@ -93,7 +93,7 @@
         callOnMainThread([weakThis, command] {
             if (!weakThis)
                 return;
-            weakThis->m_client.didReceiveRemoteControlCommand(command, nullptr);
+            weakThis->m_client.didReceiveRemoteControlCommand(command, WTF::nullopt);
         });
 
         return MPRemoteCommandHandlerStatusSuccess;
@@ -108,7 +108,7 @@
         callOnMainThread([weakThis, command] {
             if (!weakThis)
                 return;
-            weakThis->m_client.didReceiveRemoteControlCommand(command, nullptr);
+            weakThis->m_client.didReceiveRemoteControlCommand(command, WTF::nullopt);
         });
 
         return MPRemoteCommandHandlerStatusSuccess;
@@ -117,16 +117,16 @@
     m_seekToTimeTarget = [[center changePlaybackPositionCommand] addTargetWithHandler:^(MPRemoteCommandEvent *event) {
         ASSERT([event isKindOfClass:getMPChangePlaybackPositionCommandEventClass()]);
 
-        if (!client.supportsSeeking())
+        if (!m_supportsSeeking)
             return MPRemoteCommandHandlerStatusCommandFailed;
 
         MPChangePlaybackPositionCommandEvent* seekEvent = static_cast<MPChangePlaybackPositionCommandEvent *>(event);
         PlatformMediaSession::RemoteCommandArgument argument { [seekEvent positionTime] };
 
-        callOnMainThread([weakThis, argument] {
+        callOnMainThread([weakThis, argument = WTFMove(argument)] {
             if (!weakThis)
                 return;
-            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::SeekToPlaybackPositionCommand, &argument);
+            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::SeekToPlaybackPositionCommand, argument);
         });
 
         return MPRemoteCommandHandlerStatusSuccess;
@@ -146,7 +146,7 @@
 
 void RemoteCommandListenerIOS::updateSupportedCommands()
 {
-    [[[getMPRemoteCommandCenterClass() sharedCommandCenter] changePlaybackPositionCommand] setEnabled:!!client().supportsSeeking()];
+    [[[getMPRemoteCommandCenterClass() sharedCommandCenter] changePlaybackPositionCommand] setEnabled:m_supportsSeeking];
 }
 
 }

Modified: trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h (272747 => 272748)


--- trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -35,6 +35,7 @@
 
 class RemoteCommandListenerMac : public RemoteCommandListener, public CanMakeWeakPtr<RemoteCommandListenerMac> {
 public:
+    static std::unique_ptr<RemoteCommandListenerMac> create(RemoteCommandListenerClient&);
     RemoteCommandListenerMac(RemoteCommandListenerClient&);
     virtual ~RemoteCommandListenerMac();
 

Modified: trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm (272747 => 272748)


--- trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm	2021-02-11 21:49:12 UTC (rev 272748)
@@ -64,7 +64,7 @@
     return { };
 }
 
-std::unique_ptr<RemoteCommandListener> RemoteCommandListener::create(RemoteCommandListenerClient& client)
+std::unique_ptr<RemoteCommandListenerMac> RemoteCommandListenerMac::create(RemoteCommandListenerClient& client)
 {
     return makeUnique<RemoteCommandListenerMac>(client);
 }
@@ -102,12 +102,12 @@
         return;
 
     auto& supportedCommands = !m_registeredCommands.isEmpty() ? m_registeredCommands : defaultCommands();
-    if (m_supportsSeeking == client().supportsSeeking() && m_currentCommands == supportedCommands)
+    if (m_currentCommands == supportedCommands)
         return;
 
     auto commandInfoArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, supportedCommands.size(), &kCFTypeArrayCallBacks));
     for (auto platformCommand : supportedCommands) {
-        if (isSeekCommand(platformCommand) && !client().supportsSeeking())
+        if (isSeekCommand(platformCommand) && !m_supportsSeeking)
             continue;
 
         auto command = mediaRemoteCommandForPlatformCommand(platformCommand);
@@ -123,7 +123,6 @@
 
     MRMediaRemoteSetSupportedCommands(commandInfoArray.get(), MRMediaRemoteGetLocalOrigin(), nullptr, nullptr);
     m_currentCommands = supportedCommands;
-    m_supportsSeeking = client().supportsSeeking();
 }
 
 RemoteCommandListenerMac::RemoteCommandListenerMac(RemoteCommandListenerClient& client)
@@ -140,8 +139,7 @@
         LOG(Media, "RemoteCommandListenerMac::RemoteCommandListenerMac - received command %u", command);
 
         PlatformMediaSession::RemoteControlCommandType platformCommand { PlatformMediaSession::NoCommand };
-        PlatformMediaSession::RemoteCommandArgument argument { 0 };
-        PlatformMediaSession::RemoteCommandArgument* argumentPtr = nullptr;
+        PlatformMediaSession::RemoteCommandArgument argument;
         MRMediaRemoteCommandHandlerStatus status = MRMediaRemoteCommandHandlerStatusSuccess;
 
         switch (command) {
@@ -170,7 +168,7 @@
             platformCommand = PlatformMediaSession::EndSeekingBackwardCommand;
             break;
         case MRMediaRemoteCommandSeekToPlaybackPosition: {
-            if (!client.supportsSeeking()) {
+            if (!m_supportsSeeking) {
                 status = MRMediaRemoteCommandHandlerStatusCommandFailed;
                 break;
             }
@@ -181,21 +179,23 @@
                 break;
             }
 
-            CFNumberGetValue(positionRef, kCFNumberDoubleType, &argument.asDouble);
-            argumentPtr = &argument;
+            double position = 0;
+            CFNumberGetValue(positionRef, kCFNumberDoubleType, &position);
+            argument = position;
             platformCommand = PlatformMediaSession::SeekToPlaybackPositionCommand;
             break;
         }
         case MRMediaRemoteCommandSkipForward:
         case MRMediaRemoteCommandSkipBackward:
-            if (!client.supportsSeeking()) {
+            if (!m_supportsSeeking) {
                 status = MRMediaRemoteCommandHandlerStatusCommandFailed;
                 break;
             }
 
             if (auto positionRef = static_cast<CFNumberRef>(CFDictionaryGetValue(options, kMRMediaRemoteOptionSkipInterval))) {
-                CFNumberGetValue(positionRef, kCFNumberDoubleType, &argument.asDouble);
-                argumentPtr = &argument;
+                double position = 0;
+                CFNumberGetValue(positionRef, kCFNumberDoubleType, &position);
+                argument = position;
             }
 
             platformCommand = (command == MRMediaRemoteCommandSkipForward) ? PlatformMediaSession::SkipForwardCommand : PlatformMediaSession::SkipBackwardCommand;
@@ -212,7 +212,7 @@
         };
 
         if (weakThis && status != MRMediaRemoteCommandHandlerStatusCommandFailed)
-            weakThis->m_client.didReceiveRemoteControlCommand(platformCommand, argumentPtr);
+            weakThis->m_client.didReceiveRemoteControlCommand(platformCommand, argument);
 
         completion((__bridge CFArrayRef)@[@(status)]);
     });

Modified: trunk/Source/WebCore/testing/Internals.cpp (272747 => 272748)


--- trunk/Source/WebCore/testing/Internals.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebCore/testing/Internals.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -4305,7 +4305,7 @@
     else
         return Exception { InvalidAccessError };
 
-    PlatformMediaSessionManager::sharedManager().processDidReceiveRemoteControlCommand(command, &parameter);
+    PlatformMediaSessionManager::sharedManager().processDidReceiveRemoteControlCommand(command, parameter);
     return { };
 }
 

Modified: trunk/Source/WebKit/CMakeLists.txt (272747 => 272748)


--- trunk/Source/WebKit/CMakeLists.txt	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/CMakeLists.txt	2021-02-11 21:49:12 UTC (rev 272748)
@@ -138,6 +138,7 @@
     GPUProcess/media/RemoteMediaPlayerProxy
     GPUProcess/media/RemoteMediaResourceManager
     GPUProcess/media/RemoteMediaSourceProxy
+    GPUProcess/media/RemoteRemoteCommandListenerProxy
     GPUProcess/media/RemoteSourceBufferProxy
 
     GPUProcess/webrtc/LibWebRTCCodecsProxy
@@ -230,6 +231,7 @@
     WebProcess/GPU/media/RemoteCDMInstance
     WebProcess/GPU/media/RemoteCDMInstanceSession
     WebProcess/GPU/media/RemoteLegacyCDMSession
+    WebProcess/GPU/media/RemoteRemoteCommandListener
     WebProcess/GPU/media/SourceBufferPrivateRemote
 
     WebProcess/GPU/webrtc/LibWebRTCCodecs

Modified: trunk/Source/WebKit/ChangeLog (272747 => 272748)


--- trunk/Source/WebKit/ChangeLog	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/ChangeLog	2021-02-11 21:49:12 UTC (rev 272748)
@@ -1,3 +1,47 @@
+2021-02-11  Jer Noble  <[email protected]>
+
+        [Cocoa][GPUP] Move RemoteCommandListener into the GPU Process
+        https://bugs.webkit.org/show_bug.cgi?id=221732
+
+        Reviewed by Eric Carlson.
+
+        Add a new Remote/Proxy class pair to facilitate RemoteCommandListener being
+        created in the GPU Process.
+
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * GPUProcess/GPUConnectionToWebProcess.cpp:
+        (WebKit::GPUConnectionToWebProcess::createRemoteCommandListener):
+        (WebKit::GPUConnectionToWebProcess::releaseRemoteCommandListener):
+        * GPUProcess/GPUConnectionToWebProcess.h:
+        * GPUProcess/GPUConnectionToWebProcess.messages.in:
+        * GPUProcess/media/RemoteRemoteCommandListenerProxy.cpp:
+        (WebKit::RemoteRemoteCommandListenerProxy::RemoteRemoteCommandListenerProxy):
+        (WebKit::RemoteRemoteCommandListenerProxy::didReceiveRemoteControlCommand):
+        (WebKit::RemoteRemoteCommandListenerProxy::updateSupportedCommands):
+        * GPUProcess/media/RemoteRemoteCommandListenerProxy.h:
+        * GPUProcess/media/RemoteRemoteCommandListenerProxy.messages.in:
+        * Scripts/webkit/messages.py:
+        * Sources.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/GPU/GPUProcessConnection.cpp:
+        (WebKit::GPUProcessConnection::didReceiveRemoteCommand):
+        * WebProcess/GPU/media/RemoteRemoteCommandListener.cpp: Added.
+        (WebKit::RemoteRemoteCommandListener::create):
+        (WebKit::RemoteRemoteCommandListener::RemoteRemoteCommandListener):
+        (WebKit::RemoteRemoteCommandListener::~RemoteRemoteCommandListener):
+        (WebKit::RemoteRemoteCommandListener::gpuProcessConnectionDidClose):
+        (WebKit::RemoteRemoteCommandListener::didReceiveRemoteControlCommand):
+        * WebProcess/GPU/media/RemoteRemoteCommandListener.h:
+        * WebProcess/GPU/media/RemoteRemoteCommandListener.messages.in:
+        * WebProcess/GPU/media/RemoteRemoteCommandListenerIdentifier.h:
+        * WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp:
+        (WebKit::RemoteMediaSessionHelper::activeVideoRouteDidChange):
+        * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::setUseGPUProcessForMedia):
+
 2021-02-11  Darin Adler  <[email protected]>
 
         [Cocoa] IPC decoder is using decoded size to allocate memory for an array

Modified: trunk/Source/WebKit/DerivedSources-input.xcfilelist (272747 => 272748)


--- trunk/Source/WebKit/DerivedSources-input.xcfilelist	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/DerivedSources-input.xcfilelist	2021-02-11 21:49:12 UTC (rev 272748)
@@ -40,6 +40,7 @@
 $(PROJECT_DIR)/GPUProcess/media/RemoteMediaPlayerProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteMediaResourceManager.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteMediaSourceProxy.messages.in
+$(PROJECT_DIR)/GPUProcess/media/RemoteRemoteCommandListenerProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteSourceBufferProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteTextTrackProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteVideoTrackProxy.messages.in
@@ -150,6 +151,7 @@
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteImageDecoderAVF.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteImageDecoderAVFManager.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteLegacyCDMSession.messages.in
+$(PROJECT_DIR)/WebProcess/GPU/media/RemoteRemoteCommandListener.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/webrtc/LibWebRTCCodecs.messages.in

Modified: trunk/Source/WebKit/DerivedSources-output.xcfilelist (272747 => 272748)


--- trunk/Source/WebKit/DerivedSources-output.xcfilelist	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/DerivedSources-output.xcfilelist	2021-02-11 21:49:12 UTC (rev 272748)
@@ -247,6 +247,12 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteObjectRegistryMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteObjectRegistryMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteObjectRegistryMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteRemoteCommandListenerMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteRemoteCommandListenerMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteRemoteCommandListenerMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteRemoteCommandListenerProxyMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteRemoteCommandListenerProxyMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteRemoteCommandListenerProxyMessagesReplies.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteRenderingBackendMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteRenderingBackendMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteRenderingBackendMessagesReplies.h

Modified: trunk/Source/WebKit/DerivedSources.make (272747 => 272748)


--- trunk/Source/WebKit/DerivedSources.make	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/DerivedSources.make	2021-02-11 21:49:12 UTC (rev 272748)
@@ -185,6 +185,7 @@
 	WebProcess/GPU/media/RemoteCDMInstanceSession \
 	WebProcess/GPU/media/RemoteImageDecoderAVFManager \
 	WebProcess/GPU/media/RemoteLegacyCDMSession \
+	WebProcess/GPU/media/RemoteRemoteCommandListener \
 	WebProcess/GPU/media/SourceBufferPrivateRemote \
 	WebProcess/GPU/media/ios/RemoteMediaSessionHelper \
 	WebProcess/WebStorage/StorageAreaMap \
@@ -259,6 +260,7 @@
 	GPUProcess/media/RemoteMediaPlayerProxy \
 	GPUProcess/media/RemoteMediaResourceManager \
 	GPUProcess/media/RemoteMediaSourceProxy \
+	GPUProcess/media/RemoteRemoteCommandListenerProxy \
 	GPUProcess/media/RemoteSourceBufferProxy \
 	WebAuthnProcess/WebAuthnConnectionToWebProcess \
 	WebAuthnProcess/WebAuthnProcess \

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (272747 => 272748)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -48,6 +48,7 @@
 #include "RemoteMediaRecorderMessages.h"
 #include "RemoteMediaResourceManager.h"
 #include "RemoteMediaResourceManagerMessages.h"
+#include "RemoteRemoteCommandListenerProxy.h"
 #include "RemoteRenderingBackend.h"
 #include "RemoteSampleBufferDisplayLayerManager.h"
 #include "RemoteSampleBufferDisplayLayerManagerMessages.h"
@@ -419,6 +420,20 @@
     ASSERT_UNUSED(found, found);
 }
 
+void GPUConnectionToWebProcess::createRemoteCommandListener(RemoteRemoteCommandListenerIdentifier identifier)
+{
+    auto addResult = m_remoteRemoteCommandListenerMap.ensure(identifier, [&]() {
+        return makeUnique<RemoteRemoteCommandListenerProxy>(*this, WTFMove(identifier));
+    });
+    ASSERT_UNUSED(addResult, addResult.isNewEntry);
+}
+
+void GPUConnectionToWebProcess::releaseRemoteCommandListener(RemoteRemoteCommandListenerIdentifier identifier)
+{
+    bool found = m_remoteRemoteCommandListenerMap.remove(identifier);
+    ASSERT_UNUSED(found, found);
+}
+
 bool GPUConnectionToWebProcess::dispatchMessage(IPC::Connection& connection, IPC::Decoder& decoder)
 {
 #if ENABLE(WEB_AUDIO)

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (272747 => 272748)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -32,6 +32,7 @@
 #include "MessageReceiverMap.h"
 #include "RemoteAudioHardwareListenerIdentifier.h"
 #include "RemoteAudioSessionIdentifier.h"
+#include "RemoteRemoteCommandListenerIdentifier.h"
 #include "RenderingBackendIdentifier.h"
 
 #include <WebCore/LibWebRTCEnumTraits.h>
@@ -63,6 +64,7 @@
 class RemoteMediaRecorderManager;
 class RemoteMediaResourceManager;
 class RemoteMediaSessionHelperProxy;
+class RemoteRemoteCommandListenerProxy;
 class RemoteRenderingBackend;
 class RemoteGraphicsContextGL;
 class RemoteSampleBufferDisplayLayerManager;
@@ -160,6 +162,8 @@
 
     void createAudioHardwareListener(RemoteAudioHardwareListenerIdentifier);
     void releaseAudioHardwareListener(RemoteAudioHardwareListenerIdentifier);
+    void createRemoteCommandListener(RemoteRemoteCommandListenerIdentifier);
+    void releaseRemoteCommandListener(RemoteRemoteCommandListenerIdentifier);
 
     // IPC::Connection::Client
     void didClose(IPC::Connection&) final;
@@ -238,6 +242,8 @@
 
     using RemoteAudioHardwareListenerMap = HashMap<RemoteAudioHardwareListenerIdentifier, std::unique_ptr<RemoteAudioHardwareListenerProxy>>;
     RemoteAudioHardwareListenerMap m_remoteAudioHardwareListenerMap;
+    using RemoteRemoteCommandListenerMap = HashMap<RemoteRemoteCommandListenerIdentifier, std::unique_ptr<RemoteRemoteCommandListenerProxy>>;
+    RemoteRemoteCommandListenerMap m_remoteRemoteCommandListenerMap;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in (272747 => 272748)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in	2021-02-11 21:49:12 UTC (rev 272748)
@@ -42,6 +42,8 @@
 #endif
     CreateAudioHardwareListener(WebKit::RemoteAudioHardwareListenerIdentifier identifier)
     ReleaseAudioHardwareListener(WebKit::RemoteAudioHardwareListenerIdentifier identifier)
+    CreateRemoteCommandListener(WebKit::RemoteRemoteCommandListenerIdentifier identifier)
+    ReleaseRemoteCommandListener(WebKit::RemoteRemoteCommandListenerIdentifier identifier)
 }
 
 #endif // ENABLE(GPU_PROCESS)

Copied: trunk/Source/WebKit/GPUProcess/media/RemoteRemoteCommandListenerProxy.cpp (from rev 272747, trunk/Source/WebCore/platform/NowPlayingManager.h) (0 => 272748)


--- trunk/Source/WebKit/GPUProcess/media/RemoteRemoteCommandListenerProxy.cpp	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteRemoteCommandListenerProxy.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RemoteRemoteCommandListenerProxy.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "GPUConnectionToWebProcess.h"
+#include "RemoteRemoteCommandListenerMessages.h"
+
+namespace WebKit {
+
+using namespace WebCore;
+
+RemoteRemoteCommandListenerProxy::RemoteRemoteCommandListenerProxy(GPUConnectionToWebProcess& gpuConnection, RemoteRemoteCommandListenerIdentifier&& identifier)
+    : m_gpuConnection(gpuConnection)
+    , m_identifier(WTFMove(identifier))
+    , m_listener(WebCore::RemoteCommandListener::create(*this))
+{
+}
+
+RemoteRemoteCommandListenerProxy::~RemoteRemoteCommandListenerProxy() = default;
+
+void RemoteRemoteCommandListenerProxy::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument& argument)
+{
+    m_gpuConnection.connection().send(Messages::RemoteRemoteCommandListener::DidReceiveRemoteControlCommand(command, argument), m_identifier);
+}
+
+void RemoteRemoteCommandListenerProxy::updateSupportedCommands(bool supportsSeeking)
+{
+    m_listener->setSupportsSeeking(supportsSeeking);
+    m_listener->updateSupportedCommands();
+}
+
+}
+
+#endif

Copied: trunk/Source/WebKit/GPUProcess/media/RemoteRemoteCommandListenerProxy.h (from rev 272747, trunk/Source/WebCore/platform/NowPlayingManager.h) (0 => 272748)


--- trunk/Source/WebKit/GPUProcess/media/RemoteRemoteCommandListenerProxy.h	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteRemoteCommandListenerProxy.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS)
+
+#include "MessageReceiver.h"
+#include "RemoteRemoteCommandListenerIdentifier.h"
+#include <WebCore/RemoteCommandListener.h>
+#include <wtf/UniqueRef.h>
+
+namespace IPC {
+class Connection;
+}
+
+namespace WebKit {
+
+class GPUConnectionToWebProcess;
+
+class RemoteRemoteCommandListenerProxy
+    : private WebCore::RemoteCommandListenerClient
+    , private IPC::MessageReceiver {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    RemoteRemoteCommandListenerProxy(GPUConnectionToWebProcess&, RemoteRemoteCommandListenerIdentifier&&);
+    virtual ~RemoteRemoteCommandListenerProxy();
+
+private:
+    // IPC::MessageReceiver
+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+
+    // RemoteCommandListenerClient
+    void didReceiveRemoteControlCommand(WebCore::PlatformMediaSession::RemoteControlCommandType, const WebCore::PlatformMediaSession::RemoteCommandArgument&) final;
+
+    // Messages
+    void updateSupportedCommands(bool supportsSeeking);
+
+    GPUConnectionToWebProcess& m_gpuConnection;
+    RemoteRemoteCommandListenerIdentifier m_identifier;
+    std::unique_ptr<WebCore::RemoteCommandListener> m_listener;
+};
+
+}
+
+#endif

Copied: trunk/Source/WebKit/GPUProcess/media/RemoteRemoteCommandListenerProxy.messages.in (from rev 272747, trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h) (0 => 272748)


--- trunk/Source/WebKit/GPUProcess/media/RemoteRemoteCommandListenerProxy.messages.in	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteRemoteCommandListenerProxy.messages.in	2021-02-11 21:49:12 UTC (rev 272748)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if ENABLE(GPU_PROCESS)
+
+messages -> RemoteRemoteCommandListenerProxy NotRefCounted {
+    UpdateSupportedCommands(bool supportsSeeking)
+}
+
+#endif

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (272747 => 272748)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2021-02-11 21:49:12 UTC (rev 272748)
@@ -317,6 +317,7 @@
         'WebKit::RemoteLegacyCDMSessionIdentifier',
         'WebKit::RemoteMediaResourceIdentifier',
         'WebKit::RemoteMediaSourceIdentifier',
+        'WebKit::RemoteRemoteCommandListenerIdentifier',
         'WebKit::RemoteSourceBufferIdentifier',
         'WebKit::RenderingBackendIdentifier',
         'WebKit::RTCDecoderIdentifier',

Modified: trunk/Source/WebKit/Sources.txt (272747 => 272748)


--- trunk/Source/WebKit/Sources.txt	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/Sources.txt	2021-02-11 21:49:12 UTC (rev 272748)
@@ -46,6 +46,7 @@
 GPUProcess/media/RemoteMediaResourceLoader.cpp
 GPUProcess/media/RemoteMediaResourceManager.cpp
 GPUProcess/media/RemoteMediaSourceProxy.cpp
+GPUProcess/media/RemoteRemoteCommandListenerProxy.cpp
 GPUProcess/media/RemoteSourceBufferProxy.cpp
 GPUProcess/media/RemoteTextTrackProxy.cpp
 GPUProcess/media/RemoteVideoTrackProxy.cpp
@@ -599,6 +600,7 @@
 WebProcess/GPU/media/RemoteMediaPlayerManager.cpp
 WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp @no-unify
 WebProcess/GPU/media/RemoteMediaResourceProxy.cpp
+WebProcess/GPU/media/RemoteRemoteCommandListener.cpp
 WebProcess/GPU/media/SourceBufferPrivateRemote.cpp
 WebProcess/GPU/media/TextTrackPrivateRemote.cpp
 WebProcess/GPU/media/VideoTrackPrivateRemote.cpp

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (272747 => 272748)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-02-11 21:49:12 UTC (rev 272748)
@@ -1861,6 +1861,8 @@
 		CD78E1151DB7D7ED0014A2DE /* FullscreenClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD78E1131DB7D7ED0014A2DE /* FullscreenClient.h */; };
 		CD78E1171DB7DC0A0014A2DE /* APIFullscreenClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD78E1161DB7DC0A0014A2DE /* APIFullscreenClient.h */; };
 		CD78E1191DB7E5AD0014A2DE /* _WKFullscreenDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD78E1181DB7E5AD0014A2DE /* _WKFullscreenDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		CD8252DE25D4916C00862FD8 /* RemoteRemoteCommandListenerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD8252DA25D4915400862FD8 /* RemoteRemoteCommandListenerProxyMessageReceiver.cpp */; };
+		CD8252E225D4919100862FD8 /* RemoteRemoteCommandListenerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD8252E025D4918400862FD8 /* RemoteRemoteCommandListenerMessageReceiver.cpp */; };
 		CDA041F41ACE2105004A13EC /* BackBoardServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA041F31ACE2105004A13EC /* BackBoardServicesSPI.h */; };
 		CDA29A1B1CBDBF4100901CCF /* PlaybackSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A191CBDBF4100901CCF /* PlaybackSessionManager.h */; };
 		CDA29A201CBEB5FB00901CCF /* PlaybackSessionManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A1E1CBEB5FB00901CCF /* PlaybackSessionManagerProxy.h */; };
@@ -5550,6 +5552,19 @@
 		CD78E1131DB7D7ED0014A2DE /* FullscreenClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullscreenClient.h; sourceTree = "<group>"; };
 		CD78E1161DB7DC0A0014A2DE /* APIFullscreenClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIFullscreenClient.h; sourceTree = "<group>"; };
 		CD78E1181DB7E5AD0014A2DE /* _WKFullscreenDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKFullscreenDelegate.h; sourceTree = "<group>"; };
+		CD8252D125D464AB00862FD8 /* RemoteRemoteCommandListener.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRemoteCommandListener.h; sourceTree = "<group>"; };
+		CD8252D225D464AB00862FD8 /* RemoteRemoteCommandListener.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteRemoteCommandListener.cpp; sourceTree = "<group>"; };
+		CD8252D325D464BF00862FD8 /* RemoteRemoteCommandListener.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteRemoteCommandListener.messages.in; sourceTree = "<group>"; };
+		CD8252D425D4651000862FD8 /* RemoteRemoteCommandListenerIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRemoteCommandListenerIdentifier.h; sourceTree = "<group>"; };
+		CD8252D525D4763100862FD8 /* RemoteRemoteCommandListenerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRemoteCommandListenerProxy.h; sourceTree = "<group>"; };
+		CD8252D625D4763100862FD8 /* RemoteRemoteCommandListenerProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteRemoteCommandListenerProxy.cpp; sourceTree = "<group>"; };
+		CD8252D725D4765900862FD8 /* RemoteRemoteCommandListenerProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteRemoteCommandListenerProxy.messages.in; sourceTree = "<group>"; };
+		CD8252D825D4915300862FD8 /* RemoteRemoteCommandListenerProxyMessagesReplies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteRemoteCommandListenerProxyMessagesReplies.h; sourceTree = "<group>"; };
+		CD8252D925D4915400862FD8 /* RemoteRemoteCommandListenerProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteRemoteCommandListenerProxyMessages.h; sourceTree = "<group>"; };
+		CD8252DA25D4915400862FD8 /* RemoteRemoteCommandListenerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteRemoteCommandListenerProxyMessageReceiver.cpp; sourceTree = "<group>"; };
+		CD8252DF25D4918400862FD8 /* RemoteRemoteCommandListenerMessagesReplies.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRemoteCommandListenerMessagesReplies.h; sourceTree = "<group>"; };
+		CD8252E025D4918400862FD8 /* RemoteRemoteCommandListenerMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteRemoteCommandListenerMessageReceiver.cpp; sourceTree = "<group>"; };
+		CD8252E125D4918500862FD8 /* RemoteRemoteCommandListenerMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRemoteCommandListenerMessages.h; sourceTree = "<group>"; };
 		CDA041F31ACE2105004A13EC /* BackBoardServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackBoardServicesSPI.h; sourceTree = "<group>"; };
 		CDA29A181CBDBF4100901CCF /* PlaybackSessionManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlaybackSessionManager.mm; sourceTree = "<group>"; };
 		CDA29A191CBDBF4100901CCF /* PlaybackSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaybackSessionManager.h; sourceTree = "<group>"; };
@@ -6032,6 +6047,10 @@
 				1D32F89D23A84C5B00B1EA6A /* RemoteMediaResourceProxy.cpp */,
 				1D32F89B23A84BA600B1EA6A /* RemoteMediaResourceProxy.h */,
 				1DD2A646255F32B100FF7B6F /* RemoteMediaSourceIdentifier.h */,
+				CD8252D125D464AB00862FD8 /* RemoteRemoteCommandListener.h */,
+				CD8252D225D464AB00862FD8 /* RemoteRemoteCommandListener.cpp */,
+				CD8252D325D464BF00862FD8 /* RemoteRemoteCommandListener.messages.in */,
+				CD8252D425D4651000862FD8 /* RemoteRemoteCommandListenerIdentifier.h */,
 				1DD2A63A255DE6D100FF7B6F /* SourceBufferPrivateRemote.cpp */,
 				1DD2A639255DE6D100FF7B6F /* SourceBufferPrivateRemote.h */,
 				1DD2A66F25622F1100FF7B6F /* SourceBufferPrivateRemote.messages.in */,
@@ -6112,6 +6131,9 @@
 				1DD2A63F255E3F1F00FF7B6F /* RemoteMediaSourceProxy.cpp */,
 				1DD2A63E255E3F1F00FF7B6F /* RemoteMediaSourceProxy.h */,
 				1DD2A64A2560F54C00FF7B6F /* RemoteMediaSourceProxy.messages.in */,
+				CD8252D525D4763100862FD8 /* RemoteRemoteCommandListenerProxy.h */,
+				CD8252D625D4763100862FD8 /* RemoteRemoteCommandListenerProxy.cpp */,
+				CD8252D725D4765900862FD8 /* RemoteRemoteCommandListenerProxy.messages.in */,
 				1DD2A6682561F68400FF7B6F /* RemoteSourceBufferIdentifier.h */,
 				1DD2A643255E3F3D00FF7B6F /* RemoteSourceBufferProxy.cpp */,
 				1DD2A642255E3F3D00FF7B6F /* RemoteSourceBufferProxy.h */,
@@ -10892,6 +10914,12 @@
 				1DD2A661256122F100FF7B6F /* RemoteMediaSourceProxyMessagesReplies.h */,
 				1AC1338318590C4600F3EC05 /* RemoteObjectRegistryMessageReceiver.cpp */,
 				1AC1338418590C4600F3EC05 /* RemoteObjectRegistryMessages.h */,
+				CD8252E025D4918400862FD8 /* RemoteRemoteCommandListenerMessageReceiver.cpp */,
+				CD8252E125D4918500862FD8 /* RemoteRemoteCommandListenerMessages.h */,
+				CD8252DF25D4918400862FD8 /* RemoteRemoteCommandListenerMessagesReplies.h */,
+				CD8252DA25D4915400862FD8 /* RemoteRemoteCommandListenerProxyMessageReceiver.cpp */,
+				CD8252D925D4915400862FD8 /* RemoteRemoteCommandListenerProxyMessages.h */,
+				CD8252D825D4915300862FD8 /* RemoteRemoteCommandListenerProxyMessagesReplies.h */,
 				0F5947A5187B517600437857 /* RemoteScrollingCoordinatorMessageReceiver.cpp */,
 				0F5947A6187B517600437857 /* RemoteScrollingCoordinatorMessages.h */,
 				1DD2A66B2562021E00FF7B6F /* RemoteSourceBufferProxyMessageReceiver.cpp */,
@@ -13770,6 +13798,7 @@
 				51F060E11654318500F3281E /* NetworkRTCMonitorMessageReceiver.cpp in Sources */,
 				4176901422FDD41B00B1576D /* NetworkRTCProvider.mm in Sources */,
 				51F060E11654318500F3282E /* NetworkRTCProviderMessageReceiver.cpp in Sources */,
+				CD8252DE25D4916C00862FD8 /* RemoteRemoteCommandListenerProxyMessageReceiver.cpp in Sources */,
 				31F060E11654318500F3281C /* NetworkSocketChannelMessageReceiver.cpp in Sources */,
 				5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */,
 				2D92A790212B6AD400F493FD /* NPIdentifierData.cpp in Sources */,
@@ -13911,6 +13940,7 @@
 				2D11B78D2126A283006F8878 /* UnifiedSource31-mm.mm in Sources */,
 				2D11B78F2126A283006F8878 /* UnifiedSource32-mm.mm in Sources */,
 				2D11B7902126A283006F8878 /* UnifiedSource32.cpp in Sources */,
+				CD8252E225D4919100862FD8 /* RemoteRemoteCommandListenerMessageReceiver.cpp in Sources */,
 				2D11B7912126A283006F8878 /* UnifiedSource33-mm.mm in Sources */,
 				2D11B7922126A283006F8878 /* UnifiedSource33.cpp in Sources */,
 				2D11B7942126A283006F8878 /* UnifiedSource34.cpp in Sources */,

Modified: trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp (272747 => 272748)


--- trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -191,8 +191,7 @@
 
 void GPUProcessConnection::didReceiveRemoteCommand(PlatformMediaSession::RemoteControlCommandType type, Optional<double> argument)
 {
-    const PlatformMediaSession::RemoteCommandArgument value { argument ? *argument : 0 };
-    PlatformMediaSessionManager::sharedManager().processDidReceiveRemoteControlCommand(type, argument ? &value : nullptr);
+    PlatformMediaSessionManager::sharedManager().processDidReceiveRemoteControlCommand(type, argument);
 }
 
 void GPUProcessConnection::updateParameters(const WebPageCreationParameters& parameters)

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.cpp (0 => 272748)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.cpp	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RemoteRemoteCommandListener.h"
+
+#if ENABLE(GPU_PROCESS)
+
+#include "GPUConnectionToWebProcessMessages.h"
+#include "GPUProcessProxy.h"
+#include "RemoteRemoteCommandListenerMessages.h"
+#include "WebProcess.h"
+
+namespace WebKit {
+
+using namespace WebCore;
+
+std::unique_ptr<RemoteRemoteCommandListener> RemoteRemoteCommandListener::create(RemoteCommandListenerClient& client, WebProcess& webProcess)
+{
+    return makeUnique<RemoteRemoteCommandListener>(client, webProcess);
+}
+
+RemoteRemoteCommandListener::RemoteRemoteCommandListener(RemoteCommandListenerClient& client, WebProcess& webProcess)
+    : RemoteCommandListener(client)
+    , m_process(webProcess)
+    , m_identifier(RemoteRemoteCommandListenerIdentifier::generate())
+{
+    auto& connection = WebProcess::singleton().ensureGPUProcessConnection();
+    connection.addClient(*this);
+    connection.messageReceiverMap().addMessageReceiver(Messages::RemoteRemoteCommandListener::messageReceiverName(), m_identifier.toUInt64(), *this);
+    connection.connection().send(Messages::GPUConnectionToWebProcess::CreateRemoteCommandListener(m_identifier), { });
+}
+
+RemoteRemoteCommandListener::~RemoteRemoteCommandListener()
+{
+    auto& connection = WebProcess::singleton().ensureGPUProcessConnection();
+    connection.messageReceiverMap().removeMessageReceiver(*this);
+    connection.connection().send(Messages::GPUConnectionToWebProcess::ReleaseRemoteCommandListener(m_identifier), 0);
+}
+
+void RemoteRemoteCommandListener::gpuProcessConnectionDidClose(GPUProcessConnection&)
+{
+}
+
+void RemoteRemoteCommandListener::didReceiveRemoteControlCommand(WebCore::PlatformMediaSession::RemoteControlCommandType type, const PlatformMediaSession::RemoteCommandArgument& argument)
+{
+    m_client.didReceiveRemoteControlCommand(type, argument);
+}
+
+}
+
+#endif

Copied: trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.h (from rev 272747, trunk/Source/WebCore/platform/NowPlayingManager.h) (0 => 272748)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS)
+
+#include "GPUProcessConnection.h"
+#include "MessageReceiver.h"
+#include "RemoteRemoteCommandListenerIdentifier.h"
+#include <WebCore/RemoteCommandListener.h>
+
+namespace IPC {
+class Connection;
+}
+
+namespace WebKit {
+
+class GPUProcessConnection;
+class WebProcess;
+
+class RemoteRemoteCommandListener final
+    : public WebCore::RemoteCommandListener
+    , private GPUProcessConnection::Client
+    , private IPC::MessageReceiver {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    static std::unique_ptr<RemoteRemoteCommandListener> create(WebCore::RemoteCommandListenerClient&, WebProcess&);
+    RemoteRemoteCommandListener(WebCore::RemoteCommandListenerClient&, WebProcess&);
+    ~RemoteRemoteCommandListener();
+
+private:
+    // IPC::MessageReceiver
+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+
+    // GPUProcessConnection::Client
+    void gpuProcessConnectionDidClose(GPUProcessConnection&) final;
+
+    // Messages
+    void didReceiveRemoteControlCommand(WebCore::PlatformMediaSession::RemoteControlCommandType, const WebCore::PlatformMediaSession::RemoteCommandArgument&);
+
+    WebProcess& m_process;
+    RemoteRemoteCommandListenerIdentifier m_identifier;
+};
+
+}
+
+#endif

Copied: trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.messages.in (from rev 272747, trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h) (0 => 272748)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.messages.in	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.messages.in	2021-02-11 21:49:12 UTC (rev 272748)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if ENABLE(GPU_PROCESS)
+
+messages -> RemoteRemoteCommandListener NotRefCounted {
+    DidReceiveRemoteControlCommand(enum:uint8_t WebCore::PlatformMediaSession::RemoteControlCommandType command, Optional<double> argument)
+}
+
+#endif

Copied: trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListenerIdentifier.h (from rev 272747, trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h) (0 => 272748)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListenerIdentifier.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListenerIdentifier.h	2021-02-11 21:49:12 UTC (rev 272748)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS)
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebKit {
+
+enum RemoteRemoteCommandListenerIdentifierType { };
+using RemoteRemoteCommandListenerIdentifier = ObjectIdentifier<RemoteRemoteCommandListenerIdentifierType>;
+
+} // namespace WebKit
+
+#endif

Modified: trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp (272747 => 272748)


--- trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -139,7 +139,7 @@
 {
     RefPtr<MediaPlaybackTarget> targetObject;
     if (targetContext.type() == MediaPlaybackTargetContext::AVOutputContextType)
-        targetObject = WebCore::MediaPlaybackTargetCocoa::create(targetContext.avOutputContext());
+        m_playbackTarget = WebCore::MediaPlaybackTargetCocoa::create(targetContext.avOutputContext());
     else {
         ASSERT_NOT_REACHED();
         return;
@@ -146,7 +146,7 @@
     }
 
     for (auto& client : m_clients)
-        client.activeVideoRouteDidChange(supportsAirPlayVideo, targetObject.copyRef().releaseNonNull());
+        client.activeVideoRouteDidChange(supportsAirPlayVideo, *m_playbackTarget);
 }
 
 }

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (272747 => 272748)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-02-11 21:38:10 UTC (rev 272747)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-02-11 21:49:12 UTC (rev 272748)
@@ -47,6 +47,7 @@
 #include "RemoteAudioSession.h"
 #include "RemoteLegacyCDMFactory.h"
 #include "RemoteMediaEngineConfigurationFactory.h"
+#include "RemoteRemoteCommandListener.h"
 #include "SpeechRecognitionRealtimeMediaSourceManager.h"
 #include "StorageAreaMap.h"
 #include "UserData.h"
@@ -122,6 +123,7 @@
 #include <WebCore/PlatformMediaSessionManager.h>
 #include <WebCore/ProcessWarming.h>
 #include <WebCore/RegistrableDomain.h>
+#include <WebCore/RemoteCommandListener.h>
 #include <WebCore/ResourceLoadStatistics.h>
 #include <WebCore/RuntimeApplicationChecks.h>
 #include <WebCore/RuntimeEnabledFeatures.h>
@@ -1958,6 +1960,11 @@
         WebCore::AudioHardwareListener::setCreationFunction([this] (WebCore::AudioHardwareListener::Client& client) { return RemoteAudioHardwareListener::create(client, *this); });
     else
         WebCore::AudioHardwareListener::resetCreationFunction();
+
+    if (useGPUProcessForMedia)
+        WebCore::RemoteCommandListener::setCreationFunction([this] (WebCore::RemoteCommandListenerClient& client) { return RemoteRemoteCommandListener::create(client, *this); });
+    else
+        WebCore::RemoteCommandListener::resetCreationFunction();
 }
 
 bool WebProcess::shouldUseRemoteRenderingFor(RenderingPurpose purpose)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to