Tag Parser  7.1.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Public Member Functions | Protected Member Functions | List of all members
TagParser::Mp4Container Class Reference

Implementation of GenericContainer<MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom>. More...

#include <mp4container.h>

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

Public Member Functions

 Mp4Container (MediaFileInfo &fileInfo, uint64 startOffset)
 Constructs a new container for the specified fileInfo at the specified startOffset. More...
 
 ~Mp4Container () override
 
bool supportsTrackModifications () const override
 Returns whether the implementation supports adding or removing of tracks. More...
 
bool isFragmented () const
 Returns whether the file is fragmented. More...
 
void reset () override
 Discards all parsing results. 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...
 
- Public Member Functions inherited from TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >
 GenericContainer (MediaFileInfo &fileInfo, uint64 startOffset)
 Constructs a new container for the specified fileInfo at the specified startOffset. More...
 
 ~GenericContainer () override
 Destroys the container. More...
 
void validateElementStructure (Diagnostics &diag, uint64 *paddingSize=nullptr)
 Parses all elements the file consists of. More...
 
MediaFileInfofileInfo () const
 Returns the related file info. More...
 
Mp4AtomfirstElement () const
 Returns the first element of the file if available; otherwiese returns nullptr. More...
 
const std::vector< std::unique_ptr< Mp4Atom > > & additionalElements () const
 Returns all available additional elements. More...
 
std::vector< std::unique_ptr< Mp4Atom > > & additionalElements ()
 Returns all available additional elements. More...
 
Mp4Tagtag (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...
 
Mp4Tracktrack (std::size_t index) override
 Returns the track with the specified index. More...
 
Mp4TracktrackById (uint64 id)
 
std::size_t trackCount () const override
 Returns the number of tracks the container holds. More...
 
const std::vector< std::unique_ptr< Mp4Tag > > & tags () const
 Returns the tags of the file. More...
 
std::vector< std::unique_ptr< Mp4Tag > > & tags ()
 Returns the tags of the file. More...
 
const std::vector< std::unique_ptr< Mp4Track > > & tracks () const
 Returns the tracks of the file. More...
 
std::vector< std::unique_ptr< Mp4Track > > & tracks ()
 Returns the tracks of the file. More...
 
Mp4TagcreateTag (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 (Mp4Track *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...
 
- Public Member Functions inherited from TagParser::AbstractContainer
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 (Diagnostics &diag)
 Parses the header if not parsed yet. More...
 
void parseTags (Diagnostics &diag)
 Parses the tag information if not parsed yet. More...
 
void parseTracks (Diagnostics &diag)
 Parses the tracks of the file if not parsed yet. More...
 
void parseChapters (Diagnostics &diag)
 Parses the chapters of the file if not parsed yet. More...
 
void parseAttachments (Diagnostics &diag)
 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 AbstractChapterchapter (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 AbstractAttachmentcreateAttachment ()
 Creates and returns a new attachment. More...
 
virtual AbstractAttachmentattachment (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...
 

Protected Member Functions

void internalParseHeader (Diagnostics &diag) override
 Internally called to parse the header. More...
 
void internalParseTags (Diagnostics &diag) override
 Internally called to parse the tags. More...
 
void internalParseTracks (Diagnostics &diag) override
 Internally called to parse the tracks. More...
 
void internalMakeFile (Diagnostics &diag, AbortableProgressFeedback &progress) override
 Internally called to make the file. More...
 
- Protected Member Functions inherited from TagParser::AbstractContainer
 AbstractContainer (std::iostream &stream, uint64 startOffset)
 Constructs a new container for the specified file stream at the specified startOffset. More...
 
virtual void internalParseChapters (Diagnostics &diag)
 Internally called to parse the chapters. More...
 
virtual void internalParseAttachments (Diagnostics &diag)
 Internally called to parse the attachments. More...
 

Additional Inherited Members

- Public Types inherited from TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >
typedef MediaFileInfo ContainerFileInfoType
 
typedef Mp4Tag ContainerTagType
 
typedef Mp4Track ContainerTrackType
 
typedef Mp4Atom ContainerElementType
 
- Protected Attributes inherited from TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >
std::unique_ptr< Mp4Atomm_firstElement
 
std::vector< std::unique_ptr< Mp4Atom > > m_additionalElements
 
std::vector< std::unique_ptr< Mp4Tag > > m_tags
 
std::vector< std::unique_ptr< Mp4Track > > m_tracks
 
- Protected Attributes inherited from TagParser::AbstractContainer
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
 

Detailed Description

Implementation of GenericContainer<MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom>.

Definition at line 19 of file mp4container.h.

Constructor & Destructor Documentation

◆ Mp4Container()

TagParser::Mp4Container::Mp4Container ( MediaFileInfo fileInfo,
uint64  startOffset 
)

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

Definition at line 35 of file mp4container.cpp.

◆ ~Mp4Container()

TagParser::Mp4Container::~Mp4Container ( )
override

Definition at line 41 of file mp4container.cpp.

Member Function Documentation

◆ determineIndexPosition()

ElementPosition TagParser::Mp4Container::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 63 of file mp4container.cpp.

◆ determineTagPosition()

ElementPosition TagParser::Mp4Container::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 51 of file mp4container.cpp.

◆ internalMakeFile()

void TagParser::Mp4Container::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 218 of file mp4container.cpp.

◆ internalParseHeader()

void TagParser::Mp4Container::internalParseHeader ( Diagnostics diag)
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 75 of file mp4container.cpp.

◆ internalParseTags()

void TagParser::Mp4Container::internalParseTags ( Diagnostics diag)
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 91 of file mp4container.cpp.

◆ internalParseTracks()

void TagParser::Mp4Container::internalParseTracks ( Diagnostics diag)
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 120 of file mp4container.cpp.

◆ isFragmented()

bool TagParser::Mp4Container::isFragmented ( ) const
inline

Returns whether the file is fragmented.

Track information needs to be parsed to detect fragmentation.

Definition at line 51 of file mp4container.h.

◆ reset()

void TagParser::Mp4Container::reset ( )
overridevirtual

Discards all parsing results.

Reimplemented from TagParser::AbstractContainer.

Definition at line 45 of file mp4container.cpp.

◆ supportsTrackModifications()

bool TagParser::Mp4Container::supportsTrackModifications ( ) const
inlineoverridevirtual

Returns whether the implementation supports adding or removing of tracks.

Reimplemented from TagParser::AbstractContainer.

Definition at line 42 of file mp4container.h.


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