MythTV  master
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
MetaIOID3 Class Reference

Read and write metadata in MPEG (mp3) ID3V2 tags. More...

#include <metaioid3.h>

Inheritance diagram for MetaIOID3:
Inheritance graph
[legend]
Collaboration diagram for MetaIOID3:
Collaboration graph
[legend]

Public Member Functions

 MetaIOID3 (void)=default
 
 ~MetaIOID3 (void) override
 
bool write (const QString &filename, MusicMetadata *mdata) override
 Writes all metadata back to a file. More...
 
bool writeVolatileMetadata (const QString &filename, MusicMetadata *mdata) override
 
bool writeAlbumArt (const QString &filename, const AlbumArtImage *albumart) override
 Write the albumart image to the file. More...
 
bool removeAlbumArt (const QString &filename, const AlbumArtImage *albumart) override
 Remove the albumart image from the file. More...
 
MusicMetadataread (const QString &filename) override
 Reads MusicMetadata from a file. More...
 
AlbumArtList getAlbumArtList (const QString &filename) override
 Read the albumart images from the file. More...
 
QImage * getAlbumArt (const QString &filename, ImageType type) override
 Read the albumart image from the file. More...
 
bool supportsEmbeddedImages (void) override
 Does the tag support embedded cover art. More...
 
bool changeImageType (const QString &filename, const AlbumArtImage *albumart, ImageType newType) override
 
bool TagExists (const QString &filename) override
 
- Public Member Functions inherited from MetaIOTagLib
 MetaIOTagLib (void)=default
 
 ~MetaIOTagLib (void) override=default
 
- Public Member Functions inherited from MetaIO
 MetaIO (void)
 
virtual ~MetaIO (void)=default
 
virtual bool writeVolatileMetadata ([[maybe_unused]] const QString &filename, [[maybe_unused]] MusicMetadata *mdata)
 Writes rating and playcount back to a file. More...
 
virtual AlbumArtList getAlbumArtList ([[maybe_unused]] const QString &filename)
 Reads the list of embedded images in the tag. More...
 
virtual bool writeAlbumArt ([[maybe_unused]] const QString &filename, [[maybe_unused]] const AlbumArtImage *albumart)
 
virtual bool removeAlbumArt ([[maybe_unused]] const QString &filename, [[maybe_unused]] const AlbumArtImage *albumart)
 
virtual bool changeImageType ([[maybe_unused]] const QString &filename, [[maybe_unused]] const AlbumArtImage *albumart, [[maybe_unused]] ImageType newType)
 
virtual QImage * getAlbumArt ([[maybe_unused]] const QString &filename, [[maybe_unused]] ImageType type)
 
void readFromFilename (const QString &filename, QString &artist, QString &album, QString &title, QString &genre, int &tracknum)
 Reads MusicMetadata based on the folder/filename. More...
 
MusicMetadatareadFromFilename (const QString &filename, bool blnLength=false)
 Reads MusicMetadata based on the folder/filename. More...
 
void readFromFilename (MusicMetadata *metadata)
 Reads MusicMetadata based on the folder/filename. More...
 
virtual bool TagExists ([[maybe_unused]] const QString &filename)
 

Private Types

enum  TagType { kMPEG, kFLAC }
 

Private Member Functions

bool OpenFile (const QString &filename, bool forWriting=false)
 Open the file to read the tag. More...
 
bool SaveFile ()
 
void CloseFile ()
 
TagLib::ID3v2::Tag * GetID3v2Tag (bool create=false)
 
TagLib::ID3v1::Tag * GetID3v1Tag (bool create=false)
 

Static Private Member Functions

static bool writePlayCount (TagLib::ID3v2::Tag *tag, int playcount)
 
static bool writeRating (TagLib::ID3v2::Tag *tag, int rating)
 
static bool writeLastPlay (TagLib::ID3v2::Tag *tag, QDateTime lastPlay)
 
static AlbumArtList readAlbumArt (TagLib::ID3v2::Tag *tag)
 Read the albumart images from the file. More...
 
static UserTextIdentificationFrame * find (TagLib::ID3v2::Tag *tag, const String &description)
 Find the a custom comment tag by description. This is a copy of the same function in the TagLib::ID3v2::UserTextIdentificationFrame Class with a static instead of dynamic cast. More...
 
static PopularimeterFrame * findPOPM (TagLib::ID3v2::Tag *tag, const String &email)
 Find the POPM tag associated with MythTV. More...
 
static AttachedPictureFrame * findAPIC (TagLib::ID3v2::Tag *tag, AttachedPictureFrame::Type type, const String &description=String())
 Find an APIC tag by type and optionally description. More...
 
static QString getExtFromMimeType (const QString &mimeType)
 

Private Attributes

TagLib::File * m_file {nullptr}
 
TagType m_fileType {kMPEG}
 

Additional Inherited Members

