Title: [274829] trunk/Source
Revision
274829
Author
[email protected]
Date
2021-03-22 17:43:11 -0700 (Mon, 22 Mar 2021)

Log Message

Source/WebCore:
Move management of RemoteCommandListener from MediaSessionManagerCocoa into NowPlayingManager.
https://bugs.webkit.org/show_bug.cgi?id=223435
<rdar://problem/75567198>

Patch by Jean-Yves Avenard <[email protected]> on 2021-03-22
Reviewed by Eric Carlson.

NowPlaying and RemoteCommandListener kind of do the same things, as such it make sense to combine the two
and hide the implementation details from consumers.
We move the handling of setting and clearing the NowPlayingInfo information to an expanded
NowPlayingManager which now also runs in the webcontent process.
The job to ensure a RemoteCommandListener is set is now up to the NowPlayingManager as well as
dealing with changes in NowPlayingInfo content.
Ideally we would prefer to remove all code related to MediaRemote from MediaSessionManagerCocoa;
however for ease we leave it there to avoid having to deal with objective-C interface in NowPlayingManager.
No change in observable behavior.

* platform/MediaStrategy.h: The two existing methods dealing with NowPlayingInfo are removed, instead we can override the entire creation of the NowPlayingManager.
* platform/MediaStrategy.cpp:
(WebCore::MediaStrategy::createNowPlayingManager const): default implementation for createNowPlayingManager
* platform/NowPlayingManager.cpp: Add methods used in MediaSessionManagerCocoa used to deal with RemoteCommandListener.
(WebCore::NowPlayingManager::didReceiveRemoteControlCommand):
(WebCore::NowPlayingManager::addClient): Add explicit method to add a RemoteCommandListener listener, to be called before calling setNowPlayingInfo if needed.
(WebCore::NowPlayingManager::removeClient): renamed from clearNowPlayingInfoClient.
(WebCore::NowPlayingManager::clearNowPlayingInfo):
(WebCore::NowPlayingManager::clearNowPlayingInfoPrivate): Virtual class with default implementation which will immediately communicate with MediaRemote.
(WebCore::NowPlayingManager::setNowPlayingInfo):
(WebCore::NowPlayingManager::setNowPlayingInfoPrivate):  Virtual class with default implementation which will immediately communicate with MediaRemote.
(WebCore::NowPlayingManager::setSupportsSeeking): We explicitly set a different setSupportsSeeking method for code clarity.
(WebCore::NowPlayingManager::addSupportedCommand):
(WebCore::NowPlayingManager::removeSupportedCommand):
(WebCore::NowPlayingManager::setSupportedRemoteCommands):
(WebCore::NowPlayingManager::updateSupportedCommands):
(WebCore::NowPlayingManager::ensureRemoteCommandListenerCreated):
(WebCore::NowPlayingManager::clearNowPlayingInfoClient): Deleted.
* platform/NowPlayingManager.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.h: Remove now unused members
* platform/audio/cocoa/MediaSessionManagerCocoa.mm: Amended to use new NowPlayingManager.
(WebCore::MediaSessionManagerCocoa::MediaSessionManagerCocoa):
(WebCore::MediaSessionManagerCocoa::scheduleSessionStatusUpdate):
(WebCore::MediaSessionManagerCocoa::addSession):
(WebCore::MediaSessionManagerCocoa::removeSession):
(WebCore::MediaSessionManagerCocoa::setCurrentSession):
(WebCore::MediaSessionManagerCocoa::addSupportedCommand):
(WebCore::MediaSessionManagerCocoa::removeSupportedCommand):
(WebCore::MediaSessionManagerCocoa::updateNowPlayingInfo):

Source/WebKit:
Move management of RemoteCommandListener from MediaSessionManagerCocoa into NowPlayingManager
https://bugs.webkit.org/show_bug.cgi?id=223435
<rdar://problem/75567198>

Patch by Jean-Yves Avenard <[email protected]> on 2021-03-22
Reviewed by Eric Carlson.

