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
qwavedecoder.h
Go to the documentation of this file.
1// Copyright (C) 2016 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// Qt-Security score:critical reason:data-parser
4
5#ifndef WAVEDECODER_H
6#define WAVEDECODER_H
7
8#include <QtMultimedia/qaudioformat.h>
9#include <QtCore/qiodevice.h>
10#include <QtCore/qbytearray.h>
11#include <memory>
12
14
15#if QT_DEPRECATED_SINCE(6, 11)
16
17namespace QtMultimediaPrivate {
18
20{
22
23public:
24 bool haveFormat = false;
25 bool haveHeader = false;
26 qint64 dataSize = 0;
27 QIODevice *device = nullptr;
31 bool bigEndian = false;
32 bool byteSwap = false;
33 int bps = 0;
34};
35
36} // namespace QtMultimediaPrivate
37
39{
41
42public:
43 QT_DEPRECATED_VERSION_X_6_11("QWaveDecoder is deprecated. Please use QAudioDecoder instead.")
44 explicit QWaveDecoder(QIODevice *device, QObject *parent = nullptr);
45 QT_DEPRECATED_VERSION_X_6_11("QWaveDecoder is deprecated. Please use QAudioDecoder instead.")
46 explicit QWaveDecoder(QIODevice *device, const QAudioFormat &format, QObject *parent = nullptr);
48
51 int duration() const;
52 static qint64 headerLength();
53
55 void close() override;
56 bool seek(qint64 pos) override;
57 qint64 pos() const override;
59 qint64 size() const override;
60 bool isSequential() const override;
62
64 void formatKnown();
65 void parsingError();
66
67private Q_SLOTS:
68 void handleData();
69
70private:
72 qint64 writeData(const char *data, qint64 len) override;
73
74 bool writeHeader();
75 bool writeDataLength();
76 void parsingFailed();
77
78 struct chunk
79 {
80 char id[4];
82 };
83
84 struct RIFFHeader
85 {
87 char type[4];
88 };
89 struct WAVEHeader
90 {
98 };
99
100 struct DATAHeader
101 {
103 };
104
105 struct CombinedHeader
106 {
110 };
111 static const int HeaderLength = sizeof(CombinedHeader);
112
113 bool haveFormat = false;
114 bool haveHeader = false;
115 qint64 dataSize = 0;
116 QIODevice *device = nullptr;
118 std::unique_ptr<QByteArray> m_headerBuf; // accumulates bytes for dr_wav parsing
119 bool m_byteSwap = false; // true when WAV endian != host endian
120
121# if QT_POINTER_SIZE == 4
123# endif
124};
125
126static_assert(sizeof(QWaveDecoder) == sizeof(QtMultimediaPrivate::QWaveDecoderOldLayout),
127 "QWaveDecoder ABI size mismatch — adjust fields or QWaveDecoderNewFields");
128
129#endif // QT_DEPRECATED_SINCE(6, 11)
130
132
133#endif // WAVEDECODER_H
\inmodule QtSql