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 QMediaPlayer;
29class QAudioDecoder;
30class QCamera;
31class QScreenCapture;
32class QWindowCapture;
33class QMediaRecorder;
34class QImageCapture;
35class QMediaDevices;
36class QPlatformMediaDevices;
37class QPlatformMediaCaptureSession;
38class QPlatformMediaPlayer;
39class QPlatformAudioDecoder;
40class QPlatformAudioResampler;
41class QPlatformCamera;
42class QPlatformSurfaceCapture;
43class QPlatformMediaRecorder;
44class QPlatformImageCapture;
45class QPlatformMediaFormatInfo;
46class QObject;
47class QPlatformVideoSink;
48class QVideoSink;
49class QAudioInput;
50class QAudioOutput;
51class QPlatformAudioInput;
52class QPlatformAudioOutput;
53class QPlatformVideoDevices;
54class QCapturableWindow;
55class QPlatformCapturableWindows;
56class QVideoFrame;
57
58class Q_MULTIMEDIA_EXPORT QAbstractPlatformSpecificInterface
59{
60public:
61 virtual ~QAbstractPlatformSpecificInterface() = default;
62};
63
64class Q_MULTIMEDIA_EXPORT QPlatformMediaIntegration : public QObject
65{
66 Q_OBJECT
67 inline static const QString notAvailable = QStringLiteral("Not available");
68public:
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
111protected:
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
120private:
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
136QT_END_NAMESPACE
137
138
139#endif // QPLATFORMMEDIAINTERFACE_H
140

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

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