summaryrefslogtreecommitdiffstats
path: root/src/multimedia/platform
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2023-06-21 18:13:28 +0200
committerArtem Dyomin <artem.dyomin@qt.io>2023-06-23 20:51:00 +0200
commita7565989a0815e41d4abfde5af5712b2968584b9 (patch)
tree536c3626e5f36c03f4163c888b764dd672370fce /src/multimedia/platform
parent2bca3087d2b48bed46e6d959b35ebf34d5d256ac (diff)
Apply window capture to media capture session
It's a second step of QWindowCapture integration. The patch propagates window capture to a video sink or a recorder. The refactoring has been done with moving some duplicated functionality to QPlatformVideoSource The patch is supposed to be integrated partually to 6.5 in order to have as much code compatibility as possible. Pick-to: 6.6 6.5 Change-Id: I8c3e6b3a899fb246d48135025ee2213ed9a2f571 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Diffstat (limited to 'src/multimedia/platform')
-rw-r--r--src/multimedia/platform/qplatformcamera_p.h3
-rw-r--r--src/multimedia/platform/qplatformmediacapture.cpp18
-rw-r--r--src/multimedia/platform/qplatformmediacapture_p.h10
-rw-r--r--src/multimedia/platform/qplatformsurfacecapture_p.h1
-rw-r--r--src/multimedia/platform/qplatformvideosource_p.h4
5 files changed, 30 insertions, 6 deletions
diff --git a/src/multimedia/platform/qplatformcamera_p.h b/src/multimedia/platform/qplatformcamera_p.h
index c920c4424..794e4372e 100644
--- a/src/multimedia/platform/qplatformcamera_p.h
+++ b/src/multimedia/platform/qplatformcamera_p.h
@@ -30,8 +30,6 @@ public:
virtual bool setCameraFormat(const QCameraFormat &/*format*/) { return false; }
QCameraFormat cameraFormat() const { return m_cameraFormat; }
- virtual void setCaptureSession(QPlatformMediaCaptureSession *) {}
-
virtual bool isFocusModeSupported(QCamera::FocusMode mode) const { return mode == QCamera::FocusModeAuto; }
virtual void setFocusMode(QCamera::FocusMode /*mode*/) {}
@@ -113,7 +111,6 @@ public:
static int colorTemperatureForWhiteBalance(QCamera::WhiteBalanceMode mode);
Q_SIGNALS:
- void activeChanged(bool);
void error(int error, const QString &errorString);
protected:
diff --git a/src/multimedia/platform/qplatformmediacapture.cpp b/src/multimedia/platform/qplatformmediacapture.cpp
index b9b271942..826228764 100644
--- a/src/multimedia/platform/qplatformmediacapture.cpp
+++ b/src/multimedia/platform/qplatformmediacapture.cpp
@@ -5,11 +5,27 @@
#include "qplatformmediacapture_p.h"
#include "qaudiodevice.h"
#include "qaudioinput.h"
+#include "qplatformcamera_p.h"
+#include "qplatformsurfacecapture_p.h"
QT_BEGIN_NAMESPACE
-QPlatformMediaCaptureSession::~QPlatformMediaCaptureSession()
+QPlatformMediaCaptureSession::~QPlatformMediaCaptureSession() = default;
+
+std::vector<QPlatformVideoSource *> QPlatformMediaCaptureSession::activeVideoSources()
{
+ std::vector<QPlatformVideoSource *> result;
+
+ auto checkSource = [&result](QPlatformVideoSource *source) {
+ if (source && source->isActive())
+ result.push_back(source);
+ };
+
+ checkSource(camera());
+ checkSource(screenCapture());
+ checkSource(windowCapture());
+
+ return result;
}
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/qplatformmediacapture_p.h b/src/multimedia/platform/qplatformmediacapture_p.h
index 2c901fc37..814fa160c 100644
--- a/src/multimedia/platform/qplatformmediacapture_p.h
+++ b/src/multimedia/platform/qplatformmediacapture_p.h
@@ -28,13 +28,14 @@ class QPlatformAudioInput;
class QPlatformAudioOutput;
class QMediaCaptureSession;
class QPlatformSurfaceCapture;
+class QPlatformVideoSource;
class Q_MULTIMEDIA_EXPORT QPlatformMediaCaptureSession : public QObject
{
Q_OBJECT
public:
QPlatformMediaCaptureSession() = default;
- virtual ~QPlatformMediaCaptureSession();
+ ~QPlatformMediaCaptureSession() override;
void setCaptureSession(QMediaCaptureSession *session) { m_session = session; }
QMediaCaptureSession *captureSession() const { return m_session; }
@@ -45,6 +46,9 @@ public:
virtual QPlatformSurfaceCapture *screenCapture() { return nullptr; }
virtual void setScreenCapture(QPlatformSurfaceCapture *) {}
+ virtual QPlatformSurfaceCapture *windowCapture() { return nullptr; }
+ virtual void setWindowCapture(QPlatformSurfaceCapture *) { }
+
virtual QPlatformImageCapture *imageCapture() = 0;
virtual void setImageCapture(QPlatformImageCapture *) {}
@@ -57,9 +61,13 @@ public:
virtual void setAudioOutput(QPlatformAudioOutput *) {}
+ // TBD: implement ordering of the sources basing on the order of adding
+ std::vector<QPlatformVideoSource *> activeVideoSources();
+
Q_SIGNALS:
void cameraChanged();
void screenCaptureChanged();
+ void windowCaptureChanged();
void imageCaptureChanged();
void encoderChanged();
diff --git a/src/multimedia/platform/qplatformsurfacecapture_p.h b/src/multimedia/platform/qplatformsurfacecapture_p.h
index dca48e2a1..c99708f9a 100644
--- a/src/multimedia/platform/qplatformsurfacecapture_p.h
+++ b/src/multimedia/platform/qplatformsurfacecapture_p.h
@@ -73,7 +73,6 @@ public Q_SLOTS:
Q_SIGNALS:
void sourceChanged(WindowSource);
void sourceChanged(ScreenSource);
- void activeChanged(bool);
void errorChanged();
void errorOccurred(Error error, QString errorString);
diff --git a/src/multimedia/platform/qplatformvideosource_p.h b/src/multimedia/platform/qplatformvideosource_p.h
index fc99a30ef..3ed76d3e2 100644
--- a/src/multimedia/platform/qplatformvideosource_p.h
+++ b/src/multimedia/platform/qplatformvideosource_p.h
@@ -26,6 +26,7 @@
QT_BEGIN_NAMESPACE
class QVideoFrame;
+class QPlatformMediaCaptureSession;
class Q_MULTIMEDIA_EXPORT QPlatformVideoSource : public QObject
{
@@ -40,8 +41,11 @@ public:
virtual std::optional<int> ffmpegHWPixelFormat() const;
+ virtual void setCaptureSession(QPlatformMediaCaptureSession *) { }
+
Q_SIGNALS:
void newVideoFrame(const QVideoFrame &);
+ void activeChanged(bool);
};
QT_END_NAMESPACE