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
13
QT_BEGIN_NAMESPACE
14
15
#
if
QT_DEPRECATED_SINCE
(
6
,
11
)
16
17
namespace
QtMultimediaPrivate
{
18
19
class
QWaveDecoderOldLayout
:
public
QIODevice
20
{
21
enum
State
{
InitialState
,
WaitingForFormatState
,
WaitingForDataState
};
22
23
public
:
24
bool
haveFormat
=
false
;
25
bool
haveHeader
=
false
;
26
qint64
dataSize
= 0;
27
QIODevice
*
device
=
nullptr
;
28
QAudioFormat
format
;
29
State
state
=
InitialState
;
30
quint32
junkToSkip
= 0;
31
bool
bigEndian
=
false
;
32
bool
byteSwap
=
false
;
33
int
bps
= 0;
34
};
35
36
}
// namespace QtMultimediaPrivate
37
38
class
Q_MULTIMEDIA_EXPORT
QWaveDecoder
:
public
QIODevice
39
{
40
Q_OBJECT
41
42
public
:
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
);
47
~
QWaveDecoder
()
override
;
48
49
QAudioFormat
audioFormat
()
const
;
50
QIODevice
*
getDevice
();
51
int
duration
()
const
;
52
static
qint64
headerLength
();
53
54
bool
open
(
QIODevice
::
OpenMode
mode
)
override
;
55
void
close
()
override
;
56
bool
seek
(
qint64
pos
)
override
;
57
qint64
pos
()
const
override
;
58
void
setIODevice
(
QIODevice
*
device
);
59
qint64
size
()
const
override
;
60
bool
isSequential
()
const
override
;
61
qint64
bytesAvailable
()
const
override
;
62
63
Q_SIGNALS
:
64
void
formatKnown
();
65
void
parsingError
();
66
67
private
Q_SLOTS
:
68
void
handleData
();
69
70
private
:
71
qint64
readData
(
char
*
data
,
qint64
maxlen
)
override
;
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];
81
quint32
size
;
82
};
83
84
struct
RIFFHeader
85
{
86
chunk
descriptor
;
87
char
type
[4];
88
};
89
struct
WAVEHeader
90
{
91
chunk
descriptor
;
92
quint16
audioFormat
;
93
quint16
numChannels
;
94
quint32
sampleRate
;
95
quint32
byteRate
;
96
quint16
blockAlign
;
97
quint16
bitsPerSample
;
98
};
99
100
struct
DATAHeader
101
{
102
chunk
descriptor
;
103
};
104
105
struct
CombinedHeader
106
{
107
RIFFHeader
riff
;
108
WAVEHeader
wave
;
109
DATAHeader
data
;
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
;
117
QAudioFormat
format
;
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
122
Q_DECL_UNUSED_MEMBER
char
m_abiPadding
[8];
123
#
endif
124
};
125
126
static_assert
(
sizeof
(
QWaveDecoder
) ==
sizeof
(
QtMultimediaPrivate
::
QWaveDecoderOldLayout
),
127
"QWaveDecoder ABI size mismatch — adjust fields or QWaveDecoderNewFields"
);
128
129
#
endif
// QT_DEPRECATED_SINCE(6, 11)
130
131
QT_END_NAMESPACE
132
133
#
endif
// WAVEDECODER_H
QSqlRelationalDelegate
\inmodule QtSql
qtmultimedia
src
multimedia
audio
qwavedecoder.h
Generated on
for Qt by
1.16.1