summaryrefslogtreecommitdiffstats
path: root/src/multimedia/platform
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2023-03-22 14:47:39 +0100
committerArtem Dyomin <artem.dyomin@qt.io>2023-03-22 22:17:42 +0100
commitcd1fdbfe2ccbb9f44749fcdeecd65f34deeb29fc (patch)
tree2773e0483a85a2aed2f8b5749cd637e73862b172 /src/multimedia/platform
parenta757c89932cc5e09c2c22367b278e46880ec9357 (diff)
Implement the base video source class for camera and screen capturing
QPlatformVideoSource becomes the base of QPlatformCamera and QPlatformScreenCapture The advantage is using the single video source interface in the encoder instead of defferent ones. Pick-to: 6.5 Change-Id: Ic8bab3258dbe3efe851330d9a0e0461266dc64c9 Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/multimedia/platform')
-rw-r--r--src/multimedia/platform/qplatformcamera.cpp4
-rw-r--r--src/multimedia/platform/qplatformcamera_p.h16
-rw-r--r--src/multimedia/platform/qplatformscreencapture.cpp9
-rw-r--r--src/multimedia/platform/qplatformscreencapture_p.h22
-rw-r--r--src/multimedia/platform/qplatformvideosource.cpp15
-rw-r--r--src/multimedia/platform/qplatformvideosource_p.h49
6 files changed, 73 insertions, 42 deletions
diff --git a/src/multimedia/platform/qplatformcamera.cpp b/src/multimedia/platform/qplatformcamera.cpp
index 74a114ca9..77f1a327a 100644
--- a/src/multimedia/platform/qplatformcamera.cpp
+++ b/src/multimedia/platform/qplatformcamera.cpp
@@ -5,9 +5,7 @@
QT_BEGIN_NAMESPACE
-QPlatformCamera::QPlatformCamera(QCamera *parent)
- : QObject(parent),
- m_camera(parent)
+QPlatformCamera::QPlatformCamera(QCamera *parent) : QPlatformVideoSource(parent), m_camera(parent)
{
qRegisterMetaType<QVideoFrame>();
}
diff --git a/src/multimedia/platform/qplatformcamera_p.h b/src/multimedia/platform/qplatformcamera_p.h
index 555adeef5..c920c4424 100644
--- a/src/multimedia/platform/qplatformcamera_p.h
+++ b/src/multimedia/platform/qplatformcamera_p.h
@@ -15,23 +15,17 @@
// We mean it.
//
-#include <QtCore/qobject.h>
-#include <QtMultimedia/qtmultimediaglobal.h>
+#include "qplatformvideosource_p.h"
#include <QtMultimedia/qcamera.h>
-#include <QtMultimedia/qvideoframeformat.h>
-#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
-class Q_MULTIMEDIA_EXPORT QPlatformCamera : public QObject
+class Q_MULTIMEDIA_EXPORT QPlatformCamera : public QPlatformVideoSource
{
Q_OBJECT
public:
- virtual bool isActive() const = 0;
- virtual void setActive(bool active) = 0;
-
virtual void setCamera(const QCameraDevice &camera) = 0;
virtual bool setCameraFormat(const QCameraFormat &/*format*/) { return false; }
QCameraFormat cameraFormat() const { return m_cameraFormat; }
@@ -67,7 +61,7 @@ public:
virtual void setWhiteBalanceMode(QCamera::WhiteBalanceMode /*mode*/) {}
virtual void setColorTemperature(int /*temperature*/) {}
- QVideoFrameFormat frameFormat() const;
+ QVideoFrameFormat frameFormat() const override;
QCamera::Features supportedFeatures() const { return m_supportedFeatures; }
@@ -118,13 +112,9 @@ public:
static int colorTemperatureForWhiteBalance(QCamera::WhiteBalanceMode mode);
- // Can't use FFmpeg specific struct here, use void * for now.
- virtual std::optional<int> ffmpegHWPixelFormat() const { return {}; }
-
Q_SIGNALS:
void activeChanged(bool);
void error(int error, const QString &errorString);
- void newVideoFrame(const QVideoFrame &); // only used by FFmpeg
protected:
explicit QPlatformCamera(QCamera *parent);
diff --git a/src/multimedia/platform/qplatformscreencapture.cpp b/src/multimedia/platform/qplatformscreencapture.cpp
index 67140f23d..de7f74d9d 100644
--- a/src/multimedia/platform/qplatformscreencapture.cpp
+++ b/src/multimedia/platform/qplatformscreencapture.cpp
@@ -8,7 +8,7 @@
QT_BEGIN_NAMESPACE
QPlatformScreenCapture::QPlatformScreenCapture(QScreenCapture *screenCapture)
- : QObject(screenCapture), m_screenCapture(screenCapture)
+ : QPlatformVideoSource(screenCapture), m_screenCapture(screenCapture)
{
qRegisterMetaType<QVideoFrame>();
}
@@ -53,11 +53,6 @@ QScreenCapture *QPlatformScreenCapture::screenCapture() const
return m_screenCapture;
}
-std::optional<int> QPlatformScreenCapture::ffmpegHWPixelFormat() const
-{
- return {};
-}
-
void QPlatformScreenCapture::updateError(QScreenCapture::Error error, const QString &errorString)
{
bool changed = error != m_error || errorString != m_errorString;
@@ -74,3 +69,5 @@ void QPlatformScreenCapture::updateError(QScreenCapture::Error error, const QStr
}
QT_END_NAMESPACE
+
+#include "moc_qplatformscreencapture_p.cpp"
diff --git a/src/multimedia/platform/qplatformscreencapture_p.h b/src/multimedia/platform/qplatformscreencapture_p.h
index 8da927d8d..b5a865e22 100644
--- a/src/multimedia/platform/qplatformscreencapture_p.h
+++ b/src/multimedia/platform/qplatformscreencapture_p.h
@@ -15,31 +15,20 @@
// We mean it.
//
-#include <QtCore/qobject.h>
-#include <QtCore/qnativeinterface.h>
-#include <QtCore/private/qglobal_p.h>
-
-#include <QtMultimedia/qtmultimediaglobal.h>
-
+#include "qplatformvideosource_p.h"
#include "qscreencapture.h"
-#include "qvideoframeformat.h"
-
-#include <optional>
QT_BEGIN_NAMESPACE
class QVideoFrame;
-class Q_MULTIMEDIA_EXPORT QPlatformScreenCapture : public QObject
+class Q_MULTIMEDIA_EXPORT QPlatformScreenCapture : public QPlatformVideoSource
{
Q_OBJECT
public:
explicit QPlatformScreenCapture(QScreenCapture *screenCapture);
- virtual void setActive(bool active) = 0;
- virtual bool isActive() const = 0;
-
virtual void setScreen(QScreen *s) = 0;
virtual QScreen *screen() const = 0;
@@ -52,18 +41,11 @@ public:
virtual QScreenCapture::Error error() const;
virtual QString errorString() const;
- virtual QVideoFrameFormat format() const = 0;
-
QScreenCapture *screenCapture() const;
- virtual std::optional<int> ffmpegHWPixelFormat() const;
-
public Q_SLOTS:
void updateError(QScreenCapture::Error error, const QString &errorString);
-Q_SIGNALS:
- void newVideoFrame(const QVideoFrame &);
-
private:
QScreenCapture::Error m_error = QScreenCapture::NoError;
QString m_errorString;
diff --git a/src/multimedia/platform/qplatformvideosource.cpp b/src/multimedia/platform/qplatformvideosource.cpp
new file mode 100644
index 000000000..a23ed91ae
--- /dev/null
+++ b/src/multimedia/platform/qplatformvideosource.cpp
@@ -0,0 +1,15 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qplatformvideosource_p.h"
+
+QT_BEGIN_NAMESPACE
+
+std::optional<int> QPlatformVideoSource::ffmpegHWPixelFormat() const
+{
+ return {};
+};
+
+QT_END_NAMESPACE
+
+//#include "moc_qplatformvideosource_p.cpp
diff --git a/src/multimedia/platform/qplatformvideosource_p.h b/src/multimedia/platform/qplatformvideosource_p.h
new file mode 100644
index 000000000..fc99a30ef
--- /dev/null
+++ b/src/multimedia/platform/qplatformvideosource_p.h
@@ -0,0 +1,49 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QPLATFORMVIDEOSOURCE_P_H
+#define QPLATFORMVIDEOSOURCE_P_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 "qvideoframeformat.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qnativeinterface.h>
+#include <QtCore/private/qglobal_p.h>
+
+#include <optional>
+
+QT_BEGIN_NAMESPACE
+
+class QVideoFrame;
+
+class Q_MULTIMEDIA_EXPORT QPlatformVideoSource : public QObject
+{
+ Q_OBJECT
+public:
+ using QObject::QObject;
+
+ virtual void setActive(bool active) = 0;
+ virtual bool isActive() const = 0;
+
+ virtual QVideoFrameFormat frameFormat() const = 0;
+
+ virtual std::optional<int> ffmpegHWPixelFormat() const;
+
+Q_SIGNALS:
+ void newVideoFrame(const QVideoFrame &);
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLATFORMVIDEOSOURCE_P_H