6#include <c++utilities/conversion/stringbuilder.h>
34 CPP_UTILITIES_UNUSED(progress)
36 static const string context(
"parsing MPEG audio frame header");
42 for (
size_t invalidByteskipped = 0; m_frames.size() < 200 && invalidByteskipped <= 0x600u;) {
43 MpegAudioFrame &frame = invalidByteskipped > 0 ? m_frames.back() : m_frames.emplace_back();
47 if (++invalidByteskipped > 1) {
53 if (invalidByteskipped > 1) {
54 diag.emplace_back(
DiagLevel::Critical, argsToString(
"The next ", invalidByteskipped,
" bytes are junk as well."), context);
59 invalidByteskipped = 0;
65 if (!m_frames.back().isValid()) {
74 }
else if (xingSize !=
m_size) {
76 argsToString(
"Real size of MPEG audio frames (",
m_size,
" byte) is not in accordance with value provided by Xing header (", xingSize,
77 " byte). The real size will be used."),
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
std::uint32_t m_bytesPerSecond
AbstractTrack(std::istream &inputStream, std::ostream &outputStream, std::uint64_t startOffset)
Constructs a new track.
std::uint16_t m_channelCount
std::uint8_t m_channelConfig
CppUtilities::TimeSpan m_duration
CppUtilities::BinaryReader m_reader
std::uint64_t m_startOffset
const CppUtilities::TimeSpan & duration() const
Returns the duration if known; otherwise returns a TimeSpan of zero ticks.
std::uint32_t m_samplingFrequency
The Diagnostics class is a container for DiagMessage.
The exception that is thrown when the data to be parsed or to be made seems invalid and therefore can...
static void addInfo(const MpegAudioFrame &frame, AbstractTrack &track)
Adds the information from the specified frame to the specified track.
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
This method is internally called to parse header information.
The MpegAudioFrame class is used to parse MPEG audio frames.
std::uint32_t size() const
Returns the size if known; otherwise returns 0.
std::uint32_t samplingFrequency() const
Returns the sampeling frequency of the frame if known; otherwise returns 0.
MpegChannelMode channelMode() const
Returns the channel mode if known; otherwise returns MpegChannelMode::Unspecifed.
constexpr bool isProtectedByCrc() const
Returns an indication whether the frame is protected by CRC.
std::uint32_t sampleCount() const
Returns the sample count if known; otherwise returns 0.
int layer() const
Returns the MPEG layer if known (1, 2, or 3); 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.
constexpr bool isXingBytesfieldPresent() const
Returns an indication whether the Xing bytes field is present.
void parseHeader(CppUtilities::BinaryReader &reader, Diagnostics &diag)
Parses the header read using the specified reader.
double mpegVersion() const
Returns the MPEG version if known (1.0, 2.0 or 2.5); otherwise returns 0.
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....
Contains all classes and functions of the TagInfo library.