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