Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwindowcapture.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qwindowcapture.h"
7#include "private/qobject_p.h"
8#include "private/qplatformsurfacecapture_p.h"
9
11
16
18{
19public:
21 std::unique_ptr<QPlatformSurfaceCapture> platformWindowCapture;
22};
23
73{
74 Q_D(QWindowCapture);
75
76 qRegisterMetaType<QCapturableWindow>();
77
78 auto platformCapture = QPlatformMediaIntegration::instance()->createWindowCapture(this);
79
80 if (platformCapture) {
81 connect(platformCapture, &QPlatformSurfaceCapture::activeChanged, this,
83 connect(platformCapture, &QPlatformSurfaceCapture::errorChanged, this,
85 connect(platformCapture, &QPlatformSurfaceCapture::errorOccurred, this,
88 });
89 connect(platformCapture,
90 qOverload<QCapturableWindow>(&QPlatformSurfaceCapture::sourceChanged), this,
92
93 d->platformWindowCapture.reset(platformCapture);
94 }
95}
96
101{
102 Q_D(QWindowCapture);
103
104 d->platformWindowCapture.reset();
105
106 if (d->captureSession)
107 d->captureSession->setWindowCapture(nullptr);
108}
109
120QList<QCapturableWindow> QWindowCapture::capturableWindows()
121{
122 return QPlatformMediaIntegration::instance()->capturableWindowsList();
123}
124
126{
127 Q_D(const QWindowCapture);
128
129 return d->captureSession;
130}
131
146{
147 Q_D(const QWindowCapture);
148
149 return d->platformWindowCapture ? d->platformWindowCapture->source<QCapturableWindow>()
151}
152
154{
155 Q_D(QWindowCapture);
156
157 if (d->platformWindowCapture)
158 d->platformWindowCapture->setSource(window);
159}
160
173{
174 Q_D(const QWindowCapture);
175
176 return d->platformWindowCapture && d->platformWindowCapture->isActive();
177}
178
180{
181 Q_D(QWindowCapture);
182
183 if (d->platformWindowCapture)
184 d->platformWindowCapture->setActive(active);
185}
186
222{
223 Q_D(const QWindowCapture);
224
225 return d->platformWindowCapture ? toWindowCaptureError(d->platformWindowCapture->error())
227}
228
244{
245 Q_D(const QWindowCapture);
246
247 return d->platformWindowCapture
248 ? d->platformWindowCapture->errorString()
249 : QLatin1StringView("Capturing is not support on this platform");
250}
251
252void QWindowCapture::setCaptureSession(QMediaCaptureSession *captureSession)
253{
254 Q_D(QWindowCapture);
255
256 d->captureSession = captureSession;
257}
258
259QPlatformSurfaceCapture *QWindowCapture::platformWindowCapture() const
260{
261 Q_D(const QWindowCapture);
262
263 return d->platformWindowCapture.get();
264}
265
267
268#include "moc_qwindowcapture.cpp"
\inmodule QtMultimedia
The QMediaCaptureSession class allows capturing of audio and video content.
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
static QPlatformMediaIntegration * instance()
void errorOccurred(Error error, QString errorString)
void sourceChanged(WindowSource)
void activeChanged(bool)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QMediaCaptureSession * captureSession
std::unique_ptr< QPlatformSurfaceCapture > platformWindowCapture
\inmodule QtMultimedia
static Q_INVOKABLE QList< QCapturableWindow > capturableWindows()
\qmlmethod list<CapturableWindow> QtMultimedia::WindowCapture::capturableWindows()
QCapturableWindow window
\qmlproperty Window QtMultimedia::WindowCapture::window Describes the window for capturing.
bool active
\qmlproperty bool QtMultimedia::WindowCapture::active Describes whether the capturing is currently ac...
QString errorString
\qmlproperty string QtMultimedia::WindowCapture::errorString Returns a human readable string describi...
bool isActive() const
void setWindow(QCapturableWindow window)
void errorChanged()
void windowChanged(QCapturableWindow window)
Error
\qmltype WindowCapture \instantiates QWindowCapture \inqmlmodule QtMultimedia
~QWindowCapture() override
Destroys the object.
QMediaCaptureSession * captureSession() const
Error error
\qmlproperty enumeration QtMultimedia::WindowCapture::error Returns a code of the last error.
void errorOccurred(QWindowCapture::Error error, const QString &errorString)
Signals when an error occurs, along with the errorString.
QWindowCapture(QObject *parent=nullptr)
Constructs a new QWindowCapture object with parent.
void activeChanged(bool)
void setActive(bool active)
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
#define emit
static QT_BEGIN_NAMESPACE QWindowCapture::Error toWindowCaptureError(QPlatformSurfaceCapture::Error error)
aWidget window() -> setWindowTitle("New Window Title")
[2]