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
4#include "qplatformmediadevices_p.h"
5#include "qplatformmediaintegration_p.h"
6#include "qcameradevice.h"
7#include "qaudiosystem_p.h"
8#include "qaudiodevice.h"
9#include "qplatformvideodevices_p.h"
10
11#if defined(Q_OS_ANDROID)
12#include <qandroidmediadevices_p.h>
13#elif defined(Q_OS_DARWIN)
14#include <qdarwinmediadevices_p.h>
15#elif defined(Q_OS_WINDOWS) && QT_CONFIG(wmf)
16#include <qwindowsmediadevices_p.h>
17#elif QT_CONFIG(alsa)
18#include <qalsamediadevices_p.h>
19#elif QT_CONFIG(pulseaudio)
20#include <qpulseaudiomediadevices_p.h>
21#elif defined(Q_OS_QNX)
22#include <qqnxmediadevices_p.h>
23#elif defined(Q_OS_WASM)
24#include <private/qwasmmediadevices_p.h>
25#endif
26
27
28QT_BEGIN_NAMESPACE
29
30std::unique_ptr<QPlatformMediaDevices> QPlatformMediaDevices::create()
31{
32#ifdef Q_OS_DARWIN
33 return std::make_unique<QDarwinMediaDevices>();
34#elif defined(Q_OS_WINDOWS) && QT_CONFIG(wmf)
35 return std::make_unique<QWindowsMediaDevices>();
36#elif defined(Q_OS_ANDROID)
37 return std::make_unique<QAndroidMediaDevices>();
38#elif QT_CONFIG(alsa)
39 return std::make_unique<QAlsaMediaDevices>();
40#elif QT_CONFIG(pulseaudio)
41 return std::make_unique<QPulseAudioMediaDevices>();
42#elif defined(Q_OS_QNX)
43 return std::make_unique<QQnxMediaDevices>();
44#elif defined(Q_OS_WASM)
45 return std::make_unique<QWasmMediaDevices>();
46#else
47 return std::make_unique<QPlatformMediaDevices>();
48#endif
49}
50
51QPlatformMediaDevices::QPlatformMediaDevices() = default;
52
53void QPlatformMediaDevices::initVideoDevicesConnection()
54{
55 // Make sure we are notified if video inputs changed
56 if (const auto videoDevices = QPlatformMediaIntegration::instance()->videoDevices())
57 connect(sender: videoDevices, signal: &QPlatformVideoDevices::videoInputsChanged, context: this,
58 slot: &QPlatformMediaDevices::videoInputsChanged, type: Qt::UniqueConnection);
59}
60
61QPlatformMediaDevices::~QPlatformMediaDevices() = default;
62
63QList<QAudioDevice> QPlatformMediaDevices::audioInputs() const
64{
65 return {};
66}
67
68QList<QAudioDevice> QPlatformMediaDevices::audioOutputs() const
69{
70 return {};
71}
72
73QPlatformAudioSource *QPlatformMediaDevices::createAudioSource(const QAudioDevice &, QObject *)
74{
75 return nullptr;
76}
77QPlatformAudioSink *QPlatformMediaDevices::createAudioSink(const QAudioDevice &, QObject *)
78{
79 return nullptr;
80}
81
82QPlatformAudioSource *QPlatformMediaDevices::audioInputDevice(const QAudioFormat &format,
83 const QAudioDevice &deviceInfo,
84 QObject *parent)
85{
86 QAudioDevice info = deviceInfo;
87 if (info.isNull())
88 info = audioInputs().value(i: 0);
89
90 QPlatformAudioSource* p = !info.isNull() ? createAudioSource(info, parent) : nullptr;
91 if (p)
92 p->setFormat(format);
93 return p;
94}
95
96QPlatformAudioSink *QPlatformMediaDevices::audioOutputDevice(const QAudioFormat &format,
97 const QAudioDevice &deviceInfo,
98 QObject *parent)
99{
100 QAudioDevice info = deviceInfo;
101 if (info.isNull())
102 info = audioOutputs().value(i: 0);
103
104 QPlatformAudioSink* p = !info.isNull() ? createAudioSink(info, parent) : nullptr;
105 if (p)
106 p->setFormat(format);
107 return p;
108}
109
110void QPlatformMediaDevices::prepareAudio() { }
111
112QT_END_NAMESPACE
113
114#include "moc_qplatformmediadevices_p.cpp"
115

Provided by KDAB

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

source code of qtmultimedia/src/multimedia/platform/qplatformmediadevices.cpp