Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwasmvideooutput_p.h
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
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 QWASMVIDEOOUTPUT_H
16#define QWASMVIDEOOUTPUT_H
17
18#include <QObject>
19
20#include <emscripten/val.h>
21#include <QMediaPlayer>
22#include <QVideoFrame>
23
24#include "qwasmmediaplayer_p.h"
25#include <QtCore/qloggingcategory.h>
26
27#include <private/qstdweb_p.h>
28
30
31Q_DECLARE_LOGGING_CATEGORY(qWasmMediaVideoOutput)
32
33class QVideoSink;
34
36{
38public:
39 enum WasmVideoMode { VideoOutput, Camera };
41
43
44 void setVideoSize(const QSize &);
45 void start();
46 void stop();
47 void reset();
48 void pause();
49
50 void setSurface(QVideoSink *surface);
52
53 bool isReady() const;
54
55 void setSource(const QUrl &url);
57 void setVolume(qreal volume);
58 void setMuted(bool muted);
59
62 bool isVideoSeekable();
65
67 void newFrame(const QVideoFrame &newFrame);
68
69 void createVideoElement(const std::string &id);
70 void createOffscreenElement(const QSize &offscreenSize);
71 void doElementCallbacks();
72 void updateVideoElementGeometry(const QRect &windowGeometry);
74 void addCameraSourceElement(const std::string &id);
77
78 void setHasAudio(bool needsAudio) { m_hasAudio = needsAudio; }
79
81 emscripten::val getDeviceCapabilities();
82 bool setDeviceSetting(const std::string &key, emscripten::val value);
83 bool isCameraReady() { return m_cameraIsReady; }
84
85 static void videoFrameCallback(emscripten::val now, emscripten::val metadata);
87 // mediacapturesession has the videosink
89
90 emscripten::val currentVideoElement() { return m_video; }
91
93 void readyChanged(bool);
94 void bufferingChanged(qint32 percent);
95 void errorOccured(qint32 code, const QString &message);
98 void durationChanged(qint64 duration);
102
103private:
104 void checkNetworkState();
105 void videoComputeFrame(void *context);
106 void getDeviceSettings();
107
108 static QVideoFrameFormat::PixelFormat fromJsPixelFormat(std::string videoFormat);
109
110 emscripten::val m_video = emscripten::val::undefined();
111 emscripten::val m_videoElementSource = emscripten::val::undefined();
112
113 QString m_source;
114 float m_requestedPosition = 0.0;
115 emscripten::val m_offscreen = emscripten::val::undefined();
116
117 bool m_shouldStop = false;
118 bool m_toBePaused = false;
119 bool m_isSeeking = false;
120 bool m_hasAudio = false;
121 bool m_cameraIsReady = false;
122 bool m_shouldBeStarted = false;
123
124 emscripten::val m_offscreenContext = emscripten::val::undefined();
125 QSize m_pendingVideoSize;
127 QMediaPlayer::MediaStatus m_currentMediaStatus;
128 qreal m_currentBufferedValue;
129
130 QScopedPointer<qstdweb::EventCallback> m_timeUpdateEvent;
131 QScopedPointer<qstdweb::EventCallback> m_playEvent;
132 QScopedPointer<qstdweb::EventCallback> m_endedEvent;
133 QScopedPointer<qstdweb::EventCallback> m_durationChangeEvent;
134 QScopedPointer<qstdweb::EventCallback> m_loadedDataEvent;
135 QScopedPointer<qstdweb::EventCallback> m_errorChangeEvent;
136 QScopedPointer<qstdweb::EventCallback> m_resizeChangeEvent;
137 QScopedPointer<qstdweb::EventCallback> m_loadedMetadataChangeEvent;
138 QScopedPointer<qstdweb::EventCallback> m_loadStartChangeEvent;
139 QScopedPointer<qstdweb::EventCallback> m_canPlayChangeEvent;
140 QScopedPointer<qstdweb::EventCallback> m_canPlayThroughChangeEvent;
141 QScopedPointer<qstdweb::EventCallback> m_seekingChangeEvent;
142 QScopedPointer<qstdweb::EventCallback> m_seekedChangeEvent;
143 QScopedPointer<qstdweb::EventCallback> m_emptiedChangeEvent;
144 QScopedPointer<qstdweb::EventCallback> m_stalledChangeEvent;
145 QScopedPointer<qstdweb::EventCallback> m_waitingChangeEvent;
146 QScopedPointer<qstdweb::EventCallback> m_playingChangeEvent;
147 QScopedPointer<qstdweb::EventCallback> m_progressChangeEvent;
148 QScopedPointer<qstdweb::EventCallback> m_pauseChangeEvent;
149};
150
152#endif // QWASMVIDEOOUTPUT_H
\inmodule QtCore \reentrant
Definition qiodevice.h:34
MediaStatus
\qmlproperty enumeration QtMultimedia::MediaPlayer::playbackState
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
PixelFormat
Enumerates video data types.
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
The QVideoSink class represents a generic sink for video data.
Definition qvideosink.h:22
void addCameraSourceElement(const std::string &id)
void readyChanged(bool)
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()
void durationChanged(qint64 duration)
emscripten::val getDeviceCapabilities()
static void videoFrameCallback(emscripten::val now, emscripten::val metadata)
void setVideoSize(const QSize &)
void setMuted(bool muted)
QVideoSink * m_wasmSink
emscripten::val currentVideoElement()
void setSource(const QUrl &url)
void setVideoMode(QWasmVideoOutput::WasmVideoMode mode)
void bufferingChanged(qint32 percent)
void seekTo(qint64 position)
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 updateVideoElementSource(const QString &src)
void removeSourceElement()
void statusChanged(QMediaPlayer::MediaStatus status)
void progressChanged(qint32 position)
void errorOccured(qint32 code, const QString &message)
void setPlaybackRate(qreal rate)
void setHasAudio(bool needsAudio)
void createOffscreenElement(const QSize &offscreenSize)
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
static void * context
EGLStreamKHR stream
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLenum mode
GLuint64 key
GLint GLsizei GLsizei height
GLenum src
GLint GLsizei width
GLuint GLsizei const GLchar * message
GLuint start
GLboolean reset
GLuint GLfloat * val
GLuint GLenum * rate
GLenum cap
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ENUM(x)
#define Q_OBJECT
#define Q_SIGNALS
int qint32
Definition qtypes.h:49
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
#define explicit
QUrl url("example.com")
[constructor-url-reference]