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 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
57public Q_SLOTS:
58 void setActive(bool active);
59 void start() { setActive(true); }
60 void stop() { setActive(false); }
61
62Q_SIGNALS:
63 void activeChanged(bool);
64 void windowChanged(QCapturableWindow window);
65 void errorChanged();
66 void errorOccurred(QWindowCapture::Error error, const QString &errorString);
67 Q_REVISION(6, 12) void maximumFrameRateChanged(std::optional<qreal>);
68
69private:
70 void setCaptureSession(QMediaCaptureSession *captureSession);
71 QPlatformSurfaceCapture *platformWindowCapture() const;
73 friend class QMediaCaptureSession;
74 Q_DISABLE_COPY(QWindowCapture)
75 Q_DECLARE_PRIVATE(QWindowCapture)
76};
77
78QT_END_NAMESPACE
79
80#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.