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 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | class QMediaPlayer; |
29 | class QAudioDecoder; |
30 | class QCamera; |
31 | class QScreenCapture; |
32 | class QWindowCapture; |
33 | class QMediaRecorder; |
34 | class QImageCapture; |
35 | class QMediaDevices; |
36 | class QPlatformMediaDevices; |
37 | class QPlatformMediaCaptureSession; |
38 | class QPlatformMediaPlayer; |
39 | class QPlatformAudioDecoder; |
40 | class QPlatformCamera; |
41 | class QPlatformSurfaceCapture; |
42 | class QPlatformMediaRecorder; |
43 | class QPlatformImageCapture; |
44 | class QPlatformMediaFormatInfo; |
45 | class QObject; |
46 | class QPlatformVideoSink; |
47 | class QVideoSink; |
48 | class QAudioInput; |
49 | class QAudioOutput; |
50 | class QPlatformAudioInput; |
51 | class QPlatformAudioOutput; |
52 | class QPlatformVideoDevices; |
53 | class QCapturableWindow; |
54 | class QPlatformCapturableWindows; |
55 | |
56 | class Q_MULTIMEDIA_EXPORT QPlatformMediaIntegration |
57 | { |
58 | inline static const QString notAvailable = QStringLiteral("Not available"); |
59 | public: |
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 | |
87 | protected: |
88 | virtual QPlatformMediaFormatInfo *createFormatInfo(); |
89 | |
90 | private: |
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 | |
97 | protected: |
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 | |
105 | QT_END_NAMESPACE |
106 | |
107 | |
108 | #endif // QPLATFORMMEDIAINTERFACE_H |
109 |