Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qplatformsurfacecapture_p.h
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
4
#
ifndef
QPLATFORMSURFACECAPTURE_H
5
#
define
QPLATFORMSURFACECAPTURE_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtMultimedia
/
private
/
qerrorinfo_p
.
h
>
19
#
include
<
QtMultimedia
/
private
/
qplatformvideosource_p
.
h
>
20
#
include
<
QtMultimedia
/
qcapturablewindow
.
h
>
21
#
include
<
QtGui
/
qscreen
.
h
>
22
#
include
<
QtCore
/
qpointer
.
h
>
23
#
include
<
QtCore
/
private
/
qexpected_p
.
h
>
24
25
#
include
<
optional
>
26
#
include
<
variant
>
27
28
QT_BEGIN_NAMESPACE
29
30
class
QVideoFrame;
31
32
class
Q_MULTIMEDIA_EXPORT
QPlatformSurfaceCapture
:
public
QPlatformVideoSource
33
{
34
Q_OBJECT
35
36
public
:
37
enum
class
Error {
38
NoError = 0,
39
InternalError = 1,
40
CapturingNotSupported = 2,
41
CaptureFailed = 4,
42
NotFound = 5,
43
};
44
45
using
ScreenSource = QPointer<QScreen>;
46
using
WindowSource = QCapturableWindow;
47
48
using
Source = std::variant<ScreenSource, WindowSource>;
49
50
struct
ErrorDetails
51
{
52
Error error = Error::InternalError;
53
// Description is user-facing. Emitted in errorOccurred.
54
QString description;
55
};
56
using
SourceSwitchResult = q23::expected<
void
, ErrorDetails>;
57
58
explicit
QPlatformSurfaceCapture(Source initialSource);
59
60
// When capturing a Window, we should never include the drop shadow of that Window.
61
// Ideally, when configured with QCapturableWindow constructed from a QWindow,
62
// our output frames should always have sizes matching that QWindow.
63
//
64
// If the property ignoreCursor() is set to true, we should provide a hint for the backend
65
// to not capture the cursor if possible.
66
//
67
// This method must be implemented as blocking. If the function fails for some reason,
68
// the error property can not be set to NoError.
69
void
setActive(
bool
active) override;
70
bool
isActive()
const
override;
71
72
// Changes the source. If we are active, the new source is captured right away,
73
// see switchActiveSource(). If that fails, we go inactive and report the error.
74
void
setSource(Source source);
75
76
template
<
typename
Type>
77
Type source()
const
{
78
Q_ASSERT(std::holds_alternative<Type>(m_source));
79
return
*std::get_if<Type>(&m_source);
80
}
81
82
Source source()
const
{
return
m_source; }
83
84
Error error()
const
;
85
QString errorString()
const
final;
86
87
void
setFrameRate(std::optional<qreal>);
88
[[nodiscard]] std::optional<qreal> frameRate()
const
;
89
90
void
setIgnoreCursor(
bool
);
91
// Applied on next stream start.
92
[[nodiscard]]
bool
ignoreCursor()
const
;
93
94
protected
:
95
virtual
bool
setActiveInternal(
bool
) = 0;
96
97
// Switches an active capture over to newSource, which is always of the same kind
98
// as the current source (window to window, or screen to screen).
99
//
100
// Presentation times must keep increasing across the switch.
101
//
102
// The implementatiom must not emit an end-of-stream frame when the switch occurs.
103
//
104
// This function blocks until the switch is complete. Preferably, no frames of
105
// the old source are emitted after it returns.
106
//
107
// If the switch fails, the implementation may tear its resources down immediately
108
// before returning.
109
[[nodiscard]]
virtual
std::optional<SourceSwitchResult>
110
switchActiveSource(
const
Source &newSource);
111
112
bool
checkScreenWithError(ScreenSource &screen);
113
114
public
Q_SLOTS:
115
void
updateError(Error error,
const
QString &errorString);
116
117
Q_SIGNALS:
118
void
sourceChanged(WindowSource);
119
void
sourceChanged(ScreenSource);
120
void
errorOccurred(Error error, QString errorString);
121
void
frameRateChanged(std::optional<qreal>);
122
123
private
:
124
std::optional<qreal> m_frameRate;
125
QErrorInfo<Error> m_error;
126
Source m_source;
127
bool
m_active =
false
;
128
129
// While not part of public API, this setting tends to impact
130
// integration tests.
131
bool
m_ignoreCursor =
false
;
132
};
133
134
QT_END_NAMESPACE
135
136
#
endif
// QPLATFORMSURFACECAPTURE_H
QPlatformSurfaceCapture
Definition
qplatformsurfacecapture_p.h:33
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtmultimedia
src
multimedia
platform
qplatformsurfacecapture_p.h
Generated on
for Qt by
1.18.0