1 | // Copyright (C) 2021 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 | #ifndef QPLATFORMMEDIAINTEGRATION_H |
4 | #define QPLATFORMMEDIAINTEGRATION_H |
5 | |
6 | // |
7 | // W A R N I N G |
8 | // ------------- |
9 | // |
10 | // This file is not part of the Qt API. It exists purely as an |
11 | // implementation detail. This header file may change from version to |
12 | // version without notice, or even be removed. |
13 | // |
14 | // We mean it. |
15 | // |
16 | |
17 | #include <private/qtmultimediaglobal_p.h> |
18 | #include <private/qmultimediautils_p.h> |
19 | #include <qcapturablewindow.h> |
20 | #include <qmediarecorder.h> |
21 | #include <qstring.h> |
22 | |
23 | #include <memory> |
24 | #include <mutex> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | class QMediaPlayer; |
29 | class QAudioDecoder; |
30 | class QCamera; |
31 | class QScreenCapture; |
32 | class QWindowCapture; |
33 | class QMediaRecorder; |
34 | class QImageCapture; |
35 | class QMediaDevices; |
36 | class QPlatformMediaDevices; |
37 | class QPlatformMediaCaptureSession; |
38 | class QPlatformMediaPlayer; |
39 | class QPlatformAudioDecoder; |
40 | class QPlatformAudioResampler; |
41 | class QPlatformCamera; |
42 | class QPlatformSurfaceCapture; |
43 | class QPlatformMediaRecorder; |
44 | class QPlatformImageCapture; |
45 | class QPlatformMediaFormatInfo; |
46 | class QObject; |
47 | class QPlatformVideoSink; |
48 | class QVideoSink; |
49 | class QAudioInput; |
50 | class QAudioOutput; |
51 | class QPlatformAudioInput; |
52 | class QPlatformAudioOutput; |
53 | class QPlatformVideoDevices; |
54 | class QCapturableWindow; |
55 | class QPlatformCapturableWindows; |
56 | class QVideoFrame; |
57 | |
58 | class Q_MULTIMEDIA_EXPORT QAbstractPlatformSpecificInterface |
59 | { |
60 | public: |
61 | virtual ~QAbstractPlatformSpecificInterface() = default; |
62 | }; |
63 | |
64 | class Q_MULTIMEDIA_EXPORT QPlatformMediaIntegration : public QObject |
65 | { |
66 | Q_OBJECT |
67 | inline static const QString notAvailable = QStringLiteral("Not available"); |
68 | public: |
69 | static QPlatformMediaIntegration *instance(); |
70 | |
71 | explicit QPlatformMediaIntegration(QLatin1String); |
72 | virtual ~QPlatformMediaIntegration(); |
73 | const QPlatformMediaFormatInfo *formatInfo(); |
74 | |
75 | virtual QList<QCameraDevice> videoInputs(); |
76 | virtual QMaybe<QPlatformCamera *> createCamera(QCamera *) { return notAvailable; } |
77 | virtual QPlatformSurfaceCapture *createScreenCapture(QScreenCapture *) { return nullptr; } |
78 | virtual QPlatformSurfaceCapture *createWindowCapture(QWindowCapture *) { return nullptr; } |
79 | |
80 | virtual QMaybe<QPlatformAudioDecoder *> createAudioDecoder(QAudioDecoder *) { return notAvailable; } |
81 | virtual QMaybe<std::unique_ptr<QPlatformAudioResampler>> |
82 | createAudioResampler(const QAudioFormat & /*inputFormat*/, |
83 | const QAudioFormat & /*outputFormat*/); |
84 | virtual QMaybe<QPlatformMediaCaptureSession *> createCaptureSession() { return notAvailable; } |
85 | virtual QMaybe<QPlatformMediaPlayer *> createPlayer(QMediaPlayer *) { return notAvailable; } |
86 | virtual QMaybe<QPlatformMediaRecorder *> createRecorder(QMediaRecorder *) { return notAvailable; } |
87 | virtual QMaybe<QPlatformImageCapture *> createImageCapture(QImageCapture *) { return notAvailable; } |
88 | |
89 | virtual QMaybe<QPlatformAudioInput *> createAudioInput(QAudioInput *); |
90 | virtual QMaybe<QPlatformAudioOutput *> createAudioOutput(QAudioOutput *); |
91 | |
92 | virtual QMaybe<QPlatformVideoSink *> createVideoSink(QVideoSink *) { return notAvailable; } |
93 | |
94 | QList<QCapturableWindow> capturableWindowsList(); |
95 | bool isCapturableWindowValid(const QCapturableWindowPrivate &); |
96 | |
97 | QPlatformVideoDevices *videoDevices(); |
98 | |
99 | QPlatformCapturableWindows *capturableWindows(); |
100 | |
101 | QPlatformMediaDevices *mediaDevices(); |
102 | |
103 | static QStringList availableBackends(); |
104 | QLatin1String name(); // for unit tests |
105 | |
106 | // Convert a QVideoFrame to the destination format |
107 | virtual QVideoFrame convertVideoFrame(QVideoFrame &, const QVideoFrameFormat &); |
108 | |
109 | virtual QAbstractPlatformSpecificInterface *platformSpecificInterface() { return nullptr; } |
110 | |
111 | protected: |
112 | virtual QPlatformMediaFormatInfo *createFormatInfo(); |
113 | |
114 | virtual QPlatformVideoDevices *createVideoDevices() { return nullptr; } |
115 | |
116 | virtual QPlatformCapturableWindows *createCapturableWindows() { return nullptr; } |
117 | |
118 | virtual std::unique_ptr<QPlatformMediaDevices> createMediaDevices(); |
119 | |
120 | private: |
121 | std::unique_ptr<QPlatformVideoDevices> m_videoDevices; |
122 | std::once_flag m_videoDevicesOnceFlag; |
123 | |
124 | std::unique_ptr<QPlatformCapturableWindows> m_capturableWindows; |
125 | std::once_flag m_capturableWindowsOnceFlag; |
126 | |
127 | mutable std::unique_ptr<QPlatformMediaFormatInfo> m_formatInfo; |
128 | mutable std::once_flag m_formatInfoOnceFlg; |
129 | |
130 | std::unique_ptr<QPlatformMediaDevices> m_mediaDevices; |
131 | std::once_flag m_mediaDevicesOnceFlag; |
132 | |
133 | const QLatin1String m_backendName; |
134 | }; |
135 | |
136 | QT_END_NAMESPACE |
137 | |
138 | |
139 | #endif // QPLATFORMMEDIAINTERFACE_H |
140 |
Definitions
Learn Advanced QML with KDAB
Find out more