* GPUProcess/GPUConnectionToWebProcess.cpp: Update methods to use new NowPlayingManager API.
(WebKit::GPUConnectionToWebProcess::clearNowPlayingInfo):
(WebKit::GPUConnectionToWebProcess::setNowPlayingInfo):
(WebKit::GPUConnectionToWebProcess::updateSupportedRemoteCommands): explicitly call setSupportsSeek
* GPUProcess/GPUConnectionToWebProcess.h:
* GPUProcess/GPUConnectionToWebProcess.messages.in: Remove argument that can be easily inferred in code.
* WebProcess/GPU/media/WebMediaStrategy.cpp: Override createNowPlayingManager method when using the GPU process.
(WebKit::WebMediaStrategy::createNowPlayingManager const):
(WebKit::WebMediaStrategy::clearNowPlayingInfo): Deleted.
(WebKit::WebMediaStrategy::setNowPlayingInfo): Deleted.
* WebProcess/GPU/media/WebMediaStrategy.h:

Source/WebKitLegacy/mac:
Move management of RemoteCommandListener from MediaSessionManagerCocoa into NowPlayingManager
https://bugs.webkit.org/show_bug.cgi?id=223435
<rdar://problem/75567198>

Patch by Jean-Yves Avenard <[email protected]> on 2021-03-22
Reviewed by Eric Carlson.

* WebCoreSupport/WebPlatformStrategies.mm: Remove methods, use default implementation instead.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274828 => 274829)


--- trunk/Source/WebCore/ChangeLog	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebCore/ChangeLog	2021-03-23 00:43:11 UTC (rev 274829)
@@ -1,3 +1,51 @@
+2021-03-22  Jean-Yves Avenard  <[email protected]>
+
+        Move management of RemoteCommandListener from MediaSessionManagerCocoa into NowPlayingManager.
+        https://bugs.webkit.org/show_bug.cgi?id=223435
+        <rdar://problem/75567198>
+
+        Reviewed by Eric Carlson.
+
+        NowPlaying and RemoteCommandListener kind of do the same things, as such it make sense to combine the two
+        and hide the implementation details from consumers.
+        We move the handling of setting and clearing the NowPlayingInfo information to an expanded
+        NowPlayingManager which now also runs in the webcontent process.
+        The job to ensure a RemoteCommandListener is set is now up to the NowPlayingManager as well as
+        dealing with changes in NowPlayingInfo content.
+        Ideally we would prefer to remove all code related to MediaRemote from MediaSessionManagerCocoa;
+        however for ease we leave it there to avoid having to deal with objective-C interface in NowPlayingManager.
+        No change in observable behavior.
+
+        * platform/MediaStrategy.h: The two existing methods dealing with NowPlayingInfo are removed, instead we can override the entire creation of the NowPlayingManager.
+        * platform/MediaStrategy.cpp:
+        (WebCore::MediaStrategy::createNowPlayingManager const): default implementation for createNowPlayingManager
+        * platform/NowPlayingManager.cpp: Add methods used in MediaSessionManagerCocoa used to deal with RemoteCommandListener.
+        (WebCore::NowPlayingManager::didReceiveRemoteControlCommand):
+        (WebCore::NowPlayingManager::addClient): Add explicit method to add a RemoteCommandListener listener, to be called before calling setNowPlayingInfo if needed.
+        (WebCore::NowPlayingManager::removeClient): renamed from clearNowPlayingInfoClient.
+        (WebCore::NowPlayingManager::clearNowPlayingInfo):
+        (WebCore::NowPlayingManager::clearNowPlayingInfoPrivate): Virtual class with default implementation which will immediately communicate with MediaRemote.
+        (WebCore::NowPlayingManager::setNowPlayingInfo):
+        (WebCore::NowPlayingManager::setNowPlayingInfoPrivate):  Virtual class with default implementation which will immediately communicate with MediaRemote.
+        (WebCore::NowPlayingManager::setSupportsSeeking): We explicitly set a different setSupportsSeeking method for code clarity.
+        (WebCore::NowPlayingManager::addSupportedCommand):
+        (WebCore::NowPlayingManager::removeSupportedCommand):
+        (WebCore::NowPlayingManager::setSupportedRemoteCommands):
+        (WebCore::NowPlayingManager::updateSupportedCommands):
+        (WebCore::NowPlayingManager::ensureRemoteCommandListenerCreated):
+        (WebCore::NowPlayingManager::clearNowPlayingInfoClient): Deleted.
+        * platform/NowPlayingManager.h:
+        * platform/audio/cocoa/MediaSessionManagerCocoa.h: Remove now unused members
+        * platform/audio/cocoa/MediaSessionManagerCocoa.mm: Amended to use new NowPlayingManager.
+        (WebCore::MediaSessionManagerCocoa::MediaSessionManagerCocoa):
+        (WebCore::MediaSessionManagerCocoa::scheduleSessionStatusUpdate):
+        (WebCore::MediaSessionManagerCocoa::addSession):
+        (WebCore::MediaSessionManagerCocoa::removeSession):
+        (WebCore::MediaSessionManagerCocoa::setCurrentSession):
+        (WebCore::MediaSessionManagerCocoa::addSupportedCommand):
+        (WebCore::MediaSessionManagerCocoa::removeSupportedCommand):
+        (WebCore::MediaSessionManagerCocoa::updateNowPlayingInfo):
+
 2021-03-22  Fujii Hironori  <[email protected]>
 
         Unreviewed build fix for AppleWin after r274791

