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

The MediaFileInfo class allows to read and write tag information providing a container/tag format independent interface. More...

#include <mediafileinfo.h>

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

Public Member Functions

 MediaFileInfo ()
 Constructs a new MediaFileInfo.
 
 MediaFileInfo (std::string_view path)
 Constructs a new MediaFileInfo.
 
 MediaFileInfo (std::string &&path)
 Constructs a new MediaFileInfo for the specified file.
 
 MediaFileInfo (const MediaFileInfo &)=delete
 
MediaFileInfooperator= (const MediaFileInfo &)=delete
 
 ~MediaFileInfo () override
 Destroys the MediaFileInfo.
 
void parseContainerFormat (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the container format of the current file.
 
void parseTracks (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the tracks of the current file.
 
void parseTags (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the tag(s) of the current file.
 
void parseChapters (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the chapters of the current file.
 
void parseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the attachments of the current file.
 
void parseEverything (Diagnostics &diag, AbortableProgressFeedback &progress)
 Parses the container format, the tracks and the tag information of the current file.
 
void applyChanges (Diagnostics &diag, AbortableProgressFeedback &progress)
 Applies assigned/changed tag information to the current file.
 
ContainerFormat containerFormat () const
 Returns the container format of the current file.
 
std::string_view containerFormatName () const
 Returns the name of the container format as C-style string.
 
std::string_view containerFormatAbbreviation () const
 Returns the abbreviation of the container format as C-style string.
 
std::string_view containerFormatSubversion () const
 Returns the subversion of the container format as C-style string.
 
std::string_view mimeType () const
 Returns the MIME-type of the container format as C-style string.
 
std::uint64_t containerOffset () const
 Returns the actual container start offset.
 
std::uint64_t paddingSize () const
 Returns the padding size.
 
std::uint64_t effectiveSize () const
 Returns the "effective size" of the file if know; otherwise returns 0.
 
AbstractContainercontainer () const
 Returns the container for the current file.
 
ParsingStatus containerParsingStatus () const
 Returns an indication whether the container format has been parsed yet.
 
ParsingStatus chaptersParsingStatus () const
 Returns whether the chapters have been parsed yet.
 
std::vector< AbstractChapter * > chapters () const
 Returns all chapters assigned to the current file.
 
bool areChaptersSupported () const
 Returns an indication whether this library supports parsing the chapters of the current file.
 
ParsingStatus attachmentsParsingStatus () const
 Returns whether the attachments have been parsed yet.
 
std::vector< AbstractAttachment * > attachments () const
 Returns all attachments assigned to the current file.
 
bool areAttachmentsSupported () const
 Returns an indication whether this library supports attachment format of the current file.
 
ParsingStatus tracksParsingStatus () const
 Returns an indication whether tracks have been parsed yet.
 
std::size_t trackCount () const
 Returns the number of tracks that could be parsed.
 
std::vector< AbstractTrack * > tracks () const
 Returns the tracks for the current file.
 
bool hasTracksOfType (TagParser::MediaType type) const
 Returns an indication whether the current file has tracks of the specified type.
 
CppUtilities::TimeSpan duration () const
 Returns the overall duration of the file if known; otherwise returns a TimeSpan with zero ticks.
 
double overallAverageBitrate () const
 Returns the overall average bitrate in kbit/s of the file if known; otherwise returns 0.0.
 
std::unordered_set< std::string > availableLanguages (TagParser::MediaType type=TagParser::MediaType::Audio) const
 Determines the available languages for specified media type (by default MediaType::Audio).
 
std::string technicalSummary () const
 Generates a short technical summary about the file's tracks.
 
bool areTracksSupported () const
 Returns an indication whether this library supports parsing the tracks information of the current file.
 
ParsingStatus tagsParsingStatus () const
 Returns an indication whether tag information has been parsed yet.
 
bool hasId3v1Tag () const
 Returns an indication whether an ID3v1 tag is assigned.
 
bool hasId3v2Tag () const
 Returns an indication whether an ID3v2 tag is assigned.
 
bool hasAnyTag () const
 Returns an indication whether a tag of any format is assigned.
 
Id3v1Tagid3v1Tag () const
 Returns a pointer to the assigned ID3v1 tag or nullptr if none is assigned.
 
const std::vector< std::unique_ptr< Id3v2Tag > > & id3v2Tags () const
 Returns pointers to the assigned ID3v2 tags.
 
void tags (std::vector< Tag * > &tags) const
 Stores all tags assigned to the current file in the specified vector.
 
std::vector< Tag * > tags () const
 Returns all tags assigned to the current file.
 
void parsedTags (std::vector< Tag * > &tags) const
 Returns all tags parsed from the current file.
 
std::vector< Tag * > parsedTags () const
 Returns all tags parsed from the current file.
 
Mp4Tagmp4Tag () const
 Returns a pointer to the assigned MP4 tag or nullptr if none is assigned.
 
const std::vector< std::unique_ptr< MatroskaTag > > & matroskaTags () const
 Returns pointers to the assigned Matroska tags.
 
VorbisCommentvorbisComment () const
 Returns a pointer to the first assigned Vorbis comment or nullptr if none is assigned.
 
bool areTagsSupported () const
 Returns an indication whether this library supports the tag format of the current file.
 
bool createAppropriateTags (const TagCreationSettings &settings=TagCreationSettings())
 Ensures appropriate tags are created according the given settings.
 
bool removeId3v1Tag ()
 Removes a possibly assigned ID3v1 tag from the current file.
 
Id3v1TagcreateId3v1Tag ()
 Creates an ID3v1 tag for the current file.
 
bool removeId3v2Tag (Id3v2Tag *tag)
 Removes an assigned ID3v2 tag from the current file.
 
bool removeAllId3v2Tags ()
 Removes all assigned ID3v2 tags from the current file.
 
Id3v2TagcreateId3v2Tag ()
 Creates an ID3v2 tag for the current file.
 
bool removeTag (Tag *tag)
 Removes a possibly assigned tag from the current file.
 
void removeAllTags ()
 Removes all assigned tags from the file.
 
void mergeId3v2Tags ()
 Merges the assigned ID3v2 tags into a single ID3v2 tag.
 
bool id3v1ToId3v2 ()
 Converts an existing ID3v1 tag into an ID3v2 tag.
 
bool id3v2ToId3v1 ()
 Converts the existing ID3v2 tags into an ID3v1 tag.
 
VorbisCommentcreateVorbisComment ()
 Creates a Vorbis comment for the current file.
 
bool removeVorbisComment ()
 Removes all assigned Vorbis comment from the current file.
 
void clearParsingResults ()
 Clears all parsing results and assigned/created/changed information such as detected container format, tracks, tags, ...
 
void reportPaddingSizeChanged (std::uint64_t newPaddingSize)
 Sets the padding size.
 
const std::string & backupDirectory () const
 Returns the directory used to store backup files.
 
void setBackupDirectory (std::string_view backupDirectory)
 Sets the directory used to store backup files.
 
void setBackupDirectory (std::string &&backupDirectory)
 Sets the directory used to store backup files.
 
const std::string & saveFilePath () const
 Returns the "save file path" which has been set using setSaveFilePath().
 
void setSaveFilePath (std::string_view saveFilePath)
 Sets the "save file path".
 
void setSaveFilePath (std::string &&saveFilePath)
 Sets the "save file path".
 
const std::string & writingApplication () const
 Sets the writing application as container-level meta-data.
 
void setWritingApplication (std::string_view writingApplication)
 Sets the writing application as container-level meta-data.
 
MediaFileHandlingFlags fileHandlingFlags ()
 Returns the currently configured file handling flags.
 
void setFileHandlingFlags (MediaFileHandlingFlags flags)
 Replaces all currently configured file handling flags with the specified flags.
 
bool isForcingFullParse () const
 Returns an indication whether forcing a full parse is enabled.
 
void setForceFullParse (bool forceFullParse)
 Sets whether forcing a full parse is enabled.
 
bool isForcingRewrite () const
 Returns whether forcing rewriting (when applying changes) is enabled.
 
void setForceRewrite (bool forceRewrite)
 Sets whether forcing rewriting (when applying changes) is enabled.
 
std::size_t minPadding () const
 Returns the minimum padding to be written before the data blocks when applying changes.
 
void setMinPadding (std::size_t minPadding)
 Sets the minimum padding to be written before the data blocks when applying changes.
 
std::size_t maxPadding () const
 Returns the maximum padding to be written before the data blocks when applying changes.
 
void setMaxPadding (std::size_t maxPadding)
 Sets the maximum padding to be written before the data blocks when applying changes.
 
std::size_t preferredPadding () const
 Returns the padding to be written before the data block when applying changes and the file needs to be rewritten anyways.
 
void setPreferredPadding (std::size_t preferredPadding)
 Sets the padding to be written before the data block when applying changes and the file needs to be rewritten anyways.
 
ElementPosition tagPosition () const
 Returns the position (in the output file) where the tag information is written when applying changes.
 
void setTagPosition (ElementPosition tagPosition)
 Sets the position (in the output file) where the tag information is written when applying changes.
 
bool forceTagPosition () const
 Returns whether tagPosition() is forced.
 
void setForceTagPosition (bool forceTagPosition)
 Sets whether tagPosition() is forced.
 
ElementPosition indexPosition () const
 Returns the position (in the output file) where the index is written when applying changes.
 
void setIndexPosition (ElementPosition indexPosition)
 Sets the position (in the output file) where the index is written when applying changes.
 
bool forceIndexPosition () const
 Returns whether indexPosition() is forced.
 
void setForceIndexPosition (bool forceTagPosition)
 Sets whether indexPosition() is forced.
 
std::uint64_t maxFullParseSize () const
 Returns the maximal file size for a "full parse" in byte.
 
void setMaxFullParseSize (std::uint64_t maxFullParseSize)
 Sets the maximal file size for a "full parse" in byte.
 
- Public Member Functions inherited from TagParser::BasicFileInfo
 BasicFileInfo ()
 Constructs a new BasicFileInfo for the specified file.
 
 BasicFileInfo (std::string &&path)
 Constructs a new BasicFileInfo for the specified file.
 
 BasicFileInfo (std::string_view path)
 Constructs a new BasicFileInfo for the specified file.
 
 BasicFileInfo (const BasicFileInfo &)=delete
 
BasicFileInfooperator= (const BasicFileInfo &)=delete
 
virtual ~BasicFileInfo ()
 Destroys the BasicFileInfo.
 
void open (bool readOnly=false)
 Opens a std::fstream for the current file.
 
void reopen (bool readOnly=false)
 Opens a std::fstream for the current file.
 
bool isOpen () const
 Indicates whether a std::fstream is open for the current file.
 
bool isReadOnly () const
 Indicates whether the last open()/reopen() call was read-only.
 
void close ()
 A possibly opened std::fstream will be closed.
 
void invalidate ()
 Invalidates the file info manually.
 
CppUtilities::NativeFileStream & stream ()
 Returns the std::fstream for the current instance.
 
const CppUtilities::NativeFileStream & stream () const
 Returns the std::fstream for the current instance.
 
const std::string & path () const
 Returns the path of the current file.
 
void setPath (std::string_view path)
 Sets the current file.
 
void setPath (std::string &&path)
 Sets the current file.
 
std::string fileName (bool cutExtension=false) const
 Returns the file name of the current file.
 
std::string extension () const
 Returns the extension of the current file.
 
std::string pathWithoutExtension () const
 Returns the path of the current file without the extension/suffix.
 
std::string containingDirectory () const
 Returns the path of the directory containing the current file.
 
std::uint64_t size () const
 Returns size of the current file in bytes.
 
void reportSizeChanged (std::uint64_t newSize)
 Call this function to report that the size changed.
 
void reportPathChanged (std::string_view newPath)
 Call this function to report that the path changed.
 
void reportPathChanged (std::string &&newPath)
 Call this function to report that the path changed.
 

Static Public Member Functions

static void writePadding (std::ostream &outputStream, uint64_t size)
 Writes the specified number of zeroes to outputStream.
 
- Static Public Member Functions inherited from TagParser::BasicFileInfo
static std::string fileName (std::string_view path, bool cutExtension=false)
 Returns the file name of the given file.
 
static std::string extension (std::string_view path)
 Returns the extension of the given file.
 
static std::string pathWithoutExtension (std::string_view fullPath)
 Returns a copy of the given path without the extension/suffix.
 
static std::string containingDirectory (std::string_view path)
 Returns the path of the directory containing the given file.
 
static std::string_view pathForOpen (std::string_view url)
 Returns removes the "file:/" prefix from url to be able to pass it to functions like open(), stat() and truncate().
 

Protected Member Functions

void invalidated () override
 Reimplemented from BasicFileInfo::invalidated().
 
- Protected Member Functions inherited from TagParser::BasicFileInfo

Detailed Description

The MediaFileInfo class allows to read and write tag information providing a container/tag format independent interface.

It also provides some technical information such as contained streams.

For examples see "cli/mainfeatures.cpp" of the tageditor repository.

Constructor & Destructor Documentation

◆ MediaFileInfo() [1/4]

TagParser::MediaFileInfo::MediaFileInfo ( )
explicit

Constructs a new MediaFileInfo.

Definition at line 107 of file mediafileinfo.cpp.

◆ MediaFileInfo() [2/4]

TagParser::MediaFileInfo::MediaFileInfo ( std::string_view path)
explicit

Constructs a new MediaFileInfo.

Definition at line 115 of file mediafileinfo.cpp.

◆ MediaFileInfo() [3/4]

TagParser::MediaFileInfo::MediaFileInfo ( std::string && path)
explicit

Constructs a new MediaFileInfo for the specified file.

Parameters
pathSpecifies the absolute or relative path of the file.

Definition at line 81 of file mediafileinfo.cpp.

◆ MediaFileInfo() [4/4]

TagParser::MediaFileInfo::MediaFileInfo ( const MediaFileInfo & )
delete

◆ ~MediaFileInfo()

TagParser::MediaFileInfo::~MediaFileInfo ( )
override

Destroys the MediaFileInfo.

Definition at line 123 of file mediafileinfo.cpp.

Member Function Documentation

◆ applyChanges()

void TagParser::MediaFileInfo::applyChanges ( Diagnostics & diag,
AbortableProgressFeedback & progress )

Applies assigned/changed tag information to the current file.

This method applies previously assigned tag information to the current file.

Depending on the changes to be applied the file will be rewritten.

When the file needs to be rewritten it will be renamed. A new file with the old name will be created to replace the old file.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
ThrowsTagParser::Failure or a derived exception when a making error occurs.
Remarks
Tags and tracks need to be parsed without errors before this method can be called. All previous parsing results are cleared (using clearParsingResults()). Hence the file must be reparsed. All related objects (tags, tracks, ...) might get invalidated. This includes notifications of these objects as well.
See also
clearParsingResults()

Definition at line 743 of file mediafileinfo.cpp.

◆ areAttachmentsSupported()

bool TagParser::MediaFileInfo::areAttachmentsSupported ( ) const

Returns an indication whether this library supports attachment format of the current file.

Definition at line 1230 of file mediafileinfo.cpp.

◆ areChaptersSupported()

bool TagParser::MediaFileInfo::areChaptersSupported ( ) const

Returns an indication whether this library supports parsing the chapters of the current file.

Definition at line 1213 of file mediafileinfo.cpp.

◆ areTagsSupported()

bool TagParser::MediaFileInfo::areTagsSupported ( ) const

Returns an indication whether this library supports the tag format of the current file.

Definition at line 1268 of file mediafileinfo.cpp.

◆ areTracksSupported()

bool TagParser::MediaFileInfo::areTracksSupported ( ) const

Returns an indication whether this library supports parsing the tracks information of the current file.

Definition at line 1247 of file mediafileinfo.cpp.

◆ attachments()

vector< AbstractAttachment * > TagParser::MediaFileInfo::attachments ( ) const

Returns all attachments assigned to the current file.

Remarks
The MediaFileInfo keeps the ownership over the object which will be destroyed when the MediaFileInfo is invalidated.

Definition at line 1354 of file mediafileinfo.cpp.

◆ attachmentsParsingStatus()

ParsingStatus TagParser::MediaFileInfo::attachmentsParsingStatus ( ) const
inline

Returns whether the attachments have been parsed yet.

Definition at line 362 of file mediafileinfo.h.

◆ availableLanguages()

unordered_set< string > TagParser::MediaFileInfo::availableLanguages ( TagParser::MediaType type = TagParser::MediaType::Audio) const

Determines the available languages for specified media type (by default MediaType::Audio).

If type is MediaType::Unknown, all media types are considered.

parseTracks() needs to be called before. Otherwise this method always returns an empty set.

See also
parseTracks()

Definition at line 984 of file mediafileinfo.cpp.

◆ backupDirectory()

const std::string & TagParser::MediaFileInfo::backupDirectory ( ) const
inline

Returns the directory used to store backup files.

Remarks
If empty, backup files will be stored in the same directory of the file being modified.
See also
setBackupDirectory()

Definition at line 421 of file mediafileinfo.h.

◆ chapters()

vector< AbstractChapter * > TagParser::MediaFileInfo::chapters ( ) const

Returns all chapters assigned to the current file.

Remarks
The MediaFileInfo keeps the ownership over the object which will be destroyed when the MediaFileInfo is invalidated.

Definition at line 1336 of file mediafileinfo.cpp.

◆ chaptersParsingStatus()

ParsingStatus TagParser::MediaFileInfo::chaptersParsingStatus ( ) const
inline

Returns whether the chapters have been parsed yet.

Definition at line 354 of file mediafileinfo.h.

◆ clearParsingResults()

void TagParser::MediaFileInfo::clearParsingResults ( )

Clears all parsing results and assigned/created/changed information such as detected container format, tracks, tags, ...

This allows a rescan of the file using parsing methods like parseContainerFormat(). Otherwise, these methods do nothing if the information to be parsed has already been gathered.

Remarks
Any pointers previously returned by tags(), tracks(), ... object should be considered invalidated.

Definition at line 1378 of file mediafileinfo.cpp.

◆ container()

AbstractContainer * TagParser::MediaFileInfo::container ( ) const
inline

Returns the container for the current file.

If there is not corresponding subclass of AbstractContainer for the container format or the container has not been parsed yet using the parseContainerFormat() method nullptr will be returned.

See also
parseContainerFormat()
AbstractContainer

Definition at line 511 of file mediafileinfo.h.

◆ containerFormat()

ContainerFormat TagParser::MediaFileInfo::containerFormat ( ) const
inline

Returns the container format of the current file.

parseContainerFormat() needs to be called before. Otherwise always ContainerFormat::Unknown will be returned.

Definition at line 262 of file mediafileinfo.h.

◆ containerFormatAbbreviation()

string_view TagParser::MediaFileInfo::containerFormatAbbreviation ( ) const

Returns the abbreviation of the container format as C-style string.

This abbreviation might be used as file extension.

parseContainerFormat() needs to be called before. Otherwise always an empty string will be returned.

See also
containerFormat()
containerFormatName()
parseContainerFormat()

Definition at line 809 of file mediafileinfo.cpp.

◆ containerFormatName()

std::string_view TagParser::MediaFileInfo::containerFormatName ( ) const
inline

Returns the name of the container format as C-style string.

parseContainerFormat() needs to be called before. Otherwise always the name "Unknown" will be returned.

See also
containerFormat()
containerFormatAbbreviation()
parseContainerFormat()

Definition at line 277 of file mediafileinfo.h.

◆ containerFormatSubversion()

std::string_view TagParser::MediaFileInfo::containerFormatSubversion ( ) const
inline

Returns the subversion of the container format as C-style string.

parseContainerFormat() needs to be called before. Otherwise always an empty string will be returned.

See also
containerFormat()
containerFormatName()
parseContainerFormat()

Definition at line 292 of file mediafileinfo.h.

◆ containerOffset()

std::uint64_t TagParser::MediaFileInfo::containerOffset ( ) const
inline

Returns the actual container start offset.

Definition at line 300 of file mediafileinfo.h.

◆ containerParsingStatus()

ParsingStatus TagParser::MediaFileInfo::containerParsingStatus ( ) const
inline

Returns an indication whether the container format has been parsed yet.

Definition at line 251 of file mediafileinfo.h.

◆ createAppropriateTags()

bool TagParser::MediaFileInfo::createAppropriateTags ( const TagCreationSettings & settings = TagCreationSettings())

Ensures appropriate tags are created according the given settings.

Returns
Returns whether appropriate tags could be created for the file.
Remarks
  • Tags must have been parsed before invoking this method (otherwise it will just return false).
  • The ID3 related arguments are only practiced when the file format is MP3 or when the file format is unknown and treatUnknownFilesAsMp3Files is true.
  • Tags might be removed as well. For example the existing ID3v1 tag of an MP3 file will be removed if id3v1Usage is set to TagUsage::Never.
  • The method might do nothing if present tag(s) already match the given specifications.
  • This is only a convenience method. The task could be done by manually using the methods createId3v1Tag(), createId3v2Tag(), removeId3v1Tag() ... as well.
  • Some tag information might be discarded. For example when an ID3v2 tag needs to be removed (TagSettings::id3v2usage is set to TagUsage::Never) and an ID3v1 tag will be created instead not all fields can be transferred.

Definition at line 616 of file mediafileinfo.cpp.

◆ createId3v1Tag()

Id3v1Tag * TagParser::MediaFileInfo::createId3v1Tag ( )

Creates an ID3v1 tag for the current file.

This method does nothing the tags of the current file haven't been parsed using the parseTags() method.

If the file has already an ID3v1 tag no new tag will be created.

To apply the created tag and other changings call the applyChanges() method.

Returns
Returns the ID3v1 tag of the current file or nullptr if the tag haven't been parsed yet.
See also
applyChanges()

Definition at line 1071 of file mediafileinfo.cpp.

◆ createId3v2Tag()

Id3v2Tag * TagParser::MediaFileInfo::createId3v2Tag ( )

Creates an ID3v2 tag for the current file.

This method does nothing the tags of the current file haven't been parsed using the parseTags() method.

If the file has already an ID3v2 tag no new tag will be created.

To apply the created tag and other changings call the applyChanges() method.

Returns
Returns the first ID3v2 tag of the current file.
Remarks
The MediaFileInfo keeps the ownership over the created tag. It will be destroyed when the MediaFileInfo is invalidated.
See also
applyChanges()

Definition at line 1138 of file mediafileinfo.cpp.

◆ createVorbisComment()

VorbisComment * TagParser::MediaFileInfo::createVorbisComment ( )

Creates a Vorbis comment for the current file.

This method does nothing if the tags/tracks of the current file haven't been parsed using the parseTags() and parseTracks() methods.

If the file has already a Vorbis comment no new tag will be created.

To apply the created tag and other changings call the applyChanges() method.

Returns
Returns the Vorbis comment or nullptr if creation is not possible.
See also
applyChanges()

Definition at line 1494 of file mediafileinfo.cpp.

◆ duration()

CppUtilities::TimeSpan TagParser::MediaFileInfo::duration ( ) const

Returns the overall duration of the file if known; otherwise returns a TimeSpan with zero ticks.

parseTracks() needs to be called before. Otherwise this method always returns false.

See also
parseTracks()

Definition at line 946 of file mediafileinfo.cpp.

◆ effectiveSize()

std::uint64_t TagParser::MediaFileInfo::effectiveSize ( ) const
inline

Returns the "effective size" of the file if know; otherwise returns 0.

Remarks
This is the size of the file minus tags at the beginning and the end.

Definition at line 317 of file mediafileinfo.h.

◆ fileHandlingFlags()

MediaFileHandlingFlags TagParser::MediaFileInfo::fileHandlingFlags ( )
inline

Returns the currently configured file handling flags.

Definition at line 519 of file mediafileinfo.h.

◆ forceIndexPosition()

bool TagParser::MediaFileInfo::forceIndexPosition ( ) const
inline

Returns whether indexPosition() is forced.

See also
setForceIndexPosition()
indexPosition(), setIndexPosition()

Definition at line 717 of file mediafileinfo.h.

◆ forceTagPosition()

bool TagParser::MediaFileInfo::forceTagPosition ( ) const
inline

Returns whether tagPosition() is forced.

See also
setForceTagPosition()
tagPosition(), setTagPosition()

Definition at line 677 of file mediafileinfo.h.

◆ hasAnyTag()

bool TagParser::MediaFileInfo::hasAnyTag ( ) const

Returns an indication whether a tag of any format is assigned.

Remarks

Definition at line 1591 of file mediafileinfo.cpp.

◆ hasId3v1Tag()

bool TagParser::MediaFileInfo::hasId3v1Tag ( ) const
inline

Returns an indication whether an ID3v1 tag is assigned.

Definition at line 370 of file mediafileinfo.h.

◆ hasId3v2Tag()

bool TagParser::MediaFileInfo::hasId3v2Tag ( ) const
inline

Returns an indication whether an ID3v2 tag is assigned.

Definition at line 378 of file mediafileinfo.h.

◆ hasTracksOfType()

bool TagParser::MediaFileInfo::hasTracksOfType ( TagParser::MediaType type) const

Returns an indication whether the current file has tracks of the specified type.

parseTracks() needs to be called before. Otherwise this method always returns false.

See also
parseTracks()

Definition at line 920 of file mediafileinfo.cpp.

◆ id3v1Tag()

Id3v1Tag * TagParser::MediaFileInfo::id3v1Tag ( ) const
inline

Returns a pointer to the assigned ID3v1 tag or nullptr if none is assigned.

Remarks
The MediaFileInfo keeps the ownership over the returned pointer. The returned ID3v1 tag will be destroyed when the MediaFileInfo gets invalidated.

Definition at line 390 of file mediafileinfo.h.

◆ id3v1ToId3v2()

bool TagParser::MediaFileInfo::id3v1ToId3v2 ( )

Converts an existing ID3v1 tag into an ID3v2 tag.

Effectively merges all ID3 tags into a single ID3v2 tag.

Remarks
Does nothing if
  • there is no ID3v1 tag assigned.
  • the file format isn't known to support ID3 tags (unless there is an ID3 tag present).
  • the tags of the current file haven't been parsed using the parseTags() method.

Definition at line 1452 of file mediafileinfo.cpp.

◆ id3v2Tags()

const std::vector< std::unique_ptr< Id3v2Tag > > & TagParser::MediaFileInfo::id3v2Tags ( ) const
inline

Returns pointers to the assigned ID3v2 tags.

Remarks
The MediaFileInfo keeps the ownership over the returned pointers. The returned ID3v2 tags will be destroyed when the MediaFileInfo gets invalidated.

Definition at line 402 of file mediafileinfo.h.

◆ id3v2ToId3v1()

bool TagParser::MediaFileInfo::id3v2ToId3v1 ( )

Converts the existing ID3v2 tags into an ID3v1 tag.

Effectively merges all ID3 tags into a single ID3v1 tag.

Remarks
Does nothing if
  • there is not at least one ID3v2 tag assigned.
  • the file format isn't known to support ID3 tags (unless there is an ID3 tag present).
  • the tags of the current file haven't been parsed using the parseTags() method.

Definition at line 1471 of file mediafileinfo.cpp.

◆ indexPosition()

ElementPosition TagParser::MediaFileInfo::indexPosition ( ) const
inline

Returns the position (in the output file) where the index is written when applying changes.

See also
setIndexPosition()
Remarks
To determine the current index position, use AbstractContainer::determineIndexPosition().

Definition at line 697 of file mediafileinfo.h.

◆ invalidated()

void TagParser::MediaFileInfo::invalidated ( )
overrideprotectedvirtual

Reimplemented from BasicFileInfo::invalidated().

Reimplemented from TagParser::BasicFileInfo.

Definition at line 1650 of file mediafileinfo.cpp.

◆ isForcingFullParse()

bool TagParser::MediaFileInfo::isForcingFullParse ( ) const
inline

Returns an indication whether forcing a full parse is enabled.

If enabled the parser will analyse the file structure as deep as possible. This might cause long parsing times for big files.

See also
setForceFullParse()

Definition at line 540 of file mediafileinfo.h.

◆ isForcingRewrite()

bool TagParser::MediaFileInfo::isForcingRewrite ( ) const
inline

Returns whether forcing rewriting (when applying changes) is enabled.

Definition at line 558 of file mediafileinfo.h.

◆ matroskaTags()

const vector< unique_ptr< MatroskaTag > > & TagParser::MediaFileInfo::matroskaTags ( ) const

Returns pointers to the assigned Matroska tags.

Remarks
The MediaFileInfo keeps the ownership over the returned pointers. The returned Matroska tags will be destroyed when the MediaFileInfo is invalidated.

Definition at line 1308 of file mediafileinfo.cpp.

◆ maxFullParseSize()

std::uint64_t TagParser::MediaFileInfo::maxFullParseSize ( ) const
inline

Returns the maximal file size for a "full parse" in byte.

Remarks
So far this is Matroska-specific: 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.

See also
setMaxFullParseSize()

Definition at line 745 of file mediafileinfo.h.

◆ maxPadding()

std::size_t TagParser::MediaFileInfo::maxPadding ( ) const
inline

Returns the maximum padding to be written before the data blocks when applying changes.

Maximum padding in front of the file allows adding additional fields afterwards without needing to rewrite the entire file or to put tag information at the end of the file.

The default value is 0 which will force the library to rewrite the entire file almost always when applying changes. Increate the value using setMaxPadding() to prevent this.

See also
minPadding()
tagPosition()
setMaxPadding()

Definition at line 611 of file mediafileinfo.h.

◆ mergeId3v2Tags()

void TagParser::MediaFileInfo::mergeId3v2Tags ( )

Merges the assigned ID3v2 tags into a single ID3v2 tag.

Some files I've got contain multiple successive ID3v2 tags. If the tags of such an file is parsed by this class, these tags will be kept separate. This method merges all assigned ID3v2 tags. All fields from the additional ID3v2 tags will be inserted to the first tag. All assigned ID3v2 tag instances except thefirst will be destroyed.

A possibly assigned ID3v1 tag remains unaffected.

This method does nothing the tags of the current file haven't been parsed using the parseTags() method.

See also
id3v2Tags()

Definition at line 1425 of file mediafileinfo.cpp.

◆ mimeType()

string_view TagParser::MediaFileInfo::mimeType ( ) const

Returns the MIME-type of the container format as C-style string.

parseContainerFormat() needs to be called before. Otherwise always an empty string will be returned.

See also
containerFormat()
containerFormatName()
parseContainerFormat()

Definition at line 863 of file mediafileinfo.cpp.

◆ minPadding()

std::size_t TagParser::MediaFileInfo::minPadding ( ) const
inline

Returns the minimum padding to be written before the data blocks when applying changes.

Minimum padding in front of the file allows adding additional fields afterwards without needing to rewrite the entire file or to put tag information at the end of the file.

The default value is 0.

See also
maxPadding()
tagPosition()
setMinPadding()

Definition at line 583 of file mediafileinfo.h.

◆ mp4Tag()

Mp4Tag * TagParser::MediaFileInfo::mp4Tag ( ) const

Returns a pointer to the assigned MP4 tag or nullptr if none is assigned.

Remarks
The MediaFileInfo keeps the ownership over the object which will be destroyed when the MediaFileInfo is invalidated.

Definition at line 1293 of file mediafileinfo.cpp.

◆ operator=()

MediaFileInfo & TagParser::MediaFileInfo::operator= ( const MediaFileInfo & )
delete

◆ overallAverageBitrate()

double TagParser::MediaFileInfo::overallAverageBitrate ( ) const

Returns the overall average bitrate in kbit/s of the file if known; otherwise returns 0.0.

parseTracks() needs to be called before. Otherwise this method always returns false.

See also
parseTracks()

Definition at line 965 of file mediafileinfo.cpp.

◆ paddingSize()

std::uint64_t TagParser::MediaFileInfo::paddingSize ( ) const
inline

Returns the padding size.

Container format and tags should have been parsed yet.

Definition at line 308 of file mediafileinfo.h.

◆ parseAttachments()

void TagParser::MediaFileInfo::parseAttachments ( Diagnostics & diag,
AbortableProgressFeedback & progress )

Parses the attachments of the current file.

This method parses the attachments of the current file if not been parsed yet.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
Remarks
parseContainerFormat() must be called before.
See also
areChaptersParsed(), parseContainerFormat(), parseTracks(), parseTags(), parseEverything()

Definition at line 554 of file mediafileinfo.cpp.

◆ parseChapters()

void TagParser::MediaFileInfo::parseChapters ( Diagnostics & diag,
AbortableProgressFeedback & progress )

Parses the chapters of the current file.

This method parses the chapters of the current file if not been parsed yet.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
Remarks
parseContainerFormat() must be called before.
See also
areChaptersParsed(), parseContainerFormat(), parseTracks(), parseTags(), parseEverything()

Definition at line 521 of file mediafileinfo.cpp.

◆ parseContainerFormat()

void TagParser::MediaFileInfo::parseContainerFormat ( Diagnostics & diag,
AbortableProgressFeedback & progress )

Parses the container format of the current file.

This method parses the container of the current file format if it has not been parsed yet.

After calling this method the methods containerFormat(), containerFormatName(), containerFormatAbbreviation(), containerFormatSubversion(), containerMimeType(), container(), mp4Container() and matroskaContainer() will return the parsed information.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
See also
isContainerParsed(), parseTracks(), parseTag(), parseChapters(), parseEverything()

Definition at line 140 of file mediafileinfo.cpp.

◆ parsedTags() [1/2]

std::vector< Tag * > TagParser::MediaFileInfo::parsedTags ( ) const

Returns all tags parsed from the current file.

Remarks

Definition at line 1640 of file mediafileinfo.cpp.

◆ parsedTags() [2/2]

void TagParser::MediaFileInfo::parsedTags ( std::vector< Tag * > & tags) const

Returns all tags parsed from the current file.

Remarks

Definition at line 1606 of file mediafileinfo.cpp.

◆ parseEverything()

void TagParser::MediaFileInfo::parseEverything ( Diagnostics & diag,
AbortableProgressFeedback & progress )

Parses the container format, the tracks and the tag information of the current file.

See the individual methods to for more details and exceptions which might be thrown.

See also
parseContainerFormat(), parseTracks(), parseTags()

Definition at line 584 of file mediafileinfo.cpp.

◆ parseTags()

void TagParser::MediaFileInfo::parseTags ( Diagnostics & diag,
AbortableProgressFeedback & progress )

Parses the tag(s) of the current file.

This method parses the tag(s) of the current file if not been parsed yet. After calling this method the methods id3v1Tag(), id3v2Tags(), mp4Tag() and allTags() will return the parsed information.

Previously assigned but not applied tag information will be discarted.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
Remarks
parseContainerFormat() must be called before.
See also
isTagParsed(), parseContainerFormat(), parseTracks(), parseChapters(), parseEverything()

Definition at line 402 of file mediafileinfo.cpp.

◆ parseTracks()

void TagParser::MediaFileInfo::parseTracks ( Diagnostics & diag,
AbortableProgressFeedback & progress )

Parses the tracks of the current file.

This method parses the tracks of the current file if not been parsed yet. After calling this method the methods trackCount(), tracks(), and hasTracksOfType() will return the parsed information.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
Remarks
parseContainerFormat() must be called before.
See also
areTracksParsed(), parseContainerFormat(), parseTags(), parseChapters(), parseEverything()

Definition at line 324 of file mediafileinfo.cpp.

◆ preferredPadding()

std::size_t TagParser::MediaFileInfo::preferredPadding ( ) const
inline

Returns the padding to be written before the data block when applying changes and the file needs to be rewritten anyways.

Padding in front of the file allows adding additional fields afterwards without needing to rewrite the entire file or to put tag information at the end of the file.

Definition at line 632 of file mediafileinfo.h.

◆ removeAllId3v2Tags()

bool TagParser::MediaFileInfo::removeAllId3v2Tags ( )

Removes all assigned ID3v2 tags from the current file.

To apply the removal and other changings call the applyChanges() method

Returns
Returns whether there where ID3v2 tags assigned which could be removed.
Remarks
Invalidates all removed tag objects (eg. returned via tags() or id3v2Tags()).
See also
applyChanges()

Definition at line 1114 of file mediafileinfo.cpp.

◆ removeAllTags()

void TagParser::MediaFileInfo::removeAllTags ( )

Removes all assigned tags from the file.

Remarks
Invalidates all removed tag objects (eg. returned via tags()).

To apply the removal and other changings call the applyChanges() method.

Definition at line 1198 of file mediafileinfo.cpp.

◆ removeId3v1Tag()

bool TagParser::MediaFileInfo::removeId3v1Tag ( )

Removes a possibly assigned ID3v1 tag from the current file.

To apply the removal and other changings call the applyChanges() method.

Returns
Returns whether there was an ID3v1 tag assigned which could be removed.
Remarks
Invalidates the removed tag object (eg. returned via tags() or id3v1Tag()).
See also
applyChanges()

Definition at line 1044 of file mediafileinfo.cpp.

◆ removeId3v2Tag()

bool TagParser::MediaFileInfo::removeId3v2Tag ( Id3v2Tag * tag)

Removes an assigned ID3v2 tag from the current file.

To apply the removal and other changings call the applyChanges() method.

Parameters
tagSpecifies the ID3v2 tag to be removed.
Returns
Returns whether there the an ID3v2 tag could be removed.
Remarks
Invalidates all removed tag objects (eg. returned via tags() or id3v2Tags()).
See also
applyChanges()

Definition at line 1092 of file mediafileinfo.cpp.

◆ removeTag()

bool TagParser::MediaFileInfo::removeTag ( Tag * tag)

Removes a possibly assigned tag from the current file.

To apply the removal and other changings call the applyChanges() method.

Parameters
tagSpecifies the tag to be removed. The tag will not only be detached from the file, it will be destroyed as well. Might be nullptr for convenience (eg. you might want to call file.removeTag(file.mp4Tag()) to ensure no MP4 tag is present without checking before).
Remarks
Invalidates the removed tag object if it has been removed.
See also
applyChanges()

Definition at line 1159 of file mediafileinfo.cpp.

◆ removeVorbisComment()

bool TagParser::MediaFileInfo::removeVorbisComment ( )

Removes all assigned Vorbis comment from the current file.

To apply the removal and other changings call the applyChanges() method.

Returns
Returns whether there was an Vorbis comment assigned which could be removed.
See also
applyChanges()

Definition at line 1521 of file mediafileinfo.cpp.

◆ reportPaddingSizeChanged()

void TagParser::MediaFileInfo::reportPaddingSizeChanged ( std::uint64_t newPaddingSize)
inline

Sets the padding size.

Remarks
This is meant to be called from container implementations.

Definition at line 411 of file mediafileinfo.h.

◆ saveFilePath()

const std::string & TagParser::MediaFileInfo::saveFilePath ( ) const
inline

Returns the "save file path" which has been set using setSaveFilePath().

See also
setSaveFilePath()

Definition at line 448 of file mediafileinfo.h.

◆ setBackupDirectory() [1/2]

void TagParser::MediaFileInfo::setBackupDirectory ( std::string && backupDirectory)
inline

Sets the directory used to store backup files.

Remarks
If empty, backup files will be stored in the same directory of the file being modified.

Definition at line 439 of file mediafileinfo.h.

◆ setBackupDirectory() [2/2]

void TagParser::MediaFileInfo::setBackupDirectory ( std::string_view backupDirectory)
inline

Sets the directory used to store backup files.

Remarks
If empty, backup files will be stored in the same directory of the file being modified.

Definition at line 430 of file mediafileinfo.h.

◆ setFileHandlingFlags()

void TagParser::MediaFileInfo::setFileHandlingFlags ( MediaFileHandlingFlags flags)
inline

Replaces all currently configured file handling flags with the specified flags.

Definition at line 527 of file mediafileinfo.h.

◆ setForceFullParse()

void TagParser::MediaFileInfo::setForceFullParse ( bool forceFullParse)
inline

Sets whether forcing a full parse is enabled.

Remarks
The setting is applied next time parsing. The current parsing results are not mutated.
See also
isForcingFullParse()

Definition at line 550 of file mediafileinfo.h.

◆ setForceIndexPosition()

void TagParser::MediaFileInfo::setForceIndexPosition ( bool forceIndexPosition)
inline

Sets whether indexPosition() is forced.

See also
forceIndexPosition()
indexPosition(), setIndexPosition()

Definition at line 727 of file mediafileinfo.h.

◆ setForceRewrite()

void TagParser::MediaFileInfo::setForceRewrite ( bool forceRewrite)
inline

Sets whether forcing rewriting (when applying changes) is enabled.

Definition at line 566 of file mediafileinfo.h.

◆ setForceTagPosition()

void TagParser::MediaFileInfo::setForceTagPosition ( bool forceTagPosition)
inline

Sets whether tagPosition() is forced.

See also
forceTagPosition()
tagPosition(), setTagPosition()

Definition at line 687 of file mediafileinfo.h.

◆ setIndexPosition()

void TagParser::MediaFileInfo::setIndexPosition ( ElementPosition indexPosition)
inline

Sets the position (in the output file) where the index is written when applying changes.

Remarks
Same rules as for tagPosition() apply. If conflicting with tagPosition(), tagPosition() has priority.

Definition at line 707 of file mediafileinfo.h.

◆ setMaxFullParseSize()

void TagParser::MediaFileInfo::setMaxFullParseSize ( std::uint64_t maxFullParseSize)
inline

Sets the maximal file size for a "full parse" in byte.

See also
maxFullParseSize()

Definition at line 754 of file mediafileinfo.h.

◆ setMaxPadding()

void TagParser::MediaFileInfo::setMaxPadding ( std::size_t maxPadding)
inline

Sets the maximum padding to be written before the data blocks when applying changes.

Remarks
This value might be ignored if not supported by the container/tag format or the corresponding implementation.
See also
maxPadding()

Definition at line 621 of file mediafileinfo.h.

◆ setMinPadding()

void TagParser::MediaFileInfo::setMinPadding ( std::size_t minPadding)
inline

Sets the minimum padding to be written before the data blocks when applying changes.

Remarks
This value might be ignored if not supported by the container/tag format or the corresponding implementation.
See also
minPadding()

Definition at line 593 of file mediafileinfo.h.

◆ setPreferredPadding()

void TagParser::MediaFileInfo::setPreferredPadding ( std::size_t preferredPadding)
inline

Sets the padding to be written before the data block when applying changes and the file needs to be rewritten anyways.

Remarks
This value might be ignored if not supported by the container/tag format or the corresponding implementation.
See also
preferredPadding()

Definition at line 642 of file mediafileinfo.h.

◆ setSaveFilePath() [1/2]

void TagParser::MediaFileInfo::setSaveFilePath ( std::string && saveFilePath)
inline

Sets the "save file path".

Definition at line 475 of file mediafileinfo.h.

◆ setSaveFilePath() [2/2]

void TagParser::MediaFileInfo::setSaveFilePath ( std::string_view saveFilePath)
inline

Sets the "save file path".

If saveFilePath is not empty, this path will be used to save the output file when applying changes using applyChanges(). Thus the current file is not modified by applyChanges() in this case and the variable isForcingRewrite() does not affect the behaviour of applyChanges(). If the changes have been applied without fatal errors the "save file path" is cleared and used as the new regular path().

By default, this path is empty.

Remarks
saveFilePath mustn't be the current path().

Definition at line 467 of file mediafileinfo.h.

◆ setTagPosition()

void TagParser::MediaFileInfo::setTagPosition ( ElementPosition tagPosition)
inline

Sets the position (in the output file) where the tag information is written when applying changes.

Remarks
  • If putting the tags at another position would prevent rewriting the entire file the specified position might not be used if forceTagPosition() is false.
  • However if the specified position is not supported by the container/tag format or by the implementation for the format it is ignored (even if forceTagPosition() is true).
  • Default value is ElementPosition::BeforeData

Definition at line 667 of file mediafileinfo.h.

◆ setWritingApplication()

void TagParser::MediaFileInfo::setWritingApplication ( std::string_view writingApplication)
inline

Sets the writing application as container-level meta-data.

Put the name of your application here.

Remarks

Definition at line 496 of file mediafileinfo.h.

◆ tagPosition()

ElementPosition TagParser::MediaFileInfo::tagPosition ( ) const
inline

Returns the position (in the output file) where the tag information is written when applying changes.

See also
setTagPosition()
Remarks
To determine the current tag position, use AbstractContainer::determineTagPosition().

Definition at line 652 of file mediafileinfo.h.

◆ tags() [1/2]

vector< Tag * > TagParser::MediaFileInfo::tags ( ) const

Returns all tags assigned to the current file.

Remarks

Definition at line 1578 of file mediafileinfo.cpp.

◆ tags() [2/2]

void TagParser::MediaFileInfo::tags ( std::vector< Tag * > & tags) const

Stores all tags assigned to the current file in the specified vector.

Remarks
  • Previous elements of the vector will not be cleared.
  • Includes tags which have only been assigned, e.g. via createAppropriateTags(), even if those tags have not been stored to disk yet via applyChanges().
  • The MediaFileInfo keeps the ownership over the tags which will be destroyed when the MediaFileInfo is invalidated.

Definition at line 1550 of file mediafileinfo.cpp.

◆ tagsParsingStatus()

ParsingStatus TagParser::MediaFileInfo::tagsParsingStatus ( ) const
inline

Returns an indication whether tag information has been parsed yet.

Definition at line 325 of file mediafileinfo.h.

◆ technicalSummary()

string TagParser::MediaFileInfo::technicalSummary ( ) const

Generates a short technical summary about the file's tracks.

parseTracks() needs to be called before. Otherwise this method always returns an empty string.

Example (exact format might change in the future!): "H.264-720p / HE-AAC-6ch-eng / HE-AAC-2ch-ger / SRT-eng / SRT-ger"

See also
parseTracks()

Definition at line 1016 of file mediafileinfo.cpp.

◆ trackCount()

std::size_t TagParser::MediaFileInfo::trackCount ( ) const
inline

Returns the number of tracks that could be parsed.

parseTracks() needs to be called before. Otherwise this method always returns zero.

See also
parseTracks()

Definition at line 346 of file mediafileinfo.h.

◆ tracks()

vector< AbstractTrack * > TagParser::MediaFileInfo::tracks ( ) const

Returns the tracks for the current file.

parseTracks() needs to be called before. Otherwise this method always returns an empty vector.

Remarks
The MediaFileInfo keeps the ownership over the returned pointers. The returned Tracks will be destroyed when the MediaFileInfo is invalidated.
See also
parseTracks()

Definition at line 890 of file mediafileinfo.cpp.

◆ tracksParsingStatus()

ParsingStatus TagParser::MediaFileInfo::tracksParsingStatus ( ) const
inline

Returns an indication whether tracks have been parsed yet.

Definition at line 333 of file mediafileinfo.h.

◆ vorbisComment()

VorbisComment * TagParser::MediaFileInfo::vorbisComment ( ) const

Returns a pointer to the first assigned Vorbis comment or nullptr if none is assigned.

Remarks
The MediaFileInfo keeps the ownership over the object which will be destroyed when the MediaFileInfo is invalidated.

Definition at line 1324 of file mediafileinfo.cpp.

◆ writePadding()

void TagParser::MediaFileInfo::writePadding ( std::ostream & outputStream,
uint64_t size )
static

Writes the specified number of zeroes to outputStream.

Definition at line 1399 of file mediafileinfo.cpp.

◆ writingApplication()

const std::string & TagParser::MediaFileInfo::writingApplication ( ) const
inline

Sets the writing application as container-level meta-data.

Remarks
This is not read from the file when parsing and only used when saving changes.
See also
setWritingApplication() for more details

Definition at line 485 of file mediafileinfo.h.


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