- Static Public Member Functions inherited from MetaIO
static MetaIOcreateTagger (const QString &filename)
 Finds an appropriate tagger for the given file. More...
 
static MusicMetadatareadMetadata (const QString &filename)
 Read the metadata from filename directly. More...
 
static MusicMetadatagetMetadata (const QString &filename)
 Get the metadata for filename. More...
 
- Static Public Attributes inherited from MetaIO
static const QString kValidFileExtensions
 
- Protected Member Functions inherited from MetaIOTagLib
std::chrono::milliseconds getTrackLength (const QString &filename) override
 Find the length of the track (in milliseconds) More...
 
void ReadGenericMetadata (TagLib::Tag *tag, MusicMetadata *metadata)
 Writes metadata common to all tag formats to the tag. More...
 
- Protected Member Functions inherited from MetaIO
void saveTimeStamps (void)
 
void restoreTimeStamps (void)
 
- Static Protected Member Functions inherited from MetaIOTagLib
static std::chrono::milliseconds getTrackLength (TagLib::File *file)
 Find the length of the track (in milliseconds) More...
 
static void WriteGenericMetadata (TagLib::Tag *tag, const MusicMetadata *metadata)
 Writes metadata common to all tag formats to the tag. More...
 
- Protected Attributes inherited from MetaIO
QString m_filename
 
QString m_filenameFormat
 

Detailed Description

Read and write metadata in MPEG (mp3) ID3V2 tags.

Will read ID3v1 but always writes ID3v2.4 compliant tags.

Definition at line 38 of file metaioid3.h.

Member Enumeration Documentation

◆ TagType

enum MetaIOID3::TagType
private
Enumerator
kMPEG 
kFLAC 

Definition at line 84 of file metaioid3.h.

Constructor & Destructor Documentation

◆ MetaIOID3()

MetaIOID3::MetaIOID3 ( void  )
default

◆ ~MetaIOID3()

MetaIOID3::~MetaIOID3 ( void  )
inlineoverride

Definition at line 42 of file metaioid3.h.

Member Function Documentation

◆ write()

bool MetaIOID3::write ( const QString &  filename,
MusicMetadata mdata 
)
overridevirtual

Writes all metadata back to a file.

Parameters
filenameThe filename to write metadata to
mdataA pointer to a MusicMetadata object
Returns
Boolean to indicate success/failure.

Implements MetaIOTagLib.

Definition at line 153 of file metaioid3.cpp.

Referenced by LameEncoder::~LameEncoder().

◆ writeVolatileMetadata()

bool MetaIOID3::writeVolatileMetadata ( const QString &  filename,
MusicMetadata mdata 
)
override

Definition at line 878 of file metaioid3.cpp.

◆ writeAlbumArt()

bool MetaIOID3::writeAlbumArt ( const QString &  filename,
const AlbumArtImage albumart 
)
override

Write the albumart image to the file.

Parameters
filenameThe music file to add the albumart
albumartThe Album Art image to write
Returns
True if successful
Note
We always save the image in JPEG format

Definition at line 607 of file metaioid3.cpp.

◆ removeAlbumArt()

bool MetaIOID3::removeAlbumArt ( const QString &  filename,
const AlbumArtImage albumart 
)
override

Remove the albumart image from the file.

Parameters
filenameThe music file to remove the albumart
albumartThe Album Art image to remove
Returns
True if successful

Definition at line 680 of file metaioid3.cpp.

◆ read()

MusicMetadata * MetaIOID3::read ( const QString &  filename)
overridevirtual

Reads MusicMetadata from a file.

Parameters
filenameThe filename to read metadata from.
Returns
MusicMetadata pointer or nullptr on error

Implements MetaIOTagLib.

Definition at line 229 of file metaioid3.cpp.

◆ getAlbumArtList()

AlbumArtList MetaIOID3::getAlbumArtList ( const QString &  filename)
override

Read the albumart images from the file.

Parameters
filenameThe filename for which we want to find the images.

Definition at line 454 of file metaioid3.cpp.

◆ getAlbumArt()

QImage * MetaIOID3::getAlbumArt ( const QString &  filename,
ImageType  type 
)
override

Read the albumart image from the file.

Parameters
filenameThe filename for which we want to find the albumart.
typeThe type of image we want - front/back etc
Returns
A pointer to a QImage owned by the caller or nullptr if not found.

Definition at line 392 of file metaioid3.cpp.

◆ supportsEmbeddedImages()

bool MetaIOID3::supportsEmbeddedImages ( void  )
inlineoverridevirtual

Does the tag support embedded cover art.

Returns
true if reading/writing embedded images are supported

Reimplemented from MetaIO.

Definition at line 54 of file metaioid3.h.

◆ changeImageType()

bool MetaIOID3::changeImageType ( const QString &  filename,
const AlbumArtImage albumart,
ImageType  newType 
)
override

Definition at line 727 of file metaioid3.cpp.

