Title: [275359] trunk/Source/WebCore
Revision
275359
Author
[email protected]
Date
2021-04-01 08:17:27 -0700 (Thu, 01 Apr 2021)

Log Message

Now Playing artwork doesn't update when changed.
https://bugs.webkit.org/show_bug.cgi?id=223731
<rdar://problem/75823923>

Source/WebCore:

Now Playing and Media Remote requires a unique identifier for the currently playing item.
If the same identifier is provided for every call to MRMediaRemoteSetNowPlayingInfo,
then some updates may be skipped.
In earlier changes, the MediaSessionElement identifier was combined with the Media Element
identifier which broke Now Playing as the MediaSession identifier never changes for the
lifetime of the web content process.
So we create a new method HTMLMediaElement::mediaUniqueIdentifier with a new MediaUniqueIdentifier
that willthat will be updated whenever the source of a media element changes and stop
using the MediaSession identifier when dealing with Now Playing.

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

Manually tested, no framework available to test such change.

* WebCore.xcodeproj/project.pbxproj: Add MediaUniqueIdentifier.h
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::prepareForLoad): Use setCurrentSrc instead of directly modifying m_currentSrc.
(WebCore::HTMLMediaElement::selectMediaResource): Use setCurrentSrc instead of directly modifying m_currentSrc.
(WebCore::HTMLMediaElement::loadResource): Use setCurrentSrc instead of directly modifying m_currentSrc.
(WebCore::HTMLMediaElement::setCurrentSrc): Add convenience method, generate new MediaUniqueIdentifier each time m_currentSrc is modified.
(WebCore::HTMLMediaElement::mediaUniqueIdentifier const): Return unique media identifier.
(WebCore::HTMLMediaElement::mediaSessionUniqueIdentifier const): Deleted.
* html/HTMLMediaElement.h:
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::nowPlayingInfo const):
* platform/audio/NowPlayingInfo.h: Use MediaUniqueIdentifier for uniqueIdentifier member.
(WebCore::NowPlayingInfo::decode):
* platform/audio/PlatformMediaSessionManager.h: Use MediaUniqueIdentifier instead.
(WebCore::PlatformMediaSessionManager::lastUpdatedNowPlayingInfoUniqueIdentifier const):
set kMRMediaRemoteNowPlayingInfoArtworkIdentifier in CFDictionary to the source of the artwork.
Workaround a bug in Media Controller component.
* platform/audio/cocoa/MediaSessionManagerCocoa.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::setNowPlayingInfo):
* platform/mac/MediaRemoteSoftLink.h: Soft-link kMRMediaRemoteNowPlayingInfoArtworkIdentifier symbol.
* platform/mac/MediaRemoteSoftLink.mm:
* testing/Internals.h: Add missing header.

Source/WebCore/PAL:

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

* pal/spi/mac/MediaRemoteSPI.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (275358 => 275359)


--- trunk/Source/WebCore/ChangeLog	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/ChangeLog	2021-04-01 15:17:27 UTC (rev 275359)
@@ -1,3 +1,47 @@
+2021-04-01  Jean-Yves Avenard  <[email protected]>
+
+        Now Playing artwork doesn't update when changed.
+        https://bugs.webkit.org/show_bug.cgi?id=223731
+        <rdar://problem/75823923>
+
+        Now Playing and Media Remote requires a unique identifier for the currently playing item.
+        If the same identifier is provided for every call to MRMediaRemoteSetNowPlayingInfo,
+        then some updates may be skipped.
+        In earlier changes, the MediaSessionElement identifier was combined with the Media Element
+        identifier which broke Now Playing as the MediaSession identifier never changes for the
+        lifetime of the web content process.
+        So we create a new method HTMLMediaElement::mediaUniqueIdentifier with a new MediaUniqueIdentifier
+        that willthat will be updated whenever the source of a media element changes and stop
+        using the MediaSession identifier when dealing with Now Playing.
+
+        Reviewed by Eric Carlson.
+
+        Manually tested, no framework available to test such change.
+
+        * WebCore.xcodeproj/project.pbxproj: Add MediaUniqueIdentifier.h
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::prepareForLoad): Use setCurrentSrc instead of directly modifying m_currentSrc.
+        (WebCore::HTMLMediaElement::selectMediaResource): Use setCurrentSrc instead of directly modifying m_currentSrc.
+        (WebCore::HTMLMediaElement::loadResource): Use setCurrentSrc instead of directly modifying m_currentSrc.
+        (WebCore::HTMLMediaElement::setCurrentSrc): Add convenience method, generate new MediaUniqueIdentifier each time m_currentSrc is modified.
+        (WebCore::HTMLMediaElement::mediaUniqueIdentifier const): Return unique media identifier.
+        (WebCore::HTMLMediaElement::mediaSessionUniqueIdentifier const): Deleted.
+        * html/HTMLMediaElement.h:
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::nowPlayingInfo const):
+        * platform/audio/NowPlayingInfo.h: Use MediaUniqueIdentifier for uniqueIdentifier member.
+        (WebCore::NowPlayingInfo::decode):
+        * platform/audio/PlatformMediaSessionManager.h: Use MediaUniqueIdentifier instead.
+        (WebCore::PlatformMediaSessionManager::lastUpdatedNowPlayingInfoUniqueIdentifier const):
+        set kMRMediaRemoteNowPlayingInfoArtworkIdentifier in CFDictionary to the source of the artwork.
+        Workaround a bug in Media Controller component.
+        * platform/audio/cocoa/MediaSessionManagerCocoa.h:
+        * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+        (WebCore::MediaSessionManagerCocoa::setNowPlayingInfo):
+        * platform/mac/MediaRemoteSoftLink.h: Soft-link kMRMediaRemoteNowPlayingInfoArtworkIdentifier symbol.
+        * platform/mac/MediaRemoteSoftLink.mm:
+        * testing/Internals.h: Add missing header.
+
 2021-04-01  Devin Rousso  <[email protected]>
 
         Limit the number of buttons shown in media controls

Modified: trunk/Source/WebCore/Headers.cmake (275358 => 275359)


--- trunk/Source/WebCore/Headers.cmake	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/Headers.cmake	2021-04-01 15:17:27 UTC (rev 275359)
@@ -1047,6 +1047,7 @@
     platform/MediaSessionGroupIdentifier.h
     platform/MediaSessionIdentifier.h
     platform/MediaStrategy.h
+    platform/MediaUniqueIdentifier.h
     platform/NowPlayingManager.h
     platform/NotImplemented.h
     platform/OrientationNotifier.h

