diff options
author | Artem Dyomin <artem.dyomin@qt.io> | 2023-05-12 17:49:13 +0200 |
---|---|---|
committer | Artem Dyomin <artem.dyomin@qt.io> | 2023-06-02 13:12:21 +0200 |
commit | 24c854fff9af00461b0920074b23d156e345a804 (patch) | |
tree | 6f71d2c9a8e1b76d12eaa2e25e7da839bad02d5c /src/multimedia/platform | |
parent | dda06373eba84999a89e539035860fc45f2fa5f5 (diff) |
Add QWindowCapure and QCapturableWindow for window capturing
The design of QMediaCaptureSession already uses different types and
setters/gettes for each video source, like QCamera, QImageCapture,
and QScreenCapture, so a new source type, QWindowCapure, has been
added instead of extending QScreenCapture.
For now we only cover the case of capturing windows enumerated though
the capturing API itself, via a list of QCapturableWindow instances,
as this is considered the primary use-case for such an API.
An extension to this would be to add a QWindow overload to either
QCapturableWindow's constructor or QWindowCapture::setWindow, to
allow capturing of windows in the application itself, either created
by Qt, or via QWindow::fromWinId(), but this has been left out
for the initial API to keep things minimal.
A WId overload has been intentionally left out of this API, as
the path for capturing by WId should go via QWindow::fromWinId().
Finally, capture of windows from other applications without
enumerating them via QWindowCapure is left out, as adding such
an API would require us to build a more generic WId replacement
that isn't tied to a single type for each OS, like WId is (it's
a NSView* on macOS e.g., but windows can also be represented by
CGWindowID).
Task-number: QTBUG-103226
Change-Id: I99e3b8bde62250aba35abcedbc8680a299a3cbb2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/multimedia/platform')
-rw-r--r-- | src/multimedia/platform/qplatformmediaintegration_p.h | 6 | ||||
-rw-r--r-- | src/multimedia/platform/qplatformscreencapture.cpp | 4 | ||||
-rw-r--r-- | src/multimedia/platform/qplatformscreencapture_p.h | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/multimedia/platform/qplatformmediaintegration_p.h b/src/multimedia/platform/qplatformmediaintegration_p.h index 27f00cdc0..6f60208de 100644 --- a/src/multimedia/platform/qplatformmediaintegration_p.h +++ b/src/multimedia/platform/qplatformmediaintegration_p.h @@ -16,6 +16,7 @@ #include <private/qtmultimediaglobal_p.h> #include <private/qmultimediautils_p.h> +#include <qcapturablewindow.h> #include <qmediarecorder.h> #include <qstring.h> @@ -47,6 +48,7 @@ class QAudioOutput; class QPlatformAudioInput; class QPlatformAudioOutput; class QPlatformVideoDevices; +class QCapturableWindow; class Q_MULTIMEDIA_EXPORT QPlatformMediaIntegration { @@ -76,6 +78,10 @@ public: virtual QMaybe<QPlatformVideoSink *> createVideoSink(QVideoSink *) { return notAvailable; } + virtual QList<QCapturableWindow> capturableWindows() { return {}; }; + + bool isCapturableWindowValid(const QCapturableWindowPrivate &) { return false; } + protected: std::unique_ptr<QPlatformVideoDevices> m_videoDevices; }; diff --git a/src/multimedia/platform/qplatformscreencapture.cpp b/src/multimedia/platform/qplatformscreencapture.cpp index de7f74d9d..afb1a6c78 100644 --- a/src/multimedia/platform/qplatformscreencapture.cpp +++ b/src/multimedia/platform/qplatformscreencapture.cpp @@ -16,7 +16,7 @@ QPlatformScreenCapture::QPlatformScreenCapture(QScreenCapture *screenCapture) void QPlatformScreenCapture::setWindow(QWindow *w) { if (w) { - emit m_screenCapture->errorOccurred(QScreenCapture::WindowCapturingNotSupported, + emit m_screenCapture->errorOccurred(QScreenCapture::InternalError, QLatin1String("Window capture is not supported")); } } @@ -29,7 +29,7 @@ QWindow *QPlatformScreenCapture::window() const void QPlatformScreenCapture::setWindowId(WId id) { if (id) { - emit m_screenCapture->errorOccurred(QScreenCapture::WindowCapturingNotSupported, + emit m_screenCapture->errorOccurred(QScreenCapture::InternalError, QLatin1String("Window capture is not supported")); } } diff --git a/src/multimedia/platform/qplatformscreencapture_p.h b/src/multimedia/platform/qplatformscreencapture_p.h index b5a865e22..a162fc7e6 100644 --- a/src/multimedia/platform/qplatformscreencapture_p.h +++ b/src/multimedia/platform/qplatformscreencapture_p.h @@ -32,9 +32,11 @@ public: virtual void setScreen(QScreen *s) = 0; virtual QScreen *screen() const = 0; + // TODO: move the methods and implementations to QPlatformWindowCapture virtual void setWindow(QWindow *w); virtual QWindow *window() const; + // to be removed virtual void setWindowId(WId id); virtual WId windowId() const; |