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
qwasmvideoframegrabber_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists purely as an
9// implementation detail. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QWASMVIDEOFRAMEGRABBER_H
16#define QWASMVIDEOFRAMEGRABBER_H
17
18#include <emscripten/html5_webgl.h>
19
20#include <QtMultimedia/qvideoframeformat.h>
21
22#include <string_view>
23
24QT_BEGIN_NAMESPACE
25
26class QWasmVideoOutput;
27
29{
30public:
31 explicit QWasmVideoFrameGrabber(QWasmVideoOutput *videoOutput);
32
33 void startFrameLoop();
34
35 static QVideoFrameFormat::PixelFormat fromJsPixelFormat(std::string_view videoFormat);
36
37private:
38 void detectWebGLContext();
39 void processVideoFrame();
40 void processWebGLVideoFrame();
41
42 QWasmVideoOutput *m_videoOutput = nullptr;
43 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE m_glContextHandle = 0;
44 bool m_hasWebGLContext = false;
45 bool m_webGLContextChecked = false;
46};
47
48QT_END_NAMESPACE
49#endif // QWASMVIDEOFRAMEGRABBER_H
QWasmVideoFrameGrabber(QWasmVideoOutput *videoOutput)
static QVideoFrameFormat::PixelFormat fromJsPixelFormat(std::string_view videoFormat)
std::string m_videoSurfaceId
Combined button and popup list for selecting options.
#define GL_CLAMP_TO_EDGE
Definition qopenglext.h:100
EM_JS(void, em_texImage2DFromVideo,(const char *videoId, int *pW, int *pH), { var gl=GL.currentContext.GLctx;var video=document.getElementById(UTF8ToString(videoId));if(!video) { return;} var frame;try { frame=new VideoFrame(video);} catch(e) { return;} HEAP32[pW > > 2]=frame.displayWidth;HEAP32[pH > > 2]=frame.displayHeight;gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, frame);frame.close();})
EM_JS(EM_VAL, qt_st_sink_createWorkletNode,(EM_VAL ctxHandle, int callbackId, int channels), { var node=new AudioWorkletNode(Emval.toValue(ctxHandle), 'qt-audio-sink', { numberOfInputs:0, numberOfOutputs:1, outputChannelCount:[channels], processorOptions:{ channels:channels } });node.port.onmessage=function() { Module._qt_sinkDeliverData(callbackId);};return Emval.toHandle(node);})