Modified: trunk/Source/WebCore/PAL/ChangeLog (275358 => 275359)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-04-01 15:17:27 UTC (rev 275359)
@@ -1,3 +1,13 @@
+2021-04-01  Jean-Yves Avenard  <[email protected]>
+
+        Now Playing artwork doesn't update when changed.
+        https://bugs.webkit.org/show_bug.cgi?id=223731
+        <rdar://problem/75823923>
+
+        Reviewed by Eric Carlson.
+
+        * pal/spi/mac/MediaRemoteSPI.h:
+
 2021-03-31  Youenn Fablet  <[email protected]>
 
         Make use of NSURLSessionWebSocket.sendCloseCode if available

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (275358 => 275359)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-04-01 15:17:27 UTC (rev 275359)
@@ -1483,6 +1483,7 @@
 		514C767B0CE923A1007EF3CD /* ResourceHandleInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C76660CE923A1007EF3CD /* ResourceHandleInternal.h */; };
 		514C767D0CE923A1007EF3CD /* ResourceRequestBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C76680CE923A1007EF3CD /* ResourceRequestBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		514C767F0CE923A1007EF3CD /* ResourceResponseBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C766A0CE923A1007EF3CD /* ResourceResponseBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		5151F07E2615435A00FDB2B4 /* MediaUniqueIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 5151F07B2615363F00FDB2B4 /* MediaUniqueIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		515BE1901D54F5FB00DD7C68 /* EmptyGamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE1891D54F5F600DD7C68 /* EmptyGamepadProvider.h */; };
 		515BE1921D54F5FB00DD7C68 /* GamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE18B1D54F5F600DD7C68 /* GamepadProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		515BE1931D54F5FB00DD7C68 /* GamepadProviderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE18C1D54F5F600DD7C68 /* GamepadProviderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8714,6 +8715,7 @@
 		514C76680CE923A1007EF3CD /* ResourceRequestBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceRequestBase.h; sourceTree = "<group>"; };
 		514C76690CE923A1007EF3CD /* ResourceResponseBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceResponseBase.cpp; sourceTree = "<group>"; };
 		514C766A0CE923A1007EF3CD /* ResourceResponseBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceResponseBase.h; sourceTree = "<group>"; };
+		5151F07B2615363F00FDB2B4 /* MediaUniqueIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaUniqueIdentifier.h; sourceTree = "<group>"; };
 		515BE1881D54F5F600DD7C68 /* EmptyGamepadProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmptyGamepadProvider.cpp; sourceTree = "<group>"; };
 		515BE1891D54F5F600DD7C68 /* EmptyGamepadProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmptyGamepadProvider.h; sourceTree = "<group>"; };
 		515BE18A1D54F5F600DD7C68 /* GamepadProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GamepadProvider.cpp; sourceTree = "<group>"; };
@@ -27823,6 +27825,7 @@
 				414460A02412994100814BE7 /* MediaSessionIdentifier.h */,
 				A31AC70A24340984007F00A2 /* MediaStrategy.cpp */,
 				9B1229C623FE4D5F008CA751 /* MediaStrategy.h */,
+				5151F07B2615363F00FDB2B4 /* MediaUniqueIdentifier.h */,
 				BC772C4C0C4EB3040083285F /* MIMETypeRegistry.cpp */,
 				BC772C4D0C4EB3040083285F /* MIMETypeRegistry.h */,
 				E1513D501677F08800149FCB /* NotImplemented.cpp */,
@@ -34059,6 +34062,7 @@
 				07FFDE69181AED420072D409 /* MediaStreamTrackPrivate.h in Headers */,
 				932CC0B71DFFD158004C0F9F /* MediaTrackConstraints.h in Headers */,
 				07C1C0E21BFB600100BD2256 /* MediaTrackSupportedConstraints.h in Headers */,
+				5151F07E2615435A00FDB2B4 /* MediaUniqueIdentifier.h in Headers */,
 				07611DC12440E59B00D80704 /* MediaUsageInfo.h in Headers */,
 				939C0D2B2564E7F300B3211B /* MediaUtilities.h in Headers */,
 				51E1BAC31BD8064E0055D81F /* MemoryBackingStoreTransaction.h in Headers */,

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (275358 => 275359)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2021-04-01 15:17:27 UTC (rev 275359)
@@ -1108,7 +1108,7 @@
     m_haveFiredLoadedData = false;
     m_completelyLoaded = false;
     m_havePreparedToPlay = false;
-    m_currentSrc = URL();
+    setCurrentSrc(URL());
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     m_failedToPlayToWirelessTarget = false;
@@ -1321,7 +1321,7 @@
         // ↳ If mode is object
         if (mode == Object) {
             // 1. Set the currentSrc attribute to the empty string.
-            m_currentSrc = URL();
+            setCurrentSrc(URL());
 
             // 2. End the synchronous section, continuing the remaining steps in parallel.
             // 3. Run the resource fetch algorithm with the assigned media provider object.
@@ -1370,7 +1370,7 @@
             }
 
             // 3. If absolute URL was obtained successfully, set the currentSrc attribute to absolute URL.
-            m_currentSrc = absoluteURL;
+            setCurrentSrc(absoluteURL);
 
             // 4. End the synchronous section, continuing the remaining steps in parallel.
             // 5. If absolute URL was obtained successfully, run the resource fetch algorithm with absolute
