summaryrefslogtreecommitdiffstats
path: root/src/multimediawidgets
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-01-12 14:22:08 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-22 07:02:55 +0000
commit98148969b112f82d2b49e77950ea5f6d8b37b8b2 (patch)
tree48fffe0533a647bb53bec7e6e33dee1b95fcd849 /src/multimediawidgets
parentb947bcabfef5f0df32a4e09b55eaa581281b4edd (diff)
Get rid of plugins for MM backends
There's no need for having those in plugins and we can further remove abstractions and simplify our code if the code is directly compiled into Qt Multimedia. Change-Id: I5267a6a776375d99be8f0de4207f0288d963e620 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimediawidgets')
-rw-r--r--src/multimediawidgets/.prev_CMakeLists.txt51
-rw-r--r--src/multimediawidgets/CMakeLists.txt12
-rw-r--r--src/multimediawidgets/gstreamer/gstreamer.pri4
-rw-r--r--src/multimediawidgets/multimediawidgets.pro14
-rw-r--r--src/multimediawidgets/platform/avfoundation/avfoundation.pri15
-rw-r--r--src/multimediawidgets/platform/avfoundation/avfvideowidget.mm187
-rw-r--r--src/multimediawidgets/platform/avfoundation/avfvideowidget_p.h96
-rw-r--r--src/multimediawidgets/platform/avfoundation/avfvideowidgetcontrol.mm145
-rw-r--r--src/multimediawidgets/platform/avfoundation/avfvideowidgetcontrol_p.h106
-rw-r--r--src/multimediawidgets/platform/gstreamer/gstreamer.pri4
-rw-r--r--src/multimediawidgets/platform/gstreamer/qgstreamervideowidget.cpp (renamed from src/multimediawidgets/gstreamer/qgstreamervideowidget.cpp)0
-rw-r--r--src/multimediawidgets/platform/gstreamer/qgstreamervideowidget_p.h (renamed from src/multimediawidgets/gstreamer/qgstreamervideowidget_p.h)0
-rw-r--r--src/multimediawidgets/platform/platform.pri2
-rw-r--r--src/multimediawidgets/qvideowidget.cpp33
14 files changed, 638 insertions, 31 deletions
diff --git a/src/multimediawidgets/.prev_CMakeLists.txt b/src/multimediawidgets/.prev_CMakeLists.txt
new file mode 100644
index 000000000..167e80ef8
--- /dev/null
+++ b/src/multimediawidgets/.prev_CMakeLists.txt
@@ -0,0 +1,51 @@
+# Generated from multimediawidgets.pro.
+
+#####################################################################
+## MultimediaWidgets Module:
+#####################################################################
+
+qt_add_module(MultimediaWidgets
+ SOURCES
+ qpaintervideosurface.cpp qpaintervideosurface_p.h
+ qtmultimediawidgetdefs.h
+ qvideowidget.cpp qvideowidget.h qvideowidget_p.h
+ qvideowidgetcontrol.cpp qvideowidgetcontrol.h
+ LIBRARIES
+ Qt::MultimediaPrivate
+ Qt::WidgetsPrivate
+ PUBLIC_LIBRARIES
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::Widgets
+ PRIVATE_MODULE_INTERFACE
+ Qt::WidgetsPrivate
+)
+
+## Scopes:
+#####################################################################
+
+qt_extend_target(MultimediaWidgets CONDITION TARGET Qt::OpenGL
+ LIBRARIES
+ Qt::OpenGL
+ PUBLIC_LIBRARIES
+ Qt::OpenGLWidgets
+)
+
+qt_extend_target(MultimediaWidgets CONDITION QT_FEATURE_graphicsview
+ SOURCES
+ qgraphicsvideoitem.cpp qgraphicsvideoitem.h
+)
+
+qt_extend_target(MultimediaWidgets CONDITION QT_FEATURE_gstreamer
+ SOURCES
+ platform/gstreamer/qgstreamervideowidget.cpp platform/gstreamer/qgstreamervideowidget_p.h
+ LIBRARIES
+ gstreamer
+)
+
+qt_extend_target(MultimediaWidgets CONDITION QT_FEATURE_avfoundation
+ SOURCES
+ platform/avfoundation/avfvideowidget.mm platform/avfoundation/avfvideowidget_p.h
+ platform/avfoundation/avfvideowidgetcontrol.mm platform/avfoundation/avfvideowidgetcontrol_p.h
+)
diff --git a/src/multimediawidgets/CMakeLists.txt b/src/multimediawidgets/CMakeLists.txt
index 7b159d659..d4aab4219 100644
--- a/src/multimediawidgets/CMakeLists.txt
+++ b/src/multimediawidgets/CMakeLists.txt
@@ -35,7 +35,7 @@ qt_extend_target(MultimediaWidgets CONDITION TARGET Qt::OpenGL
qt_extend_target(MultimediaWidgets CONDITION QT_FEATURE_graphicsview
SOURCES
- qgraphicsvideoitem.cpp qgraphicsvideoitem.h # special case
+ qgraphicsvideoitem.cpp qgraphicsvideoitem.h
)
qt_extend_target(MultimediaWidgets CONDITION QT_FEATURE_gstreamer
@@ -43,10 +43,8 @@ qt_extend_target(MultimediaWidgets CONDITION QT_FEATURE_gstreamer
gstreamer/qgstreamervideowidget.cpp gstreamer/qgstreamervideowidget_p.h
)
-#### Keys ignored in scope 3:.:.:multimediawidgets.pro:QT_FEATURE_graphicsview:
-# PUBLIC_HEADERS = "qgraphicsvideoitem.h"
-
-qt_extend_target(MultimediaWidgets CONDITION MSVC AND (QMAKE_MSC_VER LESS 1900)
- COMPILE_OPTIONS
- -Zm200
+qt_extend_target(MultimediaWidgets CONDITION QT_FEATURE_avfoundation
+ SOURCES
+ platform/avfoundation/avfvideowidget.mm platform/avfoundation/avfvideowidget_p.h
+ platform/avfoundation/avfvideowidgetcontrol.mm platform/avfoundation/avfvideowidgetcontrol_p.h
)
diff --git a/src/multimediawidgets/gstreamer/gstreamer.pri b/src/multimediawidgets/gstreamer/gstreamer.pri
deleted file mode 100644
index dc332c249..000000000
--- a/src/multimediawidgets/gstreamer/gstreamer.pri
+++ /dev/null
@@ -1,4 +0,0 @@
-QMAKE_USE_PRIVATE += gstreamer
-
-SOURCES += gstreamer/qgstreamervideowidget.cpp
-HEADERS += gstreamer/qgstreamervideowidget_p.h
diff --git a/src/multimediawidgets/multimediawidgets.pro b/src/multimediawidgets/multimediawidgets.pro
index b8204ef07..59b1f22ce 100644
--- a/src/multimediawidgets/multimediawidgets.pro
+++ b/src/multimediawidgets/multimediawidgets.pro
@@ -7,11 +7,9 @@ qtHaveModule(opengl) {
QT_PRIVATE += opengl
}
-PRIVATE_HEADERS += \
+HEADERS += \
qvideowidget_p.h \
qpaintervideosurface_p.h \
-
-PUBLIC_HEADERS += \
qtmultimediawidgetdefs.h \
qvideowidgetcontrol.h \
qvideowidget.h
@@ -22,14 +20,10 @@ SOURCES += \
qvideowidget.cpp
qtConfig(graphicsview) {
- SOURCES += qgraphicsvideoitem.cpp
- PUBLIC_HEADERS += qgraphicsvideoitem.h
+ SOURCES += qgraphicsvideoitem.cpp
+ HEADERS += qgraphicsvideoitem.h
}
-qtConfig(gstreamer):include(gstreamer/gstreamer.pri)
-
-HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
-
-msvc:lessThan(QMAKE_MSC_VER, 1900): QMAKE_CXXFLAGS += -Zm200
+include(platform/platform.pri)
load(qt_module)
diff --git a/src/multimediawidgets/platform/avfoundation/avfoundation.pri b/src/multimediawidgets/platform/avfoundation/avfoundation.pri
new file mode 100644
index 000000000..21bbe36c2
--- /dev/null
+++ b/src/multimediawidgets/platform/avfoundation/avfoundation.pri
@@ -0,0 +1,15 @@
+HEADERS += \
+ $$PWD/avfvideowidgetcontrol_p.h \
+ $$PWD/avfvideowidget_p.h
+
+SOURCES += \
+ $$PWD/avfvideowidgetcontrol.mm \
+ $$PWD/avfvideowidget.mm
+
+LIBS += -framework CoreFoundation \
+ -framework Foundation \
+ -framework QuartzCore \
+ -framework CoreVideo \
+ -framework Metal
+
+QMAKE_USE += avfoundation
diff --git a/src/multimediawidgets/platform/avfoundation/avfvideowidget.mm b/src/multimediawidgets/platform/avfoundation/avfvideowidget.mm
new file mode 100644
index 000000000..874751ec1
--- /dev/null
+++ b/src/multimediawidgets/platform/avfoundation/avfvideowidget.mm
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** 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_p.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/multimediawidgets/platform/avfoundation/avfvideowidget_p.h b/src/multimediawidgets/platform/avfoundation/avfvideowidget_p.h
new file mode 100644
index 000000000..dbbe343ec
--- /dev/null
+++ b/src/multimediawidgets/platform/avfoundation/avfvideowidget_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** 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
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#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/multimediawidgets/platform/avfoundation/avfvideowidgetcontrol.mm b/src/multimediawidgets/platform/avfoundation/avfvideowidgetcontrol.mm
new file mode 100644
index 000000000..ec1c04a09
--- /dev/null
+++ b/src/multimediawidgets/platform/avfoundation/avfvideowidgetcontrol.mm
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** 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_p.h"
+#include "avfvideowidget_p.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_p.cpp"
diff --git a/src/multimediawidgets/platform/avfoundation/avfvideowidgetcontrol_p.h b/src/multimediawidgets/platform/avfoundation/avfvideowidgetcontrol_p.h
new file mode 100644
index 000000000..60c94e72d
--- /dev/null
+++ b/src/multimediawidgets/platform/avfoundation/avfvideowidgetcontrol_p.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** 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
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qvideowidgetcontrol.h>
+#include "private/avfvideooutput_p.h"
+
+Q_FORWARD_DECLARE_OBJC_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/multimediawidgets/platform/gstreamer/gstreamer.pri b/src/multimediawidgets/platform/gstreamer/gstreamer.pri
new file mode 100644
index 000000000..c45f116ae
--- /dev/null
+++ b/src/multimediawidgets/platform/gstreamer/gstreamer.pri
@@ -0,0 +1,4 @@
+QMAKE_USE_PRIVATE += gstreamer
+
+SOURCES += $$PWD/qgstreamervideowidget.cpp
+HEADERS += $$PWD/qgstreamervideowidget_p.h
diff --git a/src/multimediawidgets/gstreamer/qgstreamervideowidget.cpp b/src/multimediawidgets/platform/gstreamer/qgstreamervideowidget.cpp
index e1c8fe47c..e1c8fe47c 100644
--- a/src/multimediawidgets/gstreamer/qgstreamervideowidget.cpp
+++ b/src/multimediawidgets/platform/gstreamer/qgstreamervideowidget.cpp
diff --git a/src/multimediawidgets/gstreamer/qgstreamervideowidget_p.h b/src/multimediawidgets/platform/gstreamer/qgstreamervideowidget_p.h
index 38985ebd0..38985ebd0 100644
--- a/src/multimediawidgets/gstreamer/qgstreamervideowidget_p.h
+++ b/src/multimediawidgets/platform/gstreamer/qgstreamervideowidget_p.h
diff --git a/src/multimediawidgets/platform/platform.pri b/src/multimediawidgets/platform/platform.pri
new file mode 100644
index 000000000..a2b2f9742
--- /dev/null
+++ b/src/multimediawidgets/platform/platform.pri
@@ -0,0 +1,2 @@
+qtConfig(gstreamer):include(gstreamer/gstreamer.pri)
+qtConfig(avfoundation):include(avfoundation/avfoundation.pri)
diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp
index 742dff6d3..2edbd6af6 100644
--- a/src/multimediawidgets/qvideowidget.cpp
+++ b/src/multimediawidgets/qvideowidget.cpp
@@ -37,6 +37,7 @@
**
****************************************************************************/
+#include <private/qtmultimediaglobal_p.h>
#include "qvideowidget_p.h"
#include "qpaintervideosurface_p.h"
@@ -57,6 +58,11 @@
#include <qwindow.h>
#include <private/qhighdpiscaling_p.h>
+#if QT_CONFIG(gstreamer)
+#include <private/qgstreamervideowidget_p.h>
+#elif QT_CONFIG(avfoundation)
+#include <private/avfvideowidgetcontrol_p.h>
+#endif
#ifdef Q_OS_WIN
#include <QtCore/qt_windows.h>
#endif
@@ -491,17 +497,24 @@ void QVideoWidgetPrivate::clearService()
bool QVideoWidgetPrivate::createWidgetBackend()
{
- if (QObject *control = service->requestControl(QVideoWidgetControl_iid)) {
- if (QVideoWidgetControl *widgetControl = qobject_cast<QVideoWidgetControl *>(control)) {
- widgetBackend = new QVideoWidgetControlBackend(service, widgetControl, q_func());
-
- setCurrentControl(widgetBackend);
+ QVideoWidgetControl *widgetControl = nullptr;
+#if QT_CONFIG(gstreamer)
+// widgetControl = new QGstreamerVideoWidgetControl(q_ptr);
+ // If the GStreamer video sink is not available, don't provide the video widget control since
+ // it won't work anyway. QVideoWidget will fall back to QVideoRendererControl in that case.
+// if (!widgetControl->videoSink()) {
+// delete widgetControl;
+// widgetControl = nullptr;
+// }
+ // ### need to set the widget as the video output on the service currently
+#elif QT_CONFIG(avfoundation)
+// widgetControl = new AVFVideoWidgetControl(q_ptr);
+ // #####m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
+#endif
+ if (widgetControl)
+ setCurrentControl(widgetBackend);
- return true;
- }
- service->releaseControl(control);
- }
- return false;
+ return widgetControl != nullptr;
}
bool QVideoWidgetPrivate::createWindowBackend()