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
qplatformsurfacecapture_p.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 QPLATFORMSURFACECAPTURE_H
5#define QPLATFORMSURFACECAPTURE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qpointer.h>
19#include <QtGui/qscreen.h>
20#include <QtMultimedia/qcapturablewindow.h>
21#include <QtMultimedia/private/qerrorinfo_p.h>
22#include <QtMultimedia/private/qplatformvideosource_p.h>
23
24#include <variant>
25
26QT_BEGIN_NAMESPACE
27
28class QVideoFrame;
29
30class Q_MULTIMEDIA_EXPORT QPlatformSurfaceCapture : public QPlatformVideoSource
31{
32 Q_OBJECT
33
34public:
35 enum Error {
36 NoError = 0,
37 InternalError = 1,
38 CapturingNotSupported = 2,
39 CaptureFailed = 4,
40 NotFound = 5,
41 };
42
43 using ScreenSource = QPointer<QScreen>;
44 using WindowSource = QCapturableWindow;
45
46 using Source = std::variant<ScreenSource, WindowSource>;
47
48 explicit QPlatformSurfaceCapture(Source initialSource);
49
50 void setActive(bool active) override;
51 bool isActive() const override;
52
53 void setSource(Source source);
54
55 template<typename Type>
56 Type source() const {
57 Q_ASSERT(std::holds_alternative<Type>(m_source));
58 return *std::get_if<Type>(&m_source);
59 }
60
61 Source source() const { return m_source; }
62
63 Error error() const;
64 QString errorString() const final;
65
66protected:
67 virtual bool setActiveInternal(bool) = 0;
68
69 bool checkScreenWithError(ScreenSource &screen);
70
71public Q_SLOTS:
72 void updateError(Error error, const QString &errorString);
73
74Q_SIGNALS:
75 void sourceChanged(WindowSource);
76 void sourceChanged(ScreenSource);
77 void errorOccurred(Error error, QString errorString);
78
79private:
80 QErrorInfo<Error> m_error;
81 Source m_source;
82 bool m_active = false;
83};
84
85QT_END_NAMESPACE
86
87#endif // QPLATFORMSURFACECAPTURE_H
Combined button and popup list for selecting options.