tagparser/vorbis/vorbisidentificationheader.cpp

43 lines
1.3 KiB
C++
Raw Normal View History

2015-09-06 19:57:33 +02:00
#include "./vorbisidentificationheader.h"
#include "./vorbispackagetypes.h"
2015-04-22 19:22:01 +02:00
2015-09-06 19:57:33 +02:00
#include "../ogg/oggiterator.h"
2015-04-22 19:22:01 +02:00
2015-09-06 19:57:33 +02:00
#include "../exceptions.h"
2015-04-22 19:22:01 +02:00
#include <c++utilities/conversion/binaryconversion.h>
using namespace std;
2019-06-10 22:49:11 +02:00
using namespace CppUtilities;
2015-04-22 19:22:01 +02:00
namespace TagParser {
2015-04-22 19:22:01 +02:00
/*!
* \class TagParser::VorbisIdentificationHeader
2015-04-22 19:22:01 +02:00
* \brief The VorbisIdentificationHeader class is a Vorbis identification header parser.
*/
/*!
* \brief Parses the Vorbis identification header which is read using the specified \a iterator.
* \remarks The header is assumed to start at the current position of \a iterator.
*/
void VorbisIdentificationHeader::parseHeader(OggIterator &iterator)
{
char buff[30 - 7];
iterator.read(buff, 7);
if ((BE::toInt<std::uint64_t>(buff) & 0xffffffffffffff00u) != 0x01766F7262697300u) {
2015-04-22 19:22:01 +02:00
throw InvalidDataException(); // not Vorbis identification header
}
iterator.read(buff, sizeof(buff));
m_version = LE::toUInt32(buff);
2019-03-13 19:06:42 +01:00
m_channels = static_cast<std::uint8_t>(*(buff + 4));
2015-04-22 19:22:01 +02:00
m_sampleRate = LE::toUInt32(buff + 5);
m_maxBitrate = LE::toUInt32(buff + 9);
m_nominalBitrate = LE::toUInt32(buff + 13);
m_minBitrate = LE::toUInt32(buff + 17);
2019-03-13 19:06:42 +01:00
m_blockSize = static_cast<std::uint8_t>(*(buff + 21));
m_framingFlag = static_cast<std::uint8_t>(*(buff + 22));
2015-04-22 19:22:01 +02:00
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser