Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
5
8
9#include <QtMultimedia/qmediacapturesession.h>
10
12
13Q_LOGGING_CATEGORY(qLcWasmWindowcapture, "qt.multimedia.wasm.windowcapture")
14
15QWasmWindowCapture::QWasmWindowCapture(QWindowCapture *winCap) :
16 QPlatformSurfaceCapture(WindowSource{})
17{
18 setCaptureSession(dynamic_cast<QPlatformMediaCaptureSession *>(winCap->captureSession()));
19}
20
22
24{
25 return {};
26}
27
29{
30 if (active)
31 m_captureSession->setVideoSource("window");
32 else
33 m_captureSession->setVideoSource("");
34
35 return true;
36}
37void QWasmWindowCapture::setCaptureSession(QPlatformMediaCaptureSession *session)
38{
39 m_captureSession = dynamic_cast<QWasmMediaCaptureSession *>(session);
40}
41
42void 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
72{
73 if (object)
74 m_videoOutput = object;
75}
76
77QT_END_NAMESPACE
QVideoFrameFormat frameFormat() const override
bool setActiveInternal(bool) override
void setCaptureSession(QPlatformMediaCaptureSession *session) override
void setVideoStream(emscripten::val stream)
void setVideoOutput(QWasmVideoOutput *object)
Combined button and popup list for selecting options.