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> 54 string Mp4Atom::parsingContext()
const 64 static const string context(
"parsing MP4 atom");
67 argsToString(
"Atom is smaller than 8 byte and hence invalid. The remaining size within the parent atom is ",
maxTotalSize(),
'.'),
82 diag.emplace_back(
DiagLevel::Critical,
"Atom is smaller than 8 byte and hence invalid.", context);
91 diag.emplace_back(
DiagLevel::Critical,
"Atom denoting 64-bit size is smaller than 16 byte and hence invalid.", parsingContext());
98 diag.emplace_back(
DiagLevel::Warning,
"The atom seems to be truncated; unable to parse siblings of that ", parsingContext());
132 ostream::pos_type currentOffset =
stream.tellp();
136 stream.seekp(currentOffset);
150 ostream::pos_type currentOffset =
stream.tellp();
154 stream.seekp(4, ios_base::cur);
156 stream.seekp(currentOffset);
164 if (size < numeric_limits<uint32>::max()) {
165 writer.writeUInt32BE(static_cast<uint32>(size));
170 writer.writeUInt64BE(size);
183 using namespace Mp4AtomIds;
234 using namespace Mp4AtomIds;
254 using namespace Mp4AtomIds;
255 using namespace FourccIds;
bool isParent() const
Returns an indication whether the atom is a parent element.
FileElementTraits< ImplementationType >::ContainerType ContainerType
Specifies the type of the corresponding container.
Mp4Atom(ContainerType &container, uint64 startOffset)
Constructs a new top level atom with the specified container at the specified startOffset.
std::unique_ptr< ImplementationType > m_firstChild
std::unique_ptr< ImplementationType > m_nextSibling
DataSizeType dataSize() const
Returns the data size of the element in byte.
uint64 startOffset() const
Returns the start offset in the related stream.
bool isPadding() const
Returns an indication whether the atom is a padding element.
uint64 totalSize() const
Returns the total size of the element.
static constexpr byte minimumElementSize()
Returns the mimimum element size.
IoUtilities::BinaryReader & reader()
Returns the related BinaryReader.
Contains utility classes helping to read and write streams.
ContainerType & container()
Returns the related container.
void internalParse(Diagnostics &diag)
Parses the MP4 atom.
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.
uint64 firstChildOffset() const
Returns the offset of the first child (relative to the start offset of this atom).
static void seekBackAndWriteAtomSize(std::ostream &stream, const std::ostream::pos_type &startOffset)
This function helps to write the atom size after writing an atom to a stream.
uint32 headerSize() const
Returns the header size of the element in byte.
IoUtilities::BinaryWriter & writer()
Returns the related BinaryWriter.
uint64 maxTotalSize() const
Returns maximum total size.
static void makeHeader(uint64 size, uint32 id, IoUtilities::BinaryWriter &writer)
Writes an MP4 atom header to the specified stream.
std::iostream & stream()
Returns the related stream.
std::string idToString() const
Converts the specified atom ID to a printable string.
ImplementationType * parent()
Returns the parent of the element.