@@ -1467,7 +1467,7 @@
 
     // Set m_currentSrc *before* changing to the cache URL, the fact that we are loading from the app
     // cache is an internal detail not exposed through the media element API.
-    m_currentSrc = url;
+    setCurrentSrc(url);
 
     if (resource) {
         url = ""
@@ -7517,11 +7517,17 @@
     return title;
 }
 
-MediaSessionIdentifier HTMLMediaElement::mediaSessionUniqueIdentifier() const
+void HTMLMediaElement::setCurrentSrc(const URL& src)
 {
-    return m_mediaSession->mediaSessionIdentifier();
+    m_currentSrc = src;
+    m_currentIdentifier = MediaUniqueIdentifier::generate();
 }
 
+MediaUniqueIdentifier HTMLMediaElement::mediaUniqueIdentifier() const
+{
+    return m_currentIdentifier;
+}
+
 void HTMLMediaElement::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument& argument)
 {
     ALWAYS_LOG(LOGIDENTIFIER, command);

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (275358 => 275359)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2021-04-01 15:17:27 UTC (rev 275359)
@@ -40,7 +40,7 @@
 #include "MediaElementSession.h"
 #include "MediaPlayer.h"
 #include "MediaProducer.h"
-#include "MediaSessionIdentifier.h"
+#include "MediaUniqueIdentifier.h"
 #include "TextTrack.h"
 #include "VideoTrack.h"
 #include "VisibilityChangeClient.h"
@@ -566,7 +566,7 @@
     void applicationWillResignActive();
     void applicationDidBecomeActive();
 
-    MediaSessionIdentifier mediaSessionUniqueIdentifier() const;
+    MediaUniqueIdentifier mediaUniqueIdentifier() const;
     String mediaSessionTitle() const;
     String sourceApplicationIdentifier() const;
 
@@ -846,6 +846,7 @@
     void updateMediaController();
     bool isBlocked() const;
     bool isBlockedOnMediaController() const;
+    void setCurrentSrc(const URL&);
     bool hasCurrentSrc() const override { return !m_currentSrc.isEmpty(); }
     bool isLiveStream() const override { return movieLoadType() == MovieLoadType::LiveStream; }
 
@@ -966,6 +967,7 @@
     ReadyState m_readyState { HAVE_NOTHING };
     ReadyState m_readyStateMaximum { HAVE_NOTHING };
     URL m_currentSrc;
+    MediaUniqueIdentifier m_currentIdentifier;
 
     RefPtr<MediaError> m_error;
 

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (275358 => 275359)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2021-04-01 15:17:27 UTC (rev 275359)
@@ -1161,11 +1161,11 @@
         if (sessionMetadata->artworkImage()) {
             artwork = NowPlayingInfoArtwork { sessionMetadata->artworkSrc(), sessionMetadata->artworkImage()->mimeType(), sessionMetadata->artworkImage()->data() };
         }
-        return NowPlayingInfo { sessionMetadata->title(), sessionMetadata->artist(), sessionMetadata->album(), m_element.sourceApplicationIdentifier(), duration, currentTime, supportsSeeking, m_element.mediaSessionUniqueIdentifier(), isPlaying, allowsNowPlayingControlsVisibility, WTFMove(artwork) };
+        return NowPlayingInfo { sessionMetadata->title(), sessionMetadata->artist(), sessionMetadata->album(), m_element.sourceApplicationIdentifier(), duration, currentTime, supportsSeeking, m_element.mediaUniqueIdentifier(), isPlaying, allowsNowPlayingControlsVisibility, WTFMove(artwork) };
     }
 #endif
 
-    return NowPlayingInfo { m_element.mediaSessionTitle(), emptyString(), emptyString(), m_element.sourceApplicationIdentifier(), duration, currentTime, supportsSeeking, m_element.mediaSessionUniqueIdentifier(), isPlaying, allowsNowPlayingControlsVisibility, { }};
+    return NowPlayingInfo { m_element.mediaSessionTitle(), emptyString(), emptyString(), m_element.sourceApplicationIdentifier(), duration, currentTime, supportsSeeking, m_element.mediaUniqueIdentifier(), isPlaying, allowsNowPlayingControlsVisibility, { }};
 }
 
 void MediaElementSession::updateMediaUsageIfChanged()

