From f02d9e934322fbf9af8a5503c1bda37552988b2b Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Tue, 30 Sep 2014 16:41:25 +0200 Subject: [PATCH] AVFoundation: fix media player video rendering in QML. The AVPlayerLayer was set on the QVideoRendererControl before its geometry was updated, causing the renderer control to display frames with an invalid size. Change-Id: I90e18dce69d4b48a3d7932d44a7eab4fd443f1fb Reviewed-by: Christian Stromme --- .../mediaplayer/avfmediaplayersession.h | 2 -- .../mediaplayer/avfmediaplayersession.mm | 21 ++++----------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h index c850f45..5157a85 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h @@ -97,8 +97,6 @@ public Q_SLOTS: void processPositionChange(); void processMediaLoadError(); - void processCurrentItemChanged(); - Q_SIGNALS: void positionChanged(qint64 position); void durationChanged(qint64 duration); diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm index d6f0607..73e9d76 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm @@ -340,9 +340,6 @@ static void *AVFMediaPlayerSessionObserverCurrentItemObservationContext = &AVFMe AVPlayerItem *newPlayerItem = [change objectForKey:NSKeyValueChangeNewKey]; if (m_playerItem != newPlayerItem) m_playerItem = newPlayerItem; - - if (self.session) - QMetaObject::invokeMethod(m_session, "processCurrentItemChanged", Qt::AutoConnection); } else { @@ -806,6 +803,10 @@ void AVFMediaPlayerSession::processLoadStateChange() playerLayer.bounds = CGRectMake(0.0f, 0.0f, videoTrack.naturalSize.width, videoTrack.naturalSize.height); + + if (m_videoOutput && m_state != QMediaPlayer::StoppedState) { + m_videoOutput->setLayer(playerLayer); + } } } @@ -836,17 +837,3 @@ void AVFMediaPlayerSession::processMediaLoadError() Q_EMIT mediaStatusChanged(m_mediaStatus = QMediaPlayer::InvalidMedia); Q_EMIT stateChanged(m_state = QMediaPlayer::StoppedState); } - -void AVFMediaPlayerSession::processCurrentItemChanged() -{ -#ifdef QT_DEBUG_AVF - qDebug() << Q_FUNC_INFO; -#endif - - AVPlayerLayer *playerLayer = [(AVFMediaPlayerSessionObserver*)m_observer playerLayer]; - - if (m_videoOutput && m_state != QMediaPlayer::StoppedState) { - m_videoOutput->setLayer(playerLayer); - } - -} -- 2.7.4