◆ TagExists()

bool MetaIOID3::TagExists ( const QString &  filename)
override

Definition at line 955 of file metaioid3.cpp.

◆ OpenFile()

bool MetaIOID3::OpenFile ( const QString &  filename,
bool  forWriting = false 
)
private

Open the file to read the tag.

Parameters
filenameThe filename
forWritingNeed write permission on the file.
Returns
A taglib file object for this format

Definition at line 31 of file metaioid3.cpp.

Referenced by changeImageType(), getAlbumArt(), getAlbumArtList(), read(), removeAlbumArt(), TagExists(), write(), writeAlbumArt(), and writeVolatileMetadata().

◆ SaveFile()

bool MetaIOID3::SaveFile ( )
private

◆ CloseFile()

void MetaIOID3::CloseFile ( )
private

Definition at line 107 of file metaioid3.cpp.

Referenced by OpenFile().

◆ GetID3v2Tag()

TagLib::ID3v2::Tag * MetaIOID3::GetID3v2Tag ( bool  create = false)
private

◆ GetID3v1Tag()

TagLib::ID3v1::Tag * MetaIOID3::GetID3v1Tag ( bool  create = false)
private

Definition at line 136 of file metaioid3.cpp.

Referenced by read(), and TagExists().

◆ writePlayCount()

bool MetaIOID3::writePlayCount ( TagLib::ID3v2::Tag *  tag,
int  playcount 
)
staticprivate

Definition at line 842 of file metaioid3.cpp.

Referenced by write(), and writeVolatileMetadata().

◆ writeRating()

bool MetaIOID3::writeRating ( TagLib::ID3v2::Tag *  tag,
int  rating 
)
staticprivate

Definition at line 904 of file metaioid3.cpp.

Referenced by write(), and writeVolatileMetadata().

◆ writeLastPlay()

bool MetaIOID3::writeLastPlay ( TagLib::ID3v2::Tag *  tag,
QDateTime  lastPlay 
)
staticprivate

Definition at line 935 of file metaioid3.cpp.

Referenced by write(), and writeVolatileMetadata().

◆ readAlbumArt()

AlbumArtList MetaIOID3::readAlbumArt ( TagLib::ID3v2::Tag *  tag)
staticprivate

Read the albumart images from the file.

Parameters
tagThe ID3v2 tag object in which to look for Album Art
Returns
A QList containing a list of AlbumArtImage's with the type and description of the APIC tag.

Definition at line 477 of file metaioid3.cpp.

Referenced by getAlbumArtList().

◆ find()

UserTextIdentificationFrame * MetaIOID3::find ( TagLib::ID3v2::Tag *  tag,
const String &  description 
)
staticprivate

Find the a custom comment tag by description. This is a copy of the same function in the TagLib::ID3v2::UserTextIdentificationFrame Class with a static instead of dynamic cast.

Parameters
tagPointer to TagLib::ID3v2::Tag object
descriptionDescription of tag to search for
Returns
Pointer to frame

Definition at line 809 of file metaioid3.cpp.

Referenced by read(), write(), and writeLastPlay().

◆ findPOPM()

PopularimeterFrame * MetaIOID3::findPOPM ( TagLib::ID3v2::Tag *  tag,
const String &  _email 
)
staticprivate

Find the POPM tag associated with MythTV.

Parameters
tagPointer to TagLib::ID3v2::Tag object
emailEmail address associated with this POPM frame
Returns
Pointer to frame

Definition at line 829 of file metaioid3.cpp.

Referenced by read(), writePlayCount(), and writeRating().

◆ findAPIC()

AttachedPictureFrame * MetaIOID3::findAPIC ( TagLib::ID3v2::Tag *  tag,
AttachedPictureFrame::Type  type,
const String &  description = String() 
)
staticprivate

Find an APIC tag by type and optionally description.

Parameters
tagPointer to TagLib::ID3v2::Tag object
typeType of picture to search for
descriptionDescription of picture to search for (optional)
Returns
Pointer to frame

Definition at line 583 of file metaioid3.cpp.

Referenced by changeImageType(), removeAlbumArt(), and writeAlbumArt().

◆ getExtFromMimeType()

QString MetaIOID3::getExtFromMimeType ( const QString &  mimeType)
staticprivate

Definition at line 558 of file metaioid3.cpp.

Referenced by readAlbumArt().

Member Data Documentation

◆ m_file

TagLib::File* MetaIOID3::m_file {nullptr}
private

Definition at line 82 of file metaioid3.h.

Referenced by CloseFile(), GetID3v1Tag(), GetID3v2Tag(), OpenFile(), read(), and SaveFile().

◆ m_fileType

TagType MetaIOID3::m_fileType {kMPEG}
private

Definition at line 85 of file metaioid3.h.

Referenced by CloseFile(), GetID3v1Tag(), GetID3v2Tag(), and OpenFile().


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