Added: trunk/Source/WebCore/platform/MediaUniqueIdentifier.h (0 => 275359)


--- trunk/Source/WebCore/platform/MediaUniqueIdentifier.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/MediaUniqueIdentifier.h	2021-04-01 15:17:27 UTC (rev 275359)
@@ -0,0 +1,35 @@
+/*
+ * 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
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebCore {
+
+enum MediaUniqueIdentifierType { };
+using MediaUniqueIdentifier = ObjectIdentifier<MediaUniqueIdentifierType>;
+
+}

Modified: trunk/Source/WebCore/platform/audio/NowPlayingInfo.h (275358 => 275359)


--- trunk/Source/WebCore/platform/audio/NowPlayingInfo.h	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/platform/audio/NowPlayingInfo.h	2021-04-01 15:17:27 UTC (rev 275359)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "MediaSessionIdentifier.h"
+#include "MediaUniqueIdentifier.h"
 #include "SharedBuffer.h"
 #include <wtf/Optional.h>
 #include <wtf/URL.h>
@@ -83,7 +83,7 @@
     double duration { 0 };
     double currentTime { 0 };
     bool supportsSeeking { false };
-    MediaSessionIdentifier uniqueIdentifier;
+    MediaUniqueIdentifier uniqueIdentifier;
     bool isPlaying { false };
     bool allowsNowPlayingControlsVisibility { false };
     Optional<NowPlayingInfoArtwork> artwork;
@@ -147,7 +147,7 @@
     if (!decoder.decode(supportsSeeking))
         return { };
 
-    MediaSessionIdentifier uniqueIdentifier;
+    MediaUniqueIdentifier uniqueIdentifier;
     if (!decoder.decode(uniqueIdentifier))
         return { };
 

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (275358 => 275359)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2021-04-01 15:17:27 UTC (rev 275359)
@@ -27,7 +27,7 @@
 #define PlatformMediaSessionManager_h
 
 #include "GenericTaskQueue.h"
-#include "MediaSessionIdentifier.h"
+#include "MediaUniqueIdentifier.h"
 #include "PlatformMediaSession.h"
 #include "Timer.h"
 #include <wtf/AggregateLogger.h>
@@ -86,7 +86,7 @@
     virtual String lastUpdatedNowPlayingTitle() const { return emptyString(); }
     virtual double lastUpdatedNowPlayingDuration() const { return NAN; }
     virtual double lastUpdatedNowPlayingElapsedTime() const { return NAN; }
-    virtual MediaSessionIdentifier lastUpdatedNowPlayingInfoUniqueIdentifier() const { return { }; }
+    virtual MediaUniqueIdentifier lastUpdatedNowPlayingInfoUniqueIdentifier() const { return { }; }
     virtual bool registeredAsNowPlayingApplication() const { return false; }
     virtual bool haveEverRegisteredAsNowPlayingApplication() const { return false; }
     virtual void prepareToSendUserMediaPermissionRequest() { }

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


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h	2021-04-01 15:17:27 UTC (rev 275359)
@@ -52,7 +52,7 @@
     String lastUpdatedNowPlayingTitle() const final { return m_lastUpdatedNowPlayingTitle; }
     double lastUpdatedNowPlayingDuration() const final { return m_lastUpdatedNowPlayingDuration; }
     double lastUpdatedNowPlayingElapsedTime() const final { return m_lastUpdatedNowPlayingElapsedTime; }
-    MediaSessionIdentifier lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }
+    MediaUniqueIdentifier lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }
     bool registeredAsNowPlayingApplication() const final { return m_registeredAsNowPlayingApplication; }
     bool haveEverRegisteredAsNowPlayingApplication() const final { return m_haveEverRegisteredAsNowPlayingApplication; }
 
@@ -109,7 +109,7 @@
     String m_lastUpdatedNowPlayingTitle;
     double m_lastUpdatedNowPlayingDuration { NAN };
     double m_lastUpdatedNowPlayingElapsedTime { NAN };
-    MediaSessionIdentifier m_lastUpdatedNowPlayingInfoUniqueIdentifier;
+    MediaUniqueIdentifier m_lastUpdatedNowPlayingInfoUniqueIdentifier;
 
     GenericTaskQueue<Timer> m_taskQueue;
 

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


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-04-01 15:17:27 UTC (rev 275359)
@@ -293,7 +293,9 @@
     auto cfRate = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &rate));
     CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoPlaybackRate, cfRate.get());
 
-    auto lastUpdatedNowPlayingInfoUniqueIdentifier = nowPlayingInfo.uniqueIdentifier.toUInt64();
+    // FIXME: This is a workaround Control Center not updating the artwork when refreshed.
+    // We force the identifier to be reloaded to the new artwork if available.
+    auto lastUpdatedNowPlayingInfoUniqueIdentifier = nowPlayingInfo.artwork ? nowPlayingInfo.artwork->src.hash() : nowPlayingInfo.uniqueIdentifier.toUInt64();
     auto cfIdentifier = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberLongLongType, &lastUpdatedNowPlayingInfoUniqueIdentifier));
     CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoUniqueIdentifier, cfIdentifier.get());
 
@@ -305,6 +307,7 @@
         auto nsArtwork = nowPlayingInfo.artwork->imageData->createNSData();
         CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoArtworkData, nsArtwork.get());
         CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoArtworkMIMEType, nowPlayingInfo.artwork->mimeType.createCFString().get());
+        CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoArtworkIdentifier, String::number(nowPlayingInfo.artwork->src.hash()).createCFString().get());
     }
 
     if (canLoad_MediaRemote_MRMediaRemoteSetParentApplication() && !nowPlayingInfo.sourceApplicationIdentifier.isEmpty())

Modified: trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h (275358 => 275359)


--- trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h	2021-04-01 15:17:27 UTC (rev 275359)
@@ -67,6 +67,8 @@
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoArtworkMIMEType, CFStringRef);
 #define kMRMediaRemoteNowPlayingInfoArtworkMIMEType get_MediaRemote_kMRMediaRemoteNowPlayingInfoArtworkMIMEType()
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoDuration, CFStringRef);
+#define kMRMediaRemoteNowPlayingInfoArtworkIdentifier get_MediaRemote_kMRMediaRemoteNowPlayingInfoArtworkIdentifier()
+SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoArtworkIdentifier, CFStringRef);
 #define kMRMediaRemoteNowPlayingInfoDuration get_MediaRemote_kMRMediaRemoteNowPlayingInfoDuration()
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoElapsedTime, CFStringRef);
 #define kMRMediaRemoteNowPlayingInfoElapsedTime get_MediaRemote_kMRMediaRemoteNowPlayingInfoElapsedTime()

Modified: trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.mm (275358 => 275359)


--- trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.mm	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.mm	2021-04-01 15:17:27 UTC (rev 275359)
@@ -48,6 +48,7 @@
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoAlbum, CFStringRef);
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoArtworkData, CFStringRef);
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoArtworkMIMEType, CFStringRef);
+SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoArtworkIdentifier, CFStringRef);
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoDuration, CFStringRef);
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoElapsedTime, CFStringRef);
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoPlaybackRate, CFStringRef);

Modified: trunk/Source/WebCore/testing/Internals.h (275358 => 275359)


--- trunk/Source/WebCore/testing/Internals.h	2021-04-01 15:05:24 UTC (rev 275358)
+++ trunk/Source/WebCore/testing/Internals.h	2021-04-01 15:17:27 UTC (rev 275359)
@@ -43,6 +43,7 @@
 
 #if ENABLE(VIDEO)
 #include "MediaElementSession.h"
+#include "MediaUniqueIdentifier.h"
 #endif
 
 namespace WebCore {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to