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

Implementation of Media::AbstractContainer for OGG files. More...

#include <oggcontainer.h>

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

Public Member Functions

 OggContainer (MediaFileInfo &fileInfo, uint64 startOffset)
 Constructs a new container for the specified stream at the specified startOffset. More...
 
 ~OggContainer ()
 
bool isChecksumValidationEnabled () const
 Returns whether checksum validation is enabled. More...
 
void setChecksumValidationEnabled (bool enabled)
 Sets whether checksum validation is enabled. More...
 
void reset ()
 Discards all parsing results. More...
 
OggVorbisCommentcreateTag (const TagTarget &target)
 Creates a new tag. More...
 
OggVorbisCommenttag (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...
 
bool removeTag (Tag *tag)
 Actually just flags the specified tag as removed and clears all assigned fields. More...
 
void removeAllTags ()
 Actually just flags all tags as removed and clears all assigned fields. More...
 
- Public Member Functions inherited from Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >
 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...
 
MediaFileInfofileInfo () const
 Returns the related file info. More...
 
OggPagefirstElement () const
 Returns the first element of the file if available; otherwiese returns nullptr. More...
 
const std::vector< std::unique_ptr< OggPage > > & additionalElements () const
 Returns all available additional elements. More...
 
std::vector< std::unique_ptr< OggPage > > & additionalElements ()
 Returns all available additional elements. More...
 
OggVorbisCommenttag (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...
 
OggStreamtrack (std::size_t index)
 Returns the track with the specified index. More...
 
std::size_t trackCount () const
 Returns the number of tracks the container holds. More...
 
const std::vector< std::unique_ptr< OggVorbisComment > > & tags () const
 Returns the tags of the file. More...
 
std::vector< std::unique_ptr< OggVorbisComment > > & tags ()
 Returns the tags of the file. More...
 
const std::vector< std::unique_ptr< OggStream > > & tracks () const
 Returns the tracks of the file. More...
 
std::vector< std::unique_ptr< OggStream > > & tracks ()
 Returns the tracks of the file. More...
 
OggVorbisCommentcreateTag (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 (OggStream *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...
 
- Public Member Functions inherited from Media::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 ()
 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 ElementPosition determineTagPosition () const
 Determines the position of the tags inside the file. 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 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...
 
- Public Member Functions inherited from Media::StatusProvider
const NotificationListnotifications () 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...
 
StatusProviderusedProvider ()
 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 &notification)
 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 &notifications)
 This protected method is meant to be called by the derived class to add the specified notifications. 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 internalMakeFile ()
 Internally called to make the file. More...
 
- Protected Member Functions inherited from Media::AbstractContainer
 AbstractContainer (std::iostream &stream, uint64 startOffset)
 Constructs a new container for the specified file stream at the specified startOffset. More...
 
virtual void internalParseChapters ()
 Internally called to parse the chapters. More...
 
virtual void internalParseAttachments ()
 Internally called to parse the attachments. More...
 
- Protected Member Functions inherited from Media::StatusProvider
 StatusProvider ()
 Constructs a new StatusProvider. More...
 

Friends

class OggStream
 

Additional Inherited Members

- Public Types inherited from Media::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >
typedef MediaFileInfo fileInfoType
 
typedef OggVorbisComment tagType
 
typedef OggStream trackType
 
typedef OggPage elementType
 
- Public Types inherited from Media::StatusProvider
typedef std::function< void(StatusProvider &sender)> CallbackFunction
 
typedef std::vector< CallbackFunctionCallbackVector
 
typedef std::pair< int, CallbackFunctionCallbackPair
 
- Protected Attributes inherited from Media::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 Media::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 Media::AbstractContainer for OGG files.

Definition at line 127 of file oggcontainer.h.

Constructor & Destructor Documentation

◆ OggContainer()

Media::OggContainer::OggContainer ( MediaFileInfo fileInfo,
uint64  startOffset 
)

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

Definition at line 47 of file oggcontainer.cpp.

◆ ~OggContainer()

Media::OggContainer::~OggContainer ( )

Definition at line 53 of file oggcontainer.cpp.

Member Function Documentation

◆ createTag()

OggVorbisComment * Media::OggContainer::createTag ( const TagTarget target)
virtual

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 Media::AbstractContainer.

Definition at line 71 of file oggcontainer.cpp.

◆ internalMakeFile()

void Media::OggContainer::internalMakeFile ( )
protectedvirtual

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 Media::AbstractContainer.

Definition at line 328 of file oggcontainer.cpp.

◆ internalParseHeader()

void Media::OggContainer::internalParseHeader ( )
protectedvirtual

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 Media::AbstractContainer.

Definition at line 185 of file oggcontainer.cpp.

◆ internalParseTags()

void Media::OggContainer::internalParseTags ( )
protectedvirtual

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 Media::AbstractContainer.

Definition at line 225 of file oggcontainer.cpp.

◆ internalParseTracks()

void Media::OggContainer::internalParseTracks ( )
protectedvirtual

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 Media::AbstractContainer.

Definition at line 271 of file oggcontainer.cpp.

◆ isChecksumValidationEnabled()

bool Media::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 169 of file oggcontainer.h.

◆ removeAllTags()

void Media::OggContainer::removeAllTags ( )
virtual

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

This specialization is neccessary because completeley removing the tag whould also remove the OGG parameter which are needed when appying 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 Media::AbstractContainer.

Definition at line 177 of file oggcontainer.cpp.

◆ removeTag()

bool Media::OggContainer::removeTag ( Tag tag)
virtual

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

This specialization is neccessary because removing the tag completely whould also remove the OGG parameter which are needed when appying 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 Media::AbstractContainer.

Definition at line 155 of file oggcontainer.cpp.

◆ reset()

void Media::OggContainer::reset ( )
virtual

Discards all parsing results.

Reimplemented from Media::AbstractContainer.

Definition at line 56 of file oggcontainer.cpp.

◆ setChecksumValidationEnabled()

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

Sets whether checksum validation is enabled.

See also
isChecksumValidationEnabled()

Definition at line 178 of file oggcontainer.h.

◆ tag()

OggVorbisComment * Media::OggContainer::tag ( std::size_t  index)
virtual

Returns the tag with the specified index.

index must be less than tagCount().

Reimplemented from Media::AbstractContainer.

Definition at line 121 of file oggcontainer.cpp.

◆ tagCount()

size_t Media::OggContainer::tagCount ( ) const
virtual

Returns the number of tags attached to the container.

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

Reimplemented from Media::AbstractContainer.

Definition at line 135 of file oggcontainer.cpp.

Friends And Related Function Documentation

◆ OggStream

friend class OggStream
friend

Definition at line 129 of file oggcontainer.h.


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