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
qaudio_parsing_support_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 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
QAUDIO_PARSING_SUPPORT_P_H
5
#
define
QAUDIO_PARSING_SUPPORT_P_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
<
QtMultimedia
/
qtmultimediaglobal
.
h
>
19
#
include
<
QtCore
/
qspan
.
h
>
20
21
#
include
<
optional
>
22
23
QT_BEGIN_NAMESPACE
24
25
namespace
QtMultimediaPrivate
::
ParsingSupport
{
26
27
// Audio codecs that can be identified from the first bytes of a stream.
28
enum
class
AudioCodec
{
29
Unknown
,
30
Mp3
,
31
Aac
,
32
Flac
,
33
Opus
,
34
Vorbis
,
35
Wav
,
36
};
37
38
// The sample rate and channel count from the identification packet of the
39
// first page of an Ogg stream.
40
struct
OggStreamInfo
41
{
42
AudioCodec
codec
=
AudioCodec
::
Unknown
;
43
int
sampleRate
= 0;
44
int
numChannels
= 0;
45
};
46
47
// The parts of a FLAC STREAMINFO metadata block that describe the stream format.
48
struct
FlacStreamInfo
49
{
50
int
sampleRate
= 0;
51
int
numChannels
= 0;
52
// Total samples per channel. 0 when the encoder did not record it.
53
qint64
totalSamples
= 0;
54
};
55
56
// Identifies the codec from the leading bytes of a stream. At least 4 bytes are
57
// needed. Anything shorter or unrecognized returns AudioCodec::Unknown.
58
Q_MULTIMEDIA_EXPORT AudioCodec
sniffCodec
(
QSpan
<
const
std
::
byte
>
header
);
59
60
// Returns true for codecs whose individual frame sizes can be computed from the
61
// frame header, i.e. the codecs mpegFrameSize()/adtsFrameSize() understand.
62
Q_MULTIMEDIA_EXPORT
bool
hasFrameParser
(
AudioCodec
codec);
63
64
// Parses the FLAC STREAMINFO metadata block at the beginning of a FLAC stream.
65
Q_MULTIMEDIA_EXPORT
std
::
optional
<
FlacStreamInfo
>
flacStreamInfo
(
QSpan
<
const
std
::
byte
>
data
);
66
67
// Parses the identification packet on the first page of an Ogg stream, which
68
// says whether the stream is Vorbis or Opus and carries its format. Returns
69
// std::nullopt if the data is too short or is not a recognized Ogg audio
70
// stream. For Opus the rate is the encoder's input rate. Opus itself always
71
// decodes at 48000 Hz, so callers must not treat it as the decoded rate.
72
Q_MULTIMEDIA_EXPORT
std
::
optional
<
OggStreamInfo
>
oggStreamInfo
(
QSpan
<
const
std
::
byte
>
data
);
73
74
// Returns the byte offset of the first FLAC audio frame in data, i.e. the
75
// position just past the "fLaC" marker and all metadata blocks. The result is
76
// always within data, so callers can use it as a slice position directly.
77
// std::nullopt covers a metadata block whose declared length runs past the
78
// end of the data.
79
Q_MULTIMEDIA_EXPORT
std
::
optional
<
qsizetype
>
flacAudioOffset
(
QSpan
<
const
std
::
byte
>
data
);
80
81
// Scans data[from..] for the first valid FLAC frame header: the 14-bit sync
82
// code, header fields that are not reserved values, and a matching header
83
// CRC-8. FLAC frames carry no length field, so a frame spans from one frame
84
// header to the next, or to the end of the stream for the final frame.
85
Q_MULTIMEDIA_EXPORT
std
::
optional
<
qsizetype
>
findFlacSync
(
QSpan
<
const
std
::
byte
>
data
,
86
qsizetype
from
= 0);
87
88
// Returns the byte length of the MPEG Layer III frame whose 4-byte header starts
89
// at data[offset], or 0 if the header is invalid or out of bounds.
90
Q_MULTIMEDIA_EXPORT qsizetype
mpegFrameSize
(
QSpan
<
const
std
::
byte
>
data
,
qsizetype
offset
= 0);
91
92
// Scans data[from..] for the first valid MPEG Layer III sync word + header.
93
Q_MULTIMEDIA_EXPORT
std
::
optional
<
qsizetype
>
findMpegSync
(
QSpan
<
const
std
::
byte
>
data
,
94
qsizetype
from
= 0);
95
96
// Returns the byte length of the ADTS AAC frame (including header) starting at
97
// data[offset], or 0 if the header is invalid or out of bounds.
98
Q_MULTIMEDIA_EXPORT qsizetype
adtsFrameSize
(
QSpan
<
const
std
::
byte
>
data
,
qsizetype
offset
= 0);
99
100
// Scans data[from..] for the first valid ADTS AAC sync word + header.
101
Q_MULTIMEDIA_EXPORT
std
::
optional
<
qsizetype
>
findAdtsSync
(
QSpan
<
const
std
::
byte
>
data
,
102
qsizetype
from
= 0);
103
104
}
// namespace QtMultimediaPrivate::ParsingSupport
105
106
QT_END_NAMESPACE
107
108
#
endif
// QAUDIO_PARSING_SUPPORT_P_H
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtMultimediaPrivate::ParsingSupport::findAdtsSync
std::optional< qsizetype > findAdtsSync(QSpan< const std::byte > data, qsizetype from)
Definition
qaudio_parsing_support.cpp:407
QtMultimediaPrivate::ParsingSupport::oggStreamInfo
std::optional< OggStreamInfo > oggStreamInfo(QSpan< const std::byte > data)
Definition
qaudio_parsing_support.cpp:225
QtMultimediaPrivate::ParsingSupport::findFlacSync
std::optional< qsizetype > findFlacSync(QSpan< const std::byte > data, qsizetype from)
Definition
qaudio_parsing_support.cpp:315
QtMultimediaPrivate::ParsingSupport::AudioCodec
AudioCodec
Definition
qaudio_parsing_support_p.h:28
QtMultimediaPrivate::ParsingSupport::AudioCodec::Wav
@ Wav
Definition
qaudio_parsing_support_p.h:35
QtMultimediaPrivate::ParsingSupport::AudioCodec::Vorbis
@ Vorbis
Definition
qaudio_parsing_support_p.h:34
QtMultimediaPrivate::ParsingSupport::AudioCodec::Flac
@ Flac
Definition
qaudio_parsing_support_p.h:32
QtMultimediaPrivate::ParsingSupport::AudioCodec::Aac
@ Aac
Definition
qaudio_parsing_support_p.h:31
QtMultimediaPrivate::ParsingSupport::AudioCodec::Unknown
@ Unknown
Definition
qaudio_parsing_support_p.h:29
QtMultimediaPrivate::ParsingSupport::AudioCodec::Mp3
@ Mp3
Definition
qaudio_parsing_support_p.h:30
QtMultimediaPrivate::ParsingSupport::AudioCodec::Opus
@ Opus
Definition
qaudio_parsing_support_p.h:33
QtMultimediaPrivate::ParsingSupport::hasFrameParser
bool hasFrameParser(AudioCodec codec)
Definition
qaudio_parsing_support.cpp:220
QtMultimediaPrivate::ParsingSupport::sniffCodec
AudioCodec sniffCodec(QSpan< const std::byte > header)
Definition
qaudio_parsing_support.cpp:182
QtMultimediaPrivate::ParsingSupport::findMpegSync
std::optional< qsizetype > findMpegSync(QSpan< const std::byte > data, qsizetype from)
Definition
qaudio_parsing_support.cpp:382
QtMultimediaPrivate::ParsingSupport::adtsFrameSize
qsizetype adtsFrameSize(QSpan< const std::byte > data, qsizetype offset)
Definition
qaudio_parsing_support.cpp:387
QtMultimediaPrivate::ParsingSupport::flacStreamInfo
std::optional< FlacStreamInfo > flacStreamInfo(QSpan< const std::byte > data)
Definition
qaudio_parsing_support.cpp:270
QtMultimediaPrivate::ParsingSupport::flacAudioOffset
std::optional< qsizetype > flacAudioOffset(QSpan< const std::byte > data)
Definition
qaudio_parsing_support.cpp:299
QtMultimediaPrivate::ParsingSupport::mpegFrameSize
qsizetype mpegFrameSize(QSpan< const std::byte > data, qsizetype offset)
Definition
qaudio_parsing_support.cpp:329
QtMultimediaPrivate::impl
Definition
qaudiosystem_p.h:257
QtMultimediaPrivate::ranges
Definition
qmultimedia_ranges_p.h:33
QtMultimediaPrivate::ranges::all_of
constexpr auto all_of
Definition
qmultimedia_ranges_p.h:74
QtMultimediaPrivate
Definition
qaudio_parsing_support.cpp:16
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QtMultimediaPrivate::ParsingSupport::FlacStreamInfo
Definition
qaudio_parsing_support_p.h:49
QtMultimediaPrivate::ParsingSupport::FlacStreamInfo::sampleRate
int sampleRate
Definition
qaudio_parsing_support_p.h:50
QtMultimediaPrivate::ParsingSupport::FlacStreamInfo::totalSamples
qint64 totalSamples
Definition
qaudio_parsing_support_p.h:53
QtMultimediaPrivate::ParsingSupport::FlacStreamInfo::numChannels
int numChannels
Definition
qaudio_parsing_support_p.h:51
QtMultimediaPrivate::ParsingSupport::OggStreamInfo
Definition
qaudio_parsing_support_p.h:41
QtMultimediaPrivate::ParsingSupport::OggStreamInfo::codec
AudioCodec codec
Definition
qaudio_parsing_support_p.h:42
QtMultimediaPrivate::ParsingSupport::OggStreamInfo::sampleRate
int sampleRate
Definition
qaudio_parsing_support_p.h:43
QtMultimediaPrivate::ParsingSupport::OggStreamInfo::numChannels
int numChannels
Definition
qaudio_parsing_support_p.h:44
qtmultimedia
src
multimedia
audio
qaudio_parsing_support_p.h
Generated on
for Qt by
1.16.1