Modified: trunk/Source/WebCore/platform/MediaStrategy.cpp (274828 => 274829)


--- trunk/Source/WebCore/platform/MediaStrategy.cpp	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebCore/platform/MediaStrategy.cpp	2021-03-23 00:43:11 UTC (rev 274829)
@@ -32,4 +32,9 @@
 
 MediaStrategy::~MediaStrategy() = default;
 
+std::unique_ptr<NowPlayingManager> MediaStrategy::createNowPlayingManager() const
+{
+    return makeUnique<NowPlayingManager>();
 }
+
+}

Modified: trunk/Source/WebCore/platform/MediaStrategy.h (274828 => 274829)


--- trunk/Source/WebCore/platform/MediaStrategy.h	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebCore/platform/MediaStrategy.h	2021-03-23 00:43:11 UTC (rev 274829)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "NowPlayingManager.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
@@ -33,6 +34,7 @@
 class AudioIOCallback;
 class CDMFactory;
 struct NowPlayingInfo;
+class NowPlayingManager;
 
 class WEBCORE_EXPORT MediaStrategy {
 public:
@@ -40,10 +42,7 @@
     virtual Ref<AudioDestination> createAudioDestination(
         AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate) = 0;
 #endif
-#if PLATFORM(COCOA)
-    virtual void clearNowPlayingInfo() = 0;
-    virtual void setNowPlayingInfo(bool setAsNowPlayingApplication, const NowPlayingInfo&) = 0;
-#endif
+    virtual std::unique_ptr<NowPlayingManager> createNowPlayingManager() const;
 
 protected:
     MediaStrategy();

Modified: trunk/Source/WebCore/platform/NowPlayingManager.cpp (274828 => 274829)


--- trunk/Source/WebCore/platform/NowPlayingManager.cpp	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebCore/platform/NowPlayingManager.cpp	2021-03-23 00:43:11 UTC (rev 274829)
@@ -37,14 +37,18 @@
 
 void NowPlayingManager::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType type, const PlatformMediaSession::RemoteCommandArgument& argument)
 {
-    ASSERT(m_nowPlayingInfo);
-
     if (m_client)
         m_client->didReceiveRemoteControlCommand(type, argument);
 }
 
-void NowPlayingManager::clearNowPlayingInfoClient(Client& client)
+void NowPlayingManager::addClient(Client& client)
 {
+    m_client = makeWeakPtr(client);
+    ensureRemoteCommandListenerCreated();
+}
+
+void NowPlayingManager::removeClient(Client& client)
+{
     if (m_client.get() != &client)
         return;
 
@@ -52,35 +56,76 @@
     m_client.clear();
     m_nowPlayingInfo = { };
 
+    clearNowPlayingInfo();
+}
+
+void NowPlayingManager::clearNowPlayingInfo()
+{
+    clearNowPlayingInfoPrivate();
+    m_setAsNowPlayingApplication = false;
+}
+
+void NowPlayingManager::clearNowPlayingInfoPrivate()
+{
 #if PLATFORM(COCOA)
     MediaSessionManagerCocoa::clearNowPlayingInfo();
 #endif
 }
 
-void NowPlayingManager::setNowPlayingInfo(Client& client, NowPlayingInfo&& nowPlayingInfo)
+bool NowPlayingManager::setNowPlayingInfo(const NowPlayingInfo& nowPlayingInfo)
 {
-    if (!m_remoteCommandListener)
-        m_remoteCommandListener = RemoteCommandListener::create(*this);
+    if (m_nowPlayingInfo && *m_nowPlayingInfo == nowPlayingInfo)
+        return false;
+    m_nowPlayingInfo = nowPlayingInfo;
+    setNowPlayingInfoPrivate(*m_nowPlayingInfo);
+    m_setAsNowPlayingApplication = true;
+    return true;
+}
 
