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
qwasmwindowcapture.cpp
Go to the documentation of this file.
1
// Copyright (C) 2022 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
"qwasmwindowcapture_p.h"
5
6
#
include
"qwasmmediacapturesession_p.h"
7
#
include
"qwasmcamera_p.h"
8
9
#
include
<
QtMultimedia
/
qmediacapturesession
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
Q_LOGGING_CATEGORY(qLcWasmWindowcapture,
"qt.multimedia.wasm.windowcapture"
)
14
15
QWasmWindowCapture::QWasmWindowCapture(QWindowCapture *winCap) :
16
QPlatformSurfaceCapture(WindowSource{})
17
{
18
setCaptureSession(
dynamic_cast
<QPlatformMediaCaptureSession *>(winCap->captureSession()));
19
}
20
21
QWasmWindowCapture
::~
QWasmWindowCapture
() =
default
;
22
23
QVideoFrameFormat
QWasmWindowCapture
::
frameFormat
()
const
24
{
25
return
{};
26
}
27
28
bool
QWasmWindowCapture
::
setActiveInternal
(
bool
active)
29
{
30
if
(active)
31
m_captureSession->setVideoSource(
"window"
);
32
else
33
m_captureSession->setVideoSource(
""
);
34
35
return
true
;
36
}
37
void
QWasmWindowCapture
::
setCaptureSession
(QPlatformMediaCaptureSession *session)
38
{
39
m_captureSession =
dynamic_cast
<QWasmMediaCaptureSession *>(session);
40
}
41
42
void
QWasmWindowCapture
::
setVideoStream
(emscripten::val stream)
43
{
44
if
(m_videoOutput) {
45
emscripten::val videoTracks = stream.call<emscripten::val>(
"getVideoTracks"
);
46
if
(videoTracks.isNull() || videoTracks.isUndefined()) {
47
qWarning() << Q_FUNC_INFO <<
"videoTracks is null"
;
48
49
return
;
50
}
51
52
emscripten::val videoSettings = videoTracks[0].call<emscripten::val>(
"getSettings"
);
53
54
if
(!videoSettings.isNull() || !videoSettings.isUndefined()) {
55
int
width = videoSettings[
"width"
].as<
int
>();
56
int
height = videoSettings[
"height"
].as<
int
>();
57
58
QSize initialSize(width, height);
59
QRect initialRect(QPoint(0, 0),initialSize);
60
61
m_videoOutput->updateVideoElementGeometry(initialRect);
62
63
}
64
emscripten::val videoElement = m_videoOutput->currentVideoElement();
65
66
videoElement.set(
"srcObject"
, stream);
67
m_videoOutput
->
start
(
)
;
68
}
69
}
70
71
void
QWasmWindowCapture
::
setVideoOutput
(
QWasmVideoOutput
*object)
72
{
73
if
(object)
74
m_videoOutput = object;
75
}
76
77
QT_END_NAMESPACE
QWasmVideoOutput
Definition
qwasmvideooutput_p.h:41
QWasmVideoOutput::start
void start()
Definition
qwasmvideooutput.cpp:166
QWasmWindowCapture
Definition
qwasmwindowcapture_p.h:35
QWasmWindowCapture::~QWasmWindowCapture
~QWasmWindowCapture()
QWasmWindowCapture::frameFormat
QVideoFrameFormat frameFormat() const override
Definition
qwasmwindowcapture.cpp:23
QWasmWindowCapture::setActiveInternal
bool setActiveInternal(bool) override
Definition
qwasmwindowcapture.cpp:28
QWasmWindowCapture::setCaptureSession
void setCaptureSession(QPlatformMediaCaptureSession *session) override
Definition
qwasmwindowcapture.cpp:37
QWasmWindowCapture::setVideoStream
void setVideoStream(emscripten::val stream)
Definition
qwasmwindowcapture.cpp:42
QWasmWindowCapture::setVideoOutput
void setVideoOutput(QWasmVideoOutput *object)
Definition
qwasmwindowcapture.cpp:71
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtmultimedia
src
plugins
multimedia
wasm
mediacapture
qwasmwindowcapture.cpp
Generated on
for Qt by
1.18.0