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
qwasmaudiooutput_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#ifndef QWASMAUDIOOUTPUT_H
5#define QWASMAUDIOOUTPUT_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qplatformaudiooutput_p.h>
20
21#include <emscripten/val.h>
22#include <private/qstdweb_p.h>
23#include <private/qwasmaudiosink_p.h>
24#include <QIODevice>
25#include <QObject>
26
28
29class Q_MULTIMEDIA_EXPORT QWasmAudioOutput : public QObject, public QPlatformAudioOutput
30{
31 Q_OBJECT
32
33public:
34 QWasmAudioOutput(QAudioOutput *qq);
35 ~QWasmAudioOutput();
36
37 enum AudioElementError {
38 MEDIA_ERR_ABORTED = 1,
39 MEDIA_ERR_NETWORK,
40 MEDIA_ERR_DECODE,
41 MEDIA_ERR_SRC_NOT_SUPPORTED
42 };
43
44 void setAudioDevice(const QAudioDevice &device) final;
45 void setMuted(bool muted) override;
46 void setVolume(float volume) override;
47
48 void start();
49 void stop();
50 void pause();
51
52 void setSource(const QUrl &url);
53 void setSource(QIODevice *stream);
54 void setVideoElement(emscripten::val videoElement);
55
56Q_SIGNALS:
57 void readyChanged(bool);
58 void bufferingChanged(qint32 percent);
59 void errorOccured(qint32 code, const QString &message);
60 void stateChanged(QWasmMediaPlayer::QWasmMediaPlayerState newState);
61 void progressChanged(qint32 position);
62 void durationChanged(qint64 duration);
63 void statusChanged(QMediaPlayer::MediaStatus status);
64 void sizeChange(qint32 width, qint32 height);
65 void metaDataLoaded();
66 void seekableChanged(bool seekable);
67
68private:
69 void doElementCallbacks();
70 void createAudioElement(const std::string &id);
71
72 emscripten::val videoElement();
73
74 QScopedPointer<QWasmAudioSink> m_sink;
75 QScopedPointer<qstdweb::EventCallback> m_playEvent;
76 QScopedPointer<qstdweb::EventCallback> m_endedEvent;
77 QScopedPointer<qstdweb::EventCallback> m_durationChangeEvent;
78 QScopedPointer<qstdweb::EventCallback> m_errorChangeEvent;
79 QScopedPointer<qstdweb::EventCallback> m_canPlayChangeEvent;
80 QScopedPointer<qstdweb::EventCallback> m_canPlayThroughChangeEvent;
81
82 QScopedPointer<qstdweb::EventCallback> m_playingChangeEvent;
83 QScopedPointer<qstdweb::EventCallback> m_progressChangeEvent;
84 QScopedPointer<qstdweb::EventCallback> m_pauseChangeEvent;
85 QScopedPointer<qstdweb::EventCallback> m_timeUpdateEvent;
86 QScopedPointer<qstdweb::EventCallback> m_loadedDataEvent;
87
88 QString m_source;
89 QIODevice *m_audioIODevice = nullptr;
90 emscripten::val m_audio = emscripten::val::undefined();
91 emscripten::val m_videoElement = emscripten::val::undefined();
92 QMediaPlayer::MediaStatus m_currentMediaStatus;
93 qreal m_currentBufferedValue;
94};
95
96QT_END_NAMESPACE
97
98#endif // QWASMAUDIOOUTPUT_H
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")