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
qwasmscreencapture.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
"qwasmscreencapture_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(qLcWasmsSreenCapture,
"qt.multimedia.wasm.screencapture"
)
14
15
QWasmScreenCapture::QWasmScreenCapture(QScreenCapture *screenCap)
16
: QPlatformSurfaceCapture(ScreenSource{})
17
{
18
m_screenCapture = screenCap;
19
}
20
21
QWasmScreenCapture
::~
QWasmScreenCapture
() =
default
;
22
23
QVideoFrameFormat
QWasmScreenCapture
::
frameFormat
()
const
24
{
25
return
{};
26
}
27
28
bool
QWasmScreenCapture
::
setActiveInternal
(
bool
active)
29
{
30
if
(active)
31
m_captureSession->setVideoSource(
"monitor"
);
32
else
33
m_captureSession->setVideoSource(
""
);
34
return
true
;
35
}
36
37
void
QWasmScreenCapture
::
setCaptureSession
(QPlatformMediaCaptureSession *session)
38
{
39
m_captureSession =
static_cast
<QWasmMediaCaptureSession *>(session);
40
}
41
42
void
QWasmScreenCapture
::
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
return
;
48
}
49
emscripten::val videoSettings = videoTracks[0].call<emscripten::val>(
"getSettings"
);
50
float
pixelRatio = emscripten::val::global(
"window"
)[
"devicePixelRatio"
].as<
float
>();
51
52
if
(!videoSettings.isNull() || !videoSettings.isUndefined()) {
53
// double fRate = videoSettings["frameRate"].as<double>(); TODO
54
int
width =
static_cast
<
int
>(videoSettings[
"width"
].as<
int
>() / pixelRatio);
55
int
height =
static_cast
<
int
>(videoSettings[
"height"
].as<
int
>() / pixelRatio);
56
57
QSize initialSize(width, height);
58
QRect initialRect(QPoint(0, 0),initialSize);
59
60
m_videoOutput->updateVideoElementGeometry(initialRect);
61
}
62
63
emscripten::val videoElement = m_videoOutput->currentVideoElement();
64
if
(videoElement.isUndefined()) {
65
qWarning() <<
"Could not find video element"
;
66
return
;
67
}
68
videoElement.set(
"srcObject"
, stream);
69
m_videoOutput
->
start
(
)
;
70
}
71
}
72
73
void
QWasmScreenCapture
::
setVideoOutput
(
QWasmVideoOutput
*object)
74
{
75
if
(object)
76
m_videoOutput = object;
77
}
78
79
QT_END_NAMESPACE
QWasmScreenCapture
Definition
qwasmscreencapture_p.h:32
QWasmScreenCapture::setVideoOutput
void setVideoOutput(QWasmVideoOutput *output)
Definition
qwasmscreencapture.cpp:73
QWasmScreenCapture::setCaptureSession
void setCaptureSession(QPlatformMediaCaptureSession *session) override
Definition
qwasmscreencapture.cpp:37
QWasmScreenCapture::~QWasmScreenCapture
~QWasmScreenCapture()
QWasmScreenCapture::frameFormat
QVideoFrameFormat frameFormat() const override
Definition
qwasmscreencapture.cpp:23
QWasmScreenCapture::setActiveInternal
bool setActiveInternal(bool) override
Definition
qwasmscreencapture.cpp:28
QWasmScreenCapture::setVideoStream
void setVideoStream(emscripten::val stream)
Definition
qwasmscreencapture.cpp:42
QWasmVideoOutput
Definition
qwasmvideooutput_p.h:41
QWasmVideoOutput::start
void start()
Definition
qwasmvideooutput.cpp:166
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtmultimedia
src
plugins
multimedia
wasm
mediacapture
qwasmscreencapture.cpp
Generated on
for Qt by
1.18.0