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
qplatformmediaintegration_p.h
Go to the documentation of this file.
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 <QtMultimedia/private/qmultimediautils_p.h>
18#include <QtMultimedia/private/qtmultimediaglobal_p.h>
19#include <QtMultimedia/qcapturablewindow.h>
20#include <QtMultimedia/qmediarecorder.h>
21#include <QtCore/private/qexpected_p.h>
22#include <QtCore/qobject.h>
23#include <QtCore/qstring.h>
24
25#include <memory>
26#include <mutex>
27
28QT_BEGIN_NAMESPACE
29
30class QAudioDecoder;
31class QAudioFormat;
32class QAudioInput;
33class QAudioOutput;
34class QCamera;
35class QCameraDevice;
37class QImageCapture;
38class QMediaDevices;
39class QMediaPlayer;
40class QMediaRecorder;
41class QPlatformAudioDecoder;
42class QPlatformAudioDevices;
43class QPlatformAudioInput;
44class QPlatformAudioOutput;
45class QPlatformAudioResampler;
46class QPlatformCamera;
48class QPlatformImageCapture;
49class QPlatformMediaCaptureSession;
50class QPlatformMediaFormatInfo;
51class QPlatformMediaPlayer;
52class QPlatformMediaRecorder;
53class QPlatformSurfaceCapture;
54class QPlatformVideoDevices;
55class QPlatformVideoSink;
56class QScreenCapture;
57class QVideoFrame;
58class QVideoSink;
59class QWindowCapture;
60
61class Q_MULTIMEDIA_EXPORT QAbstractPlatformSpecificInterface
62{
63public:
64 virtual ~QAbstractPlatformSpecificInterface() = default;
65};
66
67class Q_MULTIMEDIA_EXPORT QPlatformMediaIntegration : public QObject
68{
69 Q_OBJECT
70public:
71 static QPlatformMediaIntegration *instance();
72
73 explicit QPlatformMediaIntegration(QLatin1String);
74 ~QPlatformMediaIntegration() override;
75 const QPlatformMediaFormatInfo *formatInfo();
76
77 virtual q23::expected<QPlatformCamera *, QString> createCamera(QCamera *)
78 {
79 return q23::unexpected{ notAvailable };
80 }
81 virtual QPlatformSurfaceCapture *createScreenCapture(QScreenCapture *) { return nullptr; }
82 virtual QPlatformSurfaceCapture *createWindowCapture(QWindowCapture *) { return nullptr; }
83
84 virtual q23::expected<QPlatformAudioDecoder *, QString> createAudioDecoder(QAudioDecoder *)
85 {
86 return q23::unexpected{ notAvailable };
87 }
88 virtual q23::expected<std::unique_ptr<QPlatformAudioResampler>, QString>
89 createAudioResampler(const QAudioFormat & /*inputFormat*/,
90 const QAudioFormat & /*outputFormat*/);
91 virtual q23::expected<QPlatformMediaCaptureSession *, QString> createCaptureSession()
92 {
93 return q23::unexpected{ notAvailable };
94 }
95 virtual q23::expected<QPlatformMediaPlayer *, QString> createPlayer(QMediaPlayer *)
96 {
97 return q23::unexpected{ notAvailable };
98 }
99 virtual q23::expected<QPlatformMediaRecorder *, QString> createRecorder(QMediaRecorder *)
100 {
101 return q23::unexpected{ notAvailable };
102 }
103 virtual q23::expected<QPlatformImageCapture *, QString> createImageCapture(QImageCapture *)
104 {
105 return q23::unexpected{ notAvailable };
106 }
107
108 virtual q23::expected<QPlatformAudioInput *, QString> createAudioInput(QAudioInput *);
109 virtual q23::expected<QPlatformAudioOutput *, QString> createAudioOutput(QAudioOutput *);
110
111 virtual q23::expected<QPlatformVideoSink *, QString> createVideoSink(QVideoSink *)
112 {
113 return q23::unexpected{ notAvailable };
114 }
115
116 QList<QCapturableWindow> capturableWindowsList();
117 bool isCapturableWindowValid(const QCapturableWindowPrivate &);
118 [[nodiscard]] q23::expected<QCapturableWindow, QString> capturableWindowFromQWindow(QWindow *);
119
120 QPlatformVideoDevices *videoDevices();
121
122 QPlatformCapturableWindows *capturableWindows();
123
124 QPlatformAudioDevices *audioDevices();
125
126 static QStringList availableBackends();
127 QLatin1String name(); // for unit tests
128
129 // Convert a QVideoFrame to the destination format
130 virtual QVideoFrame convertVideoFrame(QVideoFrame &, const QVideoFrameFormat &);
131
132 virtual QAbstractPlatformSpecificInterface *platformSpecificInterface() { return nullptr; }
133
134 static QLatin1String audioBackendName();
135
136 virtual bool isCameraSwitchingDuringRecordingSupported() const { return true; }
137
138protected:
139 virtual QPlatformMediaFormatInfo *createFormatInfo();
140
141 virtual QPlatformVideoDevices *createVideoDevices() { return nullptr; }
142
143 virtual QPlatformCapturableWindows *createCapturableWindows() { return nullptr; }
144
145 virtual std::unique_ptr<QPlatformAudioDevices> createAudioDevices();
146
147 inline static const QString notAvailable = QStringLiteral("Not available");
148
149private:
150 friend class QMockIntegration;
151 void resetInstance(); // tests only
152
153private:
154 std::unique_ptr<QPlatformVideoDevices> m_videoDevices;
155 std::once_flag m_videoDevicesOnceFlag;
156
157 std::unique_ptr<QPlatformCapturableWindows> m_capturableWindows;
158 std::once_flag m_capturableWindowsOnceFlag;
159
160 mutable std::unique_ptr<QPlatformMediaFormatInfo> m_formatInfo;
161 mutable std::once_flag m_formatInfoOnceFlg;
162
163 std::unique_ptr<QPlatformAudioDevices> m_audioDevices;
164 std::once_flag m_audioDevicesOnceFlag;
165
166 const QLatin1String m_backendName;
167};
168
169QT_END_NAMESPACE
170
171#endif // QPLATFORMMEDIAINTERFACE_H
The QAudioFormat class stores audio stream parameter information.
\inmodule QtMultimedia