Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qplatformsurfacecapture.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 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
5#include "qvideoframe.h"
6#include "qguiapplication.h"
7#include "qdebug.h"
8
10
11QPlatformSurfaceCapture::QPlatformSurfaceCapture(Source initialSource) : m_source(initialSource)
12{
13 Q_ASSERT(std::visit([](auto source) { return source == decltype(source){}; }, initialSource));
14 qRegisterMetaType<QVideoFrame>();
15}
16
18{
19 if (m_active == active)
20 return;
21
22 if (!setActiveInternal(active))
23 return;
24
25 m_active = active;
26 emit activeChanged(active);
27}
28
30{
31 return m_active;
32}
33
35{
36 Q_ASSERT(source.index() == m_source.index());
37
38 if (m_source == source)
39 return;
40
41 if (m_active)
42 setActiveInternal(false);
43
44 m_source = source;
45
46 if (m_active && !setActiveInternal(true)) {
47 m_active = false;
48 emit activeChanged(false);
49 }
50
51 std::visit([this](auto source) { emit sourceChanged(source); }, m_source);
52}
53
55{
56 return m_error;
57}
58
60{
61 return m_errorString;
62}
63
65{
66 bool changed = error != m_error || errorString != m_errorString;
67 m_error = error;
68 m_errorString = errorString;
69 if (changed) {
70 if (m_error != NoError) {
72 qWarning() << "Screen capture fail:" << error << "," << errorString;
73 }
74
76 }
77}
78
80{
81 if (!screen)
83
84 if (screen)
85 return true;
86
87 updateError(NotFound, QLatin1String("No screens found"));
88 return false;
89}
90
92
93#include "moc_qplatformsurfacecapture_p.cpp"
QScreen * primaryScreen
the primary (or default) screen of the application.
void errorOccurred(Error error, QString errorString)
void sourceChanged(WindowSource)
void updateError(Error error, const QString &errorString)
std::variant< ScreenSource, WindowSource > Source
void setActive(bool active) override
virtual bool setActiveInternal(bool)=0
QPlatformSurfaceCapture(Source initialSource)
bool checkScreenWithError(ScreenSource &screen)
void activeChanged(bool)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
#define qWarning
Definition qlogging.h:162
GLsizei GLsizei GLchar * source
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
QScreen * screen
[1]
Definition main.cpp:29
#define emit