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)
 
virtual ~MetaIOID3 (void)
 
bool write (const QString &filename, MusicMetadata *mdata) override
 Writes all metadata back to a file. More...
 
bool writeVolatileMetadata (const QString &filename, MusicMetadata *mdata) override
 Writes rating and playcount back to a file. More...
 
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)
 
virtual ~MetaIOTagLib (void)=default
 
- Public Member Functions inherited from MetaIO
 MetaIO (void)
 Constructor. More...
 
virtual ~MetaIO (void)=default
 
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...
 

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, const AttachedPictureFrame::Type &type, const String &description=String::null)
 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
int getTrackLength (const QString &filename) override
 Find the length of the track (in seconds) 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 int getTrackLength (TagLib::File *file)
 Find the length of the track (in seconds) 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 33 of file metaioid3.h.

Member Enumeration Documentation

◆ TagType

enum MetaIOID3::TagType
private
Enumerator
kMPEG 
kFLAC 

Definition at line 79 of file metaioid3.h.

Constructor & Destructor Documentation

◆ MetaIOID3()

MetaIOID3::MetaIOID3 ( void  )
inline

Definition at line 36 of file metaioid3.h.

◆ ~MetaIOID3()

virtual MetaIOID3::~MetaIOID3 ( void  )
inlinevirtual

Definition at line 37 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 149 of file metaioid3.cpp.

Referenced by LameEncoder::~LameEncoder().

◆ writeVolatileMetadata()

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

Writes rating and playcount back to a file.

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

Reimplemented from MetaIO.

Definition at line 874 of file metaioid3.cpp.

◆ writeAlbumArt()

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

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

Reimplemented from MetaIO.

Definition at line 603 of file metaioid3.cpp.

◆ removeAlbumArt()

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

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

Reimplemented from MetaIO.

Definition at line 676 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 225 of file metaioid3.cpp.

◆ getAlbumArtList()

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

Read the albumart images from the file.

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

Reimplemented from MetaIO.

Definition at line 450 of file metaioid3.cpp.

◆ getAlbumArt()

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

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.

Reimplemented from MetaIO.

Definition at line 388 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 49 of file metaioid3.h.

◆ changeImageType()

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

Reimplemented from MetaIO.

Definition at line 723 of file metaioid3.cpp.

◆ TagExists()

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

Reimplemented from MetaIO.

Definition at line 951 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 103 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 132 of file metaioid3.cpp.

Referenced by read(), and TagExists().

◆ writePlayCount()

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

Definition at line 838 of file metaioid3.cpp.

Referenced by write(), and writeVolatileMetadata().

◆ writeRating()

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

Definition at line 900 of file metaioid3.cpp.

Referenced by write(), and writeVolatileMetadata().

◆ writeLastPlay()

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

Definition at line 931 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 473 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 805 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 825 of file metaioid3.cpp.

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

◆ findAPIC()

AttachedPictureFrame * MetaIOID3::findAPIC ( TagLib::ID3v2::Tag *  tag,
const AttachedPictureFrame::Type &  type,
const String &  description = String::null 
)
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 579 of file metaioid3.cpp.

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

◆ getExtFromMimeType()

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

Definition at line 554 of file metaioid3.cpp.

Referenced by readAlbumArt().

Member Data Documentation

◆ m_file

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

Definition at line 77 of file metaioid3.h.

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

◆ m_fileType

TagType MetaIOID3::m_fileType {kMPEG}
private

Definition at line 80 of file metaioid3.h.

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


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