Changeset 289100 in webkit
- Timestamp:
- Feb 3, 2022, 6:45:45 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r289099 r289100 1 2022-02-03 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Teach VideoFullscreenInterface to keep track of its corresponding MediaPlayer's MediaPlayerIdentifier 4 https://bugs.webkit.org/show_bug.cgi?id=236090 5 6 Reviewed by Eric Carlson. 7 8 Add plumbing for an optional MediaPlayerIdentifier through the video fullscreen model. This identifier is 9 invalidated upon `loadstart`, and updated once we observe `loadedmetadata`, which ensures that if the media 10 engine (and media player) changes out from underneath the video fullscreen model, we still keep the new player 11 ID up to date. 12 13 See WebKit/ChangeLog for more details. 14 15 * platform/cocoa/VideoFullscreenModel.h: 16 (WebCore::VideoFullscreenModelClient::setPlayerIdentifier): 17 * platform/cocoa/VideoFullscreenModelVideoElement.h: 18 * platform/cocoa/VideoFullscreenModelVideoElement.mm: 19 (WebCore::VideoFullscreenModelVideoElement::updateForEventName): 20 (WebCore::VideoFullscreenModelVideoElement::observedEventNames): 21 22 Additionally listen for `loadstartEvent` and `loadedmetadataEvent` (see above). 23 24 (WebCore::VideoFullscreenModelVideoElement::setPlayerIdentifier): 25 * platform/ios/VideoFullscreenInterfaceAVKit.h: 26 * platform/mac/VideoFullscreenInterfaceMac.h: 27 (WebCore::VideoFullscreenInterfaceMac::playerIdentifier const): 28 1 29 2022-02-03 Commit Queue <commit-queue@webkit.org> 2 30 -
trunk/Source/WebCore/platform/cocoa/VideoFullscreenModel.h
r273276 r289100 33 33 #include "HTMLMediaElementEnums.h" 34 34 #include "MediaPlayerEnums.h" 35 #include "MediaPlayerIdentifier.h" 35 36 #include "PlaybackSessionModel.h" 36 37 #include <wtf/CompletionHandler.h> … … 85 86 virtual void didExitPictureInPicture() { } 86 87 virtual void modelDestroyed() { } 88 virtual void setPlayerIdentifier(std::optional<MediaPlayerIdentifier>) { } 87 89 }; 88 90 -
trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h
r287138 r289100 33 33 #include "HTMLMediaElementEnums.h" 34 34 #include "MediaPlayerEnums.h" 35 #include "MediaPlayerIdentifier.h" 35 36 #include "PlatformLayer.h" 36 37 #include "VideoFullscreenModel.h" … … 82 83 void setHasVideo(bool); 83 84 void setVideoDimensions(const FloatSize&); 85 void setPlayerIdentifier(std::optional<MediaPlayerIdentifier>); 84 86 85 87 void willEnterPictureInPicture() override; … … 101 103 Vector<RefPtr<TextTrack>> m_legibleTracksForMenu; 102 104 Vector<RefPtr<AudioTrack>> m_audioTracksForMenu; 105 std::optional<MediaPlayerIdentifier> m_playerIdentifier; 103 106 }; 104 107 -
trunk/Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm
r287138 r289100 104 104 setVideoDimensions(m_videoElement ? FloatSize(m_videoElement->videoWidth(), m_videoElement->videoHeight()) : FloatSize()); 105 105 } 106 107 if (all 108 || eventName == eventNames().loadedmetadataEvent || eventName == eventNames().loadstartEvent) { 109 setPlayerIdentifier([&]() -> std::optional<MediaPlayerIdentifier> { 110 if (eventName == eventNames().loadstartEvent) 111 return std::nullopt; 112 113 if (!m_videoElement) 114 return std::nullopt; 115 116 auto player = m_videoElement->player(); 117 if (!player) 118 return std::nullopt; 119 120 if (auto identifier = player->identifier()) 121 return identifier; 122 123 return std::nullopt; 124 }()); 125 } 106 126 } 107 127 … … 181 201 Span<const AtomString> VideoFullscreenModelVideoElement::observedEventNames() 182 202 { 183 static NeverDestroyed names = std::array { eventNames().resizeEvent };203 static NeverDestroyed names = std::array { eventNames().resizeEvent, eventNames().loadstartEvent, eventNames().loadedmetadataEvent }; 184 204 return names.get(); 185 205 } … … 239 259 } 240 260 261 void VideoFullscreenModelVideoElement::setPlayerIdentifier(std::optional<MediaPlayerIdentifier> identifier) 262 { 263 if (m_playerIdentifier == identifier) 264 return; 265 266 m_playerIdentifier = identifier; 267 268 for (auto* client : copyToVector(m_clients)) 269 client->setPlayerIdentifier(identifier); 270 } 271 241 272 void VideoFullscreenModelVideoElement::willEnterPictureInPicture() 242 273 { -
trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.h
r284857 r289100 31 31 #include "EventListener.h" 32 32 #include "HTMLMediaElementEnums.h" 33 #include "MediaPlayerIdentifier.h" 33 34 #include "PlatformLayer.h" 34 35 #include "PlaybackSessionInterfaceAVKit.h" … … 77 78 WEBCORE_EXPORT void videoDimensionsChanged(const FloatSize&) final; 78 79 WEBCORE_EXPORT void modelDestroyed() final; 80 void setPlayerIdentifier(std::optional<MediaPlayerIdentifier> identifier) final { m_playerIdentifier = identifier; } 79 81 80 82 // PlaybackSessionModelClient … … 160 162 WEBCORE_EXPORT bool pictureInPictureWasStartedWhenEnteringBackground() const; 161 163 164 std::optional<MediaPlayerIdentifier> playerIdentifier() const { return m_playerIdentifier; } 165 162 166 protected: 163 167 WEBCORE_EXPORT VideoFullscreenInterfaceAVKit(PlaybackSessionInterfaceAVKit&); … … 172 176 173 177 Ref<PlaybackSessionInterfaceAVKit> m_playbackSessionInterface; 178 std::optional<MediaPlayerIdentifier> m_playerIdentifier; 174 179 RetainPtr<WebAVPlayerViewControllerDelegate> m_playerViewControllerDelegate; 175 180 RetainPtr<WebAVPlayerViewController> m_playerViewController; -
trunk/Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.h
r279043 r289100 29 29 30 30 #include "HTMLMediaElementEnums.h" 31 #include "MediaPlayerIdentifier.h" 31 32 #include "PlaybackSessionInterfaceMac.h" 32 33 #include "PlaybackSessionModel.h" … … 71 72 WEBCORE_EXPORT void hasVideoChanged(bool) final; 72 73 WEBCORE_EXPORT void videoDimensionsChanged(const FloatSize&) final; 74 void setPlayerIdentifier(std::optional<MediaPlayerIdentifier> identifier) final { m_playerIdentifier = identifier; } 73 75 74 76 WEBCORE_EXPORT void setupFullscreen(NSView& layerHostedView, const IntRect& initialRect, NSWindow *parentWindow, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback); … … 97 99 WEBCORE_EXPORT void requestHideAndExitPiP(); 98 100 101 std::optional<MediaPlayerIdentifier> playerIdentifier() const { return m_playerIdentifier; } 102 99 103 private: 100 104 WEBCORE_EXPORT VideoFullscreenInterfaceMac(PlaybackSessionInterfaceMac&); 101 105 Ref<PlaybackSessionInterfaceMac> m_playbackSessionInterface; 106 std::optional<MediaPlayerIdentifier> m_playerIdentifier; 102 107 WeakPtr<VideoFullscreenModel> m_videoFullscreenModel; 103 108 WeakPtr<VideoFullscreenChangeObserver> m_fullscreenChangeObserver; -
trunk/Source/WebKit/ChangeLog
r289091 r289100 1 2022-02-03 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Teach VideoFullscreenInterface to keep track of its corresponding MediaPlayer's MediaPlayerIdentifier 4 https://bugs.webkit.org/show_bug.cgi?id=236090 5 6 Reviewed by Eric Carlson. 7 8 Add an IPC message between VideoFullscreenManager and VideoFullscreenManagerProxy to update the media player ID 9 corresponding to a given PlaybackSessionContextIdentifier. This is sent if the underlying media player changes 10 (and subsequently fires `loadstart` and `loadedmetadata` events), and also sent upon entering fullscreen video. 11 12 In a future patch, this mechanism will be used to teach VideoFullscreenManagerProxy to grab an image bitmap from 13 the GPU process for a given PlaybackSessionContextIdentifier. 14 15 * UIProcess/Cocoa/VideoFullscreenManagerProxy.h: 16 * UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in: 17 * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm: 18 (WebKit::VideoFullscreenManagerProxy::setPlayerIdentifier): 19 * WebProcess/cocoa/VideoFullscreenManager.h: 20 * WebProcess/cocoa/VideoFullscreenManager.mm: 21 (WebKit::VideoFullscreenInterfaceContext::setPlayerIdentifier): 22 (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement): 23 (WebKit::VideoFullscreenManager::setPlayerIdentifier): 24 1 25 2022-02-03 Michael Saboff <msaboff@apple.com> 2 26 -
trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h
r289090 r289100 33 33 #include <WebCore/AudioSession.h> 34 34 #include <WebCore/GraphicsLayer.h> 35 #include <WebCore/MediaPlayerIdentifier.h> 35 36 #include <WebCore/PlatformView.h> 36 37 #include <WebCore/VideoFullscreenChangeObserver.h> … … 181 182 void preparedToExitFullscreen(PlaybackSessionContextIdentifier); 182 183 void exitFullscreenWithoutAnimationToMode(PlaybackSessionContextIdentifier, WebCore::HTMLMediaElementEnums::VideoFullscreenMode); 184 void setPlayerIdentifier(PlaybackSessionContextIdentifier, std::optional<WebCore::MediaPlayerIdentifier>); 183 185 184 186 // Messages to VideoFullscreenManager -
trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in
r277242 r289100 26 26 SetVideoDimensions(WebKit::PlaybackSessionContextIdentifier contextId, WebCore::FloatSize videoDimensions) 27 27 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) 28 SetPlayerIdentifier(WebKit::PlaybackSessionContextIdentifier contextId, std::optional<WebCore::MediaPlayerIdentifier> playerIdentifier) 28 29 #if !PLATFORM(IOS_FAMILY) 29 30 EnterFullscreen(WebKit::PlaybackSessionContextIdentifier contextId) -
trunk/Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm
r289090 r289100 572 572 } 573 573 574 void VideoFullscreenManagerProxy::setPlayerIdentifier(PlaybackSessionContextIdentifier contextId, std::optional<MediaPlayerIdentifier> playerIdentifier) 575 { 576 if (m_mockVideoPresentationModeEnabled) 577 return; 578 579 if (auto* interface = findInterface(contextId)) 580 interface->setPlayerIdentifier(playerIdentifier); 581 } 582 574 583 void VideoFullscreenManagerProxy::setHasVideo(PlaybackSessionContextIdentifier contextId, bool hasVideo) 575 584 { -
trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h
r278253 r289100 99 99 void hasVideoChanged(bool) override; 100 100 void videoDimensionsChanged(const WebCore::FloatSize&) override; 101 void setPlayerIdentifier(std::optional<WebCore::MediaPlayerIdentifier>) final; 101 102 102 103 VideoFullscreenInterfaceContext(VideoFullscreenManager&, PlaybackSessionContextIdentifier); … … 147 148 void hasVideoChanged(PlaybackSessionContextIdentifier, bool hasVideo); 148 149 void videoDimensionsChanged(PlaybackSessionContextIdentifier, const WebCore::FloatSize&); 150 void setPlayerIdentifier(PlaybackSessionContextIdentifier, std::optional<WebCore::MediaPlayerIdentifier>); 149 151 150 152 // Messages from VideoFullscreenManagerProxy -
trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm
r287731 r289100 111 111 } 112 112 113 void VideoFullscreenInterfaceContext::setPlayerIdentifier(std::optional<MediaPlayerIdentifier> identifier) 114 { 115 if (m_manager) 116 m_manager->setPlayerIdentifier(m_contextId, identifier); 117 } 118 113 119 #pragma mark - VideoFullscreenManager 114 120 … … 310 316 311 317 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())); 318 319 if (auto player = videoElement.player()) { 320 if (auto identifier = player->identifier()) 321 setPlayerIdentifier(contextId, identifier); 322 } 312 323 } 313 324 … … 376 387 if (m_page) 377 388 m_page->send(Messages::VideoFullscreenManagerProxy::SetVideoDimensions(contextId, videoDimensions)); 389 } 390 391 void VideoFullscreenManager::setPlayerIdentifier(PlaybackSessionContextIdentifier contextIdentifier, std::optional<MediaPlayerIdentifier> playerIdentifier) 392 { 393 if (m_page) 394 m_page->send(Messages::VideoFullscreenManagerProxy::SetPlayerIdentifier(contextIdentifier, playerIdentifier)); 378 395 } 379 396
Note:
See TracChangeset
for help on using the changeset viewer.