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
26QT_BEGIN_NAMESPACE
27
28class QAudioDecoder;
29class QAudioFormat;
30class QAudioInput;
31class QAudioOutput;
32class QCamera;
33class QCameraDevice;
34class QCapturableWindow;
35class QImageCapture;
36class QMediaDevices;
37class QMediaPlayer;
38class QMediaRecorder;
39class QObject;
40class QPlatformAudioDecoder;
41class QPlatformAudioDevices;
42class QPlatformAudioInput;
43class QPlatformAudioOutput;
44class QPlatformAudioResampler;
45class QPlatformCamera;
46class QPlatformCapturableWindows;
47class QPlatformImageCapture;
48class QPlatformMediaCaptureSession;
49class QPlatformMediaFormatInfo;
50class QPlatformMediaPlayer;
51class QPlatformMediaRecorder;
52class QPlatformSurfaceCapture;
53class QPlatformVideoDevices;
54class QPlatformVideoSink;
55class QScreenCapture;
56class QVideoFrame;
57class QVideoSink;
58class QWindowCapture;
59
60class Q_MULTIMEDIA_EXPORT QAbstractPlatformSpecificInterface
61{
62public:
63 virtual ~QAbstractPlatformSpecificInterface() = default;
64};
65
66class Q_MULTIMEDIA_EXPORT QPlatformMediaIntegration : public QObject
67{
68 Q_OBJECT
69 inline static const QString notAvailable = QStringLiteral("Not available");
70public:
71 static QPlatformMediaIntegration *instance();
72
73 explicit QPlatformMediaIntegration(QLatin1String);
74 ~QPlatformMediaIntegration() override;
75 const QPlatformMediaFormatInfo *formatInfo();
76
77 virtual QMaybe<QPlatformCamera *> createCamera(QCamera *) { return notAvailable; }
78 virtual QPlatformSurfaceCapture *createScreenCapture(QScreenCapture *) { return nullptr; }
79 virtual QPlatformSurfaceCapture *createWindowCapture(QWindowCapture *) { return nullptr; }
80
81 virtual QMaybe<QPlatformAudioDecoder *> createAudioDecoder(QAudioDecoder *) { return notAvailable; }
82 virtual QMaybe<std::unique_ptr<QPlatformAudioResampler>>
83 createAudioResampler(const QAudioFormat & /*inputFormat*/,
84 const QAudioFormat & /*outputFormat*/);
85 virtual QMaybe<QPlatformMediaCaptureSession *> createCaptureSession() { return notAvailable; }
86 virtual QMaybe<QPlatformMediaPlayer *> createPlayer(QMediaPlayer *) { return notAvailable; }
87 virtual QMaybe<QPlatformMediaRecorder *> createRecorder(QMediaRecorder *) { return notAvailable; }
88 virtual QMaybe<QPlatformImageCapture *> createImageCapture(QImageCapture *) { return notAvailable; }
89
90 virtual QMaybe<QPlatformAudioInput *> createAudioInput(QAudioInput *);
91 virtual QMaybe<QPlatformAudioOutput *> createAudioOutput(QAudioOutput *);
92
93 virtual QMaybe<QPlatformVideoSink *> createVideoSink(QVideoSink *) { return notAvailable; }
94
95 QList<QCapturableWindow> capturableWindowsList();
96 bool isCapturableWindowValid(const QCapturableWindowPrivate &);
97
98 QPlatformVideoDevices *videoDevices();
99
100 QPlatformCapturableWindows *capturableWindows();
101
102 QPlatformAudioDevices *audioDevices();
103
104 static QStringList availableBackends();
105 QLatin1String name(); // for unit tests
106
107 // Convert a QVideoFrame to the destination format
108 virtual QVideoFrame convertVideoFrame(QVideoFrame &, const QVideoFrameFormat &);
109
110 virtual QAbstractPlatformSpecificInterface *platformSpecificInterface() { return nullptr; }
111
112 static QLatin1String audioBackendName();
113
114protected:
115 virtual QPlatformMediaFormatInfo *createFormatInfo();
116
117 virtual QPlatformVideoDevices *createVideoDevices() { return nullptr; }
118
119 virtual QPlatformCapturableWindows *createCapturableWindows() { return nullptr; }
120
121 virtual std::unique_ptr<QPlatformAudioDevices> createAudioDevices();
122
123private:
124 friend class QMockIntegration;
125 void resetInstance(); // tests only
126
127private:
128 std::unique_ptr<QPlatformVideoDevices> m_videoDevices;
129 std::once_flag m_videoDevicesOnceFlag;
130
131 std::unique_ptr<QPlatformCapturableWindows> m_capturableWindows;
132 std::once_flag m_capturableWindowsOnceFlag;
133
134 mutable std::unique_ptr<QPlatformMediaFormatInfo> m_formatInfo;
135 mutable std::once_flag m_formatInfoOnceFlg;
136
137 std::unique_ptr<QPlatformAudioDevices> m_audioDevices;
138 std::once_flag m_audioDevicesOnceFlag;
139
140 const QLatin1String m_backendName;
141};
142
143QT_END_NAMESPACE
144
145
146#endif // QPLATFORMMEDIAINTERFACE_H
147

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtmultimedia/src/multimedia/platform/qplatformmediaintegration_p.h