2016-01-17 21:32:57 +01:00
|
|
|
#include "./opusidentificationheader.h"
|
|
|
|
|
|
|
|
#include "../ogg/oggiterator.h"
|
|
|
|
|
|
|
|
#include "../exceptions.h"
|
|
|
|
|
|
|
|
#include <c++utilities/conversion/binaryconversion.h>
|
|
|
|
|
|
|
|
using namespace std;
|
2019-06-10 22:49:11 +02:00
|
|
|
using namespace CppUtilities;
|
2016-01-17 21:32:57 +01:00
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
namespace TagParser {
|
2016-01-17 21:32:57 +01:00
|
|
|
|
|
|
|
/*!
|
2018-06-03 20:38:32 +02:00
|
|
|
* \class TagParser::OpusIdentificationHeader
|
2016-01-17 21:32:57 +01:00
|
|
|
* \brief The OpusIdentificationHeader class is an Opus identification header parser.
|
|
|
|
* \sa https://wiki.xiph.org/OggOpus
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Parses the Opus 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 OpusIdentificationHeader::parseHeader(OggIterator &iterator)
|
|
|
|
{
|
|
|
|
char buff[19 - 8];
|
|
|
|
iterator.read(buff, 8);
|
2018-03-07 01:17:50 +01:00
|
|
|
if (BE::toUInt64(buff) != 0x4F70757348656164u) {
|
2016-01-17 21:32:57 +01:00
|
|
|
throw InvalidDataException(); // not Opus identification header
|
|
|
|
}
|
|
|
|
iterator.read(buff, sizeof(buff));
|
2019-03-13 19:06:42 +01:00
|
|
|
m_version = static_cast<std::uint8_t>(*(buff));
|
|
|
|
m_channels = static_cast<std::uint8_t>(*(buff + 1));
|
2016-01-17 21:32:57 +01:00
|
|
|
m_preSkip = LE::toUInt16(buff + 2);
|
|
|
|
m_sampleRate = LE::toUInt32(buff + 4);
|
|
|
|
m_outputGain = LE::toUInt16(buff + 8);
|
2019-03-13 19:06:42 +01:00
|
|
|
m_channelMap = static_cast<std::uint8_t>(*(buff + 10));
|
2016-01-17 21:32:57 +01:00
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|