Tag Parser  6.4.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
vorbisidentificationheader.cpp
Go to the documentation of this file.
2 #include "./vorbispackagetypes.h"
3 
4 #include "../ogg/oggiterator.h"
5 
6 #include "../exceptions.h"
7 
8 #include <c++utilities/conversion/binaryconversion.h>
9 
10 using namespace std;
11 using namespace ConversionUtilities;
12 
13 namespace Media {
14 
24 void VorbisIdentificationHeader::parseHeader(OggIterator &iterator)
25 {
26  char buff[30 - 7];
27  iterator.read(buff, 7);
28  if((BE::toUInt64(buff) & 0xffffffffffffff00u) != 0x01766F7262697300u) {
29  throw InvalidDataException(); // not Vorbis identification header
30  }
31  iterator.read(buff, sizeof(buff));
32  m_version = LE::toUInt32(buff);
33  m_channels = static_cast<byte>(*(buff + 4));
34  m_sampleRate = LE::toUInt32(buff + 5);
35  m_maxBitrate = LE::toUInt32(buff + 9);
36  m_nominalBitrate = LE::toUInt32(buff + 13);
37  m_minBitrate = LE::toUInt32(buff + 17);
38  m_blockSize = static_cast<byte>(*(buff + 21));
39  m_framingFlag = static_cast<byte>(*(buff + 22));
40 }
41 
42 }
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