Tag Parser
9.1.3
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
Go to the documentation of this file.
7 #include "../exceptions.h"
8 #include "../mediafileinfo.h"
10 #include <c++utilities/conversion/stringbuilder.h>
11 #include <c++utilities/io/binaryreader.h>
12 #include <c++utilities/io/binarywriter.h>
53 string Mp4Atom::parsingContext()
const
63 static const string context(
"parsing MP4 atom");
66 argsToString(
"Atom is smaller than 8 byte and hence invalid. The remaining size within the parent atom is ",
maxTotalSize(),
'.'),
81 diag.emplace_back(
DiagLevel::Critical,
"Atom is smaller than 8 byte and hence invalid.", context);
90 diag.emplace_back(
DiagLevel::Critical,
"Atom denoting 64-bit size is smaller than 16 byte and hence invalid.", parsingContext());
97 diag.emplace_back(
DiagLevel::Warning,
"The atom seems to be truncated; unable to parse siblings of that ", parsingContext());
135 ostream::pos_type currentOffset =
stream.tellp();
137 if (atomSize > numeric_limits<std::uint32_t>::max()) {
138 diag.emplace_back(
DiagLevel::Fatal, argsToString(atomSize,
" exceeds maximum."),
"write 32-bit atom size");
143 writer.writeUInt32BE(
static_cast<std::uint32_t
>(atomSize));
144 stream.seekp(currentOffset);
159 ostream::pos_type currentOffset =
stream.tellp();
163 stream.seekp(4, ios_base::cur);
165 stream.seekp(currentOffset);
173 if (size < numeric_limits<std::uint32_t>::max()) {
174 writer.writeUInt32BE(
static_cast<std::uint32_t
>(size));
179 writer.writeUInt64BE(size);
192 using namespace Mp4AtomIds;
246 using namespace Mp4AtomIds;
266 using namespace Mp4AtomIds;
267 using namespace FourccIds;
std::unique_ptr< ImplementationType > m_nextSibling
CppUtilities::BinaryReader & reader()
Returns the related BinaryReader.
std::uint32_t m_sizeLength
std::iostream & stream()
Returns the related stream.
ContainerType & container()
Returns the related container.
std::uint64_t startOffset() const
Returns the start offset in the related stream.
std::uint64_t firstChildOffset() const
Returns the offset of the first child (relative to the start offset of this atom).
The Diagnostics class is a container for DiagMessage.
Contains all classes and functions of the TagInfo library.
bool isPadding() const
Returns an indication whether the atom is a padding element.
static constexpr std::uint8_t minimumElementSize()
Returns the mimimum element size.
static void makeHeader(std::uint64_t size, std::uint32_t id, CppUtilities::BinaryWriter &writer)
Writes an MP4 atom header to the specified stream.
std::string idToString() const
Converts the specified atom ID to a printable string.
DataSizeType dataSize() const
Returns the data size of the element in byte.
The GenericFileElement class helps to parse binary files which consist of an arboreal element strucut...
The class inherits from std::exception and serves as base class for exceptions thrown by the elements...
ImplementationType * parent()
Returns the parent of the element.
std::uint32_t headerSize() const
Returns the header size of the element in byte.
bool isParent() const
Returns an indication whether the atom is a parent element.
static void seekBackAndWriteAtomSize64(std::ostream &stream, const std::ostream::pos_type &startOffset)
This function helps to write the atom size after writing an atom to a stream.
The exception that is thrown when the data to be parsed holds no parsable information (e....
The exception that is thrown when the data to be parsed is truncated and therefore can not be parsed ...
static void seekBackAndWriteAtomSize(std::ostream &stream, const std::ostream::pos_type &startOffset, Diagnostics &diag)
This function helps to write the atom size after writing an atom to a stream.
void internalParse(Diagnostics &diag)
Parses the MP4 atom.
typename FileElementTraits< ImplementationType >::ContainerType ContainerType
Specifies the type of the corresponding container.
std::unique_ptr< ImplementationType > m_firstChild
CppUtilities::BinaryWriter & writer()
Returns the related BinaryWriter.
The Mp4Atom class helps to parse MP4 files.
std::uint64_t maxTotalSize() const
Returns maximum total size.
std::uint64_t totalSize() const
Returns the total size of the element.
Mp4Atom(ContainerType &container, std::uint64_t startOffset)
Constructs a new top level atom with the specified container at the specified startOffset.