Tag Parser 12.3.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
TagParser::MatroskaContainer Class Reference

Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>. More...

#include <matroskacontainer.h>

Inheritance diagram for TagParser::MatroskaContainer:
[legend]
Collaboration diagram for TagParser::MatroskaContainer:
[legend]

Public Member Functions

 MatroskaContainer (MediaFileInfo &stream, std::uint64_t startOffset)
 Constructs a new container for the specified fileInfo at the specified startOffset.
 
 ~MatroskaContainer () override
 
void validateIndex (Diagnostics &diag, AbortableProgressFeedback &progress)
 Validates the file index (cue entries).
 
std::uint64_t maxIdLength () const
 Returns the maximal ID length in bytes.
 
std::uint64_t maxSizeLength () const
 Returns the maximal size length in bytes.
 
const std::vector< std::unique_ptr< MatroskaSeekInfo > > & seekInfos () const
 Returns seek information read from "SeekHead"-elements when parsing segment info.
 
const std::vector< std::unique_ptr< MatroskaEditionEntry > > & editionEntires () const
 Returns the edition entries.
 
MatroskaChapterchapter (std::size_t index) override
 Returns the chapter with the specified index.
 
std::size_t chapterCount () const override
 Returns the number of chapters the container holds.
 
MatroskaAttachmentcreateAttachment () override
 Creates and returns a new attachment.
 
MatroskaAttachmentattachment (std::size_t index) override
 Returns the attachment with the specified index.
 
std::size_t attachmentCount () const override
 Returns the number of attachments the container holds.
 
ElementPosition determineElementPosition (std::uint64_t elementId, Diagnostics &diag) const
 Determines the position of the element with the specified elementId.
 
ElementPosition determineTagPosition (Diagnostics &diag) const override
 Determines the position of the tags inside the file.
 
ElementPosition determineIndexPosition (Diagnostics &diag) const override
 Determines the position of the index.
 
virtual bool supportsTitle () const override
 Returns whether the title property is supported.
 
virtual std::size_t segmentCount () const override
 Returns the number of segments.
 
void reset () override
 Discards all parsing results.
 
- Public Member Functions inherited from TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >
 GenericContainer (MediaFileInfo &fileInfo, std::uint64_t startOffset)
 Constructs a new container for the specified fileInfo at the specified startOffset.
 
 ~GenericContainer () override
 Destroys the container.
 
void validateElementStructure (Diagnostics &diag, AbortableProgressFeedback &progress, std::uint64_t *paddingSize=nullptr)
 Parses all elements the file consists of.
 
MediaFileInfofileInfo () const
 Returns the related file info.
 
EbmlElementfirstElement () const
 Returns the first element of the file if available; otherwiese returns nullptr.
 
const std::vector< std::unique_ptr< EbmlElement > > & additionalElements () const
 Returns all available additional elements.
 
std::vector< std::unique_ptr< EbmlElement > > & additionalElements ()
 Returns all available additional elements.
 
MatroskaTagtag (std::size_t index) override
 Returns the tag with the specified index.
 
std::size_t tagCount () const override
 Returns the number of tags attached to the container.
 
MatroskaTracktrack (std::size_t index) override
 Returns the track with the specified index.
 
MatroskaTracktrackById (std::uint64_t id)
 
std::size_t trackCount () const override
 Returns the number of tracks the container holds.
 
const std::vector< std::unique_ptr< MatroskaTag > > & tags () const
 Returns the tags of the file.
 
std::vector< std::unique_ptr< MatroskaTag > > & tags ()
 Returns the tags of the file.
 
const std::vector< std::unique_ptr< MatroskaTrack > > & tracks () const
 Returns the tracks of the file.
 
std::vector< std::unique_ptr< MatroskaTrack > > & tracks ()
 Returns the tracks of the file.
 
MatroskaTagcreateTag (const TagTarget &target=TagTarget()) override
 Creates and returns a tag for the specified target.
 
bool removeTag (Tag *tag) override
 Removes the specified tag from the container.
 
void removeAllTags () override
 Removes all tags attached to the container.
 
bool addTrack (MatroskaTrack *track)
 Adds the specified track to the container.
 
bool removeTrack (AbstractTrack *track) override
 Removes the specified track to the container.
 
void removeAllTracks () override
 Removes all tracks from the container.
 
- Public Member Functions inherited from TagParser::AbstractContainer
virtual ~AbstractContainer ()
 Destroys the container.
 
std::iostream & stream ()
 Returns the related stream.
 
void setStream (std::iostream &stream)
 Sets the related stream.
 
std::uint64_t startOffset () const
 Returns the start offset in the related stream.
 
CppUtilities::BinaryReader & reader ()
 Returns the related BinaryReader.
 
CppUtilities::BinaryWriter & writer ()
 Returns the related BinaryWriter.
 
void parseHeader (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the header if not parsed yet.
 
void parseTags (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the tag information if not parsed yet.
 
void parseTracks (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the tracks of the file if not parsed yet.
 
void parseChapters (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the chapters of the file if not parsed yet.
 
void parseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the attachments of the file if not parsed yet.
 
void makeFile (Diagnostics &diag, AbortableProgressFeedback &progress)
 Rewrites the file to apply changed tag information.
 
bool isHeaderParsed () const
 Returns an indication whether the header has been parsed yet.
 
bool areTagsParsed () const
 Returns an indication whether the tags have been parsed yet.
 
bool areTracksParsed () const
 Returns an indication whether the tracks have been parsed yet.
 
bool areChaptersParsed () const
 Returns an indication whether the chapters have been parsed yet.
 
bool areAttachmentsParsed () const
 Returns an indication whether the attachments have been parsed yet.
 
virtual bool supportsTrackModifications () const
 Returns whether the implementation supports adding or removing of tracks.
 
std::uint64_t version () const
 Returns the version if known; otherwise returns 0.
 
std::uint64_t readVersion () const
 Returns the "read version" if known; otherwise returns 0.
 
const std::string & documentType () const
 Returns a string that describes the document type if available; otherwise returns an empty string.
 
std::uint64_t doctypeVersion () const
 Returns the document type version if known; otherwise returns 0.
 
std::uint64_t doctypeReadVersion () const
 Returns the document type "read version" if known; otherwise returns 0.
 
const std::vector< std::string > & titles () const
 Returns the title(s) of the file.
 
void setTitle (std::string_view title, std::size_t segmentIndex=0)
 Sets the title for the specified segment.
 
const std::vector< std::string > & muxingApplications () const
 Returns the muxing applications specified as meta-data.
 
const std::vector< std::string > & writingApplications () const
 Returns the writing applications specified as meta-data.
 
CppUtilities::TimeSpan duration () const
 Returns the duration of the file if known; otherwise returns a time span of zero ticks.
 
CppUtilities::DateTime creationTime () const
 Returns the creation time of the file if known; otherwise the returned date time is null.
 
CppUtilities::DateTime modificationTime () const
 Returns the modification time of the file if known; otherwise the returned date time is null.
 
std::uint32_t timeScale () const
 Returns the time scale of the file if known; otherwise returns 0.
 

Protected Member Functions

void internalParseHeader (Diagnostics &diag, AbortableProgressFeedback &progress) override
 Internally called to parse the header.
 
void internalParseTags (Diagnostics &diag, AbortableProgressFeedback &progress) override
 Internally called to parse the tags.
 
void internalParseTracks (Diagnostics &diag, AbortableProgressFeedback &progress) override
 Internally called to parse the tracks.
 
void internalParseChapters (Diagnostics &diag, AbortableProgressFeedback &progress) override
 Internally called to parse the chapters.
 
void internalParseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress) override
 Internally called to parse the attachments.
 
void internalMakeFile (Diagnostics &diag, AbortableProgressFeedback &progress) override
 Internally called to make the file.
 
- Protected Member Functions inherited from TagParser::AbstractContainer
 AbstractContainer (std::iostream &stream, std::uint64_t startOffset)
 Constructs a new container for the specified file stream at the specified startOffset.
 
std::vector< std::string > & muxingApplications ()
 Returns the muxing applications specified as meta-data.
 
std::vector< std::string > & writingApplications ()
 Returns the writing applications specified as meta-data.
 

Additional Inherited Members

- Public Types inherited from TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >
using ContainerFileInfoType
 
using ContainerTagType
 
using ContainerTrackType
 
using ContainerElementType
 
- Protected Attributes inherited from TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >
std::unique_ptr< EbmlElementm_firstElement
 
std::vector< std::unique_ptr< EbmlElement > > m_additionalElements
 
std::vector< std::unique_ptr< MatroskaTag > > m_tags
 
std::vector< std::unique_ptr< MatroskaTrack > > m_tracks
 
- Protected Attributes inherited from TagParser::AbstractContainer
std::uint64_t m_version
 
std::uint64_t m_readVersion
 
std::string m_doctype
 
std::uint64_t m_doctypeVersion
 
std::uint64_t m_doctypeReadVersion
 
std::vector< std::string > m_titles
 
CppUtilities::TimeSpan m_duration
 
CppUtilities::DateTime m_creationTime
 
CppUtilities::DateTime m_modificationTime
 
std::uint32_t m_timeScale
 
bool m_headerParsed
 
bool m_tagsParsed
 
bool m_tracksParsed
 
bool m_tracksAltered
 
bool m_chaptersParsed
 
bool m_attachmentsParsed
 

Detailed Description

Constructor & Destructor Documentation

◆ MatroskaContainer()

TagParser::MatroskaContainer::MatroskaContainer ( MediaFileInfo & stream,
std::uint64_t startOffset )

Constructs a new container for the specified fileInfo at the specified startOffset.

Definition at line 41 of file matroskacontainer.cpp.

◆ ~MatroskaContainer()

TagParser::MatroskaContainer::~MatroskaContainer ( )
override

Definition at line 54 of file matroskacontainer.cpp.

Member Function Documentation

◆ attachment()

MatroskaAttachment * TagParser::MatroskaContainer::attachment ( std::size_t index)
inlineoverridevirtual

Returns the attachment with the specified index.

index must be less than attachmentCount().

Reimplemented from TagParser::AbstractContainer.

Definition at line 107 of file matroskacontainer.h.

◆ attachmentCount()

std::size_t TagParser::MatroskaContainer::attachmentCount ( ) const
inlineoverridevirtual

Returns the number of attachments the container holds.

Reimplemented from TagParser::AbstractContainer.

Definition at line 112 of file matroskacontainer.h.

◆ chapter()

MatroskaChapter * TagParser::MatroskaContainer::chapter ( std::size_t index)
overridevirtual

Returns the chapter with the specified index.

index must be less than chapterCount().

Reimplemented from TagParser::AbstractContainer.

Definition at line 314 of file matroskacontainer.cpp.

◆ chapterCount()

size_t TagParser::MatroskaContainer::chapterCount ( ) const
overridevirtual

Returns the number of chapters the container holds.

Reimplemented from TagParser::AbstractContainer.

Definition at line 327 of file matroskacontainer.cpp.

◆ createAttachment()

MatroskaAttachment * TagParser::MatroskaContainer::createAttachment ( )
overridevirtual

Creates and returns a new attachment.

Returns
Returns the created attachment.
Remarks
The container keeps the ownership over the created attachment.

Reimplemented from TagParser::AbstractContainer.

Definition at line 336 of file matroskacontainer.cpp.

◆ determineElementPosition()

ElementPosition TagParser::MatroskaContainer::determineElementPosition ( std::uint64_t elementId,
Diagnostics & diag ) const

Determines the position of the element with the specified elementId.

See also
determineTagPosition() and determineIndexPosition()

Definition at line 365 of file matroskacontainer.cpp.

◆ determineIndexPosition()

ElementPosition TagParser::MatroskaContainer::determineIndexPosition ( Diagnostics & diag) const
overridevirtual

Determines the position of the index.

Returns
Returns ElementPosition::BeforeData or ElementPosition::AfterData if the position could be determined; otherwise returns ElementPosition::Keep.
Remarks
  • It might be required to parse tracks before the index position can be determined.
  • Not be applicable for files composed of multiple segments.
See also
MediaFileInfo::indexPosition()

Reimplemented from TagParser::AbstractContainer.

Definition at line 396 of file matroskacontainer.cpp.

◆ determineTagPosition()

ElementPosition TagParser::MatroskaContainer::determineTagPosition ( Diagnostics & diag) const
overridevirtual

Determines the position of the tags inside the file.

Returns
Returns ElementPosition::BeforeData or ElementPosition::AfterData if the position could be determined; otherwise returns ElementPosition::Keep.
Remarks
  • It might be required to parse tags before the tag position can be determined.
  • Not be applicable for files composed of multiple segments.
See also
MediaFileInfo::tagPosition()

Reimplemented from TagParser::AbstractContainer.

Definition at line 391 of file matroskacontainer.cpp.

◆ editionEntires()

const std::vector< std::unique_ptr< MatroskaEditionEntry > > & TagParser::MatroskaContainer::editionEntires ( ) const
inline

Returns the edition entries.

Definition at line 102 of file matroskacontainer.h.

◆ internalMakeFile()

void TagParser::MatroskaContainer::internalMakeFile ( Diagnostics & diag,
AbortableProgressFeedback & progress )
overrideprotectedvirtual

Internally called to make the file.

Must be implemented when subclassing.

Exceptions
ThrowsFailure or a derived class when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Reimplemented from TagParser::AbstractContainer.

Definition at line 861 of file matroskacontainer.cpp.

◆ internalParseAttachments()

void TagParser::MatroskaContainer::internalParseAttachments ( Diagnostics & diag,
AbortableProgressFeedback & progress )
overrideprotectedvirtual

Internally called to parse the attachments.

Must be implemented when subclassing to provide this feature.

Exceptions
ThrowsFailure or a derived class when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Reimplemented from TagParser::AbstractContainer.

Definition at line 776 of file matroskacontainer.cpp.

◆ internalParseChapters()

void TagParser::MatroskaContainer::internalParseChapters ( Diagnostics & diag,
AbortableProgressFeedback & progress )
overrideprotectedvirtual

Internally called to parse the chapters.

Must be implemented when subclassing to provide this feature.

Exceptions
ThrowsFailure or a derived class when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Reimplemented from TagParser::AbstractContainer.

Definition at line 742 of file matroskacontainer.cpp.

◆ internalParseHeader()

void TagParser::MatroskaContainer::internalParseHeader ( Diagnostics & diag,
AbortableProgressFeedback & progress )
overrideprotectedvirtual

Internally called to parse the header.

Must be implemented when subclassing to provide this feature.

Exceptions
ThrowsFailure or a derived class when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Reimplemented from TagParser::AbstractContainer.

Definition at line 401 of file matroskacontainer.cpp.

◆ internalParseTags()

void TagParser::MatroskaContainer::internalParseTags ( Diagnostics & diag,
AbortableProgressFeedback & progress )
overrideprotectedvirtual

Internally called to parse the tags.

Must be implemented when subclassing to provide this feature.

Exceptions
ThrowsFailure or a derived class when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Reimplemented from TagParser::AbstractContainer.

Definition at line 665 of file matroskacontainer.cpp.

◆ internalParseTracks()

void TagParser::MatroskaContainer::internalParseTracks ( Diagnostics & diag,
AbortableProgressFeedback & progress )
overrideprotectedvirtual

Internally called to parse the tracks.

Must be implemented when subclassing to provide this feature.

Exceptions
ThrowsFailure or a derived class when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Reimplemented from TagParser::AbstractContainer.

Definition at line 706 of file matroskacontainer.cpp.

◆ maxIdLength()

std::uint64_t TagParser::MatroskaContainer::maxIdLength ( ) const
inline

Returns the maximal ID length in bytes.

Definition at line 78 of file matroskacontainer.h.

◆ maxSizeLength()

std::uint64_t TagParser::MatroskaContainer::maxSizeLength ( ) const
inline

Returns the maximal size length in bytes.

Definition at line 86 of file matroskacontainer.h.

◆ reset()

void TagParser::MatroskaContainer::reset ( )
overridevirtual

Discards all parsing results.

Reimplemented from TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >.

Definition at line 58 of file matroskacontainer.cpp.

◆ seekInfos()

const std::vector< std::unique_ptr< MatroskaSeekInfo > > & TagParser::MatroskaContainer::seekInfos ( ) const
inline

Returns seek information read from "SeekHead"-elements when parsing segment info.

Definition at line 94 of file matroskacontainer.h.

◆ segmentCount()

std::size_t TagParser::MatroskaContainer::segmentCount ( ) const
inlineoverridevirtual

Returns the number of segments.

Reimplemented from TagParser::AbstractContainer.

Definition at line 122 of file matroskacontainer.h.

◆ supportsTitle()

bool TagParser::MatroskaContainer::supportsTitle ( ) const
inlineoverridevirtual

Returns whether the title property is supported.

Reimplemented from TagParser::AbstractContainer.

Definition at line 117 of file matroskacontainer.h.

◆ validateIndex()

void TagParser::MatroskaContainer::validateIndex ( Diagnostics & diag,
AbortableProgressFeedback & progress )

Validates the file index (cue entries).

Remarks
Checks only for cluster positions and missing, unknown or surplus elements.

Definition at line 83 of file matroskacontainer.cpp.


The documentation for this class was generated from the following files: