Tag Parser  8.0.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
flactooggmappingheader.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 TagParser {
13 
24 void FlacToOggMappingHeader::parseHeader(OggIterator &iterator)
25 {
26  // prepare parsing
27  char buff[0x0D + 0x04 + 0x22 - 0x05];
28  iterator.read(buff, 5);
29  if (*buff != 0x7Fu || BE::toUInt32(buff + 1) != 0x464C4143u) {
30  throw InvalidDataException(); // not FLAC-to-Ogg mapping header
31  }
32  iterator.read(buff, sizeof(buff));
33 
34  // parse FLAC-to-Ogg mapping header
35  m_majorVersion = static_cast<byte>(*(buff + 0x00));
36  m_minorVersion = static_cast<byte>(*(buff + 0x01));
37  m_headerCount = BE::toUInt16(buff + 0x02);
38  if (BE::toUInt32(buff + 0x04) != 0x664C6143u) {
39  throw InvalidDataException(); // native FLAC signature not present
40  }
41 
42  // parse "METADATA_BLOCK_HEADER"
44  header.parseHeader(buff + 0x0D - 0x05);
45  if (header.type() != FlacMetaDataBlockType::StreamInfo) {
46  throw InvalidDataException(); // "METADATA_BLOCK_STREAMINFO" expected
47  }
48  if (header.dataSize() < 0x22) {
49  throw TruncatedDataException(); // "METADATA_BLOCK_STREAMINFO" is truncated
50  }
51 
52  // parse "METADATA_BLOCK_STREAMINFO"
53  m_streamInfo.parse(buff + 0x0D + 0x04 - 0x05);
54 }
55 
56 } // namespace TagParser
The exception that is thrown when the data to be parsed is truncated and therefore can not be parsed ...
Definition: exceptions.h:32
constexpr uint32 dataSize() const
Returns the length in bytes of the meta data (excluding the size of the header itself).
Definition: flacmetadata.h:96
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
STL namespace.
The FlacMetaDataBlockHeader class is a FLAC "METADATA_BLOCK_HEADER" parser and maker.
Definition: flacmetadata.h:29
The exception that is thrown when the data to be parsed or to be made seems invalid and therefore can...
Definition: exceptions.h:25
void parseHeader(const char *buffer)
Parses the FLAC "METADATA_BLOCK_HEADER" which is read using the specified iterator.
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:9
constexpr byte type() const
Returns the block type.
Definition: flacmetadata.h:80