Tag Parser  6.2.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
opusidentificationheader.cpp
Go to the documentation of this file.
2 
3 #include "../ogg/oggiterator.h"
4 
5 #include "../exceptions.h"
6 
7 #include <c++utilities/conversion/binaryconversion.h>
8 
9 using namespace std;
10 using namespace ConversionUtilities;
11 
12 namespace Media {
13 
24 void OpusIdentificationHeader::parseHeader(OggIterator &iterator)
25 {
26  char buff[19 - 8];
27  iterator.read(buff, 8);
28  if(BE::toUInt64(buff) != 0x4F70757348656164u) {
29  throw InvalidDataException(); // not Opus identification header
30  }
31  iterator.read(buff, sizeof(buff));
32  m_version = static_cast<byte>(*(buff));
33  m_channels = static_cast<byte>(*(buff + 1));
34  m_preSkip = LE::toUInt16(buff + 2);
35  m_sampleRate = LE::toUInt32(buff + 4);
36  m_outputGain = LE::toUInt16(buff + 8);
37  m_channelMap = static_cast<byte>(*(buff + 10));
38 }
39 
40 }
STL namespace.
The exception that is thrown when the data to be parsed or to be made seems invalid and therefore can...
Definition: exceptions.h:27
void read(char *buffer, std::size_t count)
Reads count bytes from the OGG stream and writes it to the specified buffer.
The OggIterator class helps iterating through all segments of an OGG bitstream.
Definition: oggiterator.h:11
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9