Tag Parser
10.0.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>. More...
#include <matroskacontainer.h>
Public Member Functions | |
MatroskaContainer (MediaFileInfo &stream, std::uint64_t startOffset) | |
Constructs a new container for the specified fileInfo at the specified startOffset. More... | |
~MatroskaContainer () override | |
void | validateIndex (Diagnostics &diag, AbortableProgressFeedback &progress) |
Validates the file index (cue entries). More... | |
std::uint64_t | maxIdLength () const |
Returns the maximal ID length in bytes. More... | |
std::uint64_t | maxSizeLength () const |
Returns the maximal size length in bytes. More... | |
const std::vector< std::unique_ptr< MatroskaSeekInfo > > & | seekInfos () const |
Returns seek information read from "SeekHead"-elements when parsing segment info. More... | |
void | setMaxFullParseSize (std::uint64_t maxFullParseSize) |
Sets the maximal file size for a "full parse" in byte. More... | |
const std::vector< std::unique_ptr< MatroskaEditionEntry > > & | editionEntires () const |
Returns the edition entries. More... | |
MatroskaChapter * | chapter (std::size_t index) override |
Returns the chapter with the specified index. More... | |
std::size_t | chapterCount () const override |
Returns the number of chapters the container holds. More... | |
MatroskaAttachment * | createAttachment () override |
Creates and returns a new attachment. More... | |
MatroskaAttachment * | attachment (std::size_t index) override |
Returns the attachment with the specified index. More... | |
std::size_t | attachmentCount () const override |
Returns the number of attachments the container holds. More... | |
ElementPosition | determineElementPosition (std::uint64_t elementId, Diagnostics &diag) const |
Determines the position of the element with the specified elementId. More... | |
ElementPosition | determineTagPosition (Diagnostics &diag) const override |
Determines the position of the tags inside the file. More... | |
ElementPosition | determineIndexPosition (Diagnostics &diag) const override |
Determines the position of the index. More... | |
virtual bool | supportsTitle () const override |
Returns whether the title property is supported. More... | |
virtual std::size_t | segmentCount () const override |
Returns the number of segments. More... | |
void | reset () override |
Discards all parsing results. More... | |
![]() | |
GenericContainer (MediaFileInfo &fileInfo, std::uint64_t startOffset) | |
Constructs a new container for the specified fileInfo at the specified startOffset. More... | |
~GenericContainer () override | |
Destroys the container. More... | |
void | validateElementStructure (Diagnostics &diag, AbortableProgressFeedback &progress, std::uint64_t *paddingSize=nullptr) |
Parses all elements the file consists of. More... | |
MediaFileInfo & | fileInfo () const |
Returns the related file info. More... | |
EbmlElement * | firstElement () const |
Returns the first element of the file if available; otherwiese returns nullptr. More... | |
const std::vector< std::unique_ptr< EbmlElement > > & | additionalElements () const |
Returns all available additional elements. More... | |
std::vector< std::unique_ptr< EbmlElement > > & | additionalElements () |
Returns all available additional elements. More... | |
MatroskaTag * | tag (std::size_t index) override |
Returns the tag with the specified index. More... | |
std::size_t | tagCount () const override |
Returns the number of tags attached to the container. More... | |
MatroskaTrack * | track (std::size_t index) override |
Returns the track with the specified index. More... | |
MatroskaTrack * | trackById (std::uint64_t id) |
std::size_t | trackCount () const override |
Returns the number of tracks the container holds. More... | |
const std::vector< std::unique_ptr< MatroskaTag > > & | tags () const |
Returns the tags of the file. More... | |
std::vector< std::unique_ptr< MatroskaTag > > & | tags () |
Returns the tags of the file. More... | |
const std::vector< std::unique_ptr< MatroskaTrack > > & | tracks () const |
Returns the tracks of the file. More... | |
std::vector< std::unique_ptr< MatroskaTrack > > & | tracks () |
Returns the tracks of the file. More... | |
MatroskaTag * | createTag (const TagTarget &target=TagTarget()) override |
Creates and returns a tag for the specified target. More... | |
bool | removeTag (Tag *tag) override |
Removes the specified tag from the container. More... | |
void | removeAllTags () override |
Removes all tags attached to the container. More... | |
bool | addTrack (MatroskaTrack *track) |
Adds the specified track to the container. More... | |
bool | removeTrack (AbstractTrack *track) override |
Removes the specified track to the container. More... | |
void | removeAllTracks () override |
Removes all tracks from the container. More... | |
void | reset () override |
Discards all parsing results. More... | |
![]() | |
virtual | ~AbstractContainer () |
Destroys the container. More... | |
std::iostream & | stream () |
Returns the related stream. More... | |
void | setStream (std::iostream &stream) |
Sets the related stream. More... | |
std::uint64_t | startOffset () const |
Returns the start offset in the related stream. More... | |
CppUtilities::BinaryReader & | reader () |
Returns the related BinaryReader. More... | |
CppUtilities::BinaryWriter & | writer () |
Returns the related BinaryWriter. More... | |
void | parseHeader (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the header if not parsed yet. More... | |
void | parseTags (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the tag information if not parsed yet. More... | |
void | parseTracks (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the tracks of the file if not parsed yet. More... | |
void | parseChapters (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the chapters of the file if not parsed yet. More... | |
void | parseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the attachments of the file if not parsed yet. More... | |
void | makeFile (Diagnostics &diag, AbortableProgressFeedback &progress) |
Rewrites the file to apply changed tag information. More... | |
bool | isHeaderParsed () const |
Returns an indication whether the header has been parsed yet. More... | |
bool | areTagsParsed () const |
Returns an indication whether the tags have been parsed yet. More... | |
bool | areTracksParsed () const |
Returns an indication whether the tracks have been parsed yet. More... | |
bool | areChaptersParsed () const |
Returns an indication whether the chapters have been parsed yet. More... | |
bool | areAttachmentsParsed () const |
Returns an indication whether the attachments have been parsed yet. More... | |
virtual bool | supportsTrackModifications () const |
Returns whether the implementation supports adding or removing of tracks. More... | |
std::uint64_t | version () const |
Returns the version if known; otherwise returns 0. More... | |
std::uint64_t | readVersion () const |
Returns the "read version" if known; otherwise returns 0. More... | |
const std::string & | documentType () const |
Returns a string that describes the document type if available; otherwise returns an empty string. More... | |
std::uint64_t | doctypeVersion () const |
Returns the document type version if known; otherwise returns 0. More... | |
std::uint64_t | doctypeReadVersion () const |
Returns the document type "read version" if known; otherwise returns 0. More... | |
const std::vector< std::string > & | titles () const |
Returns the title(s) of the file. More... | |
void | setTitle (std::string_view title, std::size_t segmentIndex=0) |
Sets the title for the specified segment. More... | |
CppUtilities::TimeSpan | duration () const |
Returns the duration of the file if known; otherwise returns a time span of zero ticks. More... | |
CppUtilities::DateTime | creationTime () const |
Returns the creation time of the file if known; otherwise the returned date time is null. More... | |
CppUtilities::DateTime | modificationTime () const |
Returns the modification time of the file if known; otherwise the returned date time is null. More... | |
std::uint32_t | timeScale () const |
Returns the time scale of the file if known; otherwise returns 0. More... | |
Static Public Member Functions | |
static std::uint64_t | maxFullParseSize () |
Returns the maximal file size for a "full parse" in byte. More... | |
Protected Member Functions | |
void | internalParseHeader (Diagnostics &diag, AbortableProgressFeedback &progress) override |
Internally called to parse the header. More... | |
void | internalParseTags (Diagnostics &diag, AbortableProgressFeedback &progress) override |
Internally called to parse the tags. More... | |
void | internalParseTracks (Diagnostics &diag, AbortableProgressFeedback &progress) override |
Internally called to parse the tracks. More... | |
void | internalParseChapters (Diagnostics &diag, AbortableProgressFeedback &progress) override |
Internally called to parse the chapters. More... | |
void | internalParseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress) override |
Internally called to parse the attachments. More... | |
void | internalMakeFile (Diagnostics &diag, AbortableProgressFeedback &progress) override |
Internally called to make the file. More... | |
![]() | |
AbstractContainer (std::iostream &stream, std::uint64_t startOffset) | |
Constructs a new container for the specified file stream at the specified startOffset. More... | |
Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
Definition at line 24 of file matroskacontainer.h.
TagParser::MatroskaContainer::MatroskaContainer | ( | MediaFileInfo & | stream, |
std::uint64_t | startOffset | ||
) |
Constructs a new container for the specified fileInfo at the specified startOffset.
Definition at line 43 of file matroskacontainer.cpp.
|
override |
Definition at line 56 of file matroskacontainer.cpp.
|
inlineoverridevirtual |
Returns the attachment with the specified index.
index must be less than attachmentCount().
Reimplemented from TagParser::AbstractContainer.
Definition at line 137 of file matroskacontainer.h.
|
inlineoverridevirtual |
Returns the number of attachments the container holds.
Reimplemented from TagParser::AbstractContainer.
Definition at line 142 of file matroskacontainer.h.
|
overridevirtual |
Returns the chapter with the specified index.
index must be less than chapterCount().
Reimplemented from TagParser::AbstractContainer.
Definition at line 316 of file matroskacontainer.cpp.
|
overridevirtual |
Returns the number of chapters the container holds.
Reimplemented from TagParser::AbstractContainer.
Definition at line 329 of file matroskacontainer.cpp.
|
overridevirtual |
Creates and returns a new attachment.
Reimplemented from TagParser::AbstractContainer.
Definition at line 338 of file matroskacontainer.cpp.
ElementPosition TagParser::MatroskaContainer::determineElementPosition | ( | std::uint64_t | elementId, |
Diagnostics & | diag | ||
) | const |
Determines the position of the element with the specified elementId.
Definition at line 367 of file matroskacontainer.cpp.
|
overridevirtual |
Determines the position of the index.
Reimplemented from TagParser::AbstractContainer.
Definition at line 398 of file matroskacontainer.cpp.
|
overridevirtual |
Determines the position of the tags inside the file.
Reimplemented from TagParser::AbstractContainer.
Definition at line 393 of file matroskacontainer.cpp.
|
inline |
Returns the edition entries.
Definition at line 132 of file matroskacontainer.h.
|
overrideprotectedvirtual |
Internally called to make the file.
Must be implemented when subclassing.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented from TagParser::AbstractContainer.
Definition at line 852 of file matroskacontainer.cpp.
|
overrideprotectedvirtual |
Internally called to parse the attachments.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented from TagParser::AbstractContainer.
Definition at line 768 of file matroskacontainer.cpp.
|
overrideprotectedvirtual |
Internally called to parse the chapters.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented from TagParser::AbstractContainer.
Definition at line 734 of file matroskacontainer.cpp.
|
overrideprotectedvirtual |
Internally called to parse the header.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented from TagParser::AbstractContainer.
Definition at line 403 of file matroskacontainer.cpp.
|
overrideprotectedvirtual |
Internally called to parse the tags.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented from TagParser::AbstractContainer.
Definition at line 661 of file matroskacontainer.cpp.
|
overrideprotectedvirtual |
Internally called to parse the tracks.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented from TagParser::AbstractContainer.
Definition at line 698 of file matroskacontainer.cpp.
|
inlinestatic |
Returns the maximal file size for a "full parse" in byte.
The "Tags" element (which holds the tag information) is commonly at the end of a Matroska file. Hence the parser needs to walk through the entire file to find the tag information if no "SeekHead" element is present which might causes long loading times. To avoid this a maximal file size for a "full parse" can be specified. The disadvantage is that the parser relies on the presence of a SeekHead element on larger files to retrieve tag information.
The default value is 50 MiB.
Definition at line 115 of file matroskacontainer.h.
|
inline |
Returns the maximal ID length in bytes.
Definition at line 81 of file matroskacontainer.h.
|
inline |
Returns the maximal size length in bytes.
Definition at line 89 of file matroskacontainer.h.
|
overridevirtual |
Discards all parsing results.
Reimplemented from TagParser::AbstractContainer.
Definition at line 60 of file matroskacontainer.cpp.
|
inline |
Returns seek information read from "SeekHead"-elements when parsing segment info.
Definition at line 97 of file matroskacontainer.h.
|
inlineoverridevirtual |
Returns the number of segments.
Reimplemented from TagParser::AbstractContainer.
Definition at line 152 of file matroskacontainer.h.
|
inline |
Sets the maximal file size for a "full parse" in byte.
Definition at line 124 of file matroskacontainer.h.
|
inlineoverridevirtual |
Returns whether the title property is supported.
Reimplemented from TagParser::AbstractContainer.
Definition at line 147 of file matroskacontainer.h.
void TagParser::MatroskaContainer::validateIndex | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress | ||
) |
Validates the file index (cue entries).
Definition at line 85 of file matroskacontainer.cpp.