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