diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-11-29 14:53:59 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-12-07 16:32:05 +0100 |
commit | d9cdfeebd9eb6a067b97316daa149c7f58e1c7ec (patch) | |
tree | 9ad8ae07190f6e491397272114f0e7c4539e5c1d /src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm | |
parent | 466a4f29c20b6d797af9d67029a7329b2124b276 (diff) |
Use AVPlayerItemVideoOutput to generate video frames
This fixes rendering problems on M1 based Macs.
It also unifies the rendering pipeline between macOS and iOS as
much as possible, and avoids an intermediate copy to an FBO,
Since AVPlayerItemVideoOutput produces GL_TEXTURE_RECTANGLE
textures on macOS a new QAbstractVideoBuffer handle has been
added that explicitly maps to GL_TEXTURE_RECTANGLE.
We use this handle type internally in QSGVideoMaterial_Texture
where we know how to blit GL_TEXTURE_RECTANGLE textures.
To maintain compatibility for QAbstractVideoSurface consumers who
expect GL_TEXTURE_2D textures we blit the rectangle texture to
an FBO returned as QAbstractVideoBuffer::GLTextureHandle.
Fixes: QTBUG-89803
Done-with: Lars Knoll <lars.knoll@qt.io>
Change-Id: I36d22eafb63902ecc1097e138705812ef6a8cb71
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm')
-rw-r--r-- | src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm index ea54fe6be..ae2234764 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm @@ -110,6 +110,12 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext self->m_session = session; self->m_bufferIsLikelyToKeepUp = FALSE; + + m_playerLayer = [AVPlayerLayer playerLayerWithPlayer:nil]; + [m_playerLayer retain]; + m_playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; + m_playerLayer.anchorPoint = CGPointMake(0.0f, 0.0f); + return self; } @@ -172,10 +178,6 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext [m_player release]; m_player = 0; } - if (m_playerLayer) { - [m_playerLayer release]; - m_playerLayer = 0; - } } - (void) prepareToPlayAsset:(AVURLAsset *)asset @@ -260,14 +262,8 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext [m_player setMuted:m_session->isMuted()]; } - //Create a new player layer if we don't have one already - if (!m_playerLayer) - { - m_playerLayer = [AVPlayerLayer playerLayerWithPlayer:m_player]; - [m_playerLayer retain]; - m_playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; - m_playerLayer.anchorPoint = CGPointMake(0.0f, 0.0f); - } + //Assign the output layer to the new player + m_playerLayer.player = m_player; //Observe the AVPlayer "currentItem" property to find out when any //AVPlayer replaceCurrentItemWithPlayerItem: replacement will/did @@ -413,6 +409,7 @@ static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext } [m_mimeType release]; + [m_playerLayer release]; [super dealloc]; } |