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
15
16class QMediaCaptureSession;
17class QPlatformSurfaceCapture;
19
20class Q_MULTIMEDIA_EXPORT QScreenCapture : public QObject
21{
22 Q_OBJECT
23 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
24 Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
25 Q_PROPERTY(Error error READ error NOTIFY errorChanged)
26 Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
27 Q_PROPERTY(std::optional<qreal> frameRate READ frameRate WRITE setFrameRate RESET resetFrameRate NOTIFY frameRateChanged)
28
29public:
30 enum Error {
31 NoError = 0,
32 InternalError = 1,
33 CapturingNotSupported = 2,
34 CaptureFailed = 4,
35 NotFound = 5,
36 };
37 Q_ENUM(Error)
38
39 explicit QScreenCapture(QObject *parent = nullptr);
40 ~QScreenCapture() override;
41
42 QMediaCaptureSession *captureSession() const;
43
44 void setScreen(QScreen *screen);
45 QScreen *screen() const;
46
47 bool isActive() const;
48
49 Error error() const;
50 QString errorString() const;
51
52 void setFrameRate(std::optional<qreal> preferredFrameRate);
53 std::optional<qreal> frameRate() const;
54 void resetFrameRate();
55
56public Q_SLOTS:
57 void setActive(bool active);
58 void start() { setActive(true); }
59 void stop() { setActive(false); }
60
61Q_SIGNALS:
62 void activeChanged(bool);
63 void errorChanged();
64 void screenChanged(QScreen *);
65 void errorOccurred(QScreenCapture::Error error, const QString &errorString);
66 void frameRateChanged();
67
68private:
69 void setCaptureSession(QMediaCaptureSession *captureSession);
70 QPlatformSurfaceCapture *platformScreenCapture() const;
71 friend class QMediaCaptureSession;
72 Q_DISABLE_COPY(QScreenCapture)
73 Q_DECLARE_PRIVATE(QScreenCapture)
74};
75
76QT_END_NAMESPACE
77
78#endif // QSCREENCAPTURE_H
QPointer< QAudioBufferInput > audioBufferInput
QPointer< QVideoFrameInput > videoFrameInput
QPointer< QImageCapture > imageCapture
void setVideoSink(QVideoSink *sink)
static QMediaCaptureSessionPrivate * get(QMediaCaptureSession *session)
QPointer< QScreenCapture > screenCapture
QPointer< QWindowCapture > windowCapture
QPointer< QMediaRecorder > recorder
\inmodule QtMultimedia
Combined button and popup list for selecting options.