-    m_remoteCommandListener->setSupportsSeeking(nowPlayingInfo.supportsSeeking);
-    m_client = makeWeakPtr(client);
+void NowPlayingManager::setNowPlayingInfoPrivate(const NowPlayingInfo& nowPlayingInfo)
+{
+    setSupportsSeeking(nowPlayingInfo.supportsSeeking);
 #if PLATFORM(COCOA)
-    bool wasPlaying = !!m_nowPlayingInfo;
+    MediaSessionManagerCocoa::setNowPlayingInfo(!m_setAsNowPlayingApplication, nowPlayingInfo);
+#else
+    (void)nowPlayingInfo;
 #endif
-    m_nowPlayingInfo = WTFMove(nowPlayingInfo);
+}
 
-#if PLATFORM(COCOA)
-    MediaSessionManagerCocoa::setNowPlayingInfo(!wasPlaying && m_nowPlayingInfo, *m_nowPlayingInfo);
-#endif
+void NowPlayingManager::setSupportsSeeking(bool supports)
+{
+    if (m_remoteCommandListener)
+        m_remoteCommandListener->setSupportsSeeking(supports);
 }
 
-void NowPlayingManager::setSupportedRemoteCommands(const RemoteCommandListener::RemoteCommandsSet& commands, bool supportsSeeking)
+void NowPlayingManager::addSupportedCommand(PlatformMediaSession::RemoteControlCommandType command)
 {
-    if (!m_remoteCommandListener)
-        return;
+    if (m_remoteCommandListener)
+        m_remoteCommandListener->addSupportedCommand(command);
+}
 
-    m_remoteCommandListener->setSupportsSeeking(supportsSeeking);
-    m_remoteCommandListener->setSupportedCommands(commands);
+void NowPlayingManager::removeSupportedCommand(PlatformMediaSession::RemoteControlCommandType command)
+{
+    if (m_remoteCommandListener)
+        m_remoteCommandListener->removeSupportedCommand(command);
 }
 
+void NowPlayingManager::setSupportedRemoteCommands(const RemoteCommandListener::RemoteCommandsSet& commands)
+{
+    if (m_remoteCommandListener)
+        m_remoteCommandListener->setSupportedCommands(commands);
 }
+
+void NowPlayingManager::updateSupportedCommands()
+{
+    if (m_remoteCommandListener)
+        m_remoteCommandListener->updateSupportedCommands();
+}
+
+void NowPlayingManager::ensureRemoteCommandListenerCreated()
+{
+    if (!m_remoteCommandListener)
+        m_remoteCommandListener = RemoteCommandListener::create(*this);
+}
+
+}

Modified: trunk/Source/WebCore/platform/NowPlayingManager.h (274828 => 274829)


--- trunk/Source/WebCore/platform/NowPlayingManager.h	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebCore/platform/NowPlayingManager.h	2021-03-23 00:43:11 UTC (rev 274829)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "NowPlayingInfo.h"
+#include "PlatformMediaSession.h"
 #include "RemoteCommandListener.h"
 #include <wtf/Optional.h>
 #include <wtf/WeakPtr.h>
@@ -48,14 +49,26 @@
         virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument&) = 0;
     };
 
-    void clearNowPlayingInfoClient(Client&);
-    void setNowPlayingInfo(Client&, NowPlayingInfo&&);
-    void setSupportedRemoteCommands(const RemoteCommandListener::RemoteCommandsSet&, bool);
+    void addSupportedCommand(PlatformMediaSession::RemoteControlCommandType);
+    void removeSupportedCommand(PlatformMediaSession::RemoteControlCommandType);
 
+    void addClient(Client&);
+    void removeClient(Client&);
+
+    void clearNowPlayingInfo();
+    bool setNowPlayingInfo(const NowPlayingInfo&);
+    void setSupportsSeeking(bool);
+    void setSupportedRemoteCommands(const RemoteCommandListener::RemoteCommandsSet&);
+    void updateSupportedCommands();
+
 private:
+    virtual void clearNowPlayingInfoPrivate();
+    virtual void setNowPlayingInfoPrivate(const NowPlayingInfo&);
+    void ensureRemoteCommandListenerCreated();
     std::unique_ptr<RemoteCommandListener> m_remoteCommandListener;
     WeakPtr<Client> m_client;
     Optional<NowPlayingInfo> m_nowPlayingInfo;
+    bool m_setAsNowPlayingApplication { false };
 };
 
 }

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


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h	2021-03-23 00:43:11 UTC (rev 274829)
@@ -29,7 +29,7 @@
 
 #include "AudioHardwareListener.h"
 #include "GenericTaskQueue.h"
-#include "NowPlayingInfo.h"
+#include "NowPlayingManager.h"
 #include "PlatformMediaSessionManager.h"
 #include "RemoteCommandListener.h"
 
@@ -39,7 +39,7 @@
 
 class MediaSessionManagerCocoa
     : public PlatformMediaSessionManager
-    , private RemoteCommandListenerClient
+    , private NowPlayingManager::Client
     , private AudioHardwareListener::Client {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -93,7 +93,7 @@
     const char* logClassName() const override { return "MediaSessionManagerCocoa"; }
 #endif
 
-    // RemoteCommandListenerClient
+    // NowPlayingManager::Client
     void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType type, const PlatformMediaSession::RemoteCommandArgument& argument) final { processDidReceiveRemoteControlCommand(type, argument); }
 
     // AudioHardwareListenerClient
@@ -101,7 +101,6 @@
     void audioHardwareDidBecomeInactive() final { }
     void audioOutputDeviceChanged() final;
 
-    Optional<NowPlayingInfo> m_nowPlayingInfo;
     bool m_nowPlayingActive { false };
     bool m_registeredAsNowPlayingApplication { false };
     bool m_haveEverRegisteredAsNowPlayingApplication { false };
@@ -114,7 +113,7 @@
 
     GenericTaskQueue<Timer> m_taskQueue;
 
-    std::unique_ptr<RemoteCommandListener> m_remoteCommandListener;
+    const std::unique_ptr<NowPlayingManager> m_nowPlayingManager;
     RefPtr<AudioHardwareListener> m_audioHardwareListener;
 };
 

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


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-03-23 00:43:11 UTC (rev 274829)
@@ -57,6 +57,7 @@
 #endif // !PLATFORM(MAC)
 
 MediaSessionManagerCocoa::MediaSessionManagerCocoa()
+    : m_nowPlayingManager(platformStrategies()->mediaStrategy().createNowPlayingManager())
 {
 #if ENABLE(VP9)
     if (shouldEnableVP9Decoder())
@@ -162,11 +163,7 @@
 void MediaSessionManagerCocoa::scheduleSessionStatusUpdate()
 {
     m_taskQueue.enqueueTask([this] () mutable {
-        if (m_remoteCommandListener) {
-            m_remoteCommandListener->setSupportsSeeking(computeSupportsSeeking());
-            m_remoteCommandListener->updateSupportedCommands();
-        }
-
+        m_nowPlayingManager->setSupportsSeeking(computeSupportsSeeking());
         updateNowPlayingInfo();
 
         forEachSession([] (auto& session) {
@@ -191,8 +188,7 @@
 
 void MediaSessionManagerCocoa::addSession(PlatformMediaSession& session)
 {
-    if (!m_remoteCommandListener)
-        m_remoteCommandListener = RemoteCommandListener::create(*this);
+    m_nowPlayingManager->addClient(*this);
 
     if (!m_audioHardwareListener)
         m_audioHardwareListener = AudioHardwareListener::create(*this);
@@ -205,7 +201,7 @@
     PlatformMediaSessionManager::removeSession(session);
 
     if (hasNoSession()) {
-        m_remoteCommandListener = nullptr;
+        m_nowPlayingManager->removeClient(*this);
         m_audioHardwareListener = nullptr;
     }
 
@@ -216,8 +212,7 @@
 {
     PlatformMediaSessionManager::setCurrentSession(session);
 
-    if (m_remoteCommandListener)
-        m_remoteCommandListener->updateSupportedCommands();
+    m_nowPlayingManager->updateSupportedCommands();
 }
 
 void MediaSessionManagerCocoa::sessionWillEndPlayback(PlatformMediaSession& session, DelayCallingUpdateNowPlaying delayCallingUpdateNowPlaying)
@@ -253,14 +248,12 @@
 
 void MediaSessionManagerCocoa::addSupportedCommand(PlatformMediaSession::RemoteControlCommandType command)
 {
-    if (m_remoteCommandListener)
-        m_remoteCommandListener->addSupportedCommand(command);
+    m_nowPlayingManager->addSupportedCommand(command);
 }
 
 void MediaSessionManagerCocoa::removeSupportedCommand(PlatformMediaSession::RemoteControlCommandType command)
 {
-    if (m_remoteCommandListener)
-        m_remoteCommandListener->removeSupportedCommand(command);
+    m_nowPlayingManager->removeSupportedCommand(command);
 }
 
 void MediaSessionManagerCocoa::clearNowPlayingInfo()
@@ -358,7 +351,7 @@
 
         if (m_registeredAsNowPlayingApplication) {
             ALWAYS_LOG(LOGIDENTIFIER, "clearing now playing info");
-            platformStrategies()->mediaStrategy().clearNowPlayingInfo();
+            m_nowPlayingManager->clearNowPlayingInfo();
         }
 
         m_registeredAsNowPlayingApplication = false;
@@ -367,7 +360,6 @@
         m_lastUpdatedNowPlayingDuration = NAN;
         m_lastUpdatedNowPlayingElapsedTime = NAN;
         m_lastUpdatedNowPlayingInfoUniqueIdentifier = { };
-        m_nowPlayingInfo = { };
 
         return;
     }
@@ -374,11 +366,8 @@
 
     m_haveEverRegisteredAsNowPlayingApplication = true;
 
-    if (m_nowPlayingInfo != nowPlayingInfo) {
-        m_nowPlayingInfo = nowPlayingInfo;
-        platformStrategies()->mediaStrategy().setNowPlayingInfo(!m_registeredAsNowPlayingApplication, *nowPlayingInfo);
+    if (m_nowPlayingManager->setNowPlayingInfo(*nowPlayingInfo))
         ALWAYS_LOG(LOGIDENTIFIER, "title = \"", nowPlayingInfo->title, "\", isPlaying = ", nowPlayingInfo->isPlaying, ", duration = ", nowPlayingInfo->duration, ", now = ", nowPlayingInfo->currentTime, ", id = ", nowPlayingInfo->uniqueIdentifier.toUInt64(), ", registered = ", m_registeredAsNowPlayingApplication, ", src = "" nowPlayingInfo->artwork ? nowPlayingInfo->artwork->src : String(), "\"");
-    }
 
     if (!m_registeredAsNowPlayingApplication) {
         m_registeredAsNowPlayingApplication = true;

Modified: trunk/Source/WebKit/ChangeLog (274828 => 274829)


--- trunk/Source/WebKit/ChangeLog	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebKit/ChangeLog	2021-03-23 00:43:11 UTC (rev 274829)
@@ -1,3 +1,23 @@
+2021-03-22  Jean-Yves Avenard  <[email protected]>
+
+        Move management of RemoteCommandListener from MediaSessionManagerCocoa into NowPlayingManager
+        https://bugs.webkit.org/show_bug.cgi?id=223435
+        <rdar://problem/75567198>
+
+        Reviewed by Eric Carlson.
+
+        * GPUProcess/GPUConnectionToWebProcess.cpp: Update methods to use new NowPlayingManager API.
+        (WebKit::GPUConnectionToWebProcess::clearNowPlayingInfo):
+        (WebKit::GPUConnectionToWebProcess::setNowPlayingInfo):
+        (WebKit::GPUConnectionToWebProcess::updateSupportedRemoteCommands): explicitly call setSupportsSeek
+        * GPUProcess/GPUConnectionToWebProcess.h:
+        * GPUProcess/GPUConnectionToWebProcess.messages.in: Remove argument that can be easily inferred in code.
+        * WebProcess/GPU/media/WebMediaStrategy.cpp: Override createNowPlayingManager method when using the GPU process.
+        (WebKit::WebMediaStrategy::createNowPlayingManager const):
+        (WebKit::WebMediaStrategy::clearNowPlayingInfo): Deleted.
+        (WebKit::WebMediaStrategy::setNowPlayingInfo): Deleted.
+        * WebProcess/GPU/media/WebMediaStrategy.h:
+
 2021-03-22  Patrick Angle  <[email protected]>
 
         Web Inspector: Port grid overlay drawing to iOS

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (274828 => 274829)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-03-23 00:43:11 UTC (rev 274829)
@@ -378,13 +378,14 @@
 void GPUConnectionToWebProcess::clearNowPlayingInfo()
 {
     m_isActiveNowPlayingProcess = false;
-    gpuProcess().nowPlayingManager().clearNowPlayingInfoClient(*this);
+    gpuProcess().nowPlayingManager().removeClient(*this);
 }
 
-void GPUConnectionToWebProcess::setNowPlayingInfo(bool setAsNowPlayingApplication, NowPlayingInfo&& nowPlayingInfo)
+void GPUConnectionToWebProcess::setNowPlayingInfo(NowPlayingInfo&& nowPlayingInfo)
 {
     m_isActiveNowPlayingProcess = true;
-    gpuProcess().nowPlayingManager().setNowPlayingInfo(*this, WTFMove(nowPlayingInfo));
+    gpuProcess().nowPlayingManager().addClient(*this);
+    gpuProcess().nowPlayingManager().setNowPlayingInfo(WTFMove(nowPlayingInfo));
     updateSupportedRemoteCommands();
 }
 
@@ -393,8 +394,8 @@
     if (!m_isActiveNowPlayingProcess || !m_remoteRemoteCommandListener)
         return;
 
-    gpuProcess().nowPlayingManager().setSupportedRemoteCommands(m_remoteRemoteCommandListener->supportedCommands(), m_remoteRemoteCommandListener->supportsSeeking());
-
+    gpuProcess().nowPlayingManager().setSupportsSeeking(m_remoteRemoteCommandListener->supportsSeeking());
+    gpuProcess().nowPlayingManager().setSupportedRemoteCommands(m_remoteRemoteCommandListener->supportedCommands());
 }
 
 void GPUConnectionToWebProcess::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType type, const PlatformMediaSession::RemoteCommandArgument& argument)

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (274828 => 274829)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-03-23 00:43:11 UTC (rev 274829)
@@ -168,7 +168,7 @@
 #endif
 
     void clearNowPlayingInfo();
-    void setNowPlayingInfo(bool setAsNowPlayingApplication, WebCore::NowPlayingInfo&&);
+    void setNowPlayingInfo(WebCore::NowPlayingInfo&&);
 
 #if ENABLE(VP9)
     void enableVP9Decoders(bool shouldEnableVP8Decoder, bool shouldEnableVP9Decoder, bool shouldEnableVP9SWDecoder);

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in (274828 => 274829)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in	2021-03-23 00:43:11 UTC (rev 274829)
@@ -30,7 +30,7 @@
     void ReleaseGraphicsContextGL(WebKit::GraphicsContextGLIdentifier graphicsContextGLIdentifier)
 #endif
     void ClearNowPlayingInfo()
-    void SetNowPlayingInfo(bool setAsNowPlayingApplication, struct WebCore::NowPlayingInfo nowPlayingInfo)
+    void SetNowPlayingInfo(struct WebCore::NowPlayingInfo nowPlayingInfo)
 #if USE(AUDIO_SESSION)
     EnsureAudioSession() -> (struct WebKit::RemoteAudioSessionConfiguration configuration) Synchronous
 #endif

Modified: trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.cpp (274828 => 274829)


--- trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.cpp	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.cpp	2021-03-23 00:43:11 UTC (rev 274829)
@@ -34,7 +34,7 @@
 #include <WebCore/AudioDestination.h>
 #include <WebCore/AudioIOCallback.h>
 #include <WebCore/CDMFactory.h>
-#include <WebCore/NowPlayingInfo.h>
+#include <WebCore/NowPlayingManager.h>
 
 #if PLATFORM(COCOA)
 #include <WebCore/MediaSessionManagerCocoa.h>
@@ -56,30 +56,27 @@
 }
 #endif
 
-#if PLATFORM(COCOA)
-void WebMediaStrategy::clearNowPlayingInfo()
+std::unique_ptr<WebCore::NowPlayingManager> WebMediaStrategy::createNowPlayingManager() const
 {
 #if ENABLE(GPU_PROCESS)
     if (m_useGPUProcess) {
-        auto& connection = WebProcess::singleton().ensureGPUProcessConnection().connection();
-        connection.send(Messages::GPUConnectionToWebProcess::ClearNowPlayingInfo { }, 0);
-        return;
-    }
-#endif
-    WebCore::MediaSessionManagerCocoa::clearNowPlayingInfo();
-}
+        class NowPlayingInfoForGPUManager : public WebCore::NowPlayingManager {
+            void clearNowPlayingInfoPrivate() final
+            {
+                auto& connection = WebProcess::singleton().ensureGPUProcessConnection().connection();
+                connection.send(Messages::GPUConnectionToWebProcess::ClearNowPlayingInfo { }, 0);
+            }
 
-void WebMediaStrategy::setNowPlayingInfo(bool setAsNowPlayingApplication, const WebCore::NowPlayingInfo& nowPlayingInfo)
-{
-#if ENABLE(GPU_PROCESS)
-    if (m_useGPUProcess) {
-        auto& connection = WebProcess::singleton().ensureGPUProcessConnection().connection();
-        connection.send(Messages::GPUConnectionToWebProcess::SetNowPlayingInfo { setAsNowPlayingApplication, nowPlayingInfo }, 0);
-        return;
+            void setNowPlayingInfoPrivate(const NowPlayingInfo& nowPlayingInfo) final
+            {
+                auto& connection = WebProcess::singleton().ensureGPUProcessConnection().connection();
+                connection.send(Messages::GPUConnectionToWebProcess::SetNowPlayingInfo { nowPlayingInfo }, 0);
+            }
+        };
+        return makeUnique<NowPlayingInfoForGPUManager>();
     }
 #endif
-    WebCore::MediaSessionManagerCocoa::setNowPlayingInfo(setAsNowPlayingApplication, nowPlayingInfo);
+    return WebCore::MediaStrategy::createNowPlayingManager();
 }
-#endif
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.h (274828 => 274829)


--- trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.h	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebKit/WebProcess/GPU/media/WebMediaStrategy.h	2021-03-23 00:43:11 UTC (rev 274829)
@@ -42,10 +42,7 @@
     Ref<WebCore::AudioDestination> createAudioDestination(WebCore::AudioIOCallback&,
         const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate) override;
 #endif
-#if PLATFORM(COCOA)
-    void clearNowPlayingInfo() final;
-    void setNowPlayingInfo(bool setAsNowPlayingApplication, const WebCore::NowPlayingInfo&) final;
-#endif
+    std::unique_ptr<WebCore::NowPlayingManager> createNowPlayingManager() const final;
 
 #if ENABLE(GPU_PROCESS)
     bool m_useGPUProcess { false };

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (274828 => 274829)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-03-23 00:43:11 UTC (rev 274829)
@@ -1,3 +1,13 @@
+2021-03-22  Jean-Yves Avenard  <[email protected]>
+
+        Move management of RemoteCommandListener from MediaSessionManagerCocoa into NowPlayingManager
+        https://bugs.webkit.org/show_bug.cgi?id=223435
+        <rdar://problem/75567198>
+
+        Reviewed by Eric Carlson.
+
+        * WebCoreSupport/WebPlatformStrategies.mm: Remove methods, use default implementation instead.
+
 2021-03-22  Devin Rousso  <[email protected]>
 
         Remove unused JS and CSS files of media controls

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm (274828 => 274829)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm	2021-03-23 00:40:06 UTC (rev 274828)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm	2021-03-23 00:43:11 UTC (rev 274829)
@@ -33,7 +33,6 @@
 #import <WebCore/CDMFactory.h>
 #import <WebCore/Color.h>
 #import <WebCore/Frame.h>
-#import <WebCore/MediaSessionManagerCocoa.h>
 #import <WebCore/MediaStrategy.h>
 #import <WebCore/NetworkStorageSession.h>
 #import <WebCore/PasteboardItemInfo.h>
@@ -75,15 +74,6 @@
         return AudioDestination::create(callback, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, sampleRate);
     }
 #endif
-    void clearNowPlayingInfo() final
-    {
-        MediaSessionManagerCocoa::clearNowPlayingInfo();
-    }
-
-    void setNowPlayingInfo(bool setAsNowPlayingApplication, const NowPlayingInfo& nowPlayingInfo) final
-    {
-        MediaSessionManagerCocoa::setNowPlayingInfo(setAsNowPlayingApplication, nowPlayingInfo);
-    }
 };
 
 MediaStrategy* WebPlatformStrategies::createMediaStrategy()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to