MythTV  master
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
MetaIO Class Referenceabstract

#include <libmythmetadata/metaio.h>

Inheritance diagram for MetaIO:
[legend]

Classes

struct  m_fileinfo
 

Public Member Functions

 MetaIO (void)
 
virtual ~MetaIO (void)=default
 
virtual bool write (const QString &filename, MusicMetadata *mdata)=0
 Writes all metadata back to a file. More...
 
virtual bool writeVolatileMetadata ([[maybe_unused]] const QString &filename, [[maybe_unused]] MusicMetadata *mdata)
 Writes rating and playcount back to a file. More...
 
virtual MusicMetadataread (const QString &filename)=0
 Reads MusicMetadata from a file. More...
 
virtual bool supportsEmbeddedImages (void)
 Does the tag support embedded cover art. 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)
 

Static Public Member Functions

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

static const QString kValidFileExtensions
 

Protected Member Functions

void saveTimeStamps (void)
 
void restoreTimeStamps (void)
 
virtual std::chrono::milliseconds getTrackLength (const QString &filename)=0
 

Protected Attributes

QString m_filename
 
QString m_filenameFormat
 

Detailed Description

Definition at line 17 of file metaio.h.

Constructor & Destructor Documentation

◆ MetaIO()

MetaIO::MetaIO ( void  )
inline

Definition at line 20 of file metaio.h.

◆ ~MetaIO()

virtual MetaIO::~MetaIO ( void  )
virtualdefault

Member Function Documentation

◆ write()

virtual bool MetaIO::write ( const QString &  filename,
MusicMetadata mdata 
)
pure virtual

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.

Implemented in MetaIOTagLib, MetaIOID3, MetaIOWavPack, MetaIOFLACVorbis, MetaIOOggVorbis, MetaIOAVFComment, and MetaIOMP4.

Referenced by ImportMusicDialog::addPressed(), MainServer::HandleMusicTagUpdateMetadata(), and UpdateMeta().

◆ writeVolatileMetadata()

virtual bool MetaIO::writeVolatileMetadata ( [[maybe_unused] ] const QString &  filename,
[[maybe_unused] ] MusicMetadata mdata 
)
inlinevirtual

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.

Definition at line 39 of file metaio.h.

◆ read()

virtual MusicMetadata* MetaIO::read ( const QString &  filename)
pure virtual

Reads MusicMetadata from a file.

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

Implemented in MetaIOTagLib, MetaIOID3, MetaIOFLACVorbis, MetaIOWavPack, MetaIOOggVorbis, MetaIOAVFComment, and MetaIOMP4.

Referenced by readMetadata(), and ImportMusicDialog::scanDirectory().

◆ supportsEmbeddedImages()

virtual bool MetaIO::supportsEmbeddedImages ( void  )
inlinevirtual

Does the tag support embedded cover art.

Returns
true if reading/writing embedded images are supported

Reimplemented in MetaIOID3, and MetaIOFLACVorbis.

Definition at line 58 of file metaio.h.

Referenced by MusicFileScanner::AddFileToDB(), ExtractImage(), MainServer::HandleMusicFindAlbumArt(), MainServer::HandleMusicTagAddImage(), MainServer::HandleMusicTagChangeImage(), MainServer::HandleMusicTagRemoveImage(), and EditAlbumartDialog::showMenu().

◆ getAlbumArtList()

virtual AlbumArtList MetaIO::getAlbumArtList ( [[maybe_unused] ] const QString &  filename)
inlinevirtual

Reads the list of embedded images in the tag.

Parameters
filenameThe filename to read images from.
Returns
the list of embedded images

Definition at line 69 of file metaio.h.

Referenced by MusicFileScanner::AddFileToDB(), and MainServer::HandleMusicFindAlbumArt().

◆ writeAlbumArt()

virtual bool MetaIO::writeAlbumArt ( [[maybe_unused] ] const QString &  filename,
[[maybe_unused] ] const AlbumArtImage albumart 
)
inlinevirtual

Definition at line 74 of file metaio.h.

Referenced by MainServer::HandleMusicTagAddImage().

◆ removeAlbumArt()

virtual bool MetaIO::removeAlbumArt ( [[maybe_unused] ] const QString &  filename,
[[maybe_unused] ] const AlbumArtImage albumart 
)
inlinevirtual

Definition at line 80 of file metaio.h.

Referenced by MainServer::HandleMusicTagRemoveImage().

◆ changeImageType()

virtual bool MetaIO::changeImageType ( [[maybe_unused] ] const QString &  filename,
[[maybe_unused] ] const AlbumArtImage albumart,
[[maybe_unused] ] ImageType  newType 
)
inlinevirtual

Definition at line 86 of file metaio.h.

Referenced by MainServer::HandleMusicTagChangeImage().

◆ getAlbumArt()

virtual QImage* MetaIO::getAlbumArt ( [[maybe_unused] ] const QString &  filename,
[[maybe_unused] ] ImageType  type 
)
inlinevirtual

Definition at line 93 of file metaio.h.

Referenced by ExtractImage().

◆ readFromFilename() [1/3]

void MetaIO::readFromFilename ( const QString &  filename,
QString &  artist,
QString &  album,
QString &  title,
QString &  genre,
int &  tracknum 
)

Reads MusicMetadata based on the folder/filename.

Parameters
[in]filenameThe filename to try and determine metadata for.
[out]artist
[out]album
[out]title
[out]genre
[out]tracknum

Definition at line 95 of file metaio.cpp.

Referenced by MetaIOMP4::read(), MetaIOAVFComment::read(), readFromFilename(), MetaIOTagLib::ReadGenericMetadata(), and readMetadata().

◆ readFromFilename() [2/3]

MusicMetadata * MetaIO::readFromFilename ( const QString &  filename,
bool  blnLength = false 
)

Reads MusicMetadata based on the folder/filename.

Parameters
filenameThe filename to try and determine metadata for.
blnLengthIf true, read the file length as well.
Returns
MusicMetadata Pointer, or nullptr on error.

Definition at line 163 of file metaio.cpp.

◆ readFromFilename() [3/3]

void MetaIO::readFromFilename ( MusicMetadata metadata)

Reads MusicMetadata based on the folder/filename.

Parameters
metadataMusicMetadata Pointer

Definition at line 186 of file metaio.cpp.

◆ TagExists()

virtual bool MetaIO::TagExists ( [[maybe_unused] ] const QString &  filename)
inlinevirtual

Definition at line 124 of file metaio.h.

◆ createTagger()

MetaIO * MetaIO::createTagger ( const QString &  filename)
static

Finds an appropriate tagger for the given file.

Parameters
filenameThe filename to find a tagger for.
Returns
MetaIO Pointer, or nullptr if non found.
Note
The caller is responsible for freeing it when no longer required

Definition at line 25 of file metaio.cpp.

Referenced by MusicFileScanner::AddFileToDB(), ImportMusicDialog::addPressed(), MusicMetadata::getTagger(), readMetadata(), ImportMusicDialog::scanDirectory(), and EditAlbumartDialog::showMenu().

◆ readMetadata()

MusicMetadata * MetaIO::readMetadata ( const QString &  filename)
static

Read the metadata from filename directly.

Creates a MetaIO object using MetaIO::createTagger and uses the MetaIO object to read the metadata.

Parameters
filenameThe filename to read metadata from.
Returns
an instance of MusicMetadata owned by the caller

Definition at line 56 of file metaio.cpp.

Referenced by MusicFileScanner::AddFileToDB(), getMetadata(), handleMedia(), and MusicFileScanner::UpdateFileInDB().

◆ getMetadata()

MusicMetadata * MetaIO::getMetadata ( const QString &  filename)
static

Get the metadata for filename.

First tries to read the metadata from the database. If there is no database entry, it'll call MetaIO::readMetadata.

Parameters
filenameThe filename to get metadata for.
Returns
an instance of MusicMetadata owned by the caller

Definition at line 84 of file metaio.cpp.

Referenced by MusicFileScanner::UpdateFileInDB().

◆ saveTimeStamps()

void MetaIO::saveTimeStamps ( void  )
protected

◆ restoreTimeStamps()

void MetaIO::restoreTimeStamps ( void  )
protected

◆ getTrackLength()

virtual std::chrono::milliseconds MetaIO::getTrackLength ( const QString &  filename)
protectedpure virtual

Implemented in MetaIOTagLib, MetaIOAVFComment, and MetaIOMP4.

Referenced by readFromFilename().

Member Data Documentation

◆ kValidFileExtensions

const QString MetaIO::kValidFileExtensions
static

◆ m_filename

QString MetaIO::m_filename
protected

◆ m_filenameFormat

QString MetaIO::m_filenameFormat
protected

Definition at line 170 of file metaio.h.

Referenced by readFromFilename().


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