5#include "private/qcameradevice_p.h"
43 getOpenALAudioDevices();
49 return m_audioInputs.
values();
54 return m_audioOutputs.
values();
59 return m_cameraDevices.
values();
74void QWasmMediaDevices::getMediaDevices()
76 emscripten::val navigator = emscripten::val::global(
"navigator");
77 m_jsMediaDevicesInterface = navigator[
"mediaDevices"];
79 if (m_jsMediaDevicesInterface.isNull() || m_jsMediaDevicesInterface.isUndefined()) {
80 qWarning() <<
"No media devices found";
88 qWarning() <<
"Something went wrong enumerating devices";
96 m_videoInputsAdded =
false;
97 m_audioInputsAdded =
false;
98 m_audioOutputsAdded =
false;
100 bool m_videoInputsRemoved =
false;
101 bool m_audioInputsRemoved =
false;
102 bool m_audioOutputsRemoved =
false;
104 for (
int i = 0;
i <
devices[
"length"].as<
int>();
i++) {
106 emscripten::val mediaDevice =
devices[
i];
108 std::string defaultDeviceLabel =
"";
110 const std::string deviceKind = mediaDevice[
"kind"].as<std::string>();
111 const std::string
label = mediaDevice[
"label"].as<std::string>();
112 const std::string deviceId = mediaDevice[
"deviceId"].as<std::string>();
118 if (deviceKind.empty())
121 if (deviceId == std::string(
"default")) {
128 defaultDeviceLabel =
label;
132 const bool isDefault =
133 (defaultDeviceLabel.find(
label) != std::string::npos);
135 if (deviceKind == std::string(
"videoinput")) {
136 if (!m_cameraDevices.
contains(deviceId)) {
140 camera->isDefault = isDefault;
143 m_videoInputsAdded =
true;
145 cameraDevicesToRemove.
removeOne(deviceId);
147 }
else if (deviceKind == std::string(
"audioinput")) {
148 if (!m_audioInputs.
contains(deviceId)) {
149 m_audioInputs.
insert(deviceId,
154 m_audioInputsAdded =
true;
157 }
else if (deviceKind == std::string(
"audiooutput")) {
158 if (!m_audioOutputs.
contains(deviceId)) {
159 m_audioOutputs.
insert(deviceId,
164 m_audioOutputsAdded =
true;
166 audioOutputsToRemove.
removeOne(deviceId);
174 for (;
j < cameraDevicesToRemove.
count();
j++) {
175 m_cameraDevices.
remove(cameraDevicesToRemove.
at(
j));
177 m_videoInputsRemoved = !cameraDevicesToRemove.
isEmpty();
179 for (
j = 0;
j < audioInputsToRemove.
count();
j++) {
180 m_audioInputs.
remove(audioInputsToRemove.
at(
j));
182 m_audioInputsRemoved = !audioInputsToRemove.
isEmpty();
184 for (
j = 0;
j < audioOutputsToRemove.
count();
j++) {
185 m_audioOutputs.
remove(audioOutputsToRemove.
at(
j));
187 m_audioOutputsRemoved = !audioOutputsToRemove.
isEmpty();
189 if (m_videoInputsAdded || m_videoInputsRemoved)
191 if (m_audioInputsAdded || m_audioInputsRemoved)
193 if (m_audioOutputsAdded || m_audioOutputsRemoved)
198 [
this](emscripten::val
error) {
199 qWarning() <<
"mediadevices enumerateDevices fail"
208 std::move(enumerateDevicesCallback));
211 m_deviceChangedCallback = std::make_unique<qstdweb::EventCallback>(
212 m_jsMediaDevicesInterface,
"devicechange",
213 [
this, enumerateDevicesCallback](emscripten::val) {
216 std::move(enumerateDevicesCallback));
220void QWasmMediaDevices::getOpenALAudioDevices()
224 auto capture = alcGetString(
nullptr, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
226 if (capture && !m_audioOutputs.
contains(capture)) {
227 m_audioInputs.
insert(capture,
234 auto playback = alcGetString(
nullptr, ALC_DEFAULT_DEVICE_SPECIFIER);
236 if (playback && !m_audioOutputs.
contains(capture)) {
237 m_audioOutputs.
insert(playback,
The QAudioDevice class provides an information about audio devices and their functionality.
QByteArray id
\qmlproperty string QtMultimedia::audioDevice::id
bool isEmpty() const noexcept
bool removeOne(const AT &t)
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
iterator insert(const Key &key, const T &value)
bool contains(const Key &key) const
QList< T > values() const
size_type remove(const Key &key)
QList< Key > keys() const
QObject * parent() const
Returns a pointer to the parent object.
static QString fromStdString(const std::string &s)
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QByteArray toUtf8() const &
QList< QCameraDevice > videoDevices() const override
Combined button and popup list for selecting options.
void make(emscripten::val target, QString methodName, PromiseCallbacks callbacks, Args... args)
DBusConnection const char DBusError * error
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLuint GLsizei const GLchar * label
[43]
#define QStringLiteral(str)
std::function< void(emscripten::val)> thenFunc
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent