Tag Parser
9.4.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
Go to the documentation of this file.
3 #include "../exceptions.h"
4 #include "../mediaformat.h"
30 void MpegAudioFrameStream::internalParseHeader(
Diagnostics &diag)
32 static const string context(
"parsing MPEG audio frame header");
37 m_istream->seekg(-128, ios_base::end);
38 if (m_reader.readUInt24BE() == 0x544147) {
39 m_size =
static_cast<std::uint64_t
>(m_istream->tellg()) - 3u - m_startOffset;
41 m_size =
static_cast<std::uint64_t
>(m_istream->tellg()) + 125u - m_startOffset;
43 m_istream->seekg(
static_cast<streamoff
>(m_startOffset), ios_base::beg);
45 for (
size_t invalidByteskipped = 0; m_frames.size() < 200 && invalidByteskipped <= 0x600u;) {
46 MpegAudioFrame &frame = invalidByteskipped > 0 ? m_frames.back() : m_frames.emplace_back();
50 if (++invalidByteskipped > 1) {
53 m_istream->seekg(-3, ios_base::cur);
56 if (invalidByteskipped > 1) {
57 diag.emplace_back(DiagLevel::Critical, argsToString(
"The next ", invalidByteskipped,
" bytes are junk as well."), context);
62 invalidByteskipped = 0;
64 m_istream->seekg(2, ios_base::cur);
68 if (!m_frames.back().isValid()) {
72 addInfo(frame, *
this);
75 if (m_size && xingSize != m_size) {
76 diag.emplace_back(DiagLevel::Warning,
77 "Real length of MPEG audio frames is not in accordance with value provided by Xing header. The Xing header value will be used.",
85 m_duration = TimeSpan::fromSeconds(
static_cast<double>(m_size) / (m_bytesPerSecond =
static_cast<std::uint32_t
>(m_bitrate * 125)));
std::uint32_t m_samplingFrequency
std::uint32_t samplingFrequency() const
Returns the sampeling frequency of the frame if known; otherwise returns 0.
std::uint32_t size() const
Returns the size if known; otherwise retruns 0.
void parseHeader(CppUtilities::BinaryReader &reader, Diagnostics &diag)
Parses the header read using the specified reader.
int layer() const
Returns the MPEG layer if known (1, 2, or 3); otherwise returns 0.
The MpegAudioFrame class is used to parse MPEG audio frames.
The Diagnostics class is a container for DiagMessage.
Contains all classes and functions of the TagInfo library.
std::uint16_t bitrate() const
Returns the bitrate of the frame if known; otherwise returns 0.
std::uint32_t sampleCount() const
Returns the sample count if known; otherwise returns 0.
constexpr bool isXingBytesfieldPresent() const
Returns an indication whether the Xing bytes field is present.
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
std::uint16_t m_channelCount
constexpr std::uint32_t xingFrameCount() const
Returns an indication whether the Xing frame count is present.
MpegChannelMode channelMode() const
Returns the channel mode if known; otherwise returns MpegChannelMode::Unspecifed.
constexpr bool isXingFramefieldPresent() const
Returns an indication whether the Xing frame field is present.
constexpr std::uint32_t xingBytesfield() const
Returns the Xing bytes field if known; otherwise returns 0.
The exception that is thrown when the data to be parsed holds no parsable information (e....
The exception that is thrown when the data to be parsed or to be made seems invalid and therefore can...
constexpr bool isProtectedByCrc() const
Returns an indication whether the frame is protected by CRC.
std::uint8_t m_channelConfig
double mpegVersion() const
Returns the MPEG version if known (1.0, 2.0 or 2.5); otherwise returns 0.