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
9
10#include <QtMultimedia/qmediacapturesession.h>
11
13
14Q_LOGGING_CATEGORY(qLcWasmWindowcapture, "qt.multimedia.wasm.windowcapture")
15
16QWasmWindowCapture::QWasmWindowCapture(QWindowCapture *winCap) :
17 QPlatformSurfaceCapture(WindowSource{})
18{
19 setCaptureSession(dynamic_cast<QPlatformMediaCaptureSession *>(winCap->captureSession()));
20}
21
23
25{
26 return {};
27}
28
30{
31 if (active)
32 m_captureSession->setVideoSource("window");
33 else
34 m_captureSession->setVideoSource("");
35
36 return true;
37}
38void QWasmWindowCapture::setCaptureSession(QPlatformMediaCaptureSession *session)
39{
40 m_captureSession = dynamic_cast<QWasmMediaCaptureSession *>(session);
41}
42
43void QWasmWindowCapture::setVideoStream(emscripten::val stream)
44{
45 if (m_videoOutput) {
46 emscripten::val videoTracks = stream.call<emscripten::val>("getVideoTracks");
47 if (videoTracks.isNull() || videoTracks.isUndefined()) {
48 qWarning() << Q_FUNC_INFO << "videoTracks is null";
49
50 return;
51 }
52
53 emscripten::val videoSettings = videoTracks[0].call<emscripten::val>("getSettings");
54
55 if (!videoSettings.isNull() || !videoSettings.isUndefined()) {
56 int width = videoSettings["width"].as<int>();
57 int height = videoSettings["height"].as<int>();
58
59 QSize initialSize(width, height);
60 QRect initialRect(QPoint(0, 0),initialSize);
61
62 m_videoOutput->updateVideoElementGeometry(initialRect);
63
64 }
65 emscripten::val videoElement = m_videoOutput->currentVideoElement();
66
67 videoElement.set("srcObject", stream);
68 m_videoOutput->start();
69 }
70}
71
73{
74 if (object)
75 m_videoOutput = object;
76}
77
78QT_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.