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::OggContainer Class Reference

Implementation of TagParser::AbstractContainer for Ogg files. More...

#include <oggcontainer.h>

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

Public Member Functions

 OggContainer (MediaFileInfo &fileInfo, std::uint64_t startOffset)
 Constructs a new container for the specified stream at the specified startOffset.
 
 ~OggContainer () override
 
bool isChecksumValidationEnabled () const
 Returns whether checksum validation is enabled.
 
void setChecksumValidationEnabled (bool enabled)
 Sets whether checksum validation is enabled.
 
void reset () override
 Discards all parsing results.
 
OggVorbisCommentcreateTag (const TagTarget &target) override
 Creates a new tag.
 
OggVorbisCommenttag (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.
 
bool removeTag (Tag *tag) override
 Actually just flags the specified tag as removed and clears all assigned fields.
 
void removeAllTags () override
 Actually just flags all tags as removed and clears all assigned fields.
 
- Public Member Functions inherited from TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >
 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.
 
OggPagefirstElement () const
 Returns the first element of the file if available; otherwiese returns nullptr.
 
const std::vector< std::unique_ptr< OggPage > > & additionalElements () const
 Returns all available additional elements.
 
std::vector< std::unique_ptr< OggPage > > & additionalElements ()
 Returns all available additional elements.
 
OggStreamtrack (std::size_t index) override
 Returns the track with the specified index.
 
OggStreamtrackById (std::uint64_t id)
 
std::size_t trackCount () const override
 Returns the number of tracks the container holds.
 
const std::vector< std::unique_ptr< OggVorbisComment > > & tags () const
 Returns the tags of the file.
 
std::vector< std::unique_ptr< OggVorbisComment > > & tags ()
 Returns the tags of the file.
 
const std::vector< std::unique_ptr< OggStream > > & tracks () const
 Returns the tracks of the file.
 
std::vector< std::unique_ptr< OggStream > > & tracks ()
 Returns the tracks of the file.
 
bool addTrack (OggStream *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 ElementPosition determineTagPosition (Diagnostics &diag) const
 Determines the position of the tags inside the file.
 
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 AbstractChapterchapter (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 AbstractAttachmentcreateAttachment ()
 Creates and returns a new attachment.
 
virtual AbstractAttachmentattachment (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.
 

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 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.
 
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.
 
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.
 

Friends

class OggStream
 

Additional Inherited Members

- Public Types inherited from TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >
using ContainerFileInfoType
 
using ContainerTagType
 
using ContainerTrackType
 
using ContainerElementType
 
- Protected Attributes inherited from TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >
std::unique_ptr< OggPagem_firstElement
 
std::vector< std::unique_ptr< OggPage > > m_additionalElements
 
std::vector< std::unique_ptr< OggVorbisComment > > m_tags
 
std::vector< std::unique_ptr< OggStream > > 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

Implementation of TagParser::AbstractContainer for Ogg files.

Constructor & Destructor Documentation

◆ OggContainer()

TagParser::OggContainer::OggContainer ( MediaFileInfo & fileInfo,
std::uint64_t startOffset )

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

Definition at line 48 of file oggcontainer.cpp.

◆ ~OggContainer()

TagParser::OggContainer::~OggContainer ( )
override

Definition at line 55 of file oggcontainer.cpp.

Member Function Documentation

◆ createTag()

OggVorbisComment * TagParser::OggContainer::createTag ( const TagTarget & target)
overridevirtual

Creates a new tag.

See also
AbstractContainer::createTag()
Remarks
  • Tracks must be parsed before because tags are stored on track level!
  • The track can be specified via the target argument. However, only the first track of tracks() array of target is considered.
  • If tracks() array of target is empty, the first track/tag is picked.
  • Vorbis streams should always have a tag assigned; this method allows creation of a tag for Vorbis streams if none is present though.
  • FLAC streams should always have a tag assigned; this method does not allow creation of a tag for FLAC streams if none is present though.

Reimplemented from TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.

Definition at line 74 of file oggcontainer.cpp.

◆ internalMakeFile()

void TagParser::OggContainer::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 424 of file oggcontainer.cpp.

◆ internalParseHeader()

void TagParser::OggContainer::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 188 of file oggcontainer.cpp.

◆ internalParseTags()

void TagParser::OggContainer::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 279 of file oggcontainer.cpp.

◆ internalParseTracks()

void TagParser::OggContainer::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 360 of file oggcontainer.cpp.

◆ isChecksumValidationEnabled()

bool TagParser::OggContainer::isChecksumValidationEnabled ( ) const
inline

Returns whether checksum validation is enabled.

If checksum validation is enabled, the parser will validate the Ogg pages by checking the CRC32 checksum.

See also
setChecksumValidationEnabled()

Definition at line 177 of file oggcontainer.h.

◆ removeAllTags()

void TagParser::OggContainer::removeAllTags ( )
overridevirtual

Actually just flags all tags as removed and clears all assigned fields.

This specialization is necessary because completeley removing the tag would also remove the Ogg parameter which are needed when applying the changes.

Remarks
Seems like common players aren't able to play Vorbis when no comment is present. So do NOT use this method to remove tags from Vorbis, just call removeAllFields() on all tags.
See also
AbstractContainer::removeAllTags()

Reimplemented from TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.

Definition at line 180 of file oggcontainer.cpp.

◆ removeTag()

bool TagParser::OggContainer::removeTag ( Tag * tag)
overridevirtual

Actually just flags the specified tag as removed and clears all assigned fields.

This specialization is necessary because removing the tag completely would also remove the Ogg parameter which are needed when applying changes.

Remarks
Seems like common players aren't able to play Vorbis when no comment is present. So do NOT use this method to remove tags from Vorbis, just call Tag::removeAllFields() on tag.

Reimplemented from TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.

Definition at line 158 of file oggcontainer.cpp.

◆ reset()

void TagParser::OggContainer::reset ( )
overridevirtual

Discards all parsing results.

Reimplemented from TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.

Definition at line 59 of file oggcontainer.cpp.

◆ setChecksumValidationEnabled()

void TagParser::OggContainer::setChecksumValidationEnabled ( bool enabled)
inline

Sets whether checksum validation is enabled.

See also
isChecksumValidationEnabled()

Definition at line 186 of file oggcontainer.h.

◆ tag()

OggVorbisComment * TagParser::OggContainer::tag ( std::size_t index)
overridevirtual

Returns the tag with the specified index.

index must be less than tagCount().

Reimplemented from TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.

Definition at line 124 of file oggcontainer.cpp.

◆ tagCount()

size_t TagParser::OggContainer::tagCount ( ) const
overridevirtual

Returns the number of tags attached to the container.

This method returns zero if the tags have not been parsed yet.

Reimplemented from TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.

Definition at line 138 of file oggcontainer.cpp.

Friends And Related Symbol Documentation

◆ OggStream

friend class OggStream
friend

Definition at line 135 of file oggcontainer.h.


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