⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 197807 in webkit


Ignore:
Timestamp:
Mar 8, 2016, 3:16:29 PM (11 years ago)
Author:
adachan@apple.com
Message:

Enable API related to the video fullscreen layer in MediaPlayerPrivateMediaStreamAVFObjC for Mac.
​https://bugs.webkit.org/show_bug.cgi?id=153239

Reviewed by Eric Carlson.

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/MediaPlayerPrivateMediaStreamAVFObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC):
Create m_videoFullscreenLayerManager.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::platformLayer):
Return the video inline layer from the VideoFullscreenLayerManager.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::createPreviewLayers):
Call VideoFullscreenLayerManager::setVideoLayer() with the m_videoBackgroundLayer. To make sure
the preview layer (a sublayer of m_videoBackgroundLayer) resize according to aspect ratio, set
its contents gravity to kCAGravityResizeAspect. Also, set its autoresizing mask so it'll resize
with its superlayer.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer):
Call VideoFullscreenLayerManager::setVideoFullscreenLayer().
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenFrame):
Call VideoFullscreenLayerManager::setVideoFullscreenFrame().

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r197804 r197807  
     12016-03-08  Ada Chan  <adachan@apple.com>
     2
     3        Enable API related to the video fullscreen layer in MediaPlayerPrivateMediaStreamAVFObjC for Mac.
     4        https://bugs.webkit.org/show_bug.cgi?id=153239
     5
     6        Reviewed by Eric Carlson.
     7
     8        Reuse VideoFullscreenLayerManager to manage moving the video layer between the fullscreen
     9        layer and the inline layer depending on the current presentation mode.
     10
     11        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
     12        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
     13        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC):
     14        Create m_videoFullscreenLayerManager.
     15        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::platformLayer):
     16        Return the video inline layer from the VideoFullscreenLayerManager.
     17        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::createPreviewLayers):
     18        Call VideoFullscreenLayerManager::setVideoLayer() with the m_videoBackgroundLayer. To make sure
     19        the preview layer (a sublayer of m_videoBackgroundLayer) resize according to aspect ratio, set
     20        its contents gravity to kCAGravityResizeAspect. Also, set its autoresizing mask so it'll resize
     21        with its superlayer.
     22        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer):
     23        Call VideoFullscreenLayerManager::setVideoFullscreenLayer().
     24        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenFrame):
     25        Call VideoFullscreenLayerManager::setVideoFullscreenFrame().
     26
    1272016-03-08  Myles C. Maxfield  <mmaxfield@apple.com>
    228
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h

    r195951 r197807  
    4646class MediaSourcePrivateClient;
    4747class VideoTrackPrivateMediaStream;
     48
     49#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     50class VideoFullscreenLayerManager;
     51#endif
    4852
    4953class MediaPlayerPrivateMediaStreamAVFObjC : public MediaPlayerPrivateInterface, public MediaStreamPrivate::Observer {
    … …  
    156160    void didRemoveTrack(MediaStreamTrackPrivate&) override;
    157161
     162#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     163    void setVideoFullscreenLayer(PlatformLayer*) override;
     164    void setVideoFullscreenFrame(FloatRect) override;
     165#endif
     166
    158167    MediaPlayer* m_player { nullptr };
    159168    WeakPtrFactory<MediaPlayerPrivateMediaStreamAVFObjC> m_weakPtrFactory;
    … …  
    176185    bool m_haveEverPlayed { false };
    177186    bool m_ended { false };
     187
     188#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     189    std::unique_ptr<VideoFullscreenLayerManager> m_videoFullscreenLayerManager;
     190#endif
    178191};
    179192   
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm

    r195951 r197807  
    4343#import <wtf/NeverDestroyed.h>
    4444
     45#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     46#import "VideoFullscreenLayerManager.h"
     47#endif
     48
    4549#pragma mark - Soft Linking
    4650
    … …  
    5862    , m_weakPtrFactory(this)
    5963    , m_clock(Clock::create())
     64#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     65    , m_videoFullscreenLayerManager(VideoFullscreenLayerManager::create())
     66#endif
    6067{
    6168    LOG(Media, "MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC(%p)", this);
    … …  
    154161        return nullptr;
    155162
     163#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     164    return m_videoFullscreenLayerManager->videoInlineLayer();
     165#else
    156166    return m_videoBackgroundLayer.get();
     167#endif
    157168}
    158169
    … …  
    392403        m_videoBackgroundLayer = adoptNS([[CALayer alloc] init]);
    393404        m_videoBackgroundLayer.get().name = @"MediaPlayerPrivateMediaStreamAVFObjC preview background layer";
     405
     406#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     407        m_videoFullscreenLayerManager->setVideoLayer(m_videoBackgroundLayer.get(), snappedIntRect(m_player->client().mediaPlayerContentBoxRect()).size());
     408#endif
    394409    }
    395410
    … …  
    397412        m_previewLayer = m_mediaStreamPrivate->platformLayer();
    398413        if (m_previewLayer) {
    399             m_previewLayer.get().contentsGravity = kCAGravityResize;
     414            m_previewLayer.get().contentsGravity = kCAGravityResizeAspect;
    400415            m_previewLayer.get().anchorPoint = CGPointZero;
    401416            if (!m_playing)
    … …  
    403418
    404419            [m_videoBackgroundLayer addSublayer:m_previewLayer.get()];
     420#if PLATFORM(MAC)
     421            [m_previewLayer setFrame:[m_videoBackgroundLayer bounds]];
     422            [m_previewLayer setAutoresizingMask:(kCALayerWidthSizable | kCALayerHeightSizable)];
     423#endif
    405424        }
    406425    }
    … …  
    454473    updateTracks();
    455474}
     475
     476#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
     477void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer)
     478{
     479    m_videoFullscreenLayerManager->setVideoFullscreenLayer(videoFullscreenLayer);
     480}
     481
     482void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenFrame(FloatRect frame)
     483{
     484    m_videoFullscreenLayerManager->setVideoFullscreenFrame(frame);
     485}
     486#endif
    456487
    457488template <typename RefT, typename PassRefT>
Note: See TracChangeset for help on using the changeset viewer.