summaryrefslogtreecommitdiffstats
path: root/src/plugins/avfoundation/mediaplayer
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2015-12-30 12:02:18 +0000
committerYoann Lopes <yoann.lopes@theqtcompany.com>2016-01-13 14:16:40 +0000
commita12f3d6fee700fb19b51b85934acddf536c483cf (patch)
treeed6d0670335e90e86b5bd1e3c0ca64957c38c966 /src/plugins/avfoundation/mediaplayer
parentb323f7803abb3dff5ffd92dd6d9f228cb9a55c40 (diff)
tvOS support
Builds, tested simple video playback Change-Id: I04e1da050c587cba3609107dc88a155a6949f2c3 Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'src/plugins/avfoundation/mediaplayer')
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfdisplaylink.h4
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm14
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm2
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h2
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm12
-rw-r--r--src/plugins/avfoundation/mediaplayer/mediaplayer.pro7
6 files changed, 21 insertions, 20 deletions
diff --git a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h
index 6e00ee80d..79dfb5165 100644
--- a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h
+++ b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h
@@ -37,7 +37,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qmutex.h>
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
#include <CoreVideo/CVBase.h>
#else
#include <QuartzCore/CVDisplayLink.h>
@@ -68,7 +68,7 @@ protected:
virtual bool event(QEvent *);
private:
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
void *m_displayLink;
#else
CVDisplayLinkRef m_displayLink;
diff --git a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm
index 47b6b8324..d2ce841fa 100644
--- a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm
@@ -38,7 +38,7 @@
#include <QtCore/qdebug.h>
#endif
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
#import <QuartzCore/CADisplayLink.h>
#import <Foundation/NSRunLoop.h>
#define _m_displayLink static_cast<DisplayLinkObserver*>(m_displayLink)
@@ -47,7 +47,7 @@
QT_USE_NAMESPACE
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
@interface DisplayLinkObserver : NSObject
{
AVFDisplayLink *m_avfDisplayLink;
@@ -127,7 +127,7 @@ AVFDisplayLink::AVFDisplayLink(QObject *parent)
, m_pendingDisplayLinkEvent(false)
, m_isActive(false)
{
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
m_displayLink = [[DisplayLinkObserver alloc] initWithAVFDisplayLink:this];
#else
// create display link for the main display
@@ -150,7 +150,7 @@ AVFDisplayLink::~AVFDisplayLink()
if (m_displayLink) {
stop();
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
[_m_displayLink release];
#else
CVDisplayLinkRelease(m_displayLink);
@@ -172,7 +172,7 @@ bool AVFDisplayLink::isActive() const
void AVFDisplayLink::start()
{
if (m_displayLink && !m_isActive) {
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
[_m_displayLink start];
#else
CVDisplayLinkStart(m_displayLink);
@@ -184,7 +184,7 @@ void AVFDisplayLink::start()
void AVFDisplayLink::stop()
{
if (m_displayLink && m_isActive) {
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
[_m_displayLink stop];
#else
CVDisplayLinkStop(m_displayLink);
@@ -202,7 +202,7 @@ void AVFDisplayLink::displayLinkEvent(const CVTimeStamp *ts)
m_displayLinkMutex.lock();
bool pending = m_pendingDisplayLinkEvent;
m_pendingDisplayLinkEvent = true;
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
Q_UNUSED(ts);
memset(&m_frameTimeStamp, 0, sizeof(CVTimeStamp));
#else
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm
index 4049ea6e4..62b4d5d29 100644
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm
@@ -62,7 +62,7 @@ AVFMediaPlayerService::AVFMediaPlayerService(QObject *parent)
// AVPlayerItemVideoOutput is available in SDK
#if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_10_8, __IPHONE_6_0)
// might not be available at runtime
- #if defined(Q_OS_IOS)
+ #if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
m_enableRenderControl = [AVPlayerItemVideoOutput class] != 0;
#endif
#endif
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h
index a46026f54..0fc091af9 100644
--- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h
+++ b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h
@@ -53,7 +53,7 @@ class QAbstractVideoSurface;
typedef struct __CVBuffer *CVBufferRef;
typedef CVBufferRef CVImageBufferRef;
typedef CVImageBufferRef CVPixelBufferRef;
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
typedef struct __CVOpenGLESTextureCache *CVOpenGLESTextureCacheRef;
typedef CVImageBufferRef CVOpenGLESTextureRef;
// helpers to avoid boring if def
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm b/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm
index 03000ea43..d067c7f0b 100644
--- a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm
@@ -34,7 +34,7 @@
#include "avfvideorenderercontrol.h"
#include "avfdisplaylink.h"
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
#include "avfvideoframerenderer_ios.h"
#else
#include "avfvideoframerenderer.h"
@@ -52,7 +52,7 @@
QT_USE_NAMESPACE
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
class TextureCacheVideoBuffer : public QAbstractVideoBuffer
{
public:
@@ -164,7 +164,7 @@ void AVFVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
//Surface changed, so we need a new frame renderer
m_frameRenderer = new AVFVideoFrameRenderer(m_surface, this);
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
if (m_playerLayer) {
m_frameRenderer->setPlayerLayer(static_cast<AVPlayerLayer*>(m_playerLayer));
}
@@ -195,7 +195,7 @@ void AVFVideoRendererControl::setLayer(void *playerLayer)
if (m_surface && m_surface->isActive())
m_surface->stop();
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
if (m_frameRenderer) {
m_frameRenderer->setPlayerLayer(static_cast<AVPlayerLayer*>(playerLayer));
}
@@ -230,7 +230,7 @@ void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts)
return;
if (m_enableOpenGL) {
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
CVOGLTextureRef tex = m_frameRenderer->renderLayerToTexture(playerLayer);
//Make sure we got a valid texture
@@ -254,7 +254,7 @@ void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts)
if (!m_surface->isActive()) {
QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QAbstractVideoBuffer::GLTextureHandle);
-#if defined(Q_OS_IOS)
+#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
format.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
#else
format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
diff --git a/src/plugins/avfoundation/mediaplayer/mediaplayer.pro b/src/plugins/avfoundation/mediaplayer/mediaplayer.pro
index 28cdc2727..8b5f14b4e 100644
--- a/src/plugins/avfoundation/mediaplayer/mediaplayer.pro
+++ b/src/plugins/avfoundation/mediaplayer/mediaplayer.pro
@@ -11,7 +11,7 @@ PLUGIN_TYPE = mediaservice
PLUGIN_CLASS_NAME = AVFMediaPlayerServicePlugin
load(qt_plugin)
-LIBS += -framework AVFoundation -framework CoreMedia
+LIBS += -framework AVFoundation -framework CoreMedia -framework CoreVideo -framework QuartzCore
DEFINES += QMEDIA_AVF_MEDIAPLAYER
@@ -44,7 +44,7 @@ OBJECTIVE_SOURCES += \
avfvideowidget.mm
}
-ios {
+ios|tvos {
contains(QT_CONFIG, opengl.*) {
HEADERS += \
avfvideoframerenderer_ios.h \
@@ -56,8 +56,9 @@ ios {
avfvideorenderercontrol.mm \
avfdisplaylink.mm
}
+ LIBS += -framework Foundation
} else {
- LIBS += -framework QuartzCore -framework AppKit
+ LIBS += -framework AppKit
contains(QT_CONFIG, opengl.*) {
HEADERS += \