Tag Parser 12.4.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
The AbstractContainer class provides an interface and common functionality to parse and make a certain container format. More...
#include <abstractcontainer.h>
Public Member Functions | |
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 Tag * | createTag (const TagTarget &target=TagTarget()) |
Creates and returns a tag for the specified target. | |
virtual Tag * | tag (std::size_t index) |
Returns the tag with the specified index. | |
virtual std::size_t | tagCount () const |
Returns the number of tags attached to the container. | |
virtual bool | removeTag (Tag *tag) |
Removes the specified tag from the container. | |
virtual void | removeAllTags () |
Removes all tags attached to the container. | |
virtual ElementPosition | determineTagPosition (Diagnostics &diag) const |
Determines the position of the tags inside the file. | |
virtual AbstractTrack * | track (std::size_t index) |
Returns the track with the specified index. | |
virtual std::size_t | trackCount () const |
Returns the number of tracks the container holds. | |
virtual bool | removeTrack (AbstractTrack *track) |
Removes the specified track to the container. | |
virtual void | removeAllTracks () |
Removes all tracks from the container. | |
virtual bool | supportsTrackModifications () const |
Returns whether the implementation supports adding or removing of tracks. | |
virtual ElementPosition | determineIndexPosition (Diagnostics &diag) const |
Determines the position of the index. | |
virtual AbstractChapter * | chapter (std::size_t index) |
Returns the chapter with the specified index. | |
virtual std::size_t | chapterCount () const |
Returns the number of chapters the container holds. | |
virtual AbstractAttachment * | createAttachment () |
Creates and returns a new attachment. | |
virtual AbstractAttachment * | attachment (std::size_t index) |
Returns the attachment with the specified index. | |
virtual std::size_t | attachmentCount () const |
Returns the number of attachments the container holds. | |
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. | |
virtual bool | supportsTitle () const |
Returns whether the title property is supported. | |
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. | |
virtual std::size_t | segmentCount () const |
Returns the number of segments. | |
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. | |
virtual void | reset () |
Discards all parsing results. | |
Protected Member Functions | |
AbstractContainer (std::iostream &stream, std::uint64_t startOffset) | |
Constructs a new container for the specified file stream at the specified startOffset. | |
virtual void | internalParseHeader (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the header. | |
virtual void | internalParseTags (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the tags. | |
virtual void | internalParseTracks (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the tracks. | |
virtual void | internalParseChapters (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the chapters. | |
virtual void | internalParseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the attachments. | |
virtual void | internalMakeFile (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to make the file. | |
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. | |
Protected Attributes | |
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 |
The AbstractContainer class provides an interface and common functionality to parse and make a certain container format.
|
virtual |
Destroys the container.
Destroys the reader, the writer and track, tag, chapter and attachment objects as well. Does NOT destroy the stream which has been specified when constructing the object.
Definition at line 47 of file abstractcontainer.cpp.
|
protected |
Constructs a new container for the specified file stream at the specified startOffset.
Definition at line 22 of file abstractcontainer.cpp.
|
inline |
Returns an indication whether the attachments have been parsed yet.
Definition at line 202 of file abstractcontainer.h.
|
inline |
Returns an indication whether the chapters have been parsed yet.
Definition at line 194 of file abstractcontainer.h.
|
inline |
Returns an indication whether the tags have been parsed yet.
Definition at line 186 of file abstractcontainer.h.
|
inline |
Returns an indication whether the tracks have been parsed yet.
Definition at line 210 of file abstractcontainer.h.
|
virtual |
Returns the attachment with the specified index.
index must be less than attachmentCount().
Reimplemented in TagParser::MatroskaContainer.
Definition at line 458 of file abstractcontainer.cpp.
|
virtual |
Returns the number of attachments the container holds.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 467 of file abstractcontainer.cpp.
|
virtual |
Returns the chapter with the specified index.
index must be less than chapterCount().
Reimplemented in TagParser::MatroskaContainer.
Definition at line 429 of file abstractcontainer.cpp.
|
virtual |
Returns the number of chapters the container holds.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 438 of file abstractcontainer.cpp.
|
virtual |
Creates and returns a new attachment.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 448 of file abstractcontainer.cpp.
Creates and returns a tag for the specified target.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, and TagParser::OggContainer.
Definition at line 294 of file abstractcontainer.cpp.
|
inline |
Returns the creation time of the file if known; otherwise the returned date time is null.
Definition at line 293 of file abstractcontainer.h.
|
virtual |
Determines the position of the index.
Reimplemented in TagParser::MatroskaContainer, and TagParser::Mp4Container.
Definition at line 188 of file abstractcontainer.cpp.
|
virtual |
Determines the position of the tags inside the file.
Reimplemented in TagParser::MatroskaContainer, and TagParser::Mp4Container.
Definition at line 362 of file abstractcontainer.cpp.
|
inline |
Returns the document type "read version" if known; otherwise returns 0.
This is the minimum version an interpreter has to support to read the file.
Definition at line 254 of file abstractcontainer.h.
|
inline |
Returns the document type version if known; otherwise returns 0.
Definition at line 244 of file abstractcontainer.h.
|
inline |
Returns a string that describes the document type if available; otherwise returns an empty string.
Definition at line 236 of file abstractcontainer.h.
|
inline |
Returns the duration of the file if known; otherwise returns a time span of zero ticks.
Definition at line 285 of file abstractcontainer.h.
|
protectedvirtual |
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 in TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 277 of file abstractcontainer.cpp.
|
protectedvirtual |
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 in TagParser::MatroskaContainer.
Definition at line 262 of file abstractcontainer.cpp.
|
protectedvirtual |
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 in TagParser::MatroskaContainer.
Definition at line 247 of file abstractcontainer.cpp.
|
protectedvirtual |
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 in TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 202 of file abstractcontainer.cpp.
|
protectedvirtual |
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 in TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 217 of file abstractcontainer.cpp.
|
protectedvirtual |
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 in TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 232 of file abstractcontainer.cpp.
|
inline |
Returns an indication whether the header has been parsed yet.
Definition at line 178 of file abstractcontainer.h.
void TagParser::AbstractContainer::makeFile | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress ) |
Rewrites the file to apply changed tag information.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | TagParser::Failure or a derived exception when a making error occurs. |
Definition at line 166 of file abstractcontainer.cpp.
|
inline |
Returns the modification time of the file if known; otherwise the returned date time is null.
Definition at line 301 of file abstractcontainer.h.
|
protected |
Returns the muxing applications specified as meta-data.
Definition at line 492 of file abstractcontainer.cpp.
const std::vector< std::string > & TagParser::AbstractContainer::muxingApplications | ( | ) | const |
Returns the muxing applications specified as meta-data.
Definition at line 483 of file abstractcontainer.cpp.
void TagParser::AbstractContainer::parseAttachments | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress ) |
Parses the attachments of the file if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | TagParser::Failure or a derived exception when a parsing error occurs. |
Definition at line 150 of file abstractcontainer.cpp.
void TagParser::AbstractContainer::parseChapters | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress ) |
Parses the chapters of the file if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | TagParser::Failure or a derived exception when a parsing error occurs. |
Definition at line 131 of file abstractcontainer.cpp.
void TagParser::AbstractContainer::parseHeader | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress ) |
Parses the header if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | Failure or a derived class when an parsing error occurs. |
Definition at line 60 of file abstractcontainer.cpp.
void TagParser::AbstractContainer::parseTags | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress ) |
Parses the tag information if not parsed yet.
The header will be parsed before if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | Failure or a derived class when an parsing error occurs. |
Definition at line 87 of file abstractcontainer.cpp.
void TagParser::AbstractContainer::parseTracks | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress ) |
Parses the tracks of the file if not parsed yet.
The header will be parsed before if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | Failure or a derived class when an parsing error occurs. |
Definition at line 111 of file abstractcontainer.cpp.
|
inline |
Returns the related BinaryReader.
Definition at line 162 of file abstractcontainer.h.
|
inline |
Returns the "read version" if known; otherwise returns 0.
This is the minimum version a parser has to support to read the file.
Definition at line 228 of file abstractcontainer.h.
|
virtual |
Removes all tags attached to the container.
The tags need to be parsed before they can be removed.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, and TagParser::OggContainer.
Definition at line 349 of file abstractcontainer.cpp.
|
virtual |
Removes all tracks from the container.
Modifying tracks might be not supported by the implementation.
The tracks need to be parsed before they can be removed.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, and TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.
Definition at line 420 of file abstractcontainer.cpp.
|
virtual |
Removes the specified tag from the container.
Does nothing if the tag is not attached to the container.
The tags need to be parsed before a removal is possible.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, and TagParser::OggContainer.
Definition at line 333 of file abstractcontainer.cpp.
|
virtual |
Removes the specified track to the container.
Removal of tracks might be not supported by the implementation.
The tracks need to be parsed before a removal is possible.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, and TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.
Definition at line 401 of file abstractcontainer.cpp.
|
virtual |
Discards all parsing results.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 525 of file abstractcontainer.cpp.
|
virtual |
Returns the number of segments.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 517 of file abstractcontainer.cpp.
|
inline |
Sets the related stream.
Definition at line 144 of file abstractcontainer.h.
|
inline |
Sets the title for the specified segment.
Throws | out_of_range if the segment does not exist. |
Definition at line 277 of file abstractcontainer.h.
|
inline |
Returns the start offset in the related stream.
Definition at line 154 of file abstractcontainer.h.
|
inline |
Returns the related stream.
Definition at line 136 of file abstractcontainer.h.
|
virtual |
Returns whether the title property is supported.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 475 of file abstractcontainer.cpp.
|
virtual |
Returns whether the implementation supports adding or removing of tracks.
Reimplemented in TagParser::Mp4Container.
Definition at line 174 of file abstractcontainer.cpp.
|
virtual |
Returns the tag with the specified index.
index must be less than tagCount().
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, and TagParser::OggContainer.
Definition at line 304 of file abstractcontainer.cpp.
|
virtual |
Returns the number of tags attached to the container.
This method returns zero if the tags have not been parsed yet.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, and TagParser::OggContainer.
Definition at line 315 of file abstractcontainer.cpp.
|
inline |
Returns the time scale of the file if known; otherwise returns 0.
Definition at line 309 of file abstractcontainer.h.
|
inline |
Returns the title(s) of the file.
Definition at line 266 of file abstractcontainer.h.
|
virtual |
Returns the track with the specified index.
index must be less than trackCount().
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, and TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.
Definition at line 373 of file abstractcontainer.cpp.
|
virtual |
Returns the number of tracks the container holds.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, and TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.
Definition at line 382 of file abstractcontainer.cpp.
|
inline |
Returns the version if known; otherwise returns 0.
Definition at line 218 of file abstractcontainer.h.
|
inline |
Returns the related BinaryWriter.
Definition at line 170 of file abstractcontainer.h.
|
protected |
Returns the writing applications specified as meta-data.
Definition at line 509 of file abstractcontainer.cpp.
const std::vector< std::string > & TagParser::AbstractContainer::writingApplications | ( | ) | const |
Returns the writing applications specified as meta-data.
Definition at line 500 of file abstractcontainer.cpp.
|
protected |
Definition at line 121 of file abstractcontainer.h.
|
protected |
Definition at line 120 of file abstractcontainer.h.
|
protected |
Definition at line 112 of file abstractcontainer.h.
|
protected |
Definition at line 107 of file abstractcontainer.h.
|
protected |
Definition at line 109 of file abstractcontainer.h.
|
protected |
Definition at line 108 of file abstractcontainer.h.
|
protected |
Definition at line 111 of file abstractcontainer.h.
|
protected |
Definition at line 116 of file abstractcontainer.h.
|
protected |
Definition at line 113 of file abstractcontainer.h.
|
protected |
Definition at line 106 of file abstractcontainer.h.
|
protected |
Definition at line 117 of file abstractcontainer.h.
|
protected |
Definition at line 114 of file abstractcontainer.h.
|
protected |
Definition at line 110 of file abstractcontainer.h.
|
protected |
Definition at line 119 of file abstractcontainer.h.
|
protected |
Definition at line 118 of file abstractcontainer.h.
|
protected |
Definition at line 105 of file abstractcontainer.h.