Tag Parser
6.4.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, uint64 startOffset) | |
Constructs a new container for the specified fileInfo at the specified startOffset. More... | |
~MatroskaContainer () | |
void | validateIndex () |
Validates the file index (cue entries). More... | |
uint64 | maxIdLength () const |
Returns the maximal ID length in bytes. More... | |
uint64 | 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 (uint64 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) |
Returns the chapter with the specified index. More... | |
std::size_t | chapterCount () const |
Returns the number of chapters the container holds. More... | |
MatroskaAttachment * | createAttachment () |
Creates and returns a new attachment. More... | |
MatroskaAttachment * | attachment (std::size_t index) |
Returns the attachment with the specified index. More... | |
std::size_t | attachmentCount () const |
Returns the number of attachments the container holds. More... | |
ElementPosition | determineElementPosition (uint64 elementId) const |
Determines the position of the element with the specified elementId. More... | |
ElementPosition | determineTagPosition () const |
Determines the position of the tags inside the file. More... | |
ElementPosition | determineIndexPosition () const |
Determines the position of the index. 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... | |
void | reset () |
Discards all parsing results. More... | |
![]() | |
GenericContainer (MediaFileInfo &fileInfo, uint64 startOffset) | |
Constructs a new container for the specified fileInfo at the specified startOffset. More... | |
~GenericContainer () | |
Destroys the container. More... | |
void | validateElementStructure (NotificationList &gatheredNotifications, uint64 *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) |
Returns the tag with the specified index. More... | |
std::size_t | tagCount () const |
Returns the number of tags attached to the container. More... | |
MatroskaTrack * | track (std::size_t index) |
Returns the track with the specified index. More... | |
MatroskaTrack * | trackById (uint64 id) |
std::size_t | trackCount () const |
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()) |
Creates and returns a tag for the specified target. More... | |
bool | removeTag (Tag *tag) |
Removes the specified tag from the container. More... | |
void | removeAllTags () |
Removes all tags attached to the container. More... | |
bool | addTrack (MatroskaTrack *track) |
Adds the specified track to the container. More... | |
bool | removeTrack (AbstractTrack *track) |
Removes the specified track to the container. More... | |
void | removeAllTracks () |
Removes all tracks from the container. More... | |
void | reset () |
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... | |
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 bool | supportsTrackModifications () const |
Returns whether the implementation supports adding or removing of tracks. 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... | |
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... | |
![]() | |
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... | |
Static Public Member Functions | |
static uint64 | maxFullParseSize () |
Returns the maximal file size for a "full parse" in byte. More... | |
Protected Member Functions | |
void | internalParseHeader () |
Internally called to parse the header. More... | |
void | internalParseTags () |
Internally called to parse the tags. More... | |
void | internalParseTracks () |
Internally called to parse the tracks. More... | |
void | internalParseChapters () |
Internally called to parse the chapters. More... | |
void | internalParseAttachments () |
Internally called to parse the attachments. More... | |
void | internalMakeFile () |
Internally called to make the file. More... | |
![]() | |
AbstractContainer (std::iostream &stream, uint64 startOffset) | |
Constructs a new container for the specified file stream at the specified startOffset. More... | |
![]() | |
StatusProvider () | |
Constructs a new StatusProvider. More... | |
Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
Definition at line 25 of file matroskacontainer.h.
Media::MatroskaContainer::MatroskaContainer | ( | MediaFileInfo & | stream, |
uint64 | startOffset | ||
) |
Constructs a new container for the specified fileInfo at the specified startOffset.
Definition at line 47 of file matroskacontainer.cpp.
Media::MatroskaContainer::~MatroskaContainer | ( | ) |
Definition at line 60 of file matroskacontainer.cpp.
|
inlinevirtual |
Returns the attachment with the specified index.
index must be less than attachmentCount().
Reimplemented from Media::AbstractContainer.
Definition at line 139 of file matroskacontainer.h.
|
inlinevirtual |
Returns the number of attachments the container holds.
Reimplemented from Media::AbstractContainer.
Definition at line 144 of file matroskacontainer.h.
|
virtual |
Returns the chapter with the specified index.
index must be less than chapterCount().
Reimplemented from Media::AbstractContainer.
Definition at line 291 of file matroskacontainer.cpp.
|
virtual |
Returns the number of chapters the container holds.
Reimplemented from Media::AbstractContainer.
Definition at line 304 of file matroskacontainer.cpp.
|
virtual |
Creates and returns a new attachment.
Reimplemented from Media::AbstractContainer.
Definition at line 313 of file matroskacontainer.cpp.
ElementPosition Media::MatroskaContainer::determineElementPosition | ( | uint64 | elementId | ) | const |
Determines the position of the element with the specified elementId.
Definition at line 340 of file matroskacontainer.cpp.
|
virtual |
Determines the position of the index.
Reimplemented from Media::AbstractContainer.
Definition at line 368 of file matroskacontainer.cpp.
|
virtual |
Determines the position of the tags inside the file.
Reimplemented from Media::AbstractContainer.
Definition at line 363 of file matroskacontainer.cpp.
|
inline |
Returns the edition entries.
Definition at line 134 of file matroskacontainer.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 from Media::AbstractContainer.
Definition at line 815 of file matroskacontainer.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 from Media::AbstractContainer.
Definition at line 733 of file matroskacontainer.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 from Media::AbstractContainer.
Definition at line 699 of file matroskacontainer.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 from Media::AbstractContainer.
Definition at line 373 of file matroskacontainer.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 from Media::AbstractContainer.
Definition at line 628 of file matroskacontainer.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 from Media::AbstractContainer.
Definition at line 663 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 117 of file matroskacontainer.h.
|
inline |
Returns the maximal ID length in bytes.
Definition at line 83 of file matroskacontainer.h.
|
inline |
Returns the maximal size length in bytes.
Definition at line 91 of file matroskacontainer.h.
|
virtual |
Discards all parsing results.
Reimplemented from Media::AbstractContainer.
Definition at line 63 of file matroskacontainer.cpp.
|
inline |
Returns seek information read from "SeekHead"-elements when parsing segment info.
Definition at line 99 of file matroskacontainer.h.
|
inlinevirtual |
Returns the number of segments.
Reimplemented from Media::AbstractContainer.
Definition at line 154 of file matroskacontainer.h.
|
inline |
Sets the maximal file size for a "full parse" in byte.
Definition at line 126 of file matroskacontainer.h.
|
inlinevirtual |
Returns whether the title property is supported.
Reimplemented from Media::AbstractContainer.
Definition at line 149 of file matroskacontainer.h.
void Media::MatroskaContainer::validateIndex | ( | ) |
Validates the file index (cue entries).
Definition at line 88 of file matroskacontainer.cpp.