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 <QtMultimedia/qvideoframeformat.h>
19
20#include <emscripten/html5_webgl.h>
21
22#include <string_view>
23
24QT_BEGIN_NAMESPACE
25
26class QWasmVideoOutput;
27
29{
30public:
31 explicit QWasmVideoFrameGrabber(QWasmVideoOutput *videoOutput);
33
34 void startFrameLoop();
35
36 static QVideoFrameFormat::PixelFormat fromJsPixelFormat(std::string_view videoFormat);
37
38private:
39 void detectWebGLContext();
40 void processVideoFrame();
41 void processWebGLVideoFrame();
42
43 QWasmVideoOutput *m_videoOutput = nullptr;
44 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE m_glContextHandle = 0;
45 // Pending requestAnimationFrame id, 0 while no loop is scheduled.
46 int m_animationFrameRequestId = 0;
47 bool m_hasWebGLContext = false;
48 bool m_webGLContextChecked = false;
49};
50
51QT_END_NAMESPACE
52#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 *widthOut, int *heightOut), { videoId=Number(videoId);widthOut=Number(widthOut);heightOut=Number(heightOut);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[widthOut/4]=frame.displayWidth;HEAP32[heightOut/4]=frame.displayHeight;gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, frame);frame.close();})