summaryrefslogtreecommitdiffstats
path: root/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@digia.com>2013-08-15 15:08:35 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-27 14:16:10 +0200
commit51d0f852b9be9c5753e28e2bb4a7f2f6c35dc533 (patch)
tree92fdcdc94ca120d33363d7b827b5c2f4e3fbf4f5 /src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm
parent17a700292ad9289e8de199dc50b3e222ede42e1d (diff)
AVFoundation: Use CoreAnimation to render video to QVideoWidget
Previously a QGLWidget was used as a target for the AVFVideoFrameRenderer. This was uncessary as it is possible to render directly on top of the QWidget using the CoreAnimation Framework. Change-Id: I08923c85fd56c8874c1d8c187ae5145e220fab92 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm')
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm80
1 files changed, 4 insertions, 76 deletions
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm b/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm
index f50117d81..0d62c394b 100644
--- a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm
@@ -40,10 +40,7 @@
****************************************************************************/
#include "avfvideowidgetcontrol.h"
-
#include "avfvideowidget.h"
-#include "avfvideoframerenderer.h"
-#include "avfdisplaylink.h"
#ifdef QT_DEBUG_AVF
#include <QtCore/QDebug>
@@ -55,22 +52,13 @@ QT_USE_NAMESPACE
AVFVideoWidgetControl::AVFVideoWidgetControl(QObject *parent)
: QVideoWidgetControl(parent)
- , m_frameRenderer(0)
- , m_aspectRatioMode(Qt::KeepAspectRatio)
, m_fullscreen(false)
, m_brightness(0)
, m_contrast(0)
, m_hue(0)
, m_saturation(0)
- , m_playerLayer(0)
{
- QGLFormat format = QGLFormat::defaultFormat();
- format.setSwapInterval(1); // Vertical sync (avoid tearing)
- format.setDoubleBuffer(true);
- m_videoWidget = new AVFVideoWidget(0, format);
-
- m_displayLink = new AVFDisplayLink(this);
- connect(m_displayLink, SIGNAL(tick(CVTimeStamp)), this, SLOT(updateVideoFrame(CVTimeStamp)));
+ m_videoWidget = new AVFVideoWidget(0);
}
AVFVideoWidgetControl::~AVFVideoWidgetControl()
@@ -78,10 +66,6 @@ AVFVideoWidgetControl::~AVFVideoWidgetControl()
#ifdef QT_DEBUG_AVF
qDebug() << Q_FUNC_INFO;
#endif
- m_displayLink->stop();
- if (m_playerLayer)
- [(AVPlayerLayer*)m_playerLayer release];
-
delete m_videoWidget;
}
@@ -91,26 +75,8 @@ void AVFVideoWidgetControl::setLayer(void *playerLayer)
qDebug() << Q_FUNC_INFO << playerLayer;
#endif
- if (m_playerLayer == playerLayer)
- return;
-
- [(AVPlayerLayer*)playerLayer retain];
- [(AVPlayerLayer*)m_playerLayer release];
-
- m_playerLayer = playerLayer;
-
- //If there is no layer to render, stop scheduling updates
- if (m_playerLayer == 0) {
- m_displayLink->stop();
- return;
- }
+ m_videoWidget->setPlayerLayer((AVPlayerLayer*)playerLayer);
- setupVideoOutput();
-
- //make sure we schedule updates
- if (!m_displayLink->isActive()) {
- m_displayLink->start();
- }
}
QWidget *AVFVideoWidgetControl::videoWidget()
@@ -130,12 +96,11 @@ void AVFVideoWidgetControl::setFullScreen(bool fullScreen)
Qt::AspectRatioMode AVFVideoWidgetControl::aspectRatioMode() const
{
- return m_aspectRatioMode;
+ return m_videoWidget->aspectRatioMode();
}
void AVFVideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode mode)
{
- m_aspectRatioMode = mode;
m_videoWidget->setAspectRatioMode(mode);
}
@@ -179,41 +144,4 @@ void AVFVideoWidgetControl::setSaturation(int saturation)
m_saturation = saturation;
}
-void AVFVideoWidgetControl::updateVideoFrame(const CVTimeStamp &ts)
-{
- Q_UNUSED(ts)
-
- AVPlayerLayer *playerLayer = (AVPlayerLayer*)m_playerLayer;
-
- if (!playerLayer) {
- qWarning("updateVideoFrame called without AVPlayerLayer (which shouldn't happen)");
- return;
- }
-
- //Don't try to render a layer that is not ready
- if (!playerLayer.readyForDisplay)
- return;
-
- GLuint textureId = m_frameRenderer->renderLayerToTexture(playerLayer);
-
- //Make sure we have a valid texture
- if (textureId == 0) {
- qWarning("renderLayerToTexture failed");
- return;
- }
-
- m_videoWidget->setTexture(textureId);
-}
-
-void AVFVideoWidgetControl::setupVideoOutput()
-{
- CGRect layerBounds = [(AVPlayerLayer*)m_playerLayer bounds];
- m_nativeSize = QSize(layerBounds.size.width, layerBounds.size.height);
- m_videoWidget->setNativeSize(m_nativeSize);
-
- if (m_frameRenderer)
- delete m_frameRenderer;
-
- m_frameRenderer = new AVFVideoFrameRenderer(m_videoWidget, m_nativeSize, this);
-}
-
+#include "moc_avfvideowidgetcontrol.cpp"