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 QPlatformCamera;
41class QPlatformSurfaceCapture;
42class QPlatformMediaRecorder;
43class QPlatformImageCapture;
44class QPlatformMediaFormatInfo;
45class QObject;
46class QPlatformVideoSink;
47class QVideoSink;
48class QAudioInput;
49class QAudioOutput;
50class QPlatformAudioInput;
51class QPlatformAudioOutput;
52class QPlatformVideoDevices;
53class QCapturableWindow;
54class QPlatformCapturableWindows;
55
56class Q_MULTIMEDIA_EXPORT QPlatformMediaIntegration
57{
58 inline static const QString notAvailable = QStringLiteral("Not available");
59public:
60 static QPlatformMediaIntegration *instance();
61
62 QPlatformMediaIntegration();
63 virtual ~QPlatformMediaIntegration();
64 const QPlatformMediaFormatInfo *formatInfo();
65
66 virtual QList<QCameraDevice> videoInputs();
67 virtual QMaybe<QPlatformCamera *> createCamera(QCamera *) { return notAvailable; }
68 virtual QPlatformSurfaceCapture *createScreenCapture(QScreenCapture *) { return nullptr; }
69 virtual QPlatformSurfaceCapture *createWindowCapture(QWindowCapture *) { return nullptr; }
70
71 virtual QMaybe<QPlatformAudioDecoder *> createAudioDecoder(QAudioDecoder *) { return notAvailable; }
72 virtual QMaybe<QPlatformMediaCaptureSession *> createCaptureSession() { return notAvailable; }
73 virtual QMaybe<QPlatformMediaPlayer *> createPlayer(QMediaPlayer *) { return notAvailable; }
74 virtual QMaybe<QPlatformMediaRecorder *> createRecorder(QMediaRecorder *) { return notAvailable; }
75 virtual QMaybe<QPlatformImageCapture *> createImageCapture(QImageCapture *) { return notAvailable; }
76
77 virtual QMaybe<QPlatformAudioInput *> createAudioInput(QAudioInput *);
78 virtual QMaybe<QPlatformAudioOutput *> createAudioOutput(QAudioOutput *);
79
80 virtual QMaybe<QPlatformVideoSink *> createVideoSink(QVideoSink *) { return notAvailable; }
81
82 QList<QCapturableWindow> capturableWindows();
83 bool isCapturableWindowValid(const QCapturableWindowPrivate &);
84
85 QPlatformVideoDevices *videoDevices() { return m_videoDevices.get(); }
86
87protected:
88 virtual QPlatformMediaFormatInfo *createFormatInfo();
89
90private:
91 friend class QMockIntegrationFactory;
92 // API to be able to test with a mock backend
93 using Factory = std::function<std::unique_ptr<QPlatformMediaIntegration>()>;
94 struct InstanceHolder;
95 static void setPlatformFactory(Factory factory);
96
97protected:
98 std::unique_ptr<QPlatformVideoDevices> m_videoDevices;
99 std::unique_ptr<QPlatformCapturableWindows> m_capturableWindows;
100
101 mutable std::unique_ptr<QPlatformMediaFormatInfo> m_formatInfo;
102 mutable std::once_flag m_formatInfoOnceFlg;
103};
104
105QT_END_NAMESPACE
106
107
108#endif // QPLATFORMMEDIAINTERFACE_H
109

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