Title: [293104] branches/safari-613-branch/Source
Revision
293104
Author
[email protected]
Date
2022-04-20 10:24:59 -0700 (Wed, 20 Apr 2022)

Log Message

Cherry-pick r289100. rdar://problem/79950080

    Teach VideoFullscreenInterface to keep track of its corresponding MediaPlayer's MediaPlayerIdentifier
    https://bugs.webkit.org/show_bug.cgi?id=236090

    Reviewed by Eric Carlson.

    Source/WebCore:

    Add plumbing for an optional MediaPlayerIdentifier through the video fullscreen model. This identifier is
    invalidated upon `loadstart`, and updated once we observe `loadedmetadata`, which ensures that if the media
    engine (and media player) changes out from underneath the video fullscreen model, we still keep the new player
    ID up to date.

    See WebKit/ChangeLog for more details.

    * platform/cocoa/VideoFullscreenModel.h:
    (WebCore::VideoFullscreenModelClient::setPlayerIdentifier):
    * platform/cocoa/VideoFullscreenModelVideoElement.h:
    * platform/cocoa/VideoFullscreenModelVideoElement.mm:
    (WebCore::VideoFullscreenModelVideoElement::updateForEventName):
    (WebCore::VideoFullscreenModelVideoElement::observedEventNames):

    Additionally listen for `loadstartEvent` and `loadedmetadataEvent` (see above).

    (WebCore::VideoFullscreenModelVideoElement::setPlayerIdentifier):
    * platform/ios/VideoFullscreenInterfaceAVKit.h:
    * platform/mac/VideoFullscreenInterfaceMac.h:
    (WebCore::VideoFullscreenInterfaceMac::playerIdentifier const):

    Source/WebKit:

    Add an IPC message between VideoFullscreenManager and VideoFullscreenManagerProxy to update the media player ID
    corresponding to a given PlaybackSessionContextIdentifier. This is sent if the underlying media player changes
    (and subsequently fires `loadstart` and `loadedmetadata` events), and also sent upon entering fullscreen video.

    In a future patch, this mechanism will be used to teach VideoFullscreenManagerProxy to grab an image bitmap from
    the GPU process for a given PlaybackSessionContextIdentifier.

    * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
    * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
    * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
    (WebKit::VideoFullscreenManagerProxy::setPlayerIdentifier):
    * WebProcess/cocoa/VideoFullscreenManager.h:
    * WebProcess/cocoa/VideoFullscreenManager.mm:
    (WebKit::VideoFullscreenInterfaceContext::setPlayerIdentifier):
    (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
    (WebKit::VideoFullscreenManager::setPlayerIdentifier):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289100 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (293103 => 293104)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-04-20 17:24:59 UTC (rev 293104)
@@ -1,3 +1,84 @@
+2022-04-20  Alan Coon  <[email protected]>
+
+        Cherry-pick r289100. rdar://problem/79950080
+
+    Teach VideoFullscreenInterface to keep track of its corresponding MediaPlayer's MediaPlayerIdentifier
+    https://bugs.webkit.org/show_bug.cgi?id=236090
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    Add plumbing for an optional MediaPlayerIdentifier through the video fullscreen model. This identifier is
+    invalidated upon `loadstart`, and updated once we observe `loadedmetadata`, which ensures that if the media
+    engine (and media player) changes out from underneath the video fullscreen model, we still keep the new player
+    ID up to date.
+    
+    See WebKit/ChangeLog for more details.
+    
+    * platform/cocoa/VideoFullscreenModel.h:
+    (WebCore::VideoFullscreenModelClient::setPlayerIdentifier):
+    * platform/cocoa/VideoFullscreenModelVideoElement.h:
+    * platform/cocoa/VideoFullscreenModelVideoElement.mm:
+    (WebCore::VideoFullscreenModelVideoElement::updateForEventName):
+    (WebCore::VideoFullscreenModelVideoElement::observedEventNames):
+    
+    Additionally listen for `loadstartEvent` and `loadedmetadataEvent` (see above).
+    
+    (WebCore::VideoFullscreenModelVideoElement::setPlayerIdentifier):
+    * platform/ios/VideoFullscreenInterfaceAVKit.h:
+    * platform/mac/VideoFullscreenInterfaceMac.h:
+    (WebCore::VideoFullscreenInterfaceMac::playerIdentifier const):
+    
+    Source/WebKit:
+    
+    Add an IPC message between VideoFullscreenManager and VideoFullscreenManagerProxy to update the media player ID
+    corresponding to a given PlaybackSessionContextIdentifier. This is sent if the underlying media player changes
+    (and subsequently fires `loadstart` and `loadedmetadata` events), and also sent upon entering fullscreen video.
+    
+    In a future patch, this mechanism will be used to teach VideoFullscreenManagerProxy to grab an image bitmap from
+    the GPU process for a given PlaybackSessionContextIdentifier.
+    
+    * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
+    * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
+    * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+    (WebKit::VideoFullscreenManagerProxy::setPlayerIdentifier):
+    * WebProcess/cocoa/VideoFullscreenManager.h:
+    * WebProcess/cocoa/VideoFullscreenManager.mm:
+    (WebKit::VideoFullscreenInterfaceContext::setPlayerIdentifier):
+    (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
+    (WebKit::VideoFullscreenManager::setPlayerIdentifier):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289100 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-03  Wenson Hsieh  <[email protected]>
+
+            Teach VideoFullscreenInterface to keep track of its corresponding MediaPlayer's MediaPlayerIdentifier
+            https://bugs.webkit.org/show_bug.cgi?id=236090
+
+            Reviewed by Eric Carlson.
+
+            Add plumbing for an optional MediaPlayerIdentifier through the video fullscreen model. This identifier is
+            invalidated upon `loadstart`, and updated once we observe `loadedmetadata`, which ensures that if the media
+            engine (and media player) changes out from underneath the video fullscreen model, we still keep the new player
+            ID up to date.
+
+            See WebKit/ChangeLog for more details.
+
+            * platform/cocoa/VideoFullscreenModel.h:
+            (WebCore::VideoFullscreenModelClient::setPlayerIdentifier):
+            * platform/cocoa/VideoFullscreenModelVideoElement.h:
+            * platform/cocoa/VideoFullscreenModelVideoElement.mm:
+            (WebCore::VideoFullscreenModelVideoElement::updateForEventName):
+            (WebCore::VideoFullscreenModelVideoElement::observedEventNames):
+
+            Additionally listen for `loadstartEvent` and `loadedmetadataEvent` (see above).
+
+            (WebCore::VideoFullscreenModelVideoElement::setPlayerIdentifier):
+            * platform/ios/VideoFullscreenInterfaceAVKit.h:
+            * platform/mac/VideoFullscreenInterfaceMac.h:
+            (WebCore::VideoFullscreenInterfaceMac::playerIdentifier const):
+
 2022-04-19  Alan Coon  <[email protected]>
 
         Cherry-pick r292854. rdar://problem/91733055

Modified: branches/safari-613-branch/Source/WebCore/platform/cocoa/VideoFullscreenModel.h (293103 => 293104)


--- branches/safari-613-branch/Source/WebCore/platform/cocoa/VideoFullscreenModel.h	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebCore/platform/cocoa/VideoFullscreenModel.h	2022-04-20 17:24:59 UTC (rev 293104)
@@ -32,6 +32,7 @@
 #include "FloatRect.h"
 #include "HTMLMediaElementEnums.h"
 #include "MediaPlayerEnums.h"
+#include "MediaPlayerIdentifier.h"
 #include "PlaybackSessionModel.h"
 #include <wtf/CompletionHandler.h>
 #include <wtf/WeakPtr.h>
@@ -84,6 +85,7 @@
     virtual void willExitPictureInPicture() { }
     virtual void didExitPictureInPicture() { }
     virtual void modelDestroyed() { }
+    virtual void setPlayerIdentifier(std::optional<MediaPlayerIdentifier>) { }
 };
     
 }

Modified: branches/safari-613-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h (293103 => 293104)


--- branches/safari-613-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h	2022-04-20 17:24:59 UTC (rev 293104)
@@ -32,6 +32,7 @@
 #include "FloatRect.h"
 #include "HTMLMediaElementEnums.h"
 #include "MediaPlayerEnums.h"
+#include "MediaPlayerIdentifier.h"
 #include "PlatformLayer.h"
 #include "VideoFullscreenModel.h"
 #include <wtf/Function.h>
@@ -81,6 +82,7 @@
 private:
     void setHasVideo(bool);
     void setVideoDimensions(const FloatSize&);
+    void setPlayerIdentifier(std::optional<MediaPlayerIdentifier>);
 
     void willEnterPictureInPicture() override;
     void didEnterPictureInPicture() override;
@@ -100,6 +102,7 @@
     FloatRect m_videoFrame;
     Vector<RefPtr<TextTrack>> m_legibleTracksForMenu;
     Vector<RefPtr<AudioTrack>> m_audioTracksForMenu;
+    std::optional<MediaPlayerIdentifier> m_playerIdentifier;
 };
 
 }

Modified: branches/safari-613-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm (293103 => 293104)


--- branches/safari-613-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm	2022-04-20 17:24:59 UTC (rev 293104)
@@ -103,6 +103,26 @@
         setHasVideo(m_videoElement);
         setVideoDimensions(m_videoElement ? FloatSize(m_videoElement->videoWidth(), m_videoElement->videoHeight()) : FloatSize());
     }
+
+    if (all
+        || eventName == eventNames().loadedmetadataEvent || eventName == eventNames().loadstartEvent) {
+        setPlayerIdentifier([&]() -> std::optional<MediaPlayerIdentifier> {
+            if (eventName == eventNames().loadstartEvent)
+                return std::nullopt;
+
+            if (!m_videoElement)
+                return std::nullopt;
+
+            auto player = m_videoElement->player();
+            if (!player)
+                return std::nullopt;
+
+            if (auto identifier = player->identifier())
+                return identifier;
+
+            return std::nullopt;
+        }());
+    }
 }
 
 void VideoFullscreenModelVideoElement::willExitFullscreen()
@@ -180,7 +200,7 @@
 
 Span<const AtomString> VideoFullscreenModelVideoElement::observedEventNames()
 {
-    static NeverDestroyed names = std::array { eventNames().resizeEvent };
+    static NeverDestroyed names = std::array { eventNames().resizeEvent, eventNames().loadstartEvent, eventNames().loadedmetadataEvent };
     return names.get();
 }
 
@@ -238,6 +258,17 @@
         client->videoDimensionsChanged(m_videoDimensions);
 }
 
+void VideoFullscreenModelVideoElement::setPlayerIdentifier(std::optional<MediaPlayerIdentifier> identifier)
+{
+    if (m_playerIdentifier == identifier)
+        return;
+
+    m_playerIdentifier = identifier;
+
+    for (auto* client : copyToVector(m_clients))
+        client->setPlayerIdentifier(identifier);
+}
+
 void VideoFullscreenModelVideoElement::willEnterPictureInPicture()
 {
     for (auto& client : copyToVector(m_clients))

Modified: branches/safari-613-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h (293103 => 293104)


--- branches/safari-613-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h	2022-04-20 17:24:59 UTC (rev 293104)
@@ -30,6 +30,7 @@
 
 #include "EventListener.h"
 #include "HTMLMediaElementEnums.h"
+#include "MediaPlayerIdentifier.h"
 #include "PlatformLayer.h"
 #include "PlaybackSessionInterfaceAVKit.h"
 #include "VideoFullscreenModel.h"
@@ -160,6 +161,8 @@
     WebAVPlayerLayerView* playerLayerView() const { return m_playerLayerView.get(); }
     WEBCORE_EXPORT bool pictureInPictureWasStartedWhenEnteringBackground() const;
 
+    std::optional<MediaPlayerIdentifier> playerIdentifier() const { return m_playerIdentifier; }
+
 protected:
     WEBCORE_EXPORT VideoFullscreenInterfaceAVKit(PlaybackSessionInterfaceAVKit&);
 
@@ -172,6 +175,7 @@
     WebAVPlayerController *playerController() const;
 
     Ref<PlaybackSessionInterfaceAVKit> m_playbackSessionInterface;
+    std::optional<MediaPlayerIdentifier> m_playerIdentifier;
     RetainPtr<WebAVPlayerViewControllerDelegate> m_playerViewControllerDelegate;
     RetainPtr<WebAVPlayerViewController> m_playerViewController;
     VideoFullscreenModel* m_videoFullscreenModel { nullptr };

Modified: branches/safari-613-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h (293103 => 293104)


--- branches/safari-613-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h	2022-04-20 17:24:59 UTC (rev 293104)
@@ -28,6 +28,7 @@
 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
 
 #include "HTMLMediaElementEnums.h"
+#include "MediaPlayerIdentifier.h"
 #include "PlaybackSessionInterfaceMac.h"
 #include "PlaybackSessionModel.h"
 #include "VideoFullscreenModel.h"
@@ -70,6 +71,7 @@
     // VideoFullscreenModelClient
     WEBCORE_EXPORT void hasVideoChanged(bool) final;
     WEBCORE_EXPORT void videoDimensionsChanged(const FloatSize&) final;
+    void setPlayerIdentifier(std::optional<MediaPlayerIdentifier> identifier) final { m_playerIdentifier = identifier; }
 
     WEBCORE_EXPORT void setupFullscreen(NSView& layerHostedView, const IntRect& initialRect, NSWindow *parentWindow, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
     WEBCORE_EXPORT void enterFullscreen();
@@ -96,9 +98,12 @@
 
     WEBCORE_EXPORT void requestHideAndExitPiP();
 
+    std::optional<MediaPlayerIdentifier> playerIdentifier() const { return m_playerIdentifier; }
+
 private:
     WEBCORE_EXPORT VideoFullscreenInterfaceMac(PlaybackSessionInterfaceMac&);
     Ref<PlaybackSessionInterfaceMac> m_playbackSessionInterface;
+    std::optional<MediaPlayerIdentifier> m_playerIdentifier;
     WeakPtr<VideoFullscreenModel> m_videoFullscreenModel;
     WeakPtr<VideoFullscreenChangeObserver> m_fullscreenChangeObserver;
     HTMLMediaElementEnums::VideoFullscreenMode m_mode { HTMLMediaElementEnums::VideoFullscreenModeNone };

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (293103 => 293104)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-04-20 17:24:59 UTC (rev 293104)
@@ -1,3 +1,80 @@
+2022-04-20  Alan Coon  <[email protected]>
+
+        Cherry-pick r289100. rdar://problem/79950080
+
+    Teach VideoFullscreenInterface to keep track of its corresponding MediaPlayer's MediaPlayerIdentifier
+    https://bugs.webkit.org/show_bug.cgi?id=236090
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    Add plumbing for an optional MediaPlayerIdentifier through the video fullscreen model. This identifier is
+    invalidated upon `loadstart`, and updated once we observe `loadedmetadata`, which ensures that if the media
+    engine (and media player) changes out from underneath the video fullscreen model, we still keep the new player
+    ID up to date.
+    
+    See WebKit/ChangeLog for more details.
+    
+    * platform/cocoa/VideoFullscreenModel.h:
+    (WebCore::VideoFullscreenModelClient::setPlayerIdentifier):
+    * platform/cocoa/VideoFullscreenModelVideoElement.h:
+    * platform/cocoa/VideoFullscreenModelVideoElement.mm:
+    (WebCore::VideoFullscreenModelVideoElement::updateForEventName):
+    (WebCore::VideoFullscreenModelVideoElement::observedEventNames):
+    
+    Additionally listen for `loadstartEvent` and `loadedmetadataEvent` (see above).
+    
+    (WebCore::VideoFullscreenModelVideoElement::setPlayerIdentifier):
+    * platform/ios/VideoFullscreenInterfaceAVKit.h:
+    * platform/mac/VideoFullscreenInterfaceMac.h:
+    (WebCore::VideoFullscreenInterfaceMac::playerIdentifier const):
+    
+    Source/WebKit:
+    
+    Add an IPC message between VideoFullscreenManager and VideoFullscreenManagerProxy to update the media player ID
+    corresponding to a given PlaybackSessionContextIdentifier. This is sent if the underlying media player changes
+    (and subsequently fires `loadstart` and `loadedmetadata` events), and also sent upon entering fullscreen video.
+    
+    In a future patch, this mechanism will be used to teach VideoFullscreenManagerProxy to grab an image bitmap from
+    the GPU process for a given PlaybackSessionContextIdentifier.
+    
+    * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
+    * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
+    * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+    (WebKit::VideoFullscreenManagerProxy::setPlayerIdentifier):
+    * WebProcess/cocoa/VideoFullscreenManager.h:
+    * WebProcess/cocoa/VideoFullscreenManager.mm:
+    (WebKit::VideoFullscreenInterfaceContext::setPlayerIdentifier):
+    (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
+    (WebKit::VideoFullscreenManager::setPlayerIdentifier):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289100 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-03  Wenson Hsieh  <[email protected]>
+
+            Teach VideoFullscreenInterface to keep track of its corresponding MediaPlayer's MediaPlayerIdentifier
+            https://bugs.webkit.org/show_bug.cgi?id=236090
+
+            Reviewed by Eric Carlson.
+
+            Add an IPC message between VideoFullscreenManager and VideoFullscreenManagerProxy to update the media player ID
+            corresponding to a given PlaybackSessionContextIdentifier. This is sent if the underlying media player changes
+            (and subsequently fires `loadstart` and `loadedmetadata` events), and also sent upon entering fullscreen video.
+
+            In a future patch, this mechanism will be used to teach VideoFullscreenManagerProxy to grab an image bitmap from
+            the GPU process for a given PlaybackSessionContextIdentifier.
+
+            * UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
+            * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in:
+            * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+            (WebKit::VideoFullscreenManagerProxy::setPlayerIdentifier):
+            * WebProcess/cocoa/VideoFullscreenManager.h:
+            * WebProcess/cocoa/VideoFullscreenManager.mm:
+            (WebKit::VideoFullscreenInterfaceContext::setPlayerIdentifier):
+            (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
+            (WebKit::VideoFullscreenManager::setPlayerIdentifier):
+
 2022-04-19  Alan Coon  <[email protected]>
 
         Cherry-pick r292049. rdar://problem/89104216

Modified: branches/safari-613-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h (293103 => 293104)


--- branches/safari-613-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h	2022-04-20 17:24:59 UTC (rev 293104)
@@ -32,6 +32,7 @@
 #include "PlaybackSessionContextIdentifier.h"
 #include <WebCore/AudioSession.h>
 #include <WebCore/GraphicsLayer.h>
+#include <WebCore/MediaPlayerIdentifier.h>
 #include <WebCore/PlatformView.h>
 #include <WebCore/VideoFullscreenChangeObserver.h>
 #include <WebCore/VideoFullscreenModel.h>
@@ -180,6 +181,7 @@
     void preparedToReturnToInline(PlaybackSessionContextIdentifier, bool visible, WebCore::FloatRect inlineRect);
     void preparedToExitFullscreen(PlaybackSessionContextIdentifier);
     void exitFullscreenWithoutAnimationToMode(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
+    void setPlayerIdentifier(PlaybackSessionContextIdentifier, std::optional<WebCore::MediaPlayerIdentifier>);
 
     // Messages to VideoFullscreenManager
     void requestFullscreenMode(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool finishedWithMedia = false);

Modified: branches/safari-613-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in (293103 => 293104)


--- branches/safari-613-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in	2022-04-20 17:24:59 UTC (rev 293104)
@@ -25,6 +25,7 @@
     SetHasVideo(WebKit::PlaybackSessionContextIdentifier contextId, bool hasVideo)
     SetVideoDimensions(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::FloatSize videoDimensions)
     SetupFullscreenWithID(WebKit::PlaybackSessionContextIdentifier contextId, WebKit::LayerHostingContextID videoLayerID, WebCore::FloatRect initialRect, WebCore::FloatSize videoDimensions, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture, bool standby, bool blocksReturnToFullscreenFromPictureInPicture)
+    SetPlayerIdentifier(WebKit::PlaybackSessionContextIdentifier contextId, std::optional<WebCore::MediaPlayerIdentifier> playerIdentifier)
 #if !PLATFORM(IOS_FAMILY)
     EnterFullscreen(WebKit::PlaybackSessionContextIdentifier contextId)
 #endif

Modified: branches/safari-613-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm (293103 => 293104)


--- branches/safari-613-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm	2022-04-20 17:24:59 UTC (rev 293104)
@@ -571,6 +571,15 @@
 #endif
 }
 
+void VideoFullscreenManagerProxy::setPlayerIdentifier(PlaybackSessionContextIdentifier contextId, std::optional<MediaPlayerIdentifier> playerIdentifier)
+{
+    if (m_mockVideoPresentationModeEnabled)
+        return;
+
+    if (auto* interface = findInterface(contextId))
+        interface->setPlayerIdentifier(playerIdentifier);
+}
+
 void VideoFullscreenManagerProxy::setHasVideo(PlaybackSessionContextIdentifier contextId, bool hasVideo)
 {
     if (m_mockVideoPresentationModeEnabled)

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h (293103 => 293104)


--- branches/safari-613-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h	2022-04-20 17:24:59 UTC (rev 293104)
@@ -98,6 +98,7 @@
     // VideoFullscreenModelClient
     void hasVideoChanged(bool) override;
     void videoDimensionsChanged(const WebCore::FloatSize&) override;
+    void setPlayerIdentifier(std::optional<WebCore::MediaPlayerIdentifier>) final;
 
     VideoFullscreenInterfaceContext(VideoFullscreenManager&, PlaybackSessionContextIdentifier);
 
@@ -146,6 +147,7 @@
     // Interface to VideoFullscreenInterfaceContext
     void hasVideoChanged(PlaybackSessionContextIdentifier, bool hasVideo);
     void videoDimensionsChanged(PlaybackSessionContextIdentifier, const WebCore::FloatSize&);
+    void setPlayerIdentifier(PlaybackSessionContextIdentifier, std::optional<WebCore::MediaPlayerIdentifier>);
 
     // Messages from VideoFullscreenManagerProxy
     void requestFullscreenMode(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool finishedWithMedia);

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (293103 => 293104)


--- branches/safari-613-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2022-04-20 17:24:52 UTC (rev 293103)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2022-04-20 17:24:59 UTC (rev 293104)
@@ -110,6 +110,12 @@
         m_manager->videoDimensionsChanged(m_contextId, videoDimensions);
 }
 
+void VideoFullscreenInterfaceContext::setPlayerIdentifier(std::optional<MediaPlayerIdentifier> identifier)
+{
+    if (m_manager)
+        m_manager->setPlayerIdentifier(m_contextId, identifier);
+}
+
 #pragma mark - VideoFullscreenManager
 
 Ref<VideoFullscreenManager> VideoFullscreenManager::create(WebPage& page, PlaybackSessionManager& playbackSessionManager)
@@ -309,6 +315,11 @@
     }
 
     m_page->send(Messages::VideoFullscreenManagerProxy::SetupFullscreenWithID(contextId, interface->layerHostingContext()->contextID(), videoRect, FloatSize(videoElement.videoWidth(), videoElement.videoHeight()), m_page->deviceScaleFactor(), interface->fullscreenMode(), allowsPictureInPicture, standby, videoElement.document().quirks().blocksReturnToFullscreenFromPictureInPictureQuirk()));
+
+    if (auto player = videoElement.player()) {
+        if (auto identifier = player->identifier())
+            setPlayerIdentifier(contextId, identifier);
+    }
 }
 
 void VideoFullscreenManager::exitVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, CompletionHandler<void(bool)>&& completionHandler)
@@ -377,6 +388,12 @@
         m_page->send(Messages::VideoFullscreenManagerProxy::SetVideoDimensions(contextId, videoDimensions));
 }
 
+void VideoFullscreenManager::setPlayerIdentifier(PlaybackSessionContextIdentifier contextIdentifier, std::optional<MediaPlayerIdentifier> playerIdentifier)
+{
+    if (m_page)
+        m_page->send(Messages::VideoFullscreenManagerProxy::SetPlayerIdentifier(contextIdentifier, playerIdentifier));
+}
+
 #pragma mark Messages from VideoFullscreenManagerProxy:
 
 void VideoFullscreenManager::requestFullscreenMode(PlaybackSessionContextIdentifier contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode, bool finishedWithMedia)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to