3 #include "../mpegaudio/mpegaudioframestream.h" 5 #include "../exceptions.h" 6 #include "../mediaformat.h" 8 #include <c++utilities/conversion/stringconversion.h> 9 #include <c++utilities/io/binaryreader.h> 25 void WaveFormatHeader::parse(IoUtilities::BinaryReader &reader)
27 formatTag = reader.readUInt16LE();
29 sampleRate = reader.readUInt32LE();
30 bytesPerSecond = reader.readUInt32LE();
31 chunkSize = reader.readUInt16LE();
32 bitsPerSample = reader.readUInt16LE();
42 return GeneralMediaFormat::Pcm;
48 return GeneralMediaFormat::Unknown;
61 WaveAudioStream::WaveAudioStream(iostream &stream, uint64 startOffset)
97 const string context(
"parsing RIFF/WAVE header");
101 if (
m_reader.readUInt32BE() != 0x52494646u) {
105 if (
m_reader.readUInt32BE() != 0x57415645u) {
108 while (!m_dataOffset) {
109 uint32 segmentId =
m_reader.readUInt32BE();
110 uint32 restHeaderLen =
m_reader.readUInt32LE();
113 if (restHeaderLen >= 16u) {
117 restHeaderLen -= 16u;
123 m_dataOffset =
static_cast<uint64
>(
m_istream->tellg());
130 m_istream->seekg(restHeaderLen, ios_base::cur);
135 m_istream->seekg(static_cast<streamoff>(m_dataOffset));
140 ? ((
static_cast<double>(
m_size) * 8.0)
TAG_PARSER_EXPORT byte channelCount(byte config)
Returns the channel count for the specified MPEG-4 channel config.
uint32 sampleCount() const
Returns the sample count if known; otherwise returns 0.
IoUtilities::BinaryReader m_reader
~WaveAudioStream() override
Destroys the track.
The MpegAudioFrame class is used to parse MPEG audio frames.
static void addInfo(const WaveFormatHeader &waveHeader, AbstractTrack &track)
Adds the information from the specified waveHeader to the specified track.
constexpr bool isXingFramefieldPresent() const
Returns an indication whether the Xing frame field is present.
ChronoUtilities::TimeSpan m_duration
TrackType type() const override
Returns the type of the track if known; otherwise returns TrackType::Unspecified. ...
The exception that is thrown when the data to be parsed holds no parsable information.
void parseHeader(IoUtilities::BinaryReader &reader, Diagnostics &diag)
Parses the header read using the specified reader.
uint16 bitrate() const
Returns the bitrate of the frame if known; otherwise returns 0.
static void addInfo(const MpegAudioFrame &frame, AbstractTrack &track)
Adds the information from the specified frame to the specified track.
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
uint32 m_samplingFrequency
Contains all classes and functions of the TagInfo library.
constexpr uint32 xingFrameCount() const
Returns an indication whether the Xing frame count is present.
TrackType
Specifies the track type.
uint32 samplingFrequency() const
Returns the sampeling frequency of the frame if known; otherwise returns 0.
void internalParseHeader(Diagnostics &diag) override
This method is internally called to parse header information.
The Diagnostics class is a container for DiagMessage.