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
qsurfacecapturegrabber_p.h
Go to the documentation of this file.
1
// Copyright (C) 2021 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
QSURFACECAPTUREGRABBER_P_H
5
#
define
QSURFACECAPTUREGRABBER_P_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
/
qvideoframe
.
h
>
19
#
include
<
QtMultimedia
/
private
/
qplatformsurfacecapture_p
.
h
>
20
#
include
<
QtMultimedia
/
qtmultimediaglobal
.
h
>
21
22
#
include
<
QtCore
/
qmutex
.
h
>
23
24
#
include
<
chrono
>
25
#
include
<
memory
>
26
#
include
<
optional
>
27
28
QT_BEGIN_NAMESPACE
29
30
class
QThread;
31
32
static
constexpr
qreal
DefaultScreenCaptureFrameRate
= 60.f;
33
static
constexpr
qreal
MinScreenCaptureFrameRate
= 1.f;
34
35
class
Q_MULTIMEDIA_EXPORT
QSurfaceCaptureGrabber
:
public
QObject
36
{
37
Q_OBJECT
38
public
:
39
enum
ThreadPolicy {
40
UseCurrentThread,
41
CreateGrabbingThread,
42
};
43
44
~QSurfaceCaptureGrabber() override;
45
46
void
start();
47
void
stop();
48
49
template
<
typename
Object,
typename
Method>
50
void
addFrameCallback(Object *object, Method method)
51
{
52
connect(
this
, &QSurfaceCaptureGrabber::frameGrabbed, object, method,
53
Qt::DirectConnection);
54
}
55
56
void
setFrameRate(std::optional<qreal>);
57
qreal frameRate()
const
;
58
59
// Owning thread before start(), grabbing thread after.
60
qreal activeFrameRate()
const
;
61
62
Q_SIGNALS:
63
void
frameGrabbed(
const
QVideoFrame&);
64
void
errorUpdated(QPlatformSurfaceCapture::Error error,
const
QString &description);
65
66
protected
:
67
QSurfaceCaptureGrabber(ThreadPolicy threadPolicy = CreateGrabbingThread);
68
69
void
updateError(QPlatformSurfaceCapture::Error error,
const
QString &description = {});
70
71
virtual
QVideoFrame grabFrame() = 0;
72
73
void
updateTimerInterval();
74
void
setTimerInterval(std::chrono::nanoseconds interval, quint64 generation);
75
76
virtual
void
initializeGrabbingContext();
77
virtual
void
finalizeGrabbingContext();
78
79
bool
isGrabbingContextInitialized()
const
;
80
81
void
injectContextToGrabbingThread(QObject *context);
82
83
private
:
84
class
GrabbingProfiler;
85
struct
GrabbingContext;
86
class
GrabbingThread;
87
88
mutable
QMutex m_mutex;
89
std::unique_ptr<GrabbingContext> m_context;
90
std::optional<QPlatformSurfaceCapture::Error> m_prevError;
91
std::unique_ptr<QThread> m_thread;
92
std::chrono::nanoseconds m_timerInterval{ 0 };
93
quint64 m_contextGeneration{ 0 };
94
95
qreal m_rate{ DefaultScreenCaptureFrameRate };
96
// Locked in start()/updateTimerInterval(); lock-free on the grabbing thread.
97
qreal m_activeRate{ DefaultScreenCaptureFrameRate };
98
};
99
100
QT_END_NAMESPACE
101
102
#
endif
// QSURFACECAPTUREGRABBER_P_H
QSurfaceCaptureGrabber::GrabbingProfiler
Definition
qsurfacecapturegrabber.cpp:20
QSurfaceCaptureGrabber::GrabbingProfiler::number
qint64 number() const
Definition
qsurfacecapturegrabber.cpp:42
QSurfaceCaptureGrabber::GrabbingProfiler::avgTime
qreal avgTime() const
Definition
qsurfacecapturegrabber.cpp:37
QSurfaceCaptureGrabber::GrabbingProfiler::measure
auto measure()
Definition
qsurfacecapturegrabber.cpp:22
QSurfaceCaptureGrabber
Definition
qsurfacecapturegrabber_p.h:36
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
Q_STATIC_LOGGING_CATEGORY
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
MinScreenCaptureFrameRate
static constexpr qreal MinScreenCaptureFrameRate
Definition
qsurfacecapturegrabber_p.h:33
DefaultScreenCaptureFrameRate
static constexpr qreal DefaultScreenCaptureFrameRate
Definition
qsurfacecapturegrabber_p.h:32
qtmultimedia
src
multimedia
qsurfacecapturegrabber_p.h
Generated on
for Qt by
1.18.0