Tag Parser
6.3.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. More... | |
std::iostream & | stream () |
Returns the related stream. More... | |
void | setStream (std::iostream &stream) |
Sets the related stream. More... | |
uint64 | startOffset () const |
Returns the start offset in the related stream. More... | |
IoUtilities::BinaryReader & | reader () |
Returns the related BinaryReader. More... | |
IoUtilities::BinaryWriter & | writer () |
Returns the related BinaryWriter. More... | |
void | parseHeader () |
Parses the header if not parsed yet. More... | |
void | parseTags () |
Parses the tag information if not parsed yet. More... | |
void | parseTracks () |
Parses the tracks of the file if not parsed yet. More... | |
void | parseChapters () |
Parses the chapters of the file if not parsed yet. More... | |
void | parseAttachments () |
Parses the attachments of the file if not parsed yet. More... | |
void | makeFile () |
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 Tag * | createTag (const TagTarget &target=TagTarget()) |
Creates and returns a tag for the specified target. More... | |
virtual Tag * | tag (std::size_t index) |
Returns the tag with the specified index. More... | |
virtual std::size_t | tagCount () const |
Returns the number of tags attached to the container. More... | |
virtual bool | removeTag (Tag *tag) |
Removes the specified tag from the container. More... | |
virtual void | removeAllTags () |
Removes all tags attached to the container. More... | |
virtual ElementPosition | determineTagPosition () const |
Determines the position of the tags inside the file. More... | |
virtual AbstractTrack * | track (std::size_t index) |
Returns the track with the specified index. More... | |
virtual std::size_t | trackCount () const |
Returns the number of tracks the container holds. More... | |
virtual bool | removeTrack (AbstractTrack *track) |
Removes the specified track to the container. More... | |
virtual void | removeAllTracks () |
Removes all tracks from the container. More... | |
virtual bool | supportsTrackModifications () const |
Returns whether the implementation supports adding or removing of tracks. More... | |
virtual ElementPosition | determineIndexPosition () const |
Determines the position of the index. More... | |
virtual AbstractChapter * | chapter (std::size_t index) |
Returns the chapter with the specified index. More... | |
virtual std::size_t | chapterCount () const |
Returns the number of chapters the container holds. More... | |
virtual AbstractAttachment * | createAttachment () |
Creates and returns a new attachment. More... | |
virtual AbstractAttachment * | attachment (std::size_t index) |
Returns the attachment with the specified index. More... | |
virtual std::size_t | attachmentCount () const |
Returns the number of attachments the container holds. More... | |
uint64 | version () const |
Returns the version if known; otherwise returns 0. More... | |
uint64 | 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... | |
uint64 | doctypeVersion () const |
Returns the document type version if known; otherwise returns 0. More... | |
uint64 | 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 (const std::string &title, std::size_t segmentIndex=0) |
Sets the title for the specified segment. More... | |
virtual bool | supportsTitle () const |
Returns whether the title property is supported. More... | |
virtual std::size_t | segmentCount () const |
Returns the number of segments. More... | |
ChronoUtilities::TimeSpan | duration () const |
Returns the duration of the file if known; otherwise returns a time span of zero ticks. More... | |
ChronoUtilities::DateTime | creationTime () const |
Returns the creation time of the file if known; otherwise the returned date time is null. More... | |
ChronoUtilities::DateTime | modificationTime () const |
Returns the modification time of the file if known; otherwise the returned date time is null. More... | |
uint32 | timeScale () const |
Returns the time scale of the file if known; otherwise returns 0. More... | |
virtual void | reset () |
Discards all parsing results. More... | |
![]() | |
const NotificationList & | notifications () const |
Returns notifications for the current object. More... | |
bool | hasNotifications () const |
Returns an indication whether there are notifications for the current object. More... | |
bool | hasCriticalNotifications () const |
Returns an indication whether there are critical notifications for the current object. More... | |
NotificationType | worstNotificationType () const |
Returns the worst notification type. More... | |
const std::string & | currentStatus () const |
Returns a status information for the current object. More... | |
double | currentPercentage () const |
Returns the progress percentage of the current object. More... | |
size_t | registerCallback (CallbackFunction callback) |
Registers a callback function. More... | |
void | unregisterCallback (size_t id) |
Unregisters a previously registered callback function whith the specified id. More... | |
void | unregisterAllCallbacks () |
Unregisters all callback functions. More... | |
void | forwardStatusUpdateCalls (StatusProvider *other=nullptr) |
Forwards all status updates calls to the specified statusProvider. More... | |
StatusProvider * | usedProvider () |
Returns the provider which callback functions will be called when the status or the percentage is updated. More... | |
void | tryToAbort () |
Commands the object to abort the current operation. More... | |
bool | isAborted () const |
Returns an indication whether the current operation should be aborted. More... | |
void | invalidateStatus () |
Invalidates the current status. More... | |
void | invalidateNotifications () |
Invalidates the object's notifications. More... | |
void | updateStatus (const std::string &status) |
This method is meant to be called by the derived class to report updated status information. More... | |
void | updateStatus (const std::string &status, double percentage) |
This method is meant to be called by the derived class to report updated status information. More... | |
void | updatePercentage (double percentage) |
This method is meant to be called by the derived class to report updated progress percentage only. More... | |
void | addNotification (const Notification ¬ification) |
This protected method is meant to be called by the derived class to add a notification. More... | |
void | addNotification (NotificationType type, const std::string &message, const std::string &context) |
This protected method is meant to be called by the derived class to add a notification of the specified type, message and context. More... | |
void | addNotifications (const StatusProvider &from) |
This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance. More... | |
void | addNotifications (const std::string &higherContext, const StatusProvider &from) |
This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance. More... | |
void | addNotifications (const NotificationList ¬ifications) |
This protected method is meant to be called by the derived class to add the specified notifications. More... | |
Protected Member Functions | |
AbstractContainer (std::iostream &stream, uint64 startOffset) | |
Constructs a new container for the specified file stream at the specified startOffset. More... | |
virtual void | internalParseHeader () |
Internally called to parse the header. More... | |
virtual void | internalParseTags () |
Internally called to parse the tags. More... | |
virtual void | internalParseTracks () |
Internally called to parse the tracks. More... | |
virtual void | internalParseChapters () |
Internally called to parse the chapters. More... | |
virtual void | internalParseAttachments () |
Internally called to parse the attachments. More... | |
virtual void | internalMakeFile () |
Internally called to make the file. More... | |
![]() | |
StatusProvider () | |
Constructs a new StatusProvider. More... | |
Protected Attributes | |
uint64 | m_version |
uint64 | m_readVersion |
std::string | m_doctype |
uint64 | m_doctypeVersion |
uint64 | m_doctypeReadVersion |
std::vector< std::string > | m_titles |
ChronoUtilities::TimeSpan | m_duration |
ChronoUtilities::DateTime | m_creationTime |
ChronoUtilities::DateTime | m_modificationTime |
uint32 | m_timeScale |
bool | m_headerParsed |
bool | m_tagsParsed |
bool | m_tracksParsed |
bool | m_tracksAltered |
bool | m_chaptersParsed |
bool | m_attachmentsParsed |
Additional Inherited Members | |
![]() | |
typedef std::function< void(StatusProvider &sender)> | CallbackFunction |
typedef std::vector< CallbackFunction > | CallbackVector |
typedef std::pair< int, CallbackFunction > | CallbackPair |
The AbstractContainer class provides an interface and common functionality to parse and make a certain container format.
Definition at line 34 of file abstractcontainer.h.
|
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 42 of file abstractcontainer.cpp.
|
protected |
Constructs a new container for the specified file stream at the specified startOffset.
Definition at line 18 of file abstractcontainer.cpp.
|
inline |
Returns an indication whether the attachments have been parsed yet.
Definition at line 199 of file abstractcontainer.h.
|
inline |
Returns an indication whether the chapters have been parsed yet.
Definition at line 191 of file abstractcontainer.h.
|
inline |
Returns an indication whether the tags have been parsed yet.
Definition at line 183 of file abstractcontainer.h.
|
inline |
Returns an indication whether the tracks have been parsed yet.
Definition at line 207 of file abstractcontainer.h.
|
virtual |
Returns the attachment with the specified index.
index must be less than attachmentCount().
Reimplemented in Media::MatroskaContainer.
Definition at line 432 of file abstractcontainer.cpp.
|
virtual |
Returns the number of attachments the container holds.
Reimplemented in Media::MatroskaContainer.
Definition at line 440 of file abstractcontainer.cpp.
|
virtual |
Returns the chapter with the specified index.
index must be less than chapterCount().
Reimplemented in Media::MatroskaContainer.
Definition at line 404 of file abstractcontainer.cpp.
|
virtual |
Returns the number of chapters the container holds.
Reimplemented in Media::MatroskaContainer.
Definition at line 412 of file abstractcontainer.cpp.
|
virtual |
Creates and returns a new attachment.
Reimplemented in Media::MatroskaContainer.
Definition at line 422 of file abstractcontainer.cpp.
Creates and returns a tag for the specified target.
Reimplemented in Media::OggContainer, Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, and Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >.
Definition at line 276 of file abstractcontainer.cpp.
|
inline |
Returns the creation time of the file if known; otherwise the returned date time is null.
Definition at line 291 of file abstractcontainer.h.
|
virtual |
Determines the position of the index.
Reimplemented in Media::MatroskaContainer, and Media::Mp4Container.
Definition at line 183 of file abstractcontainer.cpp.
|
virtual |
Determines the position of the tags inside the file.
Reimplemented in Media::MatroskaContainer, and Media::Mp4Container.
Definition at line 341 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 251 of file abstractcontainer.h.
|
inline |
Returns the document type version if known; otherwise returns 0.
Definition at line 241 of file abstractcontainer.h.
|
inline |
Returns a string that describes the document type if available; otherwise returns an empty string.
Definition at line 233 of file abstractcontainer.h.
|
inline |
Returns the duration of the file if known; otherwise returns a time span of zero ticks.
Definition at line 283 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 Media::OggContainer, Media::MatroskaContainer, and Media::Mp4Container.
Definition at line 261 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 Media::MatroskaContainer.
Definition at line 248 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 Media::MatroskaContainer.
Definition at line 235 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 Media::OggContainer, Media::MatroskaContainer, and Media::Mp4Container.
Definition at line 196 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 Media::OggContainer, Media::MatroskaContainer, and Media::Mp4Container.
Definition at line 209 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 Media::OggContainer, Media::MatroskaContainer, and Media::Mp4Container.
Definition at line 222 of file abstractcontainer.cpp.
|
inline |
Returns an indication whether the header has been parsed yet.
Definition at line 175 of file abstractcontainer.h.
void Media::AbstractContainer::makeFile | ( | ) |
Rewrites the file to apply changed tag information.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | Media::Failure or a derived exception when a making error occurs. |
Definition at line 161 of file abstractcontainer.cpp.
|
inline |
Returns the modification time of the file if known; otherwise the returned date time is null.
Definition at line 299 of file abstractcontainer.h.
void Media::AbstractContainer::parseAttachments | ( | ) |
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 | Media::Failure or a derived exception when a parsing error occurs. |
Definition at line 145 of file abstractcontainer.cpp.
void Media::AbstractContainer::parseChapters | ( | ) |
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 | Media::Failure or a derived exception when a parsing error occurs. |
Definition at line 126 of file abstractcontainer.cpp.
void Media::AbstractContainer::parseHeader | ( | ) |
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 54 of file abstractcontainer.cpp.
void Media::AbstractContainer::parseTags | ( | ) |
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 82 of file abstractcontainer.cpp.
void Media::AbstractContainer::parseTracks | ( | ) |
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 106 of file abstractcontainer.cpp.
|
inline |
Returns the related BinaryReader.
Definition at line 159 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 225 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 Media::OggContainer, Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, and Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >.
Definition at line 329 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 Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, and Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >.
Definition at line 396 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 Media::OggContainer, Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, and Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >.
Definition at line 314 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 Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, and Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >.
Definition at line 378 of file abstractcontainer.cpp.
|
virtual |
Discards all parsing results.
Reimplemented in Media::OggContainer, Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, Media::MatroskaContainer, and Media::Mp4Container.
Definition at line 464 of file abstractcontainer.cpp.
|
virtual |
Returns the number of segments.
Reimplemented in Media::MatroskaContainer.
Definition at line 456 of file abstractcontainer.cpp.
|
inline |
Sets the related stream.
Definition at line 141 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 275 of file abstractcontainer.h.
|
inline |
Returns the start offset in the related stream.
Definition at line 151 of file abstractcontainer.h.
|
inline |
Returns the related stream.
Definition at line 133 of file abstractcontainer.h.
|
virtual |
Returns whether the title property is supported.
Reimplemented in Media::MatroskaContainer.
Definition at line 448 of file abstractcontainer.cpp.
|
virtual |
Returns whether the implementation supports adding or removing of tracks.
Reimplemented in Media::Mp4Container.
Definition at line 169 of file abstractcontainer.cpp.
|
virtual |
Returns the tag with the specified index.
index must be less than tagCount().
Reimplemented in Media::OggContainer, Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, and Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >.
Definition at line 286 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 Media::OggContainer, Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, and Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >.
Definition at line 296 of file abstractcontainer.cpp.
|
inline |
Returns the time scale of the file if known; otherwise returns 0.
Definition at line 307 of file abstractcontainer.h.
|
inline |
Returns the title(s) of the file.
Definition at line 264 of file abstractcontainer.h.
|
virtual |
Returns the track with the specified index.
index must be less than trackCount().
Reimplemented in Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, and Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >.
Definition at line 351 of file abstractcontainer.cpp.
|
virtual |
Returns the number of tracks the container holds.
Reimplemented in Media::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, Media::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, and Media::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >.
Definition at line 359 of file abstractcontainer.cpp.
|
inline |
Returns the version if known; otherwise returns 0.
Definition at line 215 of file abstractcontainer.h.
|
inline |
Returns the related BinaryWriter.
Definition at line 167 of file abstractcontainer.h.
|
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.