15#ifndef QWASMVIDEOOUTPUT_H
16#define QWASMVIDEOOUTPUT_H
20#include <emscripten/val.h>
21#include <emscripten/html5_webgl.h>
22#include <emscripten/html5.h>
24#include <QMediaPlayer>
26#include <QtMultimedia/qtvideo.h>
29#include "private/qwasmmediadevices_p.h"
32#include <private/qwasmjs_p.h>
34#include <QtCore/qloggingcategory.h>
36#include <private/qstdweb_p.h>
37#include <private/qwasmsuspendresumecontrol_p.h>
41Q_DECLARE_LOGGING_CATEGORY(qWasmMediaVideoOutput)
74 void seekTo(qint64 position);
80 void newFrame(
const QVideoFrame &newFrame);
92 void setHasAudio(
bool needsAudio) { m_hasAudio = needsAudio; }
112 m_video.isNull() || m_video.isUndefined() ? emscripten::val::null()
135 void checkNetworkState();
136 void videoComputeFrame(
void *context);
137 void getDeviceSettings();
138 bool isPlatformiOs();
144 float m_requestedPosition = 0.0;
148 int getCurrentOrientationIndex();
151 bool m_isStopped =
false;
152 bool m_toBePaused =
false;
153 bool m_isSeeking =
false;
154 bool m_hasAudio =
false;
155 bool m_cameraIsReady =
false;
156 bool m_shouldBeStarted =
false;
157 bool m_isSeekable =
false;
158 bool m_useCameraRotation =
false;
161 QSize m_pendingVideoSize;
163 QMediaPlayer::MediaStatus m_currentMediaStatus;
164 qreal m_currentBufferedValue;
165 JsMediaInputStream *m_mediaInputStream =
nullptr;
167 QScopedPointer<QWasmEventHandler> m_timeUpdateEvent;
168 QScopedPointer<QWasmEventHandler> m_playEvent;
169 QScopedPointer<QWasmEventHandler> m_endedEvent;
170 QScopedPointer<QWasmEventHandler> m_durationChangeEvent;
171 QScopedPointer<QWasmEventHandler> m_loadedDataEvent;
172 QScopedPointer<QWasmEventHandler> m_errorChangeEvent;
173 QScopedPointer<QWasmEventHandler> m_resizeChangeEvent;
174 QScopedPointer<QWasmEventHandler> m_loadedMetadataChangeEvent;
175 QScopedPointer<QWasmEventHandler> m_loadStartChangeEvent;
176 QScopedPointer<QWasmEventHandler> m_canPlayChangeEvent;
177 QScopedPointer<QWasmEventHandler> m_canPlayThroughChangeEvent;
178 QScopedPointer<QWasmEventHandler> m_seekingChangeEvent;
179 QScopedPointer<QWasmEventHandler> m_seekedChangeEvent;
180 QScopedPointer<QWasmEventHandler> m_emptiedChangeEvent;
181 QScopedPointer<QWasmEventHandler> m_stalledChangeEvent;
182 QScopedPointer<QWasmEventHandler> m_waitingChangeEvent;
183 QScopedPointer<QWasmEventHandler> m_playingChangeEvent;
184 QScopedPointer<QWasmEventHandler> m_progressChangeEvent;
185 QScopedPointer<QWasmEventHandler> m_pauseChangeEvent;
186 QScopedPointer<QWasmEventHandler> m_beforeUnloadEvent;
188 std::string m_cameraId;
189 QMetaObject::Connection m_connection;
190 QSize m_videoResolution;
191 float m_minFrameRate = 0;
192 float m_maxFrameRate = 0;
193 float m_streamFrameRate = 0;
194 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE m_glContextHandle = 0;
195 static bool orientationchangeCallback(
int eventType,
const EmscriptenOrientationChangeEvent *orientationChangeEvent,
void *userData);
void addCameraSourceElement(const std::string &id)
void updateVideoElementGeometry(const QRect &windowGeometry)
bool setDeviceSetting(const std::string &key, emscripten::val value)
void sizeChange(qint32 width, qint32 height)
void newFrame(const QVideoFrame &newFrame)
emscripten::val surfaceElement()
bool m_webGLContextChecked
void seekableChanged(bool seekable)
void durationChanged(qint64 duration)
emscripten::val getDeviceCapabilities()
void videoFrameCallback(void *context)
void setVideoSize(const QSize &)
void setMuted(bool muted)
emscripten::val currentVideoElement()
void setSource(const QUrl &url)
void setVideoMode(QWasmVideoOutput::WasmVideoMode mode)
void bufferingChanged(qint32 percent)
void setVideoConstraints(QSize resolution, float minFrameRate, float maxFrameRate)
void seekTo(qint64 position)
void webglVideoFrameCallback(void *context)
void orientationChanged(int rotationIndex)
void setVolume(qreal volume)
void createVideoElement(const std::string &id)
void stateChanged(QWasmMediaPlayer::QWasmMediaPlayerState newState)
void setSurface(QVideoSink *surface)
bool hasCapability(const QString &cap)
void removeCurrentVideoElement()
void updateVideoElementSource(const QString &src)
void removeSourceElement()
std::string m_videoSurfaceId
void statusChanged(QMediaPlayer::MediaStatus status)
static QVideoFrameFormat::PixelFormat fromJsPixelFormat(std::string_view videoFormat)
void progressChanged(qint32 position)
void errorOccured(qint32 code, const QString &message)
void setSource(QIODevice *stream)
qint64 getCurrentPosition()
void setPlaybackRate(qreal rate)
void setHasAudio(bool needsAudio)
void doElementCallbacks()
void createOffscreenElement(const QSize &offscreenSize)
void videoFrameTimerCallback()
Combined button and popup list for selecting options.
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
static bool checkForVideoFrame()
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, outputChannelCounts:[channels], processorOptions:{ channels:channels } });node.port.onmessage=function() { Module._qt_sinkDeliverData(callbackId);};return Emval.toHandle(node);})