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;
|
|
|
|
using namespace ConversionUtilities;
|
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
/*!
|
2018-06-03 20:38:32 +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);
|
2018-03-07 01:17:50 +01:00
|
|
|
if ((BE::toUInt64(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);
|
|
|
|
m_channels = static_cast<byte>(*(buff + 4));
|
|
|
|
m_sampleRate = LE::toUInt32(buff + 5);
|
|
|
|
m_maxBitrate = LE::toUInt32(buff + 9);
|
|
|
|
m_nominalBitrate = LE::toUInt32(buff + 13);
|
|
|
|
m_minBitrate = LE::toUInt32(buff + 17);
|
|
|
|
m_blockSize = static_cast<byte>(*(buff + 21));
|
|
|
|
m_framingFlag = static_cast<byte>(*(buff + 22));
|
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|