Enable API related to the video fullscreen layer in MediaPlayerPrivateMediaSourceAVFObjC
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 22:23:36 +0000 (22:23 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 22:23:36 +0000 (22:23 +0000)
also on Mac platform with video presentation mode support.
https://bugs.webkit.org/show_bug.cgi?id=153223

Reviewed by Jer Noble.

Reuse VideoFullscreenLayerManager to manage moving the video layer between the fullscreen
layer and the inline layer depending on the current presentation mode.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
Create m_videoFullscreenLayerManager.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::platformLayer):
Return the video inline layer from the VideoFullscreenLayerManager.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer):
Call VideoFullscreenLayerManager::setVideoLayer() with the m_sampleBufferDisplayLayer.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer):
Call VideoFullscreenLayerManager::didDestroyVideoLayer().
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer):
Call VideoFullscreenLayerManager::setVideoFullscreenLayer().
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenFrame):
Call VideoFullscreenLayerManager::setVideoFullscreenFrame().

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

index c9d742e..e99d6f2 100644 (file)
@@ -1,3 +1,29 @@
+2016-01-26  Ada Chan  <adachan@apple.com>
+
+        Enable API related to the video fullscreen layer in MediaPlayerPrivateMediaSourceAVFObjC
+        also on Mac platform with video presentation mode support.
+        https://bugs.webkit.org/show_bug.cgi?id=153223
+
+        Reviewed by Jer Noble.
+
+        Reuse VideoFullscreenLayerManager to manage moving the video layer between the fullscreen
+        layer and the inline layer depending on the current presentation mode.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
+        Create m_videoFullscreenLayerManager.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::platformLayer):
+        Return the video inline layer from the VideoFullscreenLayerManager.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer):
+        Call VideoFullscreenLayerManager::setVideoLayer() with the m_sampleBufferDisplayLayer.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer):
+        Call VideoFullscreenLayerManager::didDestroyVideoLayer().
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer):
+        Call VideoFullscreenLayerManager::setVideoFullscreenLayer().
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenFrame):
+        Call VideoFullscreenLayerManager::setVideoFullscreenFrame().
+
 2016-01-27  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: SQLite backend doesn't update index records as object records are added.
index 7eb99da..4b1b823 100644 (file)
@@ -48,6 +48,10 @@ class CDMSessionMediaSourceAVFObjC;
 class PlatformClockCM;
 class MediaSourcePrivateAVFObjC;
 
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+class VideoFullscreenLayerManager;
+#endif
+
 class MediaPlayerPrivateMediaSourceAVFObjC : public MediaPlayerPrivateInterface {
 public:
     explicit MediaPlayerPrivateMediaSourceAVFObjC(MediaPlayer*);
@@ -82,6 +86,11 @@ public:
     void sizeChanged();
     void characteristicsChanged();
 
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+    virtual void setVideoFullscreenLayer(PlatformLayer*) override;
+    virtual void setVideoFullscreenFrame(FloatRect) override;
+#endif
+
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     bool hasStreamSession() { return m_streamSession; }
     AVStreamSession *streamSession();
@@ -223,6 +232,9 @@ private:
     RefPtr<MediaPlaybackTarget> m_playbackTarget;
     bool m_shouldPlayToTarget { false };
 #endif
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+    std::unique_ptr<VideoFullscreenLayerManager> m_videoFullscreenLayerManager;
+#endif
 };
 
 }
index feaca80..8140e71 100644 (file)
 #import <wtf/MainThread.h>
 #import <wtf/NeverDestroyed.h>
 
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+#import "VideoFullscreenLayerManager.h"
+#endif
+
 #pragma mark - Soft Linking
 
 #import "CoreMediaSoftLink.h"
@@ -146,6 +150,9 @@ MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC(Media
     , m_seeking(false)
     , m_seekCompleted(true)
     , m_loadingProgressed(false)
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+    , m_videoFullscreenLayerManager(VideoFullscreenLayerManager::create())
+#endif
 {
     CMTimebaseRef timebase = [m_synchronizer timebase];
     CMNotificationCenterRef nc = CMNotificationCenterGetDefaultLocalCenter();
@@ -296,7 +303,11 @@ PlatformMedia MediaPlayerPrivateMediaSourceAVFObjC::platformMedia() const
 
 PlatformLayer* MediaPlayerPrivateMediaSourceAVFObjC::platformLayer() const
 {
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+    return m_videoFullscreenLayerManager->videoInlineLayer();
+#else
     return m_sampleBufferDisplayLayer.get();
+#endif
 }
 
 void MediaPlayerPrivateMediaSourceAVFObjC::play()
@@ -757,6 +768,10 @@ void MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer(AVSampleBufferDisplay
 
     // FIXME: move this somewhere appropriate:
     m_player->firstVideoFrameAvailable();
+
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+    m_videoFullscreenLayerManager->setVideoLayer(m_sampleBufferDisplayLayer.get(), snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size());
+#endif
 }
 
 void MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer(AVSampleBufferDisplayLayer* displayLayer)
@@ -771,6 +786,10 @@ void MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer(AVSampleBufferDisp
 
     m_sampleBufferDisplayLayer = nullptr;
     m_player->client().mediaPlayerRenderingModeChanged(m_player);
+
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+    m_videoFullscreenLayerManager->didDestroyVideoLayer();
+#endif
 }
 
 void MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer(AVSampleBufferAudioRenderer* audioRenderer)
@@ -808,6 +827,18 @@ void MediaPlayerPrivateMediaSourceAVFObjC::characteristicsChanged()
     m_player->characteristicChanged();
 }
 
+#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
+void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer)
+{
+    m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer);
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenFrame(FloatRect frame)
+{
+    m_videoFullscreenLayerManager->setVideoFullscreenFrame(frame);
+}
+#endif
+
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
 void MediaPlayerPrivateMediaSourceAVFObjC::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& target)
 {