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 "mediaplayer/qwasmmediaplayer_p.h"
19
20#include <QtMultimedia/private/qplatformaudiooutput_p.h>
21#include <QtMultimedia/private/qwasmwebaudiosink_p.h>
22#include <QtCore/qiodevice.h>
23#include <QtCore/qobject.h>
24#include <QtCore/private/qstdweb_p.h>
25
26#include <emscripten/val.h>
27
29
30class Q_MULTIMEDIA_EXPORT QWasmAudioOutput : public QObject, public QPlatformAudioOutput
31{
32 Q_OBJECT
33
34public:
35 QWasmAudioOutput(QAudioOutput *qq);
36 ~QWasmAudioOutput();
37
38 enum AudioElementError {
39 MEDIA_ERR_ABORTED = 1,
40 MEDIA_ERR_NETWORK,
41 MEDIA_ERR_DECODE,
42 MEDIA_ERR_SRC_NOT_SUPPORTED
43 };
44
45 void setAudioDevice(const QAudioDevice &device) final;
46 void setMuted(bool muted) override;
47 void setVolume(float volume) override;
48
49 void start();
50 void stop();
51 void pause();
52
53 void setSource(const QUrl &url);
54 void setSource(QIODevice *stream);
55 void setVideoElement(emscripten::val videoElement);
56
57Q_SIGNALS:
58 void readyChanged(bool);
59 void bufferingChanged(qint32 percent);
60 void errorOccured(qint32 code, const QString &message);
61 void stateChanged(QWasmMediaPlayer::QWasmMediaPlayerState newState);
62 void progressChanged(qint32 position);
63 void durationChanged(qint64 duration);
64 void statusChanged(QMediaPlayer::MediaStatus status);
65 void sizeChange(qint32 width, qint32 height);
66 void metaDataLoaded();
67 void seekableChanged(bool seekable);
68
69private:
70 void doElementCallbacks();
71 void createAudioElement(const std::string &id);
72
73 emscripten::val videoElement();
74
75 QScopedPointer<QWasmAudioSink> m_sink;
76 QScopedPointer<qstdweb::EventCallback> m_playEvent;
77 QScopedPointer<qstdweb::EventCallback> m_endedEvent;
78 QScopedPointer<qstdweb::EventCallback> m_durationChangeEvent;
79 QScopedPointer<qstdweb::EventCallback> m_errorChangeEvent;
80 QScopedPointer<qstdweb::EventCallback> m_canPlayChangeEvent;
81 QScopedPointer<qstdweb::EventCallback> m_canPlayThroughChangeEvent;
82
83 QScopedPointer<qstdweb::EventCallback> m_playingChangeEvent;
84 QScopedPointer<qstdweb::EventCallback> m_progressChangeEvent;
85 QScopedPointer<qstdweb::EventCallback> m_pauseChangeEvent;
86 QScopedPointer<qstdweb::EventCallback> m_timeUpdateEvent;
87 QScopedPointer<qstdweb::EventCallback> m_loadedDataEvent;
88
89 QString m_source;
90 QIODevice *m_audioIODevice = nullptr;
91 emscripten::val m_audio = emscripten::val::undefined();
92 emscripten::val m_videoElement = emscripten::val::undefined();
93 QMediaPlayer::MediaStatus m_currentMediaStatus;
94 qreal m_currentBufferedValue;
95};
96
97QT_END_NAMESPACE
98
99#endif // QWASMAUDIOOUTPUT_H
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)