8#include <c++utilities/conversion/stringconversion.h>
9#include <c++utilities/io/binaryreader.h>
27 uint64_t bytesRead = 0;
29 diag.emplace_back(
DiagLevel::Warning,
"\"fmt \" segment is truncated.",
"parsing WAVE format header");
45 if ((maxSize -= 16) < 2) {
46 diag.emplace_back(
DiagLevel::Warning,
"\"fmt \" segment is truncated (extended header missing).",
"parsing WAVE format header");
49 const auto extensionSize = reader.readUInt16LE();
51 if ((maxSize -= 2) < 2) {
52 diag.emplace_back(
DiagLevel::Warning,
"\"fmt \" segment is truncated (extended header truncated).",
"parsing WAVE format header");
58 reader.stream()->seekg(extensionSize, ios_base::cur);
59 bytesRead += extensionSize;
64 if (extensionSize != 22) {
65 diag.emplace_back(
DiagLevel::Warning,
"\"fmt \" extended header has unexptected size.",
"parsing WAVE format header");
70 guid1 = reader.readUInt64BE();
71 guid2 = reader.readUInt64BE();
72 return bytesRead += 22;
91 case 0x000800000aa00389b71:
93 case 0x0100000000001000ul:
95 case 0x0300000000001000ul:
149 CPP_UTILITIES_UNUSED(progress)
151 const string context(
"parsing RIFF/WAVE header");
155 if (
m_reader.readUInt32BE() != 0x52494646u) {
159 if (
m_reader.readUInt32BE() != 0x57415645u) {
162 while (!m_dataOffset) {
163 const auto segmentId =
m_reader.readUInt32BE();
164 auto restHeaderLen =
static_cast<std::uint64_t
>(
m_reader.readUInt32LE());
168 const auto bytesRead = waveHeader.
parse(
m_reader, restHeaderLen, diag);
170 restHeaderLen -= bytesRead;
173 m_dataOffset =
static_cast<std::uint64_t
>(
m_istream->tellg());
180 m_istream->seekg(
static_cast<std::streamoff
>(restHeaderLen), ios_base::cur);
185 m_istream->seekg(
static_cast<streamoff
>(m_dataOffset));
190 ? ((
static_cast<double>(
m_size) * 8.0)
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
std::uint64_t m_sampleCount
std::uint32_t m_bytesPerSecond
std::uint16_t m_bitsPerSample
std::uint16_t m_channelCount
CppUtilities::TimeSpan m_duration
CppUtilities::BinaryReader m_reader
std::uint16_t m_chunkSize
std::uint64_t m_startOffset
friend class WaveAudioStream
std::uint32_t m_samplingFrequency
The Diagnostics class is a container for DiagMessage.
static void addInfo(const MpegAudioFrame &frame, AbstractTrack &track)
Adds the information from the specified frame to the specified track.
The MpegAudioFrame class is used to parse MPEG audio frames.
std::uint32_t samplingFrequency() const
Returns the sampeling frequency of the frame if known; otherwise returns 0.
std::uint32_t sampleCount() const
Returns the sample count if known; otherwise returns 0.
std::uint16_t bitrate() const
Returns the bitrate of the frame if known; otherwise returns 0.
constexpr std::uint32_t xingFrameCount() const
Returns an indication whether the Xing frame count is present.
void parseHeader(CppUtilities::BinaryReader &reader, Diagnostics &diag)
Parses the header read using the specified reader.
constexpr bool isXingFramefieldPresent() const
Returns an indication whether the Xing frame field is present.
The exception that is thrown when the data to be parsed holds no parsable information (e....
TrackType type() const override
Returns the type of the track if known; otherwise returns TrackType::Unspecified.
static void addInfo(const WaveFormatHeader &waveHeader, AbstractTrack &track)
Adds the information from the specified waveHeader to the specified track.
~WaveAudioStream() override
Destroys the track.
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
This method is internally called to parse header information.
Contains all classes and functions of the TagInfo library.
TrackType
The TrackType enum specifies the underlying file type of a track and the concrete class of the track ...