Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qscreencapture.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 QSCREENCAPTURE_H
5#define QSCREENCAPTURE_H
6
7#include <QtCore/qobject.h>
8#include <QtCore/qnamespace.h>
9#include <QtGui/qscreen.h>
10#include <QtGui/qwindow.h>
11#include <QtGui/qwindowdefs.h>
12#include <QtMultimedia/qtmultimediaglobal.h>
13
14#include <optional>
15
16QT_BEGIN_NAMESPACE
17
18class QMediaCaptureSession;
19class QPlatformSurfaceCapture;
21
22class Q_MULTIMEDIA_EXPORT QScreenCapture : public QObject
23{
24 Q_OBJECT
25 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
26 Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
27 Q_PROPERTY(Error error READ error NOTIFY errorChanged)
28 Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
29 Q_PROPERTY(std::optional<qreal> maximumFrameRate READ maximumFrameRate WRITE setMaximumFrameRate
30 RESET resetMaximumFrameRate NOTIFY maximumFrameRateChanged REVISION(6, 12))
31
32public:
33 enum Error {
34 NoError = 0,
35 InternalError = 1,
36 CapturingNotSupported = 2,
37 CaptureFailed = 4,
38 NotFound = 5,
39 };
40 Q_ENUM(Error)
41
42 explicit QScreenCapture(QObject *parent = nullptr);
43 ~QScreenCapture() override;
44
45 QMediaCaptureSession *captureSession() const;
46
47 void setScreen(QScreen *screen);
48 QScreen *screen() const;
49
50 bool isActive() const;
51
52 Error error() const;
53 QString errorString() const;
54
55 void setMaximumFrameRate(std::optional<qreal> frameRate);
56 std::optional<qreal> maximumFrameRate() const;
57 void resetMaximumFrameRate();
58
59public Q_SLOTS:
60 void setActive(bool active);
61 void start() { setActive(true); }
62 void stop() { setActive(false); }
63
64Q_SIGNALS:
65 void activeChanged(bool);
66 void errorChanged();
67 void screenChanged(QScreen *);
68 void errorOccurred(QScreenCapture::Error error, const QString &errorString);
69 Q_REVISION(6, 12) void maximumFrameRateChanged();
70
71private:
72 void setCaptureSession(QMediaCaptureSession *captureSession);
73 QPlatformSurfaceCapture *platformScreenCapture() const;
74 friend class QMediaCaptureSession;
75 Q_DISABLE_COPY(QScreenCapture)
76 Q_DECLARE_PRIVATE(QScreenCapture)
77};
78
79QT_END_NAMESPACE
80
81#endif // QSCREENCAPTURE_H
QPlatformMediaRecorder * control
QMediaCaptureSession * captureSession
QMediaEncoderSettings encoderSettings
static QString msgFailedStartRecording()
QObject * q_ptr
Definition qobject.h:73
\inmodule QtMultimedia