Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qwasmcapturablewindows.cpp
Go to the documentation of this file.
1
// Copyright (C) 2024 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
"qwasmcapturablewindows_p.h"
5
6
#
include
<
QtMultimedia
/
private
/
qcapturablewindow_p
.
h
>
7
#
include
<
QtGui
/
qguiapplication
.
h
>
8
#
include
<
QtGui
/
qwindow
.
h
>
9
#
include
<
QtCore
/
qdebug
.
h
>
10
#
include
<
QtCore
/
quuid
.
h
>
11
#
include
<
QtCore
/
private
/
qstdweb_p
.
h
>
12
13
QT_BEGIN_NAMESPACE
14
15
QWasmCapturableWindows::QWasmCapturableWindows()
16
{
17
m_capurableWindows.push_back(QCapturableWindowPrivate::create(
18
static_cast
<QCapturableWindowPrivate::Id>(111),
19
QStringLiteral(
"Any Window"
)));
20
}
21
22
QList<QCapturableWindow> QWasmCapturableWindows::windows()
const
23
{
24
return
m_capurableWindows;
25
}
26
27
void
QWasmCapturableWindows::getDisplayMedia()
28
{
29
// populate windows from getDisplayMedia which includes windows from host platform.
30
31
emscripten::val navigator = emscripten::val::global(
"navigator"
);
32
emscripten::val mediaDevices = navigator[
"mediaDevices"
];
33
34
if
(mediaDevices.isNull() || mediaDevices.isUndefined()) {
35
qWarning() <<
"No media devices found"
;
36
return
;
37
}
38
39
emscripten::val constraints = emscripten::val::object();
40
41
constraints.set(
"video"
,
true
);
42
constraints.set(
"selfBrowserSurface"
, std::string(
"include"
));
43
44
// will ask for permissions!
45
qstdweb::PromiseCallbacks getDisplayMediaCallback{
46
// default
47
.thenFunc =
48
[
this
](emscripten::val stream) {
49
QUuid uid(QString::fromStdString(stream[
"id"
].as<std::string>()));
50
51
m_capurableWindows.push_back(QCapturableWindowPrivate::create(
52
static_cast
<QCapturableWindowPrivate::Id>(uid.toByteArray().toLong()),
53
QString::fromStdString(stream[
"id"
].as<std::string>())));
54
},
55
.catchFunc =
56
[](emscripten::val) {
57
},
58
.finallyFunc =
nullptr
59
};
60
qstdweb::Promise::make(mediaDevices, QStringLiteral(
"getDisplayMedia"
),
61
std::move(getDisplayMediaCallback), constraints);
62
}
63
64
bool
QWasmCapturableWindows::isWindowValid(
const
QCapturableWindowPrivate &)
const
65
{
66
return
m_capurableWindows.count() > 0;
67
}
68
69
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtmultimedia
src
plugins
multimedia
wasm
mediacapture
qwasmcapturablewindows.cpp
Generated on
for Qt by
1.18.0