summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-03-12 14:51:15 +0100
committerLars Knoll <lars.knoll@qt.io>2021-03-23 13:54:27 +0000
commit6d2c0dd4ecd437baedea43c92f47ec8f5f268514 (patch)
treedc1e8130bfe30d19dac9b318fbf4ad34bd0ccebc
parent1349a9da62f039476a87beda2d001a525af3105e (diff)
Add new QVideoSink class
This is the starting point for the new video output API for QtMultimedia. Nothing working yet :) Change-Id: Idaa98394b7c9461cfe5443fdd1566ecc9fc985cb Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/multimedia/CMakeLists.txt1
-rw-r--r--src/multimedia/video/qvideosink.cpp198
-rw-r--r--src/multimedia/video/qvideosink.h119
-rw-r--r--tests/auto/unit/multimedia/qabstractvideobuffer/tst_qabstractvideobuffer.cpp3
4 files changed, 319 insertions, 2 deletions
diff --git a/src/multimedia/CMakeLists.txt b/src/multimedia/CMakeLists.txt
index d6a73b947..c91e628a2 100644
--- a/src/multimedia/CMakeLists.txt
+++ b/src/multimedia/CMakeLists.txt
@@ -66,6 +66,7 @@ qt_internal_add_module(Multimedia
video/qmemoryvideobuffer.cpp video/qmemoryvideobuffer_p.h
video/qpaintervideosurface.cpp video/qpaintervideosurface_p.h
video/qvideoframe.cpp video/qvideoframe.h
+ video/qvideosink.cpp video/qvideosink.h
video/qvideoframeconversionhelper.cpp video/qvideoframeconversionhelper_p.h
video/qvideooutputorientationhandler.cpp video/qvideooutputorientationhandler_p.h
video/qvideosurfaceformat.cpp video/qvideosurfaceformat.h
diff --git a/src/multimedia/video/qvideosink.cpp b/src/multimedia/video/qvideosink.cpp
new file mode 100644
index 000000000..de619eab8
--- /dev/null
+++ b/src/multimedia/video/qvideosink.cpp
@@ -0,0 +1,198 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "qvideosink.h"
+
+#include "qvideosurfaceformat.h"
+#include "qvideoframe.h"
+
+#include <qvariant.h>
+#include <qpainter.h>
+#include <qmatrix4x4.h>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+class QVideoSinkPrivate {
+public:
+ QVideoSink::GraphicsType type = QVideoSink::Memory;
+ QVideoSurfaceFormat surfaceFormat;
+ QSize nativeResolution;
+ bool active = false;
+ WId window = 0;
+ Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio;
+ QRectF targetRect;
+ int brightness = 0;
+ int contrast = 0;
+ int saturation = 0;
+ int hue = 0;
+ QMatrix4x4 transform;
+ float opacity = 1.;
+};
+
+QVideoSink::QVideoSink(QObject *parent)
+ : QObject(parent),
+ d(new QVideoSinkPrivate)
+{
+
+}
+
+QVideoSink::~QVideoSink()
+{
+ delete d;
+}
+
+QVideoSink::GraphicsType QVideoSink::graphicsType() const
+{
+ return d->type;
+}
+
+void QVideoSink::setGraphicsType(QVideoSink::GraphicsType type)
+{
+ d->type = type;
+}
+
+WId QVideoSink::nativeWindowId() const
+{
+ return d->window;
+}
+
+void QVideoSink::setNativeWindowId(WId id)
+{
+ d->window = id;
+}
+
+Qt::AspectRatioMode QVideoSink::aspectRatioMode() const
+{
+ return d->aspectRatioMode;
+}
+
+void QVideoSink::setAspectRatioMode(Qt::AspectRatioMode mode)
+{
+ d->aspectRatioMode = mode;
+}
+
+QRectF QVideoSink::targetRect() const
+{
+ return d->targetRect;
+}
+
+void QVideoSink::setTargetRect(const QRectF &rect)
+{
+ d->targetRect = rect;
+}
+
+int QVideoSink::brightness() const
+{
+ return d->brightness;
+}
+
+void QVideoSink::setBrightness(int brightness)
+{
+ d->brightness = brightness;
+}
+
+int QVideoSink::contrast() const
+{
+ return d->contrast;
+}
+
+void QVideoSink::setContrast(int contrast)
+{
+ d->contrast = contrast;
+}
+
+int QVideoSink::hue() const
+{
+ return d->hue;
+}
+
+void QVideoSink::setHue(int hue)
+{
+ d->hue = hue;
+}
+
+int QVideoSink::saturation() const
+{
+ return d->saturation;
+}
+
+void QVideoSink::setSaturation(int saturation)
+{
+ d->saturation = saturation;
+}
+
+QMatrix4x4 QVideoSink::transform() const
+{
+ return d->transform;
+}
+
+void QVideoSink::setTransform(const QMatrix4x4 &transform)
+{
+ d->transform = transform;
+}
+
+float QVideoSink::opacity() const
+{
+ return d->opacity;
+}
+
+void QVideoSink::setOpacity(float opacity)
+{
+ d->opacity = opacity;
+}
+
+void QVideoSink::render(const QVideoFrame &frame)
+{
+ Q_UNUSED(frame);
+
+}
+
+void QVideoSink::paint(QPainter *painter, const QVideoFrame &frame)
+{
+ Q_UNUSED(painter);
+ Q_UNUSED(frame);
+
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qvideosink.cpp"
+
+
diff --git a/src/multimedia/video/qvideosink.h b/src/multimedia/video/qvideosink.h
new file mode 100644
index 000000000..e4ae146c0
--- /dev/null
+++ b/src/multimedia/video/qvideosink.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** 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 QABSTRACTVIDEOSINK_H
+#define QABSTRACTVIDEOSINK_H
+
+#include <QtCore/qobject.h>
+#include <QtGui/qwindowdefs.h>
+
+QT_BEGIN_NAMESPACE
+
+class QRectF;
+class QVideoSurfaceFormat;
+class QVideoFrame;
+
+class QVideoSinkPrivate;
+
+class QVideoSink : public QObject
+{
+ Q_OBJECT
+public:
+ enum GraphicsType
+ {
+ Memory,
+ NativeWindow,
+ OpenGL,
+ Metal,
+ Direct3D11,
+ Vulkan
+ };
+
+ QVideoSink(QObject *parent);
+ ~QVideoSink();
+
+ GraphicsType graphicsType() const;
+ void setGraphicsType(GraphicsType type);
+
+ // setter sets graphics type to NativeWindow
+ WId nativeWindowId() const;
+ void setNativeWindowId(WId id);
+
+ Qt::AspectRatioMode aspectRatioMode() const;
+ void setAspectRatioMode(Qt::AspectRatioMode mode);
+
+ QRectF targetRect() const;
+ void setTargetRect(const QRectF &rect);
+
+ int brightness() const;
+ void setBrightness(int brightness);
+
+ int contrast() const;
+ void setContrast(int contrast);
+
+ int hue() const;
+ void setHue(int hue);
+
+ int saturation() const;
+ void setSaturation(int saturation);
+
+ // ignored in windowed mode (GraphicsType == NativeWindow)
+ QMatrix4x4 transform() const;
+ void setTransform(const QMatrix4x4 &transform);
+
+ // ignored in windowed mode?
+ float opacity() const;
+ void setOpacity(float opacity);
+
+ // Thread safe
+ void render(const QVideoFrame &frame);
+
+ void paint(QPainter *painter, const QVideoFrame &frame);
+
+Q_SIGNALS:
+ // would never get called in windowed mode
+ QVideoFrame newVideoFrame() const;
+
+private:
+ QVideoSinkPrivate *d = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/unit/multimedia/qabstractvideobuffer/tst_qabstractvideobuffer.cpp b/tests/auto/unit/multimedia/qabstractvideobuffer/tst_qabstractvideobuffer.cpp
index 3d1caf38f..621cfc7af 100644
--- a/tests/auto/unit/multimedia/qabstractvideobuffer/tst_qabstractvideobuffer.cpp
+++ b/tests/auto/unit/multimedia/qabstractvideobuffer/tst_qabstractvideobuffer.cpp
@@ -102,9 +102,8 @@ void tst_QAbstractVideoBuffer::handleType_data()
ADD_ENUM_TEST(NoHandle);
ADD_ENUM_TEST(GLTextureHandle);
- ADD_ENUM_TEST(XvShmImageHandle);
+ ADD_ENUM_TEST(MTLTextureHandle);
ADD_ENUM_TEST(QPixmapHandle);
- ADD_ENUM_TEST(CoreImageHandle);
}
void tst_QAbstractVideoBuffer::handleType()