summaryrefslogtreecommitdiffstats
path: root/src/plugins/avfoundation/mediaplayer
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/avfoundation/mediaplayer')
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfdisplaylink.h90
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm241
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayer.json4
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.h99
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm192
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h74
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm161
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h70
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm134
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.h77
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.mm107
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h161
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm1067
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.h126
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm464
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h120
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.mm307
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideooutput.h60
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideooutput.mm42
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.h92
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm301
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideowidget.h85
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideowidget.mm187
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.h95
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm145
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.h118
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm255
-rw-r--r--src/plugins/avfoundation/mediaplayer/mediaplayer.pro76
28 files changed, 0 insertions, 4950 deletions
diff --git a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h
deleted file mode 100644
index ba0803807..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFDISPLAYLINK_H
-#define AVFDISPLAYLINK_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qmutex.h>
-
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
-#include <CoreVideo/CVBase.h>
-#else
-#include <QuartzCore/CVDisplayLink.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class AVFDisplayLink : public QObject
-{
- Q_OBJECT
-public:
- explicit AVFDisplayLink(QObject *parent = nullptr);
- virtual ~AVFDisplayLink();
- bool isValid() const;
- bool isActive() const;
-
-public Q_SLOTS:
- void start();
- void stop();
-
-Q_SIGNALS:
- void tick(const CVTimeStamp &ts);
-
-public:
- void displayLinkEvent(const CVTimeStamp *);
-
-protected:
- virtual bool event(QEvent *) override;
-
-private:
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- void *m_displayLink;
-#else
- CVDisplayLinkRef m_displayLink;
-#endif
- QMutex m_displayLinkMutex;
- bool m_pendingDisplayLinkEvent;
- bool m_isActive;
- CVTimeStamp m_frameTimeStamp;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFDISPLAYLINK_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm b/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm
deleted file mode 100644
index bae18bc0a..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfdisplaylink.mm
+++ /dev/null
@@ -1,241 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfdisplaylink.h"
-#include <QtCore/qcoreapplication.h>
-
-#ifdef QT_DEBUG_AVF
-#include <QtCore/qdebug.h>
-#endif
-
-#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)
-#else
-#endif
-
-QT_USE_NAMESPACE
-
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
-@interface DisplayLinkObserver : NSObject
-
-- (void)start;
-- (void)stop;
-- (void)displayLinkNotification:(CADisplayLink *)sender;
-
-@end
-
-@implementation DisplayLinkObserver
-{
- AVFDisplayLink *m_avfDisplayLink;
- CADisplayLink *m_displayLink;
-}
-
-- (id)initWithAVFDisplayLink:(AVFDisplayLink *)link
-{
- self = [super init];
-
- if (self) {
- m_avfDisplayLink = link;
- m_displayLink = [[CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkNotification:)] retain];
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- if (m_displayLink) {
- [m_displayLink release];
- m_displayLink = nullptr;
- }
-
- [super dealloc];
-}
-
-- (void)start
-{
- [m_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
-}
-
-- (void)stop
-{
- [m_displayLink removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
-}
-
-- (void)displayLinkNotification:(CADisplayLink *)sender
-{
- Q_UNUSED(sender);
- m_avfDisplayLink->displayLinkEvent(nullptr);
-}
-
-@end
-#else
-static CVReturn CVDisplayLinkCallback(CVDisplayLinkRef displayLink,
- const CVTimeStamp *inNow,
- const CVTimeStamp *inOutputTime,
- CVOptionFlags flagsIn,
- CVOptionFlags *flagsOut,
- void *displayLinkContext)
-{
- Q_UNUSED(displayLink);
- Q_UNUSED(inNow);
- Q_UNUSED(flagsIn);
- Q_UNUSED(flagsOut);
-
- AVFDisplayLink *link = (AVFDisplayLink *)displayLinkContext;
-
- link->displayLinkEvent(inOutputTime);
- return kCVReturnSuccess;
-}
-#endif
-
-AVFDisplayLink::AVFDisplayLink(QObject *parent)
- : QObject(parent)
- , m_displayLink(nullptr)
- , m_pendingDisplayLinkEvent(false)
- , m_isActive(false)
-{
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- m_displayLink = [[DisplayLinkObserver alloc] initWithAVFDisplayLink:this];
-#else
- // create display link for the main display
- CVDisplayLinkCreateWithCGDisplay(kCGDirectMainDisplay, &m_displayLink);
- if (m_displayLink) {
- // set the current display of a display link.
- CVDisplayLinkSetCurrentCGDisplay(m_displayLink, kCGDirectMainDisplay);
-
- // set the renderer output callback function
- CVDisplayLinkSetOutputCallback(m_displayLink, &CVDisplayLinkCallback, this);
- }
-#endif
-}
-
-AVFDisplayLink::~AVFDisplayLink()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
-
- if (m_displayLink) {
- stop();
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- [_m_displayLink release];
-#else
- CVDisplayLinkRelease(m_displayLink);
-#endif
- m_displayLink = nullptr;
- }
-}
-
-bool AVFDisplayLink::isValid() const
-{
- return m_displayLink != nullptr;
-}
-
-bool AVFDisplayLink::isActive() const
-{
- return m_isActive;
-}
-
-void AVFDisplayLink::start()
-{
- if (m_displayLink && !m_isActive) {
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- [_m_displayLink start];
-#else
- CVDisplayLinkStart(m_displayLink);
-#endif
- m_isActive = true;
- }
-}
-
-void AVFDisplayLink::stop()
-{
- if (m_displayLink && m_isActive) {
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- [_m_displayLink stop];
-#else
- CVDisplayLinkStop(m_displayLink);
-#endif
- m_isActive = false;
- }
-}
-
-void AVFDisplayLink::displayLinkEvent(const CVTimeStamp *ts)
-{
- // This function is called from a
- // thread != gui thread. So we post the event.
- // But we need to make sure that we don't post faster
- // than the event loop can eat:
- m_displayLinkMutex.lock();
- bool pending = m_pendingDisplayLinkEvent;
- m_pendingDisplayLinkEvent = true;
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- Q_UNUSED(ts);
- memset(&m_frameTimeStamp, 0, sizeof(CVTimeStamp));
-#else
- m_frameTimeStamp = *ts;
-#endif
- m_displayLinkMutex.unlock();
-
- if (!pending)
- qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority);
-}
-
-bool AVFDisplayLink::event(QEvent *event)
-{
- switch (event->type()){
- case QEvent::User: {
- m_displayLinkMutex.lock();
- m_pendingDisplayLinkEvent = false;
- CVTimeStamp ts = m_frameTimeStamp;
- m_displayLinkMutex.unlock();
-
- Q_EMIT tick(ts);
-
- return false;
- }
- break;
- default:
- break;
- }
- return QObject::event(event);
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayer.json b/src/plugins/avfoundation/mediaplayer/avfmediaplayer.json
deleted file mode 100644
index 5626edec0..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayer.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "Keys": ["avfoundationmediaplayer"],
- "Services": ["org.qt-project.qt.mediaplayer"]
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.h
deleted file mode 100644
index ac0ba0ab2..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFMEDIAPLAYERCONTROL_H
-#define AVFMEDIAPLAYERCONTROL_H
-
-#include <QtMultimedia/QMediaPlayerControl>
-#include <QtCore/QObject>
-
-QT_BEGIN_NAMESPACE
-
-class AVFMediaPlayerSession;
-
-class AVFMediaPlayerControl : public QMediaPlayerControl
-{
- Q_OBJECT
-public:
- explicit AVFMediaPlayerControl(QObject *parent = nullptr);
- ~AVFMediaPlayerControl();
-
- void setSession(AVFMediaPlayerSession *session);
-
- QMediaPlayer::State state() const override;
- QMediaPlayer::MediaStatus mediaStatus() const override;
-
- QMediaContent media() const override;
- const QIODevice *mediaStream() const override;
- void setMedia(const QMediaContent &content, QIODevice *stream) override;
-
- qint64 position() const override;
- qint64 duration() const override;
-
- int bufferStatus() const override;
-
- int volume() const override;
- bool isMuted() const override;
-
- bool isAudioAvailable() const override;
- bool isVideoAvailable() const override;
-
- bool isSeekable() const override;
- QMediaTimeRange availablePlaybackRanges() const override;
-
- qreal playbackRate() const override;
- void setPlaybackRate(qreal rate) override;
-
-public Q_SLOTS:
- void setPosition(qint64 pos) override;
-
- void play() override;
- void pause() override;
- void stop() override;
-
- void setVolume(int volume) override;
- void setMuted(bool muted) override;
-
-private:
- AVFMediaPlayerSession *m_session;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFMEDIAPLAYERCONTROL_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm
deleted file mode 100644
index bf7ebb4a0..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfmediaplayercontrol.h"
-#include "avfmediaplayersession.h"
-
-QT_USE_NAMESPACE
-
-AVFMediaPlayerControl::AVFMediaPlayerControl(QObject *parent) :
- QMediaPlayerControl(parent)
-{
-}
-
-AVFMediaPlayerControl::~AVFMediaPlayerControl()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
-}
-
-void AVFMediaPlayerControl::setSession(AVFMediaPlayerSession *session)
-{
- m_session = session;
-
- connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(positionChanged(qint64)));
- connect(m_session, SIGNAL(durationChanged(qint64)), this, SIGNAL(durationChanged(qint64)));
- connect(m_session, SIGNAL(bufferStatusChanged(int)), this, SIGNAL(bufferStatusChanged(int)));
- connect(m_session, SIGNAL(stateChanged(QMediaPlayer::State)),
- this, SIGNAL(stateChanged(QMediaPlayer::State)));
- connect(m_session, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
- this, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
- connect(m_session, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
- connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));
- connect(m_session, SIGNAL(audioAvailableChanged(bool)), this, SIGNAL(audioAvailableChanged(bool)));
- connect(m_session, SIGNAL(videoAvailableChanged(bool)), this, SIGNAL(videoAvailableChanged(bool)));
- connect(m_session, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString)));
- connect(m_session, &AVFMediaPlayerSession::playbackRateChanged,
- this, &AVFMediaPlayerControl::playbackRateChanged);
- connect(m_session, &AVFMediaPlayerSession::seekableChanged,
- this, &AVFMediaPlayerControl::seekableChanged);
-}
-
-QMediaPlayer::State AVFMediaPlayerControl::state() const
-{
- return m_session->state();
-}
-
-QMediaPlayer::MediaStatus AVFMediaPlayerControl::mediaStatus() const
-{
- return m_session->mediaStatus();
-}
-
-QMediaContent AVFMediaPlayerControl::media() const
-{
- return m_session->media();
-}
-
-const QIODevice *AVFMediaPlayerControl::mediaStream() const
-{
- return m_session->mediaStream();
-}
-
-void AVFMediaPlayerControl::setMedia(const QMediaContent &content, QIODevice *stream)
-{
- const QMediaContent oldContent = m_session->media();
-
- m_session->setMedia(content, stream);
-
- if (content != oldContent)
- Q_EMIT mediaChanged(content);
-}
-
-qint64 AVFMediaPlayerControl::position() const
-{
- return m_session->position();
-}
-
-qint64 AVFMediaPlayerControl::duration() const
-{
- return m_session->duration();
-}
-
-int AVFMediaPlayerControl::bufferStatus() const
-{
- return m_session->bufferStatus();
-}
-
-int AVFMediaPlayerControl::volume() const
-{
- return m_session->volume();
-}
-
-bool AVFMediaPlayerControl::isMuted() const
-{
- return m_session->isMuted();
-}
-
-bool AVFMediaPlayerControl::isAudioAvailable() const
-{
- return m_session->isAudioAvailable();
-}
-
-bool AVFMediaPlayerControl::isVideoAvailable() const
-{
- return m_session->isVideoAvailable();
-}
-
-bool AVFMediaPlayerControl::isSeekable() const
-{
- return m_session->isSeekable();
-}
-
-QMediaTimeRange AVFMediaPlayerControl::availablePlaybackRanges() const
-{
- return m_session->availablePlaybackRanges();
-}
-
-qreal AVFMediaPlayerControl::playbackRate() const
-{
- return m_session->playbackRate();
-}
-
-void AVFMediaPlayerControl::setPlaybackRate(qreal rate)
-{
- m_session->setPlaybackRate(rate);
-}
-
-void AVFMediaPlayerControl::setPosition(qint64 pos)
-{
- m_session->setPosition(pos);
-}
-
-void AVFMediaPlayerControl::play()
-{
- m_session->play();
-}
-
-void AVFMediaPlayerControl::pause()
-{
- m_session->pause();
-}
-
-void AVFMediaPlayerControl::stop()
-{
- m_session->stop();
-}
-
-void AVFMediaPlayerControl::setVolume(int volume)
-{
- m_session->setVolume(volume);
-}
-
-void AVFMediaPlayerControl::setMuted(bool muted)
-{
- m_session->setMuted(muted);
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h
deleted file mode 100644
index ae99c7eda..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFMEDIAPLAYERMETADATACONTROL_H
-#define AVFMEDIAPLAYERMETADATACONTROL_H
-
-#include <QtMultimedia/QMetaDataReaderControl>
-
-QT_BEGIN_NAMESPACE
-
-class AVFMediaPlayerSession;
-
-class AVFMediaPlayerMetaDataControl : public QMetaDataReaderControl
-{
- Q_OBJECT
-public:
- explicit AVFMediaPlayerMetaDataControl(AVFMediaPlayerSession *session, QObject *parent = nullptr);
- virtual ~AVFMediaPlayerMetaDataControl();
-
- bool isMetaDataAvailable() const override;
- bool isWritable() const;
-
- QVariant metaData(const QString &key) const override;
- QStringList availableMetaData() const override;
-
-private Q_SLOTS:
- void updateTags();
-
-private:
- AVFMediaPlayerSession *m_session;
- QVariantMap m_tags;
- void *m_asset;
-
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFMEDIAPLAYERMETADATACONTROL_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm
deleted file mode 100644
index b9ec38c0f..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayermetadatacontrol.mm
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfmediaplayermetadatacontrol.h"
-#include "avfmediaplayersession.h"
-
-#include <QtMultimedia/qmediametadata.h>
-
-#import <AVFoundation/AVFoundation.h>
-
-QT_USE_NAMESPACE
-
-AVFMediaPlayerMetaDataControl::AVFMediaPlayerMetaDataControl(AVFMediaPlayerSession *session, QObject *parent)
- : QMetaDataReaderControl(parent)
- , m_session(session)
- , m_asset(nullptr)
-{
- QObject::connect(m_session, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(updateTags()));
-}
-
-AVFMediaPlayerMetaDataControl::~AVFMediaPlayerMetaDataControl()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
-}
-
-bool AVFMediaPlayerMetaDataControl::isMetaDataAvailable() const
-{
- return !m_tags.isEmpty();
-}
-
-bool AVFMediaPlayerMetaDataControl::isWritable() const
-{
- return false;
-}
-
-QVariant AVFMediaPlayerMetaDataControl::metaData(const QString &key) const
-{
- return m_tags.value(key);
-}
-
-QStringList AVFMediaPlayerMetaDataControl::availableMetaData() const
-{
- return m_tags.keys();
-}
-
-static QString itemKey(AVMetadataItem *item)
-{
- NSString *keyString = [item commonKey];
-
- if (keyString.length != 0) {
- if ([keyString isEqualToString:AVMetadataCommonKeyTitle]) {
- return QMediaMetaData::Title;
- } else if ([keyString isEqualToString: AVMetadataCommonKeySubject]) {
- return QMediaMetaData::SubTitle;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyDescription]) {
- return QMediaMetaData::Description;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyPublisher]) {
- return QMediaMetaData::Publisher;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyCreationDate]) {
- return QMediaMetaData::Date;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyType]) {
- return QMediaMetaData::MediaType;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyLanguage]) {
- return QMediaMetaData::Language;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyCopyrights]) {
- return QMediaMetaData::Copyright;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyAlbumName]) {
- return QMediaMetaData::AlbumTitle;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyAuthor]) {
- return QMediaMetaData::Author;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyArtist]) {
- return QMediaMetaData::ContributingArtist;
- } else if ([keyString isEqualToString: AVMetadataCommonKeyArtwork]) {
- return QMediaMetaData::PosterUrl;
- }
- }
-
- return QString();
-}
-
-void AVFMediaPlayerMetaDataControl::updateTags()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- AVAsset *currentAsset = static_cast<AVAsset*>(m_session->currentAssetHandle());
-
- //Don't read the tags from the same asset more than once
- if (currentAsset == m_asset)
- return;
-
- m_asset = currentAsset;
-
- QVariantMap oldTags = m_tags;
- //Since we've changed assets, clear old tags
- m_tags.clear();
- bool changed = false;
-
- // TODO: also process ID3, iTunes and QuickTime metadata
-
- NSArray *metadataItems = [currentAsset commonMetadata];
- for (AVMetadataItem* item in metadataItems) {
- const QString key = itemKey(item);
- if (!key.isEmpty()) {
- const QString value = QString::fromNSString([item stringValue]);
- if (!value.isNull()) {
- m_tags.insert(key, value);
- if (value != oldTags.value(key)) {
- changed = true;
- Q_EMIT metaDataChanged(key, value);
- }
- }
- }
- }
-
- if (oldTags.isEmpty() != m_tags.isEmpty()) {
- Q_EMIT metaDataAvailableChanged(!m_tags.isEmpty());
- changed = true;
- }
-
- if (changed)
- Q_EMIT metaDataChanged();
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h
deleted file mode 100644
index 6a4b915cf..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFMEDIAPLAYERSERVICE_H
-#define AVFMEDIAPLAYERSERVICE_H
-
-#include <QtMultimedia/QMediaService>
-
-QT_BEGIN_NAMESPACE
-
-class AVFMediaPlayerSession;
-class AVFMediaPlayerControl;
-class AVFMediaPlayerMetaDataControl;
-class AVFVideoOutput;
-
-class AVFMediaPlayerService : public QMediaService
-{
-public:
- explicit AVFMediaPlayerService(QObject *parent = nullptr);
- ~AVFMediaPlayerService();
-
- QMediaControl* requestControl(const char *name) override;
- void releaseControl(QMediaControl *control) override;
-
-private:
- AVFMediaPlayerSession *m_session;
- AVFMediaPlayerControl *m_control;
- QMediaControl *m_videoOutput;
- AVFMediaPlayerMetaDataControl *m_playerMetaDataControl;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFMEDIAPLAYERSERVICE_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm
deleted file mode 100644
index bc59fa921..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfmediaplayerservice.h"
-#include "avfmediaplayersession.h"
-#include "avfmediaplayercontrol.h"
-#include "avfmediaplayermetadatacontrol.h"
-#include "avfvideooutput.h"
-#if QT_CONFIG(opengl)
-#include "avfvideorenderercontrol.h"
-#endif
-#ifndef QT_NO_WIDGETS
-# include "avfvideowidgetcontrol.h"
-#endif
-#include "avfvideowindowcontrol.h"
-
-#import <AVFoundation/AVFoundation.h>
-
-QT_USE_NAMESPACE
-
-AVFMediaPlayerService::AVFMediaPlayerService(QObject *parent)
- : QMediaService(parent)
- , m_videoOutput(nullptr)
-{
- m_session = new AVFMediaPlayerSession(this);
- m_control = new AVFMediaPlayerControl(this);
- m_control->setSession(m_session);
- m_playerMetaDataControl = new AVFMediaPlayerMetaDataControl(m_session, this);
-
- connect(m_control, SIGNAL(mediaChanged(QMediaContent)), m_playerMetaDataControl, SLOT(updateTags()));
-}
-
-AVFMediaPlayerService::~AVFMediaPlayerService()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- delete m_session;
-}
-
-QMediaControl *AVFMediaPlayerService::requestControl(const char *name)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << name;
-#endif
-
- if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
- return m_control;
-
- if (qstrcmp(name, QMetaDataReaderControl_iid) == 0)
- return m_playerMetaDataControl;
-
-#if QT_CONFIG(opengl)
- if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
- if (!m_videoOutput)
- m_videoOutput = new AVFVideoRendererControl(this);
-
- m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
- return m_videoOutput;
- }
-#endif
-#ifndef QT_NO_WIDGETS
- if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
- if (!m_videoOutput)
- m_videoOutput = new AVFVideoWidgetControl(this);
-
- m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
- return m_videoOutput;
- }
-#endif
- if (qstrcmp(name, QVideoWindowControl_iid) == 0) {
- if (!m_videoOutput)
- m_videoOutput = new AVFVideoWindowControl(this);
-
- m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
- return m_videoOutput;
- }
- return nullptr;
-}
-
-void AVFMediaPlayerService::releaseControl(QMediaControl *control)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << control;
-#endif
- if (m_videoOutput == control) {
-#if QT_CONFIG(opengl)
- AVFVideoRendererControl *renderControl = qobject_cast<AVFVideoRendererControl*>(m_videoOutput);
-
- if (renderControl)
- renderControl->setSurface(nullptr);
-#endif
- m_videoOutput = nullptr;
- m_session->setVideoOutput(nullptr);
-
- delete control;
- }
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.h
deleted file mode 100644
index e08f0f46e..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef AVFMEDIAPLAYERSERVICEPLUGIN_H
-#define AVFMEDIAPLAYERSERVICEPLUGIN_H
-
-#include <QtCore/qglobal.h>
-#include <QtMultimedia/qmediaserviceproviderplugin.h>
-
-QT_BEGIN_NAMESPACE
-
-class AVFMediaPlayerServicePlugin
- : public QMediaServiceProviderPlugin
- , public QMediaServiceSupportedFormatsInterface
- , public QMediaServiceFeaturesInterface
-{
- Q_OBJECT
- Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
- Q_INTERFACES(QMediaServiceFeaturesInterface)
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "avfmediaplayer.json")
-
-public:
- explicit AVFMediaPlayerServicePlugin();
-
- QMediaService* create(QString const& key) override;
- void release(QMediaService *service) override;
-
- QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const override;
- QMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const override;
- QStringList supportedMimeTypes() const override;
-
-private:
- void buildSupportedTypes();
-
- QStringList m_supportedMimeTypes;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFMEDIAPLAYERSERVICEPLUGIN_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.mm
deleted file mode 100644
index 59b29a3d2..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerserviceplugin.mm
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfmediaplayerserviceplugin.h"
-#include <QtCore/QDebug>
-
-#include "avfmediaplayerservice.h"
-
-#import <AVFoundation/AVFoundation.h>
-
-QT_USE_NAMESPACE
-
-AVFMediaPlayerServicePlugin::AVFMediaPlayerServicePlugin()
-{
- buildSupportedTypes();
-}
-
-QMediaService *AVFMediaPlayerServicePlugin::create(const QString &key)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << "AVFMediaPlayerServicePlugin::create" << key;
-#endif
- if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
- return new AVFMediaPlayerService;
-
- qWarning() << "unsupported key: " << key;
- return nullptr;
-}
-
-void AVFMediaPlayerServicePlugin::release(QMediaService *service)
-{
- delete service;
-}
-
-QMediaServiceProviderHint::Features AVFMediaPlayerServicePlugin::supportedFeatures(const QByteArray &service) const
-{
- if (service == Q_MEDIASERVICE_MEDIAPLAYER)
- return QMediaServiceProviderHint::VideoSurface;
- else
- return QMediaServiceProviderHint::Features();
-}
-
-QMultimedia::SupportEstimate AVFMediaPlayerServicePlugin::hasSupport(const QString &mimeType, const QStringList &codecs) const
-{
- Q_UNUSED(codecs);
-
- if (m_supportedMimeTypes.contains(mimeType))
- return QMultimedia::ProbablySupported;
-
- return QMultimedia::MaybeSupported;
-}
-
-QStringList AVFMediaPlayerServicePlugin::supportedMimeTypes() const
-{
- return m_supportedMimeTypes;
-}
-
-void AVFMediaPlayerServicePlugin::buildSupportedTypes()
-{
- //Populate m_supportedMimeTypes with mimetypes AVAsset supports
- NSArray *mimeTypes = [AVURLAsset audiovisualMIMETypes];
- for (NSString *mimeType in mimeTypes)
- {
- m_supportedMimeTypes.append(QString::fromUtf8([mimeType UTF8String]));
- }
-#ifdef QT_DEBUG_AVF
- qDebug() << "AVFMediaPlayerServicePlugin::buildSupportedTypes";
- qDebug() << "Supported Types: " << m_supportedMimeTypes;
-#endif
-
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h
deleted file mode 100644
index db29e88aa..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFMEDIAPLAYERSESSION_H
-#define AVFMEDIAPLAYERSESSION_H
-
-#include <QtCore/QObject>
-#include <QtCore/QByteArray>
-#include <QtCore/QSet>
-#include <QtCore/QResource>
-
-#include <QtMultimedia/QMediaPlayerControl>
-#include <QtMultimedia/QMediaPlayer>
-
-QT_BEGIN_NAMESPACE
-
-class AVFMediaPlayerService;
-class AVFVideoOutput;
-
-class AVFMediaPlayerSession : public QObject
-{
- Q_OBJECT
-public:
- AVFMediaPlayerSession(AVFMediaPlayerService *service, QObject *parent = nullptr);
- virtual ~AVFMediaPlayerSession();
-
- void setVideoOutput(AVFVideoOutput *output);
- void *currentAssetHandle();
-
- QMediaPlayer::State state() const;
- QMediaPlayer::MediaStatus mediaStatus() const;
-
- QMediaContent media() const;
- QIODevice *mediaStream() const;
- void setMedia(const QMediaContent &content, QIODevice *stream);
-
- qint64 position() const;
- qint64 duration() const;
-
- int bufferStatus() const;
-
- int volume() const;
- bool isMuted() const;
-
- bool isAudioAvailable() const;
- bool isVideoAvailable() const;
-
- bool isSeekable() const;
- QMediaTimeRange availablePlaybackRanges() const;
-
- qreal playbackRate() const;
-
-public Q_SLOTS:
- void setPlaybackRate(qreal rate);
-
- void setPosition(qint64 pos);
-
- void play();
- void pause();
- void stop();
-
- void setVolume(int volume);
- void setMuted(bool muted);
-
- void processEOS();
- void processLoadStateChange(QMediaPlayer::State newState);
- void processPositionChange();
- void processMediaLoadError();
-
- void processLoadStateChange();
- void processLoadStateFailure();
-
- void processBufferStateChange(int bufferStatus);
-
- void processDurationChange(qint64 duration);
-
- void streamReady();
- void streamDestroyed();
-
-Q_SIGNALS:
- void positionChanged(qint64 position);
- void durationChanged(qint64 duration);
- void stateChanged(QMediaPlayer::State newState);
- void bufferStatusChanged(int bufferStatus);
- void mediaStatusChanged(QMediaPlayer::MediaStatus status);
- void volumeChanged(int volume);
- void mutedChanged(bool muted);
- void audioAvailableChanged(bool audioAvailable);
- void videoAvailableChanged(bool videoAvailable);
- void playbackRateChanged(qreal rate);
- void seekableChanged(bool seekable);
- void error(int error, const QString &errorString);
-
-private:
- void setAudioAvailable(bool available);
- void setVideoAvailable(bool available);
- void setSeekable(bool seekable);
- void resetStream(QIODevice *stream = nullptr);
-
- AVFMediaPlayerService *m_service;
- AVFVideoOutput *m_videoOutput;
-
- QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_mediaStatus;
- QIODevice *m_mediaStream;
- QMediaContent m_resources;
-
- bool m_muted;
- bool m_tryingAsync;
- int m_volume;
- qreal m_rate;
- qint64 m_requestedPosition;
-
- qint64 m_duration;
- int m_bufferStatus;
- bool m_videoAvailable;
- bool m_audioAvailable;
- bool m_seekable;
-
- void *m_observer;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFMEDIAPLAYERSESSION_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
deleted file mode 100644
index 95121f58a..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
+++ /dev/null
@@ -1,1067 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfmediaplayersession.h"
-#include "avfmediaplayerservice.h"
-#include "avfvideooutput.h"
-
-#include <qpointer.h>
-#include <QFileInfo>
-
-#import <AVFoundation/AVFoundation.h>
-
-QT_USE_NAMESPACE
-
-//AVAsset Keys
-static NSString* const AVF_TRACKS_KEY = @"tracks";
-static NSString* const AVF_PLAYABLE_KEY = @"playable";
-
-//AVPlayerItem keys
-static NSString* const AVF_STATUS_KEY = @"status";
-static NSString* const AVF_BUFFER_LIKELY_KEEP_UP_KEY = @"playbackLikelyToKeepUp";
-
-//AVPlayer keys
-static NSString* const AVF_RATE_KEY = @"rate";
-static NSString* const AVF_CURRENT_ITEM_KEY = @"currentItem";
-static NSString* const AVF_CURRENT_ITEM_DURATION_KEY = @"currentItem.duration";
-
-static void *AVFMediaPlayerSessionObserverRateObservationContext = &AVFMediaPlayerSessionObserverRateObservationContext;
-static void *AVFMediaPlayerSessionObserverStatusObservationContext = &AVFMediaPlayerSessionObserverStatusObservationContext;
-static void *AVFMediaPlayerSessionObserverBufferLikelyToKeepUpContext = &AVFMediaPlayerSessionObserverBufferLikelyToKeepUpContext;
-static void *AVFMediaPlayerSessionObserverCurrentItemObservationContext = &AVFMediaPlayerSessionObserverCurrentItemObservationContext;
-static void *AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext = &AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext;
-
-@interface AVFMediaPlayerSessionObserver : NSObject<AVAssetResourceLoaderDelegate>
-
-@property (readonly, getter=player) AVPlayer* m_player;
-@property (readonly, getter=playerItem) AVPlayerItem* m_playerItem;
-@property (readonly, getter=playerLayer) AVPlayerLayer* m_playerLayer;
-@property (readonly, getter=session) AVFMediaPlayerSession* m_session;
-
-- (AVFMediaPlayerSessionObserver *) initWithMediaPlayerSession:(AVFMediaPlayerSession *)session;
-- (void) setURL:(NSURL *)url mimeType:(NSString *)mimeType;
-- (void) unloadMedia;
-- (void) prepareToPlayAsset:(AVURLAsset *)asset withKeys:(NSArray *)requestedKeys;
-- (void) assetFailedToPrepareForPlayback:(NSError *)error;
-- (void) playerItemDidReachEnd:(NSNotification *)notification;
-- (void) playerItemTimeJumped:(NSNotification *)notification;
-- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
- change:(NSDictionary *)change context:(void *)context;
-- (void) detatchSession;
-- (void) dealloc;
-- (BOOL) resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest;
-@end
-
-@implementation AVFMediaPlayerSessionObserver
-{
-@private
- AVFMediaPlayerSession *m_session;
- AVPlayer *m_player;
- AVPlayerItem *m_playerItem;
- AVPlayerLayer *m_playerLayer;
- NSURL *m_URL;
- BOOL m_bufferIsLikelyToKeepUp;
- NSData *m_data;
- NSString *m_mimeType;
-}
-
-@synthesize m_player, m_playerItem, m_playerLayer, m_session;
-
-- (AVFMediaPlayerSessionObserver *) initWithMediaPlayerSession:(AVFMediaPlayerSession *)session
-{
- if (!(self = [super init]))
- return nil;
-
- self->m_session = session;
- self->m_bufferIsLikelyToKeepUp = FALSE;
- return self;
-}
-
-- (void) setURL:(NSURL *)url mimeType:(NSString *)mimeType
-{
- [m_mimeType release];
- m_mimeType = [mimeType retain];
-
- if (m_URL != url)
- {
- [m_URL release];
- m_URL = [url copy];
-
- //Create an asset for inspection of a resource referenced by a given URL.
- //Load the values for the asset keys "tracks", "playable".
-
- // use __block to avoid maintaining strong references on variables captured by the
- // following block callback
- __block AVURLAsset *asset = [[AVURLAsset URLAssetWithURL:m_URL options:nil] retain];
- [asset.resourceLoader setDelegate:self queue:dispatch_get_main_queue()];
-
- __block NSArray *requestedKeys = [[NSArray arrayWithObjects:AVF_TRACKS_KEY, AVF_PLAYABLE_KEY, nil] retain];
-
- __block AVFMediaPlayerSessionObserver *blockSelf = self;
- QPointer<AVFMediaPlayerSession> session(m_session);
-
- // Tells the asset to load the values of any of the specified keys that are not already loaded.
- [asset loadValuesAsynchronouslyForKeys:requestedKeys completionHandler:
- ^{
- dispatch_async( dispatch_get_main_queue(),
- ^{
- if (session)
- [blockSelf prepareToPlayAsset:asset withKeys:requestedKeys];
- [asset release];
- [requestedKeys release];
- });
- }];
- }
-}
-
-- (void) unloadMedia
-{
- if (m_playerItem) {
- [m_playerItem removeObserver:self forKeyPath:AVF_STATUS_KEY];
- [m_playerItem removeObserver:self forKeyPath:AVF_BUFFER_LIKELY_KEEP_UP_KEY];
-
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:AVPlayerItemDidPlayToEndTimeNotification
- object:m_playerItem];
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:AVPlayerItemTimeJumpedNotification
- object:m_playerItem];
- m_playerItem = 0;
- }
- if (m_player) {
- [m_player setRate:0.0];
- [m_player removeObserver:self forKeyPath:AVF_CURRENT_ITEM_DURATION_KEY];
- [m_player removeObserver:self forKeyPath:AVF_CURRENT_ITEM_KEY];
- [m_player removeObserver:self forKeyPath:AVF_RATE_KEY];
- [m_player release];
- m_player = 0;
- }
- if (m_playerLayer) {
- [m_playerLayer release];
- m_playerLayer = 0;
- }
-#if defined(Q_OS_IOS)
- [[AVAudioSession sharedInstance] setActive:NO error:nil];
-#endif
-}
-
-- (void) prepareToPlayAsset:(AVURLAsset *)asset
- withKeys:(NSArray *)requestedKeys
-{
- //Make sure that the value of each key has loaded successfully.
- for (NSString *thisKey in requestedKeys)
- {
- NSError *error = nil;
- AVKeyValueStatus keyStatus = [asset statusOfValueForKey:thisKey error:&error];
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << [thisKey UTF8String] << " status: " << keyStatus;
-#endif
- if (keyStatus == AVKeyValueStatusFailed)
- {
- [self assetFailedToPrepareForPlayback:error];
- return;
- }
- }
-
- //Use the AVAsset playable property to detect whether the asset can be played.
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << "isPlayable: " << [asset isPlayable];
-#endif
- if (!asset.playable)
- {
- //Generate an error describing the failure.
- NSString *localizedDescription = NSLocalizedString(@"Item cannot be played", @"Item cannot be played description");
- NSString *localizedFailureReason = NSLocalizedString(@"The assets tracks were loaded, but could not be made playable.", @"Item cannot be played failure reason");
- NSDictionary *errorDict = [NSDictionary dictionaryWithObjectsAndKeys:
- localizedDescription, NSLocalizedDescriptionKey,
- localizedFailureReason, NSLocalizedFailureReasonErrorKey,
- nil];
- NSError *assetCannotBePlayedError = [NSError errorWithDomain:@"StitchedStreamPlayer" code:0 userInfo:errorDict];
-
- [self assetFailedToPrepareForPlayback:assetCannotBePlayedError];
-
- return;
- }
-
- //At this point we're ready to set up for playback of the asset.
- //Stop observing our prior AVPlayerItem, if we have one.
- if (m_playerItem)
- {
- //Remove existing player item key value observers and notifications.
- [self unloadMedia];
- }
-
- //Create a new instance of AVPlayerItem from the now successfully loaded AVAsset.
- m_playerItem = [AVPlayerItem playerItemWithAsset:asset];
-
- //Observe the player item "status" key to determine when it is ready to play.
- [m_playerItem addObserver:self
- forKeyPath:AVF_STATUS_KEY
- options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
- context:AVFMediaPlayerSessionObserverStatusObservationContext];
-
- [m_playerItem addObserver:self
- forKeyPath:AVF_BUFFER_LIKELY_KEEP_UP_KEY
- options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
- context:AVFMediaPlayerSessionObserverBufferLikelyToKeepUpContext];
-
- //When the player item has played to its end time we'll toggle
- //the movie controller Pause button to be the Play button
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(playerItemDidReachEnd:)
- name:AVPlayerItemDidPlayToEndTimeNotification
- object:m_playerItem];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(playerItemTimeJumped:)
- name:AVPlayerItemTimeJumpedNotification
- object:m_playerItem];
-
- //Get a new AVPlayer initialized to play the specified player item.
- m_player = [AVPlayer playerWithPlayerItem:m_playerItem];
- [m_player retain];
-
- //Set the initial volume on new player object
- if (self.session) {
- [m_player setVolume:m_session->volume() / 100.0f];
- [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);
- }
-
- //Observe the AVPlayer "currentItem" property to find out when any
- //AVPlayer replaceCurrentItemWithPlayerItem: replacement will/did
- //occur.
- [m_player addObserver:self
- forKeyPath:AVF_CURRENT_ITEM_KEY
- options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
- context:AVFMediaPlayerSessionObserverCurrentItemObservationContext];
-
- //Observe the AVPlayer "rate" property to update the scrubber control.
- [m_player addObserver:self
- forKeyPath:AVF_RATE_KEY
- options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
- context:AVFMediaPlayerSessionObserverRateObservationContext];
-
- //Observe the duration for getting the buffer state
- [m_player addObserver:self
- forKeyPath:AVF_CURRENT_ITEM_DURATION_KEY
- options:0
- context:AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext];
-#if defined(Q_OS_IOS)
- [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
- [[AVAudioSession sharedInstance] setActive:YES error:nil];
-#endif
-}
-
--(void) assetFailedToPrepareForPlayback:(NSError *)error
-{
- Q_UNUSED(error);
- QMetaObject::invokeMethod(m_session, "processMediaLoadError", Qt::AutoConnection);
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
- qDebug() << [[error localizedDescription] UTF8String];
- qDebug() << [[error localizedFailureReason] UTF8String];
- qDebug() << [[error localizedRecoverySuggestion] UTF8String];
-#endif
-}
-
-- (void) playerItemDidReachEnd:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- if (self.session)
- QMetaObject::invokeMethod(m_session, "processEOS", Qt::AutoConnection);
-}
-
-- (void) playerItemTimeJumped:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- if (self.session)
- QMetaObject::invokeMethod(m_session, "processPositionChange", Qt::AutoConnection);
-}
-
-- (void) observeValueForKeyPath:(NSString*) path
- ofObject:(id)object
- change:(NSDictionary*)change
- context:(void*)context
-{
- //AVPlayerItem "status" property value observer.
- if (context == AVFMediaPlayerSessionObserverStatusObservationContext)
- {
- AVPlayerStatus status = (AVPlayerStatus)[[change objectForKey:NSKeyValueChangeNewKey] integerValue];
- switch (status)
- {
- //Indicates that the status of the player is not yet known because
- //it has not tried to load new media resources for playback
- case AVPlayerStatusUnknown:
- {
- //QMetaObject::invokeMethod(m_session, "processLoadStateChange", Qt::AutoConnection);
- }
- break;
-
- case AVPlayerStatusReadyToPlay:
- {
- //Once the AVPlayerItem becomes ready to play, i.e.
- //[playerItem status] == AVPlayerItemStatusReadyToPlay,
- //its duration can be fetched from the item.
- if (self.session)
- QMetaObject::invokeMethod(m_session, "processLoadStateChange", Qt::AutoConnection);
- }
- break;
-
- case AVPlayerStatusFailed:
- {
- AVPlayerItem *playerItem = static_cast<AVPlayerItem*>(object);
- [self assetFailedToPrepareForPlayback:playerItem.error];
-
- if (self.session)
- QMetaObject::invokeMethod(m_session, "processLoadStateFailure", Qt::AutoConnection);
- }
- break;
- }
- }
- else if (context == AVFMediaPlayerSessionObserverBufferLikelyToKeepUpContext)
- {
- const bool isPlaybackLikelyToKeepUp = [m_playerItem isPlaybackLikelyToKeepUp];
- if (isPlaybackLikelyToKeepUp != m_bufferIsLikelyToKeepUp) {
- m_bufferIsLikelyToKeepUp = isPlaybackLikelyToKeepUp;
- QMetaObject::invokeMethod(m_session, "processBufferStateChange", Qt::AutoConnection,
- Q_ARG(int, isPlaybackLikelyToKeepUp ? 100 : 0));
- }
- }
- //AVPlayer "rate" property value observer.
- else if (context == AVFMediaPlayerSessionObserverRateObservationContext)
- {
- //QMetaObject::invokeMethod(m_session, "setPlaybackRate", Qt::AutoConnection, Q_ARG(qreal, [m_player rate]));
- }
- //AVPlayer "currentItem" property observer.
- //Called when the AVPlayer replaceCurrentItemWithPlayerItem:
- //replacement will/did occur.
- else if (context == AVFMediaPlayerSessionObserverCurrentItemObservationContext)
- {
- AVPlayerItem *newPlayerItem = [change objectForKey:NSKeyValueChangeNewKey];
- if (m_playerItem != newPlayerItem)
- m_playerItem = newPlayerItem;
- }
- else if (context == AVFMediaPlayerSessionObserverCurrentItemDurationObservationContext)
- {
- const CMTime time = [m_playerItem duration];
- const qint64 duration = static_cast<qint64>(float(time.value) / float(time.timescale) * 1000.0f);
- if (self.session)
- QMetaObject::invokeMethod(m_session, "processDurationChange", Qt::AutoConnection, Q_ARG(qint64, duration));
- }
- else
- {
- [super observeValueForKeyPath:path ofObject:object change:change context:context];
- }
-}
-
-- (void) detatchSession
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- m_session = 0;
-}
-
-- (void) dealloc
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- [self unloadMedia];
-
- if (m_URL) {
- [m_URL release];
- }
-
- [m_mimeType release];
- [super dealloc];
-}
-
-- (BOOL) resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest
-{
- Q_UNUSED(resourceLoader);
-
- if (![loadingRequest.request.URL.scheme isEqualToString:@"iodevice"])
- return NO;
-
- QIODevice *device = m_session->mediaStream();
- if (!device)
- return NO;
-
- device->seek(loadingRequest.dataRequest.requestedOffset);
- if (loadingRequest.contentInformationRequest) {
- loadingRequest.contentInformationRequest.contentType = m_mimeType;
- loadingRequest.contentInformationRequest.contentLength = device->size();
- loadingRequest.contentInformationRequest.byteRangeAccessSupported = YES;
- }
-
- if (loadingRequest.dataRequest) {
- NSInteger requestedLength = loadingRequest.dataRequest.requestedLength;
- int maxBytes = qMin(32 * 1064, int(requestedLength));
- char buffer[maxBytes];
- NSInteger submitted = 0;
- while (submitted < requestedLength) {
- qint64 len = device->read(buffer, maxBytes);
- if (len < 1)
- break;
-
- [loadingRequest.dataRequest respondWithData:[NSData dataWithBytes:buffer length:len]];
- submitted += len;
- }
-
- // Finish loading even if not all bytes submitted.
- [loadingRequest finishLoading];
- }
-
- return YES;
-}
-@end
-
-AVFMediaPlayerSession::AVFMediaPlayerSession(AVFMediaPlayerService *service, QObject *parent)
- : QObject(parent)
- , m_service(service)
- , m_videoOutput(nullptr)
- , m_state(QMediaPlayer::StoppedState)
- , m_mediaStatus(QMediaPlayer::NoMedia)
- , m_mediaStream(nullptr)
- , m_muted(false)
- , m_tryingAsync(false)
- , m_volume(100)
- , m_rate(1.0)
- , m_requestedPosition(-1)
- , m_duration(0)
- , m_bufferStatus(0)
- , m_videoAvailable(false)
- , m_audioAvailable(false)
- , m_seekable(false)
-{
- m_observer = [[AVFMediaPlayerSessionObserver alloc] initWithMediaPlayerSession:this];
-}
-
-AVFMediaPlayerSession::~AVFMediaPlayerSession()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- //Detatch the session from the sessionObserver (which could still be alive trying to communicate with this session).
- [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) detatchSession];
- [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) release];
-}
-
-void AVFMediaPlayerSession::setVideoOutput(AVFVideoOutput *output)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << output;
-#endif
-
- if (m_videoOutput == output)
- return;
-
- //Set the current output layer to null to stop rendering
- if (m_videoOutput) {
- m_videoOutput->setLayer(nullptr);
- }
-
- m_videoOutput = output;
-
- if (m_videoOutput && m_state != QMediaPlayer::StoppedState)
- m_videoOutput->setLayer([static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerLayer]);
-}
-
-void *AVFMediaPlayerSession::currentAssetHandle()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- AVAsset *currentAsset = [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem] asset];
- return currentAsset;
-}
-
-QMediaPlayer::State AVFMediaPlayerSession::state() const
-{
- return m_state;
-}
-
-QMediaPlayer::MediaStatus AVFMediaPlayerSession::mediaStatus() const
-{
- return m_mediaStatus;
-}
-
-QMediaContent AVFMediaPlayerSession::media() const
-{
- return m_resources;
-}
-
-QIODevice *AVFMediaPlayerSession::mediaStream() const
-{
- return m_mediaStream;
-}
-
-static void setURL(void *observer, const QByteArray &url, const QString &mimeType = QString())
-{
- NSString *urlString = [NSString stringWithUTF8String:url.constData()];
- NSURL *nsurl = [NSURL URLWithString:urlString];
- [static_cast<AVFMediaPlayerSessionObserver*>(observer) setURL:nsurl mimeType:[NSString stringWithUTF8String:mimeType.toLatin1().constData()]];
-}
-
-static void setStreamURL(void *observer, const QByteArray &url)
-{
- setURL(observer, QByteArrayLiteral("iodevice://") + url, QFileInfo(url).suffix());
-}
-
-void AVFMediaPlayerSession::setMedia(const QMediaContent &content, QIODevice *stream)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << content.request().url();
-#endif
-
- [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) unloadMedia];
-
- m_resources = content;
- resetStream(stream);
-
- setAudioAvailable(false);
- setVideoAvailable(false);
- setSeekable(false);
- m_requestedPosition = -1;
- Q_EMIT positionChanged(position());
-
- const QMediaPlayer::MediaStatus oldMediaStatus = m_mediaStatus;
- const QMediaPlayer::State oldState = m_state;
-
- if (!m_mediaStream && (content.isNull() || content.request().url().isEmpty())) {
- m_mediaStatus = QMediaPlayer::NoMedia;
- if (m_mediaStatus != oldMediaStatus)
- Q_EMIT mediaStatusChanged(m_mediaStatus);
-
- m_state = QMediaPlayer::StoppedState;
- if (m_state != oldState)
- Q_EMIT stateChanged(m_state);
-
- return;
- }
-
- m_mediaStatus = QMediaPlayer::LoadingMedia;
- if (m_mediaStatus != oldMediaStatus)
- Q_EMIT mediaStatusChanged(m_mediaStatus);
-
- if (m_mediaStream) {
- // If there is a data, try to load it,
- // otherwise wait for readyRead.
- if (m_mediaStream->size())
- setStreamURL(m_observer, m_resources.request().url().toEncoded());
- } else {
- //Load AVURLAsset
- //initialize asset using content's URL
- setURL(m_observer, m_resources.request().url().toEncoded());
- }
-
- m_state = QMediaPlayer::StoppedState;
- if (m_state != oldState)
- Q_EMIT stateChanged(m_state);
-}
-
-qint64 AVFMediaPlayerSession::position() const
-{
- AVPlayerItem *playerItem = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem];
-
- if (!playerItem)
- return m_requestedPosition != -1 ? m_requestedPosition : 0;
-
- CMTime time = [playerItem currentTime];
- return static_cast<quint64>(float(time.value) / float(time.timescale) * 1000.0f);
-}
-
-qint64 AVFMediaPlayerSession::duration() const
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- return m_duration;
-}
-
-int AVFMediaPlayerSession::bufferStatus() const
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- return m_bufferStatus;
-}
-
-int AVFMediaPlayerSession::volume() const
-{
- return m_volume;
-}
-
-bool AVFMediaPlayerSession::isMuted() const
-{
- return m_muted;
-}
-
-void AVFMediaPlayerSession::setAudioAvailable(bool available)
-{
- if (m_audioAvailable == available)
- return;
-
- m_audioAvailable = available;
- Q_EMIT audioAvailableChanged(available);
-}
-
-bool AVFMediaPlayerSession::isAudioAvailable() const
-{
- return m_audioAvailable;
-}
-
-void AVFMediaPlayerSession::setVideoAvailable(bool available)
-{
- if (m_videoAvailable == available)
- return;
-
- m_videoAvailable = available;
- Q_EMIT videoAvailableChanged(available);
-}
-
-bool AVFMediaPlayerSession::isVideoAvailable() const
-{
- return m_videoAvailable;
-}
-
-bool AVFMediaPlayerSession::isSeekable() const
-{
- return m_seekable;
-}
-
-void AVFMediaPlayerSession::setSeekable(bool seekable)
-{
- if (m_seekable == seekable)
- return;
-
- m_seekable = seekable;
- Q_EMIT seekableChanged(seekable);
-}
-
-QMediaTimeRange AVFMediaPlayerSession::availablePlaybackRanges() const
-{
- AVPlayerItem *playerItem = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem];
-
- if (playerItem) {
- QMediaTimeRange timeRanges;
-
- NSArray *ranges = [playerItem loadedTimeRanges];
- for (NSValue *timeRange in ranges) {
- CMTimeRange currentTimeRange = [timeRange CMTimeRangeValue];
- qint64 startTime = qint64(float(currentTimeRange.start.value) / currentTimeRange.start.timescale * 1000.0);
- timeRanges.addInterval(startTime, startTime + qint64(float(currentTimeRange.duration.value) / currentTimeRange.duration.timescale * 1000.0));
- }
- if (!timeRanges.isEmpty())
- return timeRanges;
- }
- return QMediaTimeRange(0, duration());
-}
-
-qreal AVFMediaPlayerSession::playbackRate() const
-{
- return m_rate;
-}
-
-void AVFMediaPlayerSession::setPlaybackRate(qreal rate)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << rate;
-#endif
-
- if (qFuzzyCompare(m_rate, rate))
- return;
-
- m_rate = rate;
-
- AVPlayer *player = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player];
- if (player && m_state == QMediaPlayer::PlayingState)
- [player setRate:m_rate];
-
- Q_EMIT playbackRateChanged(m_rate);
-}
-
-void AVFMediaPlayerSession::setPosition(qint64 pos)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << pos;
-#endif
-
- if (pos == position())
- return;
-
- AVPlayerItem *playerItem = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem];
- if (!playerItem) {
- m_requestedPosition = pos;
- Q_EMIT positionChanged(m_requestedPosition);
- return;
- }
-
- if (!isSeekable()) {
- if (m_requestedPosition != -1) {
- m_requestedPosition = -1;
- Q_EMIT positionChanged(position());
- }
- return;
- }
-
- pos = qMax(qint64(0), pos);
- if (duration() > 0)
- pos = qMin(pos, duration());
-
- CMTime newTime = [playerItem currentTime];
- newTime.value = (pos / 1000.0f) * newTime.timescale;
- [playerItem seekToTime:newTime toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:nil];
-
- Q_EMIT positionChanged(pos);
-
- // Reset media status if the current status is EndOfMedia
- if (m_mediaStatus == QMediaPlayer::EndOfMedia) {
- QMediaPlayer::MediaStatus newMediaStatus = (m_state == QMediaPlayer::PausedState) ? QMediaPlayer::BufferedMedia
- : QMediaPlayer::LoadedMedia;
- Q_EMIT mediaStatusChanged((m_mediaStatus = newMediaStatus));
- }
-}
-
-void AVFMediaPlayerSession::play()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << "currently: " << m_state;
-#endif
-
- if (m_mediaStatus == QMediaPlayer::NoMedia || m_mediaStatus == QMediaPlayer::InvalidMedia)
- return;
-
- if (m_state == QMediaPlayer::PlayingState)
- return;
-
- if (m_videoOutput) {
- m_videoOutput->setLayer([static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerLayer]);
- }
-
- // Reset media status if the current status is EndOfMedia
- if (m_mediaStatus == QMediaPlayer::EndOfMedia)
- setPosition(0);
-
- if (m_mediaStatus == QMediaPlayer::LoadedMedia || m_mediaStatus == QMediaPlayer::BufferedMedia) {
- // Setting the rate starts playback
- [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] setRate:m_rate];
- }
-
- m_state = QMediaPlayer::PlayingState;
- processLoadStateChange();
-
- Q_EMIT stateChanged(m_state);
-}
-
-void AVFMediaPlayerSession::pause()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << "currently: " << m_state;
-#endif
-
- if (m_mediaStatus == QMediaPlayer::NoMedia)
- return;
-
- if (m_state == QMediaPlayer::PausedState)
- return;
-
- m_state = QMediaPlayer::PausedState;
-
- if (m_videoOutput) {
- m_videoOutput->setLayer([static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerLayer]);
- }
-
- [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] pause];
-
- // Reset media status if the current status is EndOfMedia
- if (m_mediaStatus == QMediaPlayer::EndOfMedia)
- setPosition(0);
-
-
- Q_EMIT stateChanged(m_state);
-}
-
-void AVFMediaPlayerSession::stop()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << "currently: " << m_state;
-#endif
-
- if (m_state == QMediaPlayer::StoppedState)
- return;
-
- // AVPlayer doesn't have stop(), only pause() and play().
- [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] pause];
- setPosition(0);
-
- if (m_videoOutput) {
- m_videoOutput->setLayer(nullptr);
- }
-
- if (m_mediaStatus == QMediaPlayer::BufferedMedia)
- Q_EMIT mediaStatusChanged((m_mediaStatus = QMediaPlayer::LoadedMedia));
-
- Q_EMIT positionChanged(position());
- Q_EMIT stateChanged((m_state = QMediaPlayer::StoppedState));
-}
-
-void AVFMediaPlayerSession::setVolume(int volume)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << volume;
-#endif
-
- if (m_volume == volume)
- return;
-
- m_volume = volume;
-
- AVPlayer *player = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player];
- if (player)
- [player setVolume:volume / 100.0f];
-
- Q_EMIT volumeChanged(m_volume);
-}
-
-void AVFMediaPlayerSession::setMuted(bool muted)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << muted;
-#endif
-
- if (m_muted == muted)
- return;
-
- m_muted = muted;
-
- AVPlayer *player = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player];
- if (player)
- [player setMuted:muted];
-
- Q_EMIT mutedChanged(muted);
-}
-
-void AVFMediaPlayerSession::processEOS()
-{
- //AVPlayerItem has reached end of track/stream
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- Q_EMIT positionChanged(position());
- m_mediaStatus = QMediaPlayer::EndOfMedia;
- m_state = QMediaPlayer::StoppedState;
-
- // At this point, frames should not be rendered anymore.
- // Clear the output layer to make sure of that.
- if (m_videoOutput)
- m_videoOutput->setLayer(nullptr);
-
- Q_EMIT mediaStatusChanged(m_mediaStatus);
- Q_EMIT stateChanged(m_state);
-}
-
-void AVFMediaPlayerSession::processLoadStateChange(QMediaPlayer::State newState)
-{
- AVPlayerStatus currentStatus = [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] status];
-
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << currentStatus << ", " << m_mediaStatus << ", " << newState;
-#endif
-
- if (m_mediaStatus == QMediaPlayer::NoMedia)
- return;
-
- if (currentStatus == AVPlayerStatusReadyToPlay) {
-
- QMediaPlayer::MediaStatus newStatus = m_mediaStatus;
-
- AVPlayerItem *playerItem = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerItem];
-
- if (playerItem) {
- // Check each track for audio and video content
- AVAssetTrack *videoTrack = nil;
- NSArray *tracks = playerItem.tracks;
- for (AVPlayerItemTrack *track in tracks) {
- AVAssetTrack *assetTrack = track.assetTrack;
- if (assetTrack) {
- if ([assetTrack.mediaType isEqualToString:AVMediaTypeAudio])
- setAudioAvailable(true);
- if ([assetTrack.mediaType isEqualToString:AVMediaTypeVideo]) {
- setVideoAvailable(true);
- if (!videoTrack)
- videoTrack = assetTrack;
- }
- }
- }
-
- setSeekable([[playerItem seekableTimeRanges] count] > 0);
-
- // Get the native size of the video, and reset the bounds of the player layer
- AVPlayerLayer *playerLayer = [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) playerLayer];
- if (videoTrack && playerLayer) {
- if (!playerLayer.bounds.size.width || !playerLayer.bounds.size.height) {
- playerLayer.bounds = CGRectMake(0.0f, 0.0f,
- videoTrack.naturalSize.width,
- videoTrack.naturalSize.height);
- }
-
- if (m_videoOutput && newState != QMediaPlayer::StoppedState) {
- m_videoOutput->setLayer(playerLayer);
- }
- }
-
- if (m_requestedPosition != -1) {
- setPosition(m_requestedPosition);
- m_requestedPosition = -1;
- }
- }
-
- newStatus = (newState != QMediaPlayer::StoppedState) ? QMediaPlayer::BufferedMedia
- : QMediaPlayer::LoadedMedia;
-
- if (newStatus != m_mediaStatus)
- Q_EMIT mediaStatusChanged((m_mediaStatus = newStatus));
-
- }
-
- if (newState == QMediaPlayer::PlayingState && [static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player]) {
- // Setting the rate is enough to start playback, no need to call play()
- [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] setRate:m_rate];
- }
-}
-
-
-void AVFMediaPlayerSession::processLoadStateChange()
-{
- processLoadStateChange(m_state);
-}
-
-
-void AVFMediaPlayerSession::processLoadStateFailure()
-{
- Q_EMIT stateChanged((m_state = QMediaPlayer::StoppedState));
-}
-
-void AVFMediaPlayerSession::processBufferStateChange(int bufferStatus)
-{
- if (bufferStatus == m_bufferStatus)
- return;
-
- auto status = m_mediaStatus;
- // Buffered -> unbuffered.
- if (!bufferStatus) {
- status = QMediaPlayer::StalledMedia;
- } else if (status == QMediaPlayer::StalledMedia) {
- status = QMediaPlayer::BufferedMedia;
- // Resume playback.
- if (m_state == QMediaPlayer::PlayingState)
- [[static_cast<AVFMediaPlayerSessionObserver*>(m_observer) player] setRate:m_rate];
- }
-
- if (m_mediaStatus != status)
- Q_EMIT mediaStatusChanged(m_mediaStatus = status);
-
- m_bufferStatus = bufferStatus;
- Q_EMIT bufferStatusChanged(bufferStatus);
-}
-
-void AVFMediaPlayerSession::processDurationChange(qint64 duration)
-{
- if (duration == m_duration)
- return;
-
- m_duration = duration;
- Q_EMIT durationChanged(duration);
-}
-
-void AVFMediaPlayerSession::processPositionChange()
-{
- if (m_state == QMediaPlayer::StoppedState)
- return;
-
- Q_EMIT positionChanged(position());
-}
-
-void AVFMediaPlayerSession::processMediaLoadError()
-{
- if (m_requestedPosition != -1) {
- m_requestedPosition = -1;
- Q_EMIT positionChanged(position());
- }
-
- Q_EMIT mediaStatusChanged((m_mediaStatus = QMediaPlayer::InvalidMedia));
-
- Q_EMIT error(QMediaPlayer::FormatError, tr("Failed to load media"));
-}
-
-void AVFMediaPlayerSession::streamReady()
-{
- setStreamURL(m_observer, m_resources.request().url().toEncoded());
-}
-
-void AVFMediaPlayerSession::streamDestroyed()
-{
- resetStream(nullptr);
-}
-
-void AVFMediaPlayerSession::resetStream(QIODevice *stream)
-{
- if (m_mediaStream) {
- disconnect(m_mediaStream, &QIODevice::readyRead, this, &AVFMediaPlayerSession::streamReady);
- disconnect(m_mediaStream, &QIODevice::destroyed, this, &AVFMediaPlayerSession::streamDestroyed);
- }
-
- m_mediaStream = stream;
-
- if (m_mediaStream) {
- connect(m_mediaStream, &QIODevice::readyRead, this, &AVFMediaPlayerSession::streamReady);
- connect(m_mediaStream, &QIODevice::destroyed, this, &AVFMediaPlayerSession::streamDestroyed);
- }
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.h b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.h
deleted file mode 100644
index 2d8a7df81..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFVIDEOFRAMERENDERER_H
-#define AVFVIDEOFRAMERENDERER_H
-
-#include <QtCore/QObject>
-#include <QtGui/QImage>
-#include <QtGui/QOpenGLContext>
-#include <QtCore/QSize>
-
-#import "Metal/Metal.h"
-#import "MetalKit/MetalKit.h"
-
-@class CARenderer;
-@class AVPlayerLayer;
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLFramebufferObject;
-class QOpenGLShaderProgram;
-class QWindow;
-class QOpenGLContext;
-class QAbstractVideoSurface;
-
-class AVFVideoFrameRenderer : public QObject
-{
-public:
- AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent = nullptr);
-
- virtual ~AVFVideoFrameRenderer();
-
- quint64 renderLayerToTexture(AVPlayerLayer *layer);
- quint64 renderLayerToMTLTexture(AVPlayerLayer *layer);
- QImage renderLayerToImage(AVPlayerLayer *layer);
-
- static GLuint createGLTexture(CGLContextObj cglContextObj, CGLPixelFormatObj cglPixelFormtObj,
- CVOpenGLTextureCacheRef cvglTextureCache,
- CVPixelBufferRef cvPixelBufferRef,
- CVOpenGLTextureRef cvOpenGLTextureRef);
-
- static id<MTLTexture> createMetalTexture(id<MTLDevice> mtlDevice,
- CVMetalTextureCacheRef cvMetalTextureCacheRef,
- CVPixelBufferRef cvPixelBufferRef,
- MTLPixelFormat pixelFormat, size_t width, size_t height,
- CVMetalTextureRef cvMetalTextureRef);
-
-private:
- QOpenGLFramebufferObject* initRenderer(AVPlayerLayer *layer);
- void renderLayerToFBO(AVPlayerLayer *layer, QOpenGLFramebufferObject *fbo);
- void renderLayerToFBOCoreOpenGL(AVPlayerLayer *layer, QOpenGLFramebufferObject *fbo);
-
- CARenderer *m_videoLayerRenderer;
- QAbstractVideoSurface *m_surface;
- QOpenGLFramebufferObject *m_fbo[2];
- QOpenGLShaderProgram *m_shader = nullptr;
- QWindow *m_offscreenSurface;
- QOpenGLContext *m_glContext;
- QSize m_targetSize;
-
- bool m_useCoreProfile = false;
-
- // Shared pixel buffer
- CVPixelBufferRef m_CVPixelBuffer;
-
- // OpenGL Texture
- CVOpenGLTextureCacheRef m_CVGLTextureCache;
- CVOpenGLTextureRef m_CVGLTexture;
- CGLPixelFormatObj m_CGLPixelFormat;
- GLuint m_textureName = 0;
-
- // Metal Texture
- CVMetalTextureRef m_CVMTLTexture;
- CVMetalTextureCacheRef m_CVMTLTextureCache;
-
- NSOpenGLContext *m_NSGLContext = nullptr;
-
- GLuint m_quadVao = 0;
- GLuint m_quadVbos[2];
-
- uint m_currentBuffer;
- bool m_isContextShared;
-
- id<MTLDevice> m_metalDevice = nil;
- id<MTLTexture> m_metalTexture = nil;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFVIDEOFRAMERENDERER_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm
deleted file mode 100644
index f57b26dff..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm
+++ /dev/null
@@ -1,464 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfvideoframerenderer.h"
-
-#include <QtMultimedia/qabstractvideosurface.h>
-#include <QtOpenGL/QOpenGLFramebufferObject>
-#include <QtGui/QWindow>
-#include <QOpenGLShaderProgram>
-
-#ifdef QT_DEBUG_AVF
-#include <QtCore/qdebug.h>
-#endif
-
-#import <CoreVideo/CVBase.h>
-#import <AVFoundation/AVFoundation.h>
-
-QT_USE_NAMESPACE
-
-AVFVideoFrameRenderer::AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent)
- : QObject(parent)
- , m_videoLayerRenderer(nullptr)
- , m_surface(surface)
- , m_offscreenSurface(nullptr)
- , m_glContext(nullptr)
- , m_currentBuffer(1)
- , m_isContextShared(true)
-{
- m_fbo[0] = nullptr;
- m_fbo[1] = nullptr;
-}
-
-AVFVideoFrameRenderer::~AVFVideoFrameRenderer()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
-
- [m_videoLayerRenderer release];
- [m_metalDevice release];
- delete m_fbo[0];
- delete m_fbo[1];
- delete m_offscreenSurface;
- delete m_glContext;
-
- if (m_useCoreProfile) {
- glDeleteVertexArrays(1, &m_quadVao);
- glDeleteBuffers(2, m_quadVbos);
- delete m_shader;
- }
-}
-
-quint64 AVFVideoFrameRenderer::renderLayerToTexture(AVPlayerLayer *layer)
-{
- //Is layer valid
- if (!layer)
- return 0;
-
- //If the glContext isn't shared, it doesn't make sense to return a texture for us
- if (m_offscreenSurface && !m_isContextShared)
- return 0;
-
- QOpenGLFramebufferObject *fbo = initRenderer(layer);
-
- if (!fbo)
- return 0;
-
- renderLayerToFBO(layer, fbo);
- if (m_glContext)
- m_glContext->doneCurrent();
-
- return fbo->texture();
-}
-
-quint64 AVFVideoFrameRenderer::renderLayerToMTLTexture(AVPlayerLayer *layer)
-{
- m_targetSize = QSize(layer.bounds.size.width, layer.bounds.size.height);
-
- if (!m_metalDevice)
- m_metalDevice = MTLCreateSystemDefaultDevice();
-
- if (!m_metalTexture) {
- auto desc = [[MTLTextureDescriptor alloc] init];
- desc.textureType = MTLTextureType2D;
- desc.width = NSUInteger(m_targetSize.width());
- desc.height = NSUInteger(m_targetSize.height());
- desc.resourceOptions = MTLResourceStorageModePrivate;
- desc.usage = MTLTextureUsageRenderTarget;
- desc.pixelFormat = MTLPixelFormatRGBA8Unorm;
-
- m_metalTexture = [m_metalDevice newTextureWithDescriptor: desc];
- [desc release];
- }
-
- if (!m_videoLayerRenderer) {
- m_videoLayerRenderer = [CARenderer rendererWithMTLTexture:m_metalTexture options:nil];
- [m_videoLayerRenderer retain];
- }
-
- if (m_videoLayerRenderer.layer != layer) {
- m_videoLayerRenderer.layer = layer;
- m_videoLayerRenderer.bounds = layer.bounds;
- }
-
- [m_videoLayerRenderer beginFrameAtTime:CACurrentMediaTime() timeStamp:NULL];
- [m_videoLayerRenderer addUpdateRect:layer.bounds];
- [m_videoLayerRenderer render];
- [m_videoLayerRenderer endFrame];
-
- return quint64(m_metalTexture);
-}
-
-QImage AVFVideoFrameRenderer::renderLayerToImage(AVPlayerLayer *layer)
-{
- //Is layer valid
- if (!layer) {
- return QImage();
- }
-
- QOpenGLFramebufferObject *fbo = initRenderer(layer);
-
- if (!fbo)
- return QImage();
-
- renderLayerToFBO(layer, fbo);
- QImage fboImage = fbo->toImage();
- if (m_glContext)
- m_glContext->doneCurrent();
-
- return fboImage;
-}
-
-QOpenGLFramebufferObject *AVFVideoFrameRenderer::initRenderer(AVPlayerLayer *layer)
-{
-
- //Get size from AVPlayerLayer
- m_targetSize = QSize(layer.bounds.size.width, layer.bounds.size.height);
-
- QOpenGLContext *shareContext = !m_glContext && m_surface
- ? qobject_cast<QOpenGLContext*>(m_surface->property("GLContext").value<QObject*>())
- : nullptr;
-
- //Make sure we have an OpenGL context to make current
- if (shareContext || (!QOpenGLContext::currentContext() && !m_glContext)) {
-
- //Create Hidden QWindow surface to create context in this thread
- delete m_offscreenSurface;
- m_offscreenSurface = new QWindow();
- m_offscreenSurface->setSurfaceType(QWindow::OpenGLSurface);
- //Needs geometry to be a valid surface, but size is not important
- m_offscreenSurface->setGeometry(0, 0, 1, 1);
- m_offscreenSurface->create();
-
- delete m_glContext;
- m_glContext = new QOpenGLContext();
- m_glContext->setFormat(m_offscreenSurface->requestedFormat());
-
- if (shareContext) {
- m_glContext->setShareContext(shareContext);
- m_isContextShared = true;
- } else {
-#ifdef QT_DEBUG_AVF
- qWarning("failed to get Render Thread context");
-#endif
- m_isContextShared = false;
- }
- if (!m_glContext->create()) {
- qWarning("failed to create QOpenGLContext");
- return nullptr;
- }
-
- // CARenderer must be re-created with different current context, so release it now.
- // See lines below where m_videoLayerRenderer is constructed.
- if (m_videoLayerRenderer) {
- [m_videoLayerRenderer release];
- m_videoLayerRenderer = nullptr;
- }
-
- if (m_useCoreProfile) {
- glDeleteVertexArrays(1, &m_quadVao);
- glDeleteBuffers(2, m_quadVbos);
- delete m_shader;
- m_shader = nullptr;
- }
- }
-
- //Need current context
- if (m_glContext)
- m_glContext->makeCurrent(m_offscreenSurface);
-
- if (!m_metalDevice)
- m_metalDevice = MTLCreateSystemDefaultDevice();
-
- if (@available(macOS 10.13, *)) {
- m_useCoreProfile = m_metalDevice && (QOpenGLContext::currentContext()->format().profile() ==
- QSurfaceFormat::CoreProfile);
- } else {
- m_useCoreProfile = false;
- }
-
- // Create the CARenderer if needed for no Core OpenGL
- if (!m_videoLayerRenderer) {
- if (!m_useCoreProfile) {
- m_videoLayerRenderer = [CARenderer rendererWithCGLContext: CGLGetCurrentContext()
- options: nil];
- [m_videoLayerRenderer retain];
- } else if (@available(macOS 10.13, *)) {
- // This is always true when m_useCoreProfile is true, but the compiler wants the check
- // anyway
- // Setup Core OpenGL shader, VAO, VBOs and metal renderer
- m_shader = new QOpenGLShaderProgram();
- m_shader->create();
- if (!m_shader->addShaderFromSourceCode(QOpenGLShader::Vertex, R"(#version 150 core
- in vec2 qt_VertexPosition;
- in vec2 qt_VertexTexCoord;
- out vec2 qt_TexCoord;
- void main()
- {
- qt_TexCoord = qt_VertexTexCoord;
- gl_Position = vec4(qt_VertexPosition, 0.0f, 1.0f);
- })")) {
- qCritical() << "Vertex shader compilation failed" << m_shader->log();
- }
- if (!m_shader->addShaderFromSourceCode(QOpenGLShader::Fragment, R"(#version 150 core
- in vec2 qt_TexCoord;
- out vec4 fragColor;
- uniform sampler2DRect videoFrame;
- void main(void)
- {
- ivec2 textureDim = textureSize(videoFrame);
- fragColor = texture(videoFrame, qt_TexCoord * textureDim);
- })")) {
- qCritical() << "Fragment shader compilation failed" << m_shader->log();
- }
-
- // Setup quad where the video frame will be attached
- GLfloat vertices[] = {
- -1.0f, -1.0f,
- 1.0f, -1.0f,
- -1.0f, 1.0f,
- 1.0f, 1.0f,
- };
-
- GLfloat uvs[] = {
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- 0.0f, 1.0f,
- 1.0f, 1.0f,
- };
-
- glGenVertexArrays(1, &m_quadVao);
- glBindVertexArray(m_quadVao);
-
- // Create vertex buffer objects for vertices
- glGenBuffers(2, m_quadVbos);
-
- // Setup vertices
- glBindBuffer(GL_ARRAY_BUFFER, m_quadVbos[0]);
- glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), nullptr);
- glEnableVertexAttribArray(0);
-
- // Setup uvs
- glBindBuffer(GL_ARRAY_BUFFER, m_quadVbos[1]);
- glBufferData(GL_ARRAY_BUFFER, sizeof(uvs), uvs, GL_STATIC_DRAW);
- glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), nullptr);
- glEnableVertexAttribArray(1);
-
- glBindVertexArray(0);
-
- // Setup shared Metal/OpenGL pixel buffer and textures
- m_NSGLContext = QOpenGLContext::currentContext()->nativeInterface<QNativeInterface::QCocoaGLContext>()->nativeContext();
- m_CGLPixelFormat = m_NSGLContext.pixelFormat.CGLPixelFormatObj;
-
- NSDictionary* cvBufferProperties = @{
- static_cast<NSString*>(kCVPixelBufferOpenGLCompatibilityKey) : @YES,
- static_cast<NSString*>(kCVPixelBufferMetalCompatibilityKey): @YES,
- };
-
- CVPixelBufferCreate(kCFAllocatorDefault, static_cast<size_t>(m_targetSize.width()),
- static_cast<size_t>(m_targetSize.height()), kCVPixelFormatType_32BGRA,
- static_cast<CFDictionaryRef>(cvBufferProperties), &m_CVPixelBuffer);
-
- m_textureName = createGLTexture(reinterpret_cast<CGLContextObj>(m_NSGLContext.CGLContextObj),
- m_CGLPixelFormat, m_CVGLTextureCache, m_CVPixelBuffer,
- m_CVGLTexture);
- m_metalTexture = createMetalTexture(m_metalDevice, m_CVMTLTextureCache, m_CVPixelBuffer,
- MTLPixelFormatBGRA8Unorm,
- static_cast<size_t>(m_targetSize.width()),
- static_cast<size_t>(m_targetSize.height()),
- m_CVMTLTexture);
-
- m_videoLayerRenderer = [CARenderer rendererWithMTLTexture:m_metalTexture options:nil];
- [m_videoLayerRenderer retain];
- }
- }
-
- //Set/Change render source if needed
- if (m_videoLayerRenderer.layer != layer) {
- m_videoLayerRenderer.layer = layer;
- m_videoLayerRenderer.bounds = layer.bounds;
- }
-
- //Do we have FBO's already?
- if ((!m_fbo[0] && !m_fbo[0]) || (m_fbo[0]->size() != m_targetSize)) {
- delete m_fbo[0];
- delete m_fbo[1];
- m_fbo[0] = new QOpenGLFramebufferObject(m_targetSize);
- m_fbo[1] = new QOpenGLFramebufferObject(m_targetSize);
- }
-
- //Switch buffer target
- m_currentBuffer = !m_currentBuffer;
- return m_fbo[m_currentBuffer];
-}
-
-void AVFVideoFrameRenderer::renderLayerToFBO(AVPlayerLayer *layer, QOpenGLFramebufferObject *fbo)
-{
- //Start Rendering
- //NOTE: This rendering method will NOT work on iOS as there is no CARenderer in iOS
- if (!fbo->bind()) {
- qWarning("AVFVideoRender FBO failed to bind");
- return;
- }
-
- glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
-
- glViewport(0, 0, m_targetSize.width(), m_targetSize.height());
-
- if (m_useCoreProfile) {
- CGLLockContext(m_NSGLContext.CGLContextObj);
- m_shader->bind();
- glBindVertexArray(m_quadVao);
- } else {
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- // Render to FBO with inverted Y
- glOrtho(0.0, m_targetSize.width(), 0.0, m_targetSize.height(), 0.0, 1.0);
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
- }
-
- [m_videoLayerRenderer beginFrameAtTime:CACurrentMediaTime() timeStamp:nullptr];
- [m_videoLayerRenderer addUpdateRect:layer.bounds];
- [m_videoLayerRenderer render];
- [m_videoLayerRenderer endFrame];
-
- if (m_useCoreProfile) {
- glActiveTexture(0);
- glBindTexture(GL_TEXTURE_RECTANGLE, m_textureName);
-
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- glBindTexture(GL_TEXTURE_RECTANGLE, 0);
-
- glBindVertexArray(0);
-
- m_shader->release();
-
- CGLFlushDrawable(m_NSGLContext.CGLContextObj);
- CGLUnlockContext(m_NSGLContext.CGLContextObj);
- } else {
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- }
-
- glFinish(); //Rendering needs to be done before passing texture to video frame
-
- fbo->release();
-}
-
-GLuint AVFVideoFrameRenderer::createGLTexture(CGLContextObj cglContextObj, CGLPixelFormatObj cglPixelFormtObj, CVOpenGLTextureCacheRef cvglTextureCache,
- CVPixelBufferRef cvPixelBufferRef, CVOpenGLTextureRef cvOpenGLTextureRef)
-{
- CVReturn cvret;
- // Create an OpenGL CoreVideo texture cache from the pixel buffer.
- cvret = CVOpenGLTextureCacheCreate(
- kCFAllocatorDefault,
- nil,
- cglContextObj,
- cglPixelFormtObj,
- nil,
- &cvglTextureCache);
-
- // Create a CVPixelBuffer-backed OpenGL texture image from the texture cache.
- cvret = CVOpenGLTextureCacheCreateTextureFromImage(
- kCFAllocatorDefault,
- cvglTextureCache,
- cvPixelBufferRef,
- nil,
- &cvOpenGLTextureRef);
-
- // Get an OpenGL texture name from the CVPixelBuffer-backed OpenGL texture image.
- return CVOpenGLTextureGetName(cvOpenGLTextureRef);
-}
-
-id<MTLTexture> AVFVideoFrameRenderer::createMetalTexture(id<MTLDevice> mtlDevice, CVMetalTextureCacheRef cvMetalTextureCacheRef, CVPixelBufferRef cvPixelBufferRef,
- MTLPixelFormat pixelFormat, size_t width, size_t height, CVMetalTextureRef cvMetalTextureRef)
-{
- CVReturn cvret;
- // Create a Metal Core Video texture cache from the pixel buffer.
- cvret = CVMetalTextureCacheCreate(
- kCFAllocatorDefault,
- nil,
- mtlDevice,
- nil,
- &cvMetalTextureCacheRef);
-
- // Create a CoreVideo pixel buffer backed Metal texture image from the texture cache.
- cvret = CVMetalTextureCacheCreateTextureFromImage(
- kCFAllocatorDefault,
- cvMetalTextureCacheRef,
- cvPixelBufferRef, nil,
- pixelFormat,
- width, height,
- 0,
- &cvMetalTextureRef);
-
- // Get a Metal texture using the CoreVideo Metal texture reference.
- return CVMetalTextureGetTexture(cvMetalTextureRef);
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h
deleted file mode 100644
index d1de1f511..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFVIDEOFRAMERENDERER_H
-#define AVFVIDEOFRAMERENDERER_H
-
-#include <QtCore/QObject>
-#include <QtGui/QImage>
-#include <QtGui/QOpenGLContext>
-#include <QtCore/QSize>
-
-#import "Metal/Metal.h"
-#import "MetalKit/MetalKit.h"
-
-@class AVPlayerLayer;
-@class AVPlayerItemVideoOutput;
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLContext;
-class QOpenGLFramebufferObject;
-class QOpenGLShaderProgram;
-class QOffscreenSurface;
-class QAbstractVideoSurface;
-
-typedef struct __CVBuffer *CVBufferRef;
-typedef CVBufferRef CVImageBufferRef;
-typedef CVImageBufferRef CVPixelBufferRef;
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
-typedef struct __CVOpenGLESTextureCache *CVOpenGLESTextureCacheRef;
-typedef CVImageBufferRef CVOpenGLESTextureRef;
-// helpers to avoid boring if def
-typedef CVOpenGLESTextureCacheRef CVOGLTextureCacheRef;
-typedef CVOpenGLESTextureRef CVOGLTextureRef;
-#define CVOGLTextureGetTarget CVOpenGLESTextureGetTarget
-#define CVOGLTextureGetName CVOpenGLESTextureGetName
-#define CVOGLTextureCacheCreate CVOpenGLESTextureCacheCreate
-#define CVOGLTextureCacheCreateTextureFromImage CVOpenGLESTextureCacheCreateTextureFromImage
-#define CVOGLTextureCacheFlush CVOpenGLESTextureCacheFlush
-#else
-typedef struct __CVOpenGLTextureCache *CVOpenGLTextureCacheRef;
-typedef CVImageBufferRef CVOpenGLTextureRef;
-// helpers to avoid boring if def
-typedef CVOpenGLTextureCacheRef CVOGLTextureCacheRef;
-typedef CVOpenGLTextureRef CVOGLTextureRef;
-#define CVOGLTextureGetTarget CVOpenGLTextureGetTarget
-#define CVOGLTextureGetName CVOpenGLTextureGetName
-#define CVOGLTextureCacheCreate CVOpenGLTextureCacheCreate
-#define CVOGLTextureCacheCreateTextureFromImage CVOpenGLTextureCacheCreateTextureFromImage
-#define CVOGLTextureCacheFlush CVOpenGLTextureCacheFlush
-#endif
-
-class AVFVideoFrameRenderer : public QObject
-{
-public:
- AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent = nullptr);
-
- virtual ~AVFVideoFrameRenderer();
-
- void setPlayerLayer(AVPlayerLayer *layer);
-
- quint64 renderLayerToTexture(AVPlayerLayer *layer);
- quint64 renderLayerToMTLTexture(AVPlayerLayer *layer);
- QImage renderLayerToImage(AVPlayerLayer *layer);
-
-private:
- void initRenderer();
- CVPixelBufferRef copyPixelBufferFromLayer(AVPlayerLayer *layer, size_t& width, size_t& height);
- CVOGLTextureRef createCacheTextureFromLayer(AVPlayerLayer *layer, size_t& width, size_t& height);
-
- QOpenGLContext *m_glContext;
- QOffscreenSurface *m_offscreenSurface;
- QAbstractVideoSurface *m_surface;
- CVOGLTextureCacheRef m_textureCache;
- AVPlayerItemVideoOutput* m_videoOutput;
- bool m_isContextShared;
-
- id<MTLDevice> m_metalDevice = nil;
- CVMetalTextureCacheRef m_metalTextureCache = nil;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFVIDEOFRAMERENDERER_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.mm b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.mm
deleted file mode 100644
index cbaa1aa11..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.mm
+++ /dev/null
@@ -1,307 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfvideoframerenderer_ios.h"
-
-#include <QtMultimedia/qabstractvideosurface.h>
-#include <QtOpenGL/QOpenGLFramebufferObject>
-#include <QtOpenGL/QOpenGLShaderProgram>
-#include <QtGui/QOffscreenSurface>
-
-#ifdef QT_DEBUG_AVF
-#include <QtCore/qdebug.h>
-#endif
-
-#import <CoreVideo/CVBase.h>
-#import <AVFoundation/AVFoundation.h>
-QT_USE_NAMESPACE
-
-AVFVideoFrameRenderer::AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent)
- : QObject(parent)
- , m_glContext(nullptr)
- , m_offscreenSurface(nullptr)
- , m_surface(surface)
- , m_textureCache(nullptr)
- , m_videoOutput(nullptr)
- , m_isContextShared(true)
-{
-}
-
-AVFVideoFrameRenderer::~AVFVideoFrameRenderer()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
-
- [m_videoOutput release]; // sending to nil is fine
- if (m_textureCache)
- CFRelease(m_textureCache);
- if (m_metalTextureCache)
- CFRelease(m_metalTextureCache);
- [m_metalDevice release];
- delete m_offscreenSurface;
- delete m_glContext;
-}
-
-void AVFVideoFrameRenderer::setPlayerLayer(AVPlayerLayer *layer)
-{
- Q_UNUSED(layer);
- if (m_videoOutput) {
- [m_videoOutput release];
- m_videoOutput = nullptr;
- // will be re-created in first call to copyPixelBufferFromLayer
- }
-}
-
-quint64 AVFVideoFrameRenderer::renderLayerToMTLTexture(AVPlayerLayer *layer)
-{
- if (!m_metalDevice)
- m_metalDevice = MTLCreateSystemDefaultDevice();
-
- if (!m_metalTextureCache) {
- CVReturn err = CVMetalTextureCacheCreate(kCFAllocatorDefault, nullptr,
- m_metalDevice, nullptr, &m_metalTextureCache);
- if (err) {
- qWarning() << "Error at CVMetalTextureCacheCreate" << err;
- return 0;
- }
- }
-
- size_t width = 0, height = 0;
- CVPixelBufferRef pixelBuffer = copyPixelBufferFromLayer(layer, width, height);
-
- if (!pixelBuffer)
- return 0;
-
- CVMetalTextureCacheFlush(m_metalTextureCache, 0);
-
- CVMetalTextureRef texture = nil;
- CVReturn err = CVMetalTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_metalTextureCache, pixelBuffer, NULL,
- MTLPixelFormatBGRA8Unorm_sRGB, width, height, 0, &texture);
-
- if (!texture || err)
- qWarning("CVMetalTextureCacheCreateTextureFromImage failed (error: %d)", err);
-
- CVPixelBufferRelease(pixelBuffer);
- quint64 tex = 0;
- if (texture) {
- tex = quint64(CVMetalTextureGetTexture(texture));
- CFRelease(texture);
- }
-
- return tex;
-}
-
-quint64 AVFVideoFrameRenderer::renderLayerToTexture(AVPlayerLayer *layer)
-{
- initRenderer();
-
- // If the glContext isn't shared, it doesn't make sense to return a texture for us
- if (!m_isContextShared)
- return 0;
-
- size_t dummyWidth = 0, dummyHeight = 0;
- auto texture = createCacheTextureFromLayer(layer, dummyWidth, dummyHeight);
- auto tex = quint64(CVOGLTextureGetName(texture));
- CFRelease(texture);
-
- return tex;
-}
-
-static NSString* const AVF_PIXEL_FORMAT_KEY = (NSString*)kCVPixelBufferPixelFormatTypeKey;
-static NSNumber* const AVF_PIXEL_FORMAT_VALUE = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
-static NSDictionary* const AVF_OUTPUT_SETTINGS = [NSDictionary dictionaryWithObject:AVF_PIXEL_FORMAT_VALUE forKey:AVF_PIXEL_FORMAT_KEY];
-
-
-CVPixelBufferRef AVFVideoFrameRenderer::copyPixelBufferFromLayer(AVPlayerLayer *layer,
- size_t& width, size_t& height)
-{
- //Is layer valid
- if (!layer) {
-#ifdef QT_DEBUG_AVF
- qWarning("copyPixelBufferFromLayer: invalid layer");
-#endif
- return nullptr;
- }
-
- if (!m_videoOutput) {
- m_videoOutput = [[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:AVF_OUTPUT_SETTINGS];
- [m_videoOutput setDelegate:nil queue:nil];
- AVPlayerItem * item = [[layer player] currentItem];
- [item addOutput:m_videoOutput];
- }
-
- CFTimeInterval currentCAFrameTime = CACurrentMediaTime();
- CMTime currentCMFrameTime = [m_videoOutput itemTimeForHostTime:currentCAFrameTime];
- // happens when buffering / loading
- if (CMTimeCompare(currentCMFrameTime, kCMTimeZero) < 0) {
- return nullptr;
- }
-
- CVPixelBufferRef pixelBuffer = [m_videoOutput copyPixelBufferForItemTime:currentCMFrameTime
- itemTimeForDisplay:nil];
- if (!pixelBuffer) {
-#ifdef QT_DEBUG_AVF
- qWarning("copyPixelBufferForItemTime returned nil");
- CMTimeShow(currentCMFrameTime);
-#endif
- return nullptr;
- }
-
- width = CVPixelBufferGetWidth(pixelBuffer);
- height = CVPixelBufferGetHeight(pixelBuffer);
- return pixelBuffer;
-}
-
-CVOGLTextureRef AVFVideoFrameRenderer::createCacheTextureFromLayer(AVPlayerLayer *layer,
- size_t& width, size_t& height)
-{
- CVPixelBufferRef pixelBuffer = copyPixelBufferFromLayer(layer, width, height);
-
- if (!pixelBuffer)
- return nullptr;
-
- CVOGLTextureCacheFlush(m_textureCache, 0);
-
- CVOGLTextureRef texture = nullptr;
- CVReturn err = CVOGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_textureCache, pixelBuffer, nullptr,
- GL_TEXTURE_2D, GL_RGBA,
- (GLsizei) width, (GLsizei) height,
- GL_BGRA, GL_UNSIGNED_BYTE, 0,
- &texture);
-
- if (!texture || err) {
-#ifdef QT_DEBUG_AVF
- qWarning("CVOGLTextureCacheCreateTextureFromImage failed (error: %d)", err);
-#endif
- }
-
- CVPixelBufferRelease(pixelBuffer);
-
- return texture;
-}
-
-QImage AVFVideoFrameRenderer::renderLayerToImage(AVPlayerLayer *layer)
-{
- size_t width = 0;
- size_t height = 0;
- CVPixelBufferRef pixelBuffer = copyPixelBufferFromLayer(layer, width, height);
-
- if (!pixelBuffer)
- return QImage();
-
- OSType pixelFormat = CVPixelBufferGetPixelFormatType(pixelBuffer);
- if (pixelFormat != kCVPixelFormatType_32BGRA) {
-#ifdef QT_DEBUG_AVF
- qWarning("CVPixelBuffer format is not BGRA32 (got: %d)", static_cast<quint32>(pixelFormat));
-#endif
- return QImage();
- }
-
- CVPixelBufferLockBaseAddress(pixelBuffer, 0);
- char *data = (char *)CVPixelBufferGetBaseAddress(pixelBuffer);
- size_t stride = CVPixelBufferGetBytesPerRow(pixelBuffer);
-
- // format here is not relevant, only using for storage
- QImage img = QImage(width, height, QImage::Format_ARGB32);
- for (size_t j = 0; j < height; j++) {
- memcpy(img.scanLine(j), data, width * 4);
- data += stride;
- }
-
- CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
- CVPixelBufferRelease(pixelBuffer);
- return img;
-}
-
-void AVFVideoFrameRenderer::initRenderer()
-{
- // even for using a texture directly, we need to be able to make a context current,
- // so we need an offscreen, and we shouldn't assume we can make the surface context
- // current on that offscreen, so use our own (sharing with it). Slightly
- // excessive but no performance penalty and makes the QImage path easier to maintain
-
- //Make sure we have an OpenGL context to make current
- if (!m_glContext) {
- //Create OpenGL context and set share context from surface
- QOpenGLContext *shareContext = nullptr;
- if (m_surface) {
- shareContext = qobject_cast<QOpenGLContext*>(m_surface->property("GLContext").value<QObject*>());
- }
-
- m_glContext = new QOpenGLContext();
- if (shareContext) {
- m_glContext->setShareContext(shareContext);
- m_isContextShared = true;
- } else {
-#ifdef QT_DEBUG_AVF
- qWarning("failed to get Render Thread context");
-#endif
- m_isContextShared = false;
- }
- if (!m_glContext->create()) {
-#ifdef QT_DEBUG_AVF
- qWarning("failed to create QOpenGLContext");
-#endif
- return;
- }
- }
-
- if (!m_offscreenSurface) {
- m_offscreenSurface = new QOffscreenSurface();
- m_offscreenSurface->setFormat(m_glContext->format());
- m_offscreenSurface->create();
- }
-
- //Need current context
- m_glContext->makeCurrent(m_offscreenSurface);
-
- if (!m_textureCache) {
- // Create a new open gl texture cache
- CVReturn err = CVOGLTextureCacheCreate(kCFAllocatorDefault, nullptr,
- [EAGLContext currentContext],
- nullptr, &m_textureCache);
- if (err) {
- #ifdef QT_DEBUG_AVF
- qWarning("Error at CVOGLTextureCacheCreate %d", err);
- #endif
- }
- }
-
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideooutput.h b/src/plugins/avfoundation/mediaplayer/avfvideooutput.h
deleted file mode 100644
index d3bcfecf7..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideooutput.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFVIDEOOUTPUT_H
-#define AVFVIDEOOUTPUT_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_NAMESPACE
-
-class AVFVideoOutput
-{
-public:
- virtual ~AVFVideoOutput() {}
- virtual void setLayer(void *playerLayer) = 0;
-};
-
-#define AVFVideoOutput_iid \
- "org.qt-project.qt.AVFVideoOutput/5.0"
-Q_DECLARE_INTERFACE(AVFVideoOutput, AVFVideoOutput_iid)
-
-QT_END_NAMESPACE
-
-#endif // AVFVIDEOOUTPUT_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideooutput.mm b/src/plugins/avfoundation/mediaplayer/avfvideooutput.mm
deleted file mode 100644
index 327681f50..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideooutput.mm
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfvideooutput.h"
-
-QT_USE_NAMESPACE
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.h b/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.h
deleted file mode 100644
index c1a629944..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFVIDEORENDERERCONTROL_H
-#define AVFVIDEORENDERERCONTROL_H
-
-#include <QtMultimedia/QVideoRendererControl>
-#include <QtCore/QMutex>
-#include <QtCore/QSize>
-
-#include "avfvideooutput.h"
-
-#import <CoreVideo/CVBase.h>
-
-QT_BEGIN_NAMESPACE
-
-class AVFDisplayLink;
-class AVFVideoFrameRenderer;
-
-class AVFVideoRendererControl : public QVideoRendererControl, public AVFVideoOutput
-{
- Q_OBJECT
- Q_INTERFACES(AVFVideoOutput)
-public:
- explicit AVFVideoRendererControl(QObject *parent = nullptr);
- virtual ~AVFVideoRendererControl();
-
- QAbstractVideoSurface *surface() const override;
- void setSurface(QAbstractVideoSurface *surface) override;
-
- void setLayer(void *playerLayer) override;
-
-private Q_SLOTS:
- void updateVideoFrame(const CVTimeStamp &ts);
-
-Q_SIGNALS:
- void surfaceChanged(QAbstractVideoSurface *surface);
-
-private:
- void setupVideoOutput();
-
- QMutex m_mutex;
- QAbstractVideoSurface *m_surface;
-
- void *m_playerLayer;
-
- AVFVideoFrameRenderer *m_frameRenderer;
- AVFDisplayLink *m_displayLink;
- QSize m_nativeSize;
- bool m_enableOpenGL;
- bool m_enableMetal;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFVIDEORENDERERCONTROL_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm b/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm
deleted file mode 100644
index 726dc5193..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideorenderercontrol.mm
+++ /dev/null
@@ -1,301 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfvideorenderercontrol.h"
-#include "avfdisplaylink.h"
-
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
-#include "avfvideoframerenderer_ios.h"
-#else
-#include "avfvideoframerenderer.h"
-#endif
-
-#include <QtMultimedia/qabstractvideobuffer.h>
-#include <QtMultimedia/qabstractvideosurface.h>
-#include <QtMultimedia/qvideosurfaceformat.h>
-
-#include <private/qimagevideobuffer_p.h>
-
-#include <QtCore/qdebug.h>
-
-#import <AVFoundation/AVFoundation.h>
-
-QT_USE_NAMESPACE
-
-class TextureVideoBuffer : public QAbstractVideoBuffer
-{
-public:
- TextureVideoBuffer(HandleType type, quint64 tex)
- : QAbstractVideoBuffer(type)
- , m_texture(tex)
- {}
-
- virtual ~TextureVideoBuffer()
- {
- }
-
- MapMode mapMode() const { return NotMapped; }
- uchar *map(MapMode, int*, int*) { return 0; }
- void unmap() {}
-
- QVariant handle() const
- {
- return QVariant::fromValue<unsigned long long>(m_texture);
- }
-
-private:
- quint64 m_texture;
-};
-
-AVFVideoRendererControl::AVFVideoRendererControl(QObject *parent)
- : QVideoRendererControl(parent)
- , m_surface(nullptr)
- , m_playerLayer(nullptr)
- , m_frameRenderer(nullptr)
- , m_enableOpenGL(false)
- , m_enableMetal(false)
-
-{
- m_displayLink = new AVFDisplayLink(this);
- connect(m_displayLink, SIGNAL(tick(CVTimeStamp)), SLOT(updateVideoFrame(CVTimeStamp)));
-}
-
-AVFVideoRendererControl::~AVFVideoRendererControl()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- m_displayLink->stop();
- [static_cast<AVPlayerLayer*>(m_playerLayer) release];
-}
-
-QAbstractVideoSurface *AVFVideoRendererControl::surface() const
-{
- return m_surface;
-}
-
-void AVFVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << "Set video surface" << surface;
-#endif
-
- //When we have a valid surface, we can setup a frame renderer
- //and schedule surface updates with the display link.
- if (surface == m_surface)
- return;
-
- QMutexLocker locker(&m_mutex);
-
- if (m_surface && m_surface->isActive())
- m_surface->stop();
-
- m_surface = surface;
-
- //If the surface changed, then the current frame renderer is no longer valid
- delete m_frameRenderer;
- m_frameRenderer = nullptr;
-
- //If there is now no surface to render too
- if (m_surface == nullptr) {
- m_displayLink->stop();
- return;
- }
-
- //Surface changed, so we need a new frame renderer
- m_frameRenderer = new AVFVideoFrameRenderer(m_surface, this);
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- if (m_playerLayer) {
- m_frameRenderer->setPlayerLayer(static_cast<AVPlayerLayer*>(m_playerLayer));
- }
-#endif
-
- auto checkHandleType = [this] {
- m_enableOpenGL = m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).contains(QVideoFrame::Format_BGR32);
- m_enableMetal = m_surface->supportedPixelFormats(QAbstractVideoBuffer::MTLTextureHandle).contains(QVideoFrame::Format_BGR32);
- };
- checkHandleType();
- connect(m_surface, &QAbstractVideoSurface::supportedFormatsChanged, this, checkHandleType);
-
- //If we already have a layer, but changed surfaces start rendering again
- if (m_playerLayer && !m_displayLink->isActive()) {
- m_displayLink->start();
- }
-
-}
-
-void AVFVideoRendererControl::setLayer(void *playerLayer)
-{
- if (m_playerLayer == playerLayer)
- return;
-
- [static_cast<AVPlayerLayer*>(m_playerLayer) release];
-
- m_playerLayer = [static_cast<AVPlayerLayer*>(playerLayer) retain];
-
- //If there is an active surface, make sure it has been stopped so that
- //we can update it's state with the new content.
- if (m_surface && m_surface->isActive())
- m_surface->stop();
-
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- if (m_frameRenderer) {
- m_frameRenderer->setPlayerLayer(static_cast<AVPlayerLayer*>(playerLayer));
- }
-#endif
-
- //If there is no layer to render, stop scheduling updates
- if (m_playerLayer == nullptr) {
- m_displayLink->stop();
- return;
- }
-
- setupVideoOutput();
-
- //If we now have both a valid surface and layer, start scheduling updates
- if (m_surface && !m_displayLink->isActive()) {
- m_displayLink->start();
- }
-}
-
-void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts)
-{
- Q_UNUSED(ts);
-
- AVPlayerLayer *playerLayer = static_cast<AVPlayerLayer*>(m_playerLayer);
-
- if (!playerLayer) {
- qWarning("updateVideoFrame called without AVPlayerLayer (which shouldn't happen");
- return;
- }
-
- if (!playerLayer.readyForDisplay || !m_surface)
- return;
-
- if (m_enableMetal) {
- quint64 tex = m_frameRenderer->renderLayerToMTLTexture(playerLayer);
- if (tex == 0)
- return;
-
- auto buffer = new TextureVideoBuffer(QAbstractVideoBuffer::MTLTextureHandle, tex);
- QVideoFrame frame(buffer, m_nativeSize, QVideoFrame::Format_BGR32);
- if (m_surface->isActive() && m_surface->surfaceFormat().pixelFormat() != frame.pixelFormat())
- m_surface->stop();
-
- if (!m_surface->isActive()) {
- QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QAbstractVideoBuffer::MTLTextureHandle);
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- format.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
-#else
- format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
-#endif
- if (!m_surface->start(format))
- qWarning("Failed to activate video surface");
- }
-
- if (m_surface->isActive())
- m_surface->present(frame);
-
- return;
- }
-
- if (m_enableOpenGL) {
- quint64 tex = m_frameRenderer->renderLayerToTexture(playerLayer);
- //Make sure we got a valid texture
- if (tex == 0)
- return;
-
- QAbstractVideoBuffer *buffer = new TextureVideoBuffer(QAbstractVideoBuffer::GLTextureHandle, tex);
- QVideoFrame frame = QVideoFrame(buffer, m_nativeSize, QVideoFrame::Format_BGR32);
-
- if (m_surface && frame.isValid()) {
- if (m_surface->isActive() && m_surface->surfaceFormat().pixelFormat() != frame.pixelFormat())
- m_surface->stop();
-
- if (!m_surface->isActive()) {
- QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QAbstractVideoBuffer::GLTextureHandle);
-#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
- format.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
-#else
- format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
-#endif
- if (!m_surface->start(format)) {
- //Surface doesn't support GLTextureHandle
- qWarning("Failed to activate video surface");
- }
- }
-
- if (m_surface->isActive())
- m_surface->present(frame);
- }
- } else {
- //fallback to rendering frames to QImages
- QImage frameData = m_frameRenderer->renderLayerToImage(playerLayer);
-
- if (frameData.isNull()) {
- return;
- }
-
- QAbstractVideoBuffer *buffer = new QImageVideoBuffer(frameData);
- QVideoFrame frame = QVideoFrame(buffer, m_nativeSize, QVideoFrame::Format_ARGB32);
- if (m_surface && frame.isValid()) {
- if (m_surface->isActive() && m_surface->surfaceFormat().pixelFormat() != frame.pixelFormat())
- m_surface->stop();
-
- if (!m_surface->isActive()) {
- QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QAbstractVideoBuffer::NoHandle);
-
- if (!m_surface->start(format)) {
- qWarning("Failed to activate video surface");
- }
- }
-
- if (m_surface->isActive())
- m_surface->present(frame);
- }
-
- }
-}
-
-void AVFVideoRendererControl::setupVideoOutput()
-{
- AVPlayerLayer *playerLayer = static_cast<AVPlayerLayer*>(m_playerLayer);
- if (playerLayer)
- m_nativeSize = QSize(playerLayer.bounds.size.width, playerLayer.bounds.size.height);
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidget.h b/src/plugins/avfoundation/mediaplayer/avfvideowidget.h
deleted file mode 100644
index faf71f1a4..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideowidget.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFVIDEOWIDGET_H
-#define AVFVIDEOWIDGET_H
-
-#include <QtWidgets/QWidget>
-
-@class AVPlayerLayer;
-#if defined(Q_OS_OSX)
-@class NSView;
-#else
-@class UIView;
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class AVFVideoWidget : public QWidget
-{
-public:
- AVFVideoWidget(QWidget *parent);
- virtual ~AVFVideoWidget();
-
- QSize sizeHint() const override;
- Qt::AspectRatioMode aspectRatioMode() const;
- void setAspectRatioMode(Qt::AspectRatioMode mode);
- void setPlayerLayer(AVPlayerLayer *layer);
-
-protected:
- void resizeEvent(QResizeEvent *) override;
- void paintEvent(QPaintEvent *) override;
-
-private:
- void updateAspectRatio();
- void updatePlayerLayerBounds(const QSize &size);
-
- QSize m_nativeSize;
- Qt::AspectRatioMode m_aspectRatioMode;
- AVPlayerLayer *m_playerLayer;
-#if defined(Q_OS_OSX)
- NSView *m_nativeView;
-#else
- UIView *m_nativeView;
-#endif
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFVIDEOWIDGET_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm b/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm
deleted file mode 100644
index 0987342b4..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideowidget.mm
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfvideowidget.h"
-
-#import <AVFoundation/AVFoundation.h>
-#import <QuartzCore/CATransaction.h>
-
-#if defined(Q_OS_MACOS)
-#import <AppKit/AppKit.h>
-#else
-#import <UIKit/UIKit.h>
-#endif
-
-#include <QtCore/QDebug>
-#include <QtGui/QResizeEvent>
-#include <QtGui/QPaintEvent>
-#include <QtGui/QPainter>
-
-QT_USE_NAMESPACE
-
-AVFVideoWidget::AVFVideoWidget(QWidget *parent)
- : QWidget(parent)
- , m_aspectRatioMode(Qt::KeepAspectRatio)
- , m_playerLayer(nullptr)
- , m_nativeView(nullptr)
-{
- setAutoFillBackground(false);
-}
-
-AVFVideoWidget::~AVFVideoWidget()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
-
- if (m_playerLayer) {
- [m_playerLayer removeFromSuperlayer];
- [m_playerLayer release];
- }
-}
-
-QSize AVFVideoWidget::sizeHint() const
-{
- return m_nativeSize;
-}
-
-Qt::AspectRatioMode AVFVideoWidget::aspectRatioMode() const
-{
- return m_aspectRatioMode;
-}
-
-void AVFVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode)
-{
- if (m_aspectRatioMode != mode) {
- m_aspectRatioMode = mode;
-
- updateAspectRatio();
- }
-}
-
-void AVFVideoWidget::setPlayerLayer(AVPlayerLayer *layer)
-{
- if (m_playerLayer == layer)
- return;
-
- if (!m_nativeView) {
- //make video widget a native window
-#if defined(Q_OS_OSX)
- m_nativeView = (NSView*)this->winId();
- [m_nativeView setWantsLayer:YES];
-#else
- m_nativeView = (UIView*)this->winId();
-#endif
- }
-
- if (m_playerLayer) {
- [m_playerLayer removeFromSuperlayer];
- [m_playerLayer release];
- }
-
- m_playerLayer = layer;
-
- CALayer *nativeLayer = [m_nativeView layer];
-
- if (layer) {
- [layer retain];
-
- m_nativeSize = QSize(m_playerLayer.bounds.size.width,
- m_playerLayer.bounds.size.height);
-
- updateAspectRatio();
- [nativeLayer addSublayer:m_playerLayer];
- updatePlayerLayerBounds(this->size());
- }
-#ifdef QT_DEBUG_AVF
- NSArray *sublayers = [nativeLayer sublayers];
- qDebug() << "playerlayer: " << "at z:" << [m_playerLayer zPosition]
- << " frame: " << m_playerLayer.frame.size.width << "x" << m_playerLayer.frame.size.height;
- qDebug() << "superlayer: " << "at z:" << [nativeLayer zPosition]
- << " frame: " << nativeLayer.frame.size.width << "x" << nativeLayer.frame.size.height;
- int i = 0;
- for (CALayer *layer in sublayers) {
- qDebug() << "layer " << i << ": at z:" << [layer zPosition]
- << " frame: " << layer.frame.size.width << "x" << layer.frame.size.height;
- i++;
- }
-#endif
-
-}
-
-void AVFVideoWidget::resizeEvent(QResizeEvent *event)
-{
- updatePlayerLayerBounds(event->size());
- QWidget::resizeEvent(event);
-}
-
-void AVFVideoWidget::paintEvent(QPaintEvent *event)
-{
- QPainter painter(this);
- painter.fillRect(rect(), Qt::black);
-
- QWidget::paintEvent(event);
-}
-
-void AVFVideoWidget::updateAspectRatio()
-{
- if (m_playerLayer) {
- switch (m_aspectRatioMode) {
- case Qt::IgnoreAspectRatio:
- [m_playerLayer setVideoGravity:AVLayerVideoGravityResize];
- break;
- case Qt::KeepAspectRatio:
- [m_playerLayer setVideoGravity:AVLayerVideoGravityResizeAspect];
- break;
- case Qt::KeepAspectRatioByExpanding:
- [m_playerLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
- break;
- default:
- break;
- }
- }
-}
-
-void AVFVideoWidget::updatePlayerLayerBounds(const QSize &size)
-{
- [CATransaction begin];
- [CATransaction setDisableActions: YES]; // disable animation/flicks
- m_playerLayer.bounds = QRect(QPoint(0, 0), size).toCGRect();
- [CATransaction commit];
-}
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.h b/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.h
deleted file mode 100644
index 22379d273..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFVIDEOWIDGETCONTROL_H
-#define AVFVIDEOWIDGETCONTROL_H
-
-#include <qvideowidgetcontrol.h>
-#include "avfvideooutput.h"
-
-@class AVPlayerLayer;
-
-QT_BEGIN_NAMESPACE
-
-class AVFVideoWidget;
-
-class AVFVideoWidgetControl : public QVideoWidgetControl, public AVFVideoOutput
-{
- Q_OBJECT
- Q_INTERFACES(AVFVideoOutput)
-public:
- AVFVideoWidgetControl(QObject *parent = nullptr);
- virtual ~AVFVideoWidgetControl();
-
- void setLayer(void *playerLayer) override;
-
- QWidget *videoWidget() override;
-
- bool isFullScreen() const override;
- void setFullScreen(bool fullScreen) override;
-
- Qt::AspectRatioMode aspectRatioMode() const override;
- void setAspectRatioMode(Qt::AspectRatioMode mode) override;
-
- int brightness() const override;
- void setBrightness(int brightness) override;
-
- int contrast() const override;
- void setContrast(int contrast) override;
-
- int hue() const override;
- void setHue(int hue) override;
-
- int saturation() const override;
- void setSaturation(int saturation) override;
-
-private:
- AVFVideoWidget *m_videoWidget;
-
- bool m_fullscreen;
- int m_brightness;
- int m_contrast;
- int m_hue;
- int m_saturation;
-
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFVIDEOWIDGETCONTROL_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm b/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm
deleted file mode 100644
index 91ece817e..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideowidgetcontrol.mm
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfvideowidgetcontrol.h"
-#include "avfvideowidget.h"
-
-#ifdef QT_DEBUG_AVF
-#include <QtCore/QDebug>
-#endif
-
-#import <AVFoundation/AVFoundation.h>
-
-QT_USE_NAMESPACE
-
-AVFVideoWidgetControl::AVFVideoWidgetControl(QObject *parent)
- : QVideoWidgetControl(parent)
- , m_fullscreen(false)
- , m_brightness(0)
- , m_contrast(0)
- , m_hue(0)
- , m_saturation(0)
-{
- m_videoWidget = new AVFVideoWidget(nullptr);
-}
-
-AVFVideoWidgetControl::~AVFVideoWidgetControl()
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO;
-#endif
- delete m_videoWidget;
-}
-
-void AVFVideoWidgetControl::setLayer(void *playerLayer)
-{
-#ifdef QT_DEBUG_AVF
- qDebug() << Q_FUNC_INFO << playerLayer;
-#endif
-
- m_videoWidget->setPlayerLayer(static_cast<AVPlayerLayer*>(playerLayer));
-
-}
-
-QWidget *AVFVideoWidgetControl::videoWidget()
-{
- return m_videoWidget;
-}
-
-bool AVFVideoWidgetControl::isFullScreen() const
-{
- return m_fullscreen;
-}
-
-void AVFVideoWidgetControl::setFullScreen(bool fullScreen)
-{
- m_fullscreen = fullScreen;
-}
-
-Qt::AspectRatioMode AVFVideoWidgetControl::aspectRatioMode() const
-{
- return m_videoWidget->aspectRatioMode();
-}
-
-void AVFVideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode mode)
-{
- m_videoWidget->setAspectRatioMode(mode);
-}
-
-int AVFVideoWidgetControl::brightness() const
-{
- return m_brightness;
-}
-
-void AVFVideoWidgetControl::setBrightness(int brightness)
-{
- m_brightness = brightness;
-}
-
-int AVFVideoWidgetControl::contrast() const
-{
- return m_contrast;
-}
-
-void AVFVideoWidgetControl::setContrast(int contrast)
-{
- m_contrast = contrast;
-}
-
-int AVFVideoWidgetControl::hue() const
-{
- return m_hue;
-}
-
-void AVFVideoWidgetControl::setHue(int hue)
-{
- m_hue = hue;
-}
-
-int AVFVideoWidgetControl::saturation() const
-{
- return m_saturation;
-}
-
-void AVFVideoWidgetControl::setSaturation(int saturation)
-{
- m_saturation = saturation;
-}
-
-#include "moc_avfvideowidgetcontrol.cpp"
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.h b/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.h
deleted file mode 100644
index 763656c6c..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef AVFVIDEOWINDOWCONTROL_H
-#define AVFVIDEOWINDOWCONTROL_H
-
-#include <QVideoWindowControl>
-
-@class AVPlayerLayer;
-#if defined(Q_OS_OSX)
-@class NSView;
-typedef NSView NativeView;
-#else
-@class UIView;
-typedef UIView NativeView;
-#endif
-
-#include "avfvideooutput.h"
-
-QT_BEGIN_NAMESPACE
-
-class AVFVideoWindowControl : public QVideoWindowControl, public AVFVideoOutput
-{
- Q_OBJECT
- Q_INTERFACES(AVFVideoOutput)
-
-public:
- AVFVideoWindowControl(QObject *parent = nullptr);
- virtual ~AVFVideoWindowControl();
-
- // QVideoWindowControl interface
-public:
- WId winId() const override;
- void setWinId(WId id) override;
-
- QRect displayRect() const override;
- void setDisplayRect(const QRect &rect) override;
-
- bool isFullScreen() const override;
- void setFullScreen(bool fullScreen) override;
-
- void repaint() override;
- QSize nativeSize() const override;
-
- Qt::AspectRatioMode aspectRatioMode() const override;
- void setAspectRatioMode(Qt::AspectRatioMode mode) override;
-
- int brightness() const override;
- void setBrightness(int brightness) override;
-
- int contrast() const override;
- void setContrast(int contrast) override;
-
- int hue() const override;
- void setHue(int hue) override;
-
- int saturation() const override;
- void setSaturation(int saturation) override;
-
- // AVFVideoOutput interface
- void setLayer(void *playerLayer) override;
-
-private:
- void updateAspectRatio();
- void updatePlayerLayerBounds();
-
- WId m_winId;
- QRect m_displayRect;
- bool m_fullscreen;
- int m_brightness;
- int m_contrast;
- int m_hue;
- int m_saturation;
- Qt::AspectRatioMode m_aspectRatioMode;
- QSize m_nativeSize;
- AVPlayerLayer *m_playerLayer;
- NativeView *m_nativeView;
-};
-
-QT_END_NAMESPACE
-
-#endif // AVFVIDEOWINDOWCONTROL_H
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm b/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm
deleted file mode 100644
index d61129ec9..000000000
--- a/src/plugins/avfoundation/mediaplayer/avfvideowindowcontrol.mm
+++ /dev/null
@@ -1,255 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "avfvideowindowcontrol.h"
-
-#include <AVFoundation/AVFoundation.h>
-#import <QuartzCore/CATransaction.h>
-
-#if QT_HAS_INCLUDE(<AppKit/AppKit.h>)
-#include <AppKit/AppKit.h>
-#endif
-
-#if QT_HAS_INCLUDE(<UIKit/UIKit.h>)
-#include <UIKit/UIKit.h>
-#endif
-
-QT_USE_NAMESPACE
-
-AVFVideoWindowControl::AVFVideoWindowControl(QObject *parent)
- : QVideoWindowControl(parent)
- , m_winId(0)
- , m_fullscreen(false)
- , m_brightness(0)
- , m_contrast(0)
- , m_hue(0)
- , m_saturation(0)
- , m_aspectRatioMode(Qt::IgnoreAspectRatio)
- , m_playerLayer(nullptr)
- , m_nativeView(nullptr)
-{
-}
-
-AVFVideoWindowControl::~AVFVideoWindowControl()
-{
- if (m_playerLayer) {
- [m_playerLayer removeFromSuperlayer];
- [m_playerLayer release];
- }
-}
-
-WId AVFVideoWindowControl::winId() const
-{
- return m_winId;
-}
-
-void AVFVideoWindowControl::setWinId(WId id)
-{
- m_winId = id;
- m_nativeView = (NativeView*)m_winId;
-}
-
-QRect AVFVideoWindowControl::displayRect() const
-{
- return m_displayRect;
-}
-
-void AVFVideoWindowControl::setDisplayRect(const QRect &rect)
-{
- if (m_displayRect != rect) {
- m_displayRect = rect;
- updatePlayerLayerBounds();
- }
-}
-
-bool AVFVideoWindowControl::isFullScreen() const
-{
- return m_fullscreen;
-}
-
-void AVFVideoWindowControl::setFullScreen(bool fullScreen)
-{
- if (m_fullscreen != fullScreen) {
- m_fullscreen = fullScreen;
- Q_EMIT QVideoWindowControl::fullScreenChanged(fullScreen);
- }
-}
-
-void AVFVideoWindowControl::repaint()
-{
- if (m_playerLayer)
- [m_playerLayer setNeedsDisplay];
-}
-
-QSize AVFVideoWindowControl::nativeSize() const
-{
- return m_nativeSize;
-}
-
-Qt::AspectRatioMode AVFVideoWindowControl::aspectRatioMode() const
-{
- return m_aspectRatioMode;
-}
-
-void AVFVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
-{
- if (m_aspectRatioMode != mode) {
- m_aspectRatioMode = mode;
- updateAspectRatio();
- }
-}
-
-int AVFVideoWindowControl::brightness() const
-{
- return m_brightness;
-}
-
-void AVFVideoWindowControl::setBrightness(int brightness)
-{
- if (m_brightness != brightness) {
- m_brightness = brightness;
- Q_EMIT QVideoWindowControl::brightnessChanged(brightness);
- }
-}
-
-int AVFVideoWindowControl::contrast() const
-{
- return m_contrast;
-}
-
-void AVFVideoWindowControl::setContrast(int contrast)
-{
- if (m_contrast != contrast) {
- m_contrast = contrast;
- Q_EMIT QVideoWindowControl::contrastChanged(contrast);
- }
-}
-
-int AVFVideoWindowControl::hue() const
-{
- return m_hue;
-}
-
-void AVFVideoWindowControl::setHue(int hue)
-{
- if (m_hue != hue) {
- m_hue = hue;
- Q_EMIT QVideoWindowControl::hueChanged(hue);
- }
-}
-
-int AVFVideoWindowControl::saturation() const
-{
- return m_saturation;
-}
-
-void AVFVideoWindowControl::setSaturation(int saturation)
-{
- if (m_saturation != saturation) {
- m_saturation = saturation;
- Q_EMIT QVideoWindowControl::saturationChanged(saturation);
- }
-}
-
-void AVFVideoWindowControl::setLayer(void *playerLayer)
-{
- AVPlayerLayer *layer = static_cast<AVPlayerLayer*>(playerLayer);
- if (m_playerLayer == layer)
- return;
-
- if (!m_winId) {
- qDebug("AVFVideoWindowControl: No video window");
- return;
- }
-
-#if defined(Q_OS_OSX)
- [m_nativeView setWantsLayer:YES];
-#endif
-
- if (m_playerLayer) {
- [m_playerLayer removeFromSuperlayer];
- [m_playerLayer release];
- }
-
- m_playerLayer = layer;
-
- CALayer *nativeLayer = [m_nativeView layer];
-
- if (layer) {
- [layer retain];
-
- m_nativeSize = QSize(m_playerLayer.bounds.size.width,
- m_playerLayer.bounds.size.height);
-
- updateAspectRatio();
- [nativeLayer addSublayer:m_playerLayer];
- updatePlayerLayerBounds();
- }
-}
-
-void AVFVideoWindowControl::updateAspectRatio()
-{
- if (m_playerLayer) {
- switch (m_aspectRatioMode) {
- case Qt::IgnoreAspectRatio:
- [m_playerLayer setVideoGravity:AVLayerVideoGravityResize];
- break;
- case Qt::KeepAspectRatio:
- [m_playerLayer setVideoGravity:AVLayerVideoGravityResizeAspect];
- break;
- case Qt::KeepAspectRatioByExpanding:
- [m_playerLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
- break;
- default:
- break;
- }
- }
-}
-
-void AVFVideoWindowControl::updatePlayerLayerBounds()
-{
- if (m_playerLayer) {
- [CATransaction begin];
- [CATransaction setDisableActions: YES]; // disable animation/flicks
- m_playerLayer.frame = m_displayRect.toCGRect();
- [CATransaction commit];
- }
-}
-
-#include "moc_avfvideowindowcontrol.cpp"
diff --git a/src/plugins/avfoundation/mediaplayer/mediaplayer.pro b/src/plugins/avfoundation/mediaplayer/mediaplayer.pro
deleted file mode 100644
index 604866058..000000000
--- a/src/plugins/avfoundation/mediaplayer/mediaplayer.pro
+++ /dev/null
@@ -1,76 +0,0 @@
-TARGET = qavfmediaplayer
-
-#DEFINES += QT_DEBUG_AVF
-# Avoid clash with a variable named `slots' in a Quartz header
-CONFIG += no_keywords
-
-QT += opengl multimedia-private network
-
-LIBS += -framework CoreMedia -framework CoreVideo -framework QuartzCore -framework Metal
-
-QMAKE_USE += avfoundation
-
-HEADERS += \
- avfmediaplayercontrol.h \
- avfmediaplayermetadatacontrol.h \
- avfmediaplayerservice.h \
- avfmediaplayersession.h \
- avfmediaplayerserviceplugin.h \
- avfvideooutput.h \
- avfvideowindowcontrol.h
-
-OBJECTIVE_SOURCES += \
- avfmediaplayercontrol.mm \
- avfmediaplayermetadatacontrol.mm \
- avfmediaplayerservice.mm \
- avfmediaplayerserviceplugin.mm \
- avfmediaplayersession.mm \
- avfvideooutput.mm \
- avfvideowindowcontrol.mm
-
- qtHaveModule(widgets) {
- QT += multimediawidgets-private
- HEADERS += \
- avfvideowidgetcontrol.h \
- avfvideowidget.h
-
- OBJECTIVE_SOURCES += \
- avfvideowidgetcontrol.mm \
- avfvideowidget.mm
- }
-
-ios|tvos {
- qtConfig(opengl) {
- HEADERS += \
- avfvideoframerenderer_ios.h \
- avfvideorenderercontrol.h \
- avfdisplaylink.h
-
- OBJECTIVE_SOURCES += \
- avfvideoframerenderer_ios.mm \
- avfvideorenderercontrol.mm \
- avfdisplaylink.mm
- }
- LIBS += -framework Foundation
-} else {
- LIBS += -framework AppKit
-
- qtConfig(opengl) {
- HEADERS += \
- avfvideoframerenderer.h \
- avfvideorenderercontrol.h \
- avfdisplaylink.h
-
- OBJECTIVE_SOURCES += \
- avfvideoframerenderer.mm \
- avfvideorenderercontrol.mm \
- avfdisplaylink.mm
- }
-}
-
-OTHER_FILES += \
- avfmediaplayer.json
-
-PLUGIN_TYPE = mediaservice
-PLUGIN_CLASS_NAME = AVFMediaPlayerServicePlugin
-load(qt_plugin)