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 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
58public Q_SLOTS:
59 void setActive(bool active);
60 void start() { setActive(true); }
61 void stop() { setActive(false); }
62
63Q_SIGNALS:
64 void activeChanged(bool);
65 void errorChanged();
66 void screenChanged(QScreen *);
67 void errorOccurred(QScreenCapture::Error error, const QString &errorString);
68 Q_REVISION(6, 12) void maximumFrameRateChanged(std::optional<qreal>);
69
70private:
71 void setCaptureSession(QMediaCaptureSession *captureSession);
72 QPlatformSurfaceCapture *platformScreenCapture() const;
73 friend class QMediaCaptureSession;
74 Q_DISABLE_COPY(QScreenCapture)
75 Q_DECLARE_PRIVATE(QScreenCapture)
76};
77
78QT_END_NAMESPACE
79
80#endif // QSCREENCAPTURE_H
QPlatformMediaRecorder * control
QMediaCaptureSession * captureSession
QMediaEncoderSettings encoderSettings
static QString msgFailedStartRecording()
QObject * q_ptr
Definition qobject.h:73
\inmodule QtMultimedia