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
qwindowcapture.h
Go to the documentation of this file.
1// Copyright (C) 2023 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 QWINDOWCAPTURE_H
5#define QWINDOWCAPTURE_H
6
7#include <QtMultimedia/qtmultimediaexports.h>
8#include <QtMultimedia/qcapturablewindow.h>
9#include <QtCore/qobject.h>
10#include <QtCore/qlist.h>
11
12#include <optional>
13
15
16class QPlatformSurfaceCapture;
17
18class Q_MULTIMEDIA_EXPORT QWindowCapture : public QObject
19{
20 Q_OBJECT
21 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
22 Q_PROPERTY(QCapturableWindow window READ window WRITE setWindow NOTIFY windowChanged)
23 Q_PROPERTY(Error error READ error NOTIFY errorChanged)
24 Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
25 Q_PROPERTY(std::optional<qreal> maximumFrameRate READ maximumFrameRate WRITE setMaximumFrameRate
26 RESET resetMaximumFrameRate NOTIFY maximumFrameRateChanged REVISION(6, 12))
27
28public:
29 enum Error {
30 NoError = 0,
31 InternalError = 1,
32 CapturingNotSupported = 2,
33 CaptureFailed = 4,
34 NotFound = 5,
35 };
36 Q_ENUM(Error)
37
38 explicit QWindowCapture(QObject *parent = nullptr);
39 ~QWindowCapture() override;
40
41 Q_INVOKABLE static QList<QCapturableWindow> capturableWindows();
42
43 QMediaCaptureSession *captureSession() const;
44
45 void setWindow(QCapturableWindow window);
46
47 QCapturableWindow window() const;
48
49 bool isActive() const;
50
51 Error error() const;
52 QString errorString() const;
53
54 void setMaximumFrameRate(std::optional<qreal> frameRate);
55 std::optional<qreal> maximumFrameRate() const;
56 void resetMaximumFrameRate();
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 windowChanged(QCapturableWindow window);
66 void errorChanged();
67 void errorOccurred(QWindowCapture::Error error, const QString &errorString);
68 Q_REVISION(6, 12) void maximumFrameRateChanged();
69
70private:
71 void setCaptureSession(QMediaCaptureSession *captureSession);
72 QPlatformSurfaceCapture *platformWindowCapture() const;
74 friend class QMediaCaptureSession;
75 Q_DISABLE_COPY(QWindowCapture)
76 Q_DECLARE_PRIVATE(QWindowCapture)
77};
78
79QT_END_NAMESPACE
80
81#endif // QWINDOWCAPTURE_H
QPlatformMediaRecorder * control
QMediaCaptureSession * captureSession
QMediaEncoderSettings encoderSettings
static QString msgFailedStartRecording()
QObject * q_ptr
Definition qobject.h:73
\inmodule QtMultimedia
\inmodule QtMultimedia
Combined button and popup list for selecting options.