TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Decoder Class Referenceabstract

The Decoder class provides the base interface class of audio decoders. More...

#include <decoder.h>

Public Member Functions

 Decoder (QIODevice *input=nullptr)
 
virtual ~Decoder ()=default
 
virtual bool initialize ()=0
 
virtual qint64 totalTime () const =0
 
virtual void seek (qint64 time)=0
 
virtual qint64 read (unsigned char *data, qint64 maxSize)=0
 
virtual int bitrate () const =0
 
virtual void next ()
 
virtual const QString nextURL () const
 
const AudioParametersaudioParameters () const
 
const QMap< Qmmp::ReplayGainKey, double > & replayGainInfo () const
 
void setReplayGainInfo (const QMap< Qmmp::ReplayGainKey, double > &rg)
 
QIODevice * input ()
 
void addMetaData (const QMap< Qmmp::MetaData, QString > &metaData)
 
bool hasMetaData () const
 
QMap< Qmmp::MetaData, QString > takeMetaData ()
 
void setProperty (Qmmp::TrackProperty key, const QVariant &value)
 
void setProperties (const QMap< Qmmp::TrackProperty, QString > &properties)
 
QMap< Qmmp::TrackProperty, QString > properties () const
 

Static Public Member Functions

static DecoderFactoryfindByFilePath (const QString &path, bool useContent=false)
 
static DecoderFactoryfindByMime (const QString &mime)
 
static DecoderFactoryfindByContent (QIODevice *input)
 
static DecoderFactoryfindByProtocol (const QString &p)
 
static QList< DecoderFactory * > findByFileExtension (const QString &path)
 
static QList< DecoderFactory * > factories ()
 
static QList< DecoderFactory * > enabledFactories ()
 
static QStringList nameFilters ()
 
static QStringList contentTypes ()
 
static QString file (const DecoderFactory *factory)
 
static QStringList protocols ()
 
static void setEnabled (DecoderFactory *factory, bool enable=true)
 
static bool isEnabled (const DecoderFactory *factory)
 

Protected Member Functions

void configure (quint32 srate, const ChannelMap &map, Qmmp::AudioFormat f=Qmmp::PCM_S16LE)
 
void configure (quint32 srate, int channels, Qmmp::AudioFormat f=Qmmp::PCM_S16LE)
 
void configure (const AudioParameters &p)
 

Static Private Member Functions

static void loadPlugins ()
 

Private Attributes

AudioParameters m_parameters
 
QMap< Qmmp::TrackProperty, QString > m_properties
 
QIODevice * m_input = nullptr
 
bool m_hasMetaData = false
 
QMap< Qmmp::MetaData, QString > m_metaData
 
QMap< Qmmp::ReplayGainKey, double > m_rg
 

Static Private Attributes

static QList< QmmpPluginCache * > * m_cache
 
static QStringList m_disabledNames
 

Detailed Description

The Decoder class provides the base interface class of audio decoders.

Author
Brad Hughes bhugh.nosp@m.es@t.nosp@m.rollt.nosp@m.ech..nosp@m.com
Ilya Kotov forko.nosp@m.tov0.nosp@m.2@ya..nosp@m.ru

Definition at line 38 of file decoder.h.

Constructor & Destructor Documentation

Decoder::Decoder ( QIODevice *  input = nullptr)
explicit

Object contsructor.

Parameters
inputQIODevice-based input source.
virtual Decoder::~Decoder ( )
virtualdefault

Destructor.

Member Function Documentation

void Decoder::addMetaData ( const QMap< Qmmp::MetaData, QString > &  metaData)

Informs decoder about new received metadata. Call of this function is required for all non-local streams/files

Parameters
metaDataMetadata map.
const AudioParameters& Decoder::audioParameters ( ) const

Returns detected audio parameters.

virtual int Decoder::bitrate ( ) const
pure virtual

Returns current bitrate (in kbps). Subclass should reimplement this function.

void Decoder::configure ( quint32  srate,
const ChannelMap map,
Qmmp::AudioFormat  f = Qmmp::PCM_S16LE 
)
protected

Use this function inside initialize() reimplementation to tell other plugins about audio parameters.

Parameters
srateSample rate.
mapMap of channels.
fAudio format.
void Decoder::configure ( quint32  srate,
int  channels,
Qmmp::AudioFormat  f = Qmmp::PCM_S16LE 
)
protected

Use this function inside initialize() reimplementation to tell other plugins about audio parameters.

Parameters
srateSample rate.
channelsNumber of channels (internal channel sequence).
fAudio format.
void Decoder::configure ( const AudioParameters p)
protected

Use this function inside initialize() reimplementation to tell other plugins about audio parameters.

Parameters
pAudio parameters.
static QStringList Decoder::contentTypes ( )
static

Returns a list of the supported mime types.

Referenced by MusicMPRISPlayerRoot::supportedMimeTypes().

static QList<DecoderFactory*> Decoder::enabledFactories ( )
static

Returns a list of enabled decoder factories.

static QList<DecoderFactory*> Decoder::factories ( )
static

Returns a list of decoder factories.

Referenced by MusicPluginWidget::loadPluginsInfo().

static QString Decoder::file ( const DecoderFactory factory)
static

Returns plugin file path.

Parameters
factoryDecoder plugin factory.

Referenced by MusicPluginWidget::loadPluginsInfo().

static DecoderFactory* Decoder::findByContent ( QIODevice *  input)
static

Returns DecoderFactory pointer which supports data provided by input or 0 if data is unsupported.

static QList<DecoderFactory *> Decoder::findByFileExtension ( const QString &  path)
static

Returns a list of DecoderFactory pointers which support extension of the required file

Parameters
pathFull file path or url with correct extension.
static DecoderFactory* Decoder::findByFilePath ( const QString &  path,
bool  useContent = false 
)
static

Returns DecoderFactory pointer which supports file path or nullptr if file path is unsupported

Parameters
pathFull local file path.
useContentContent-based file type determination (true - enabled, false - disabled)

Referenced by MusicSongMeta::readInformation(), and MusicSongMeta::saveInformation().

static DecoderFactory* Decoder::findByMime ( const QString &  mime)
static

Returns DecoderFactory pointer which supports mime type mime or nullptr if mime type mime is unsupported

static DecoderFactory* Decoder::findByProtocol ( const QString &  p)
static

Returns DecoderFactory pointer which supports protocol p or nullptr if protocol is not supported.

bool Decoder::hasMetaData ( ) const

Returns true when new metadata has received, otherwise returns false.

virtual bool Decoder::initialize ( )
pure virtual

Prepares decoder for usage. Subclass should reimplement this function.

QIODevice* Decoder::input ( )

Returns QIODevice-based input source assigned for this decoder.

static bool Decoder::isEnabled ( const DecoderFactory factory)
static

Returns true if input plugin is enabled, otherwise returns false

Parameters
factoryDecoder plugin factory.

Referenced by MusicPluginItem::MusicPluginItem().

static void Decoder::loadPlugins ( )
staticprivate
static QStringList Decoder::nameFilters ( )
static

Returns a list of file name filters, i.e. "*.mp3 *.mpg".

virtual void Decoder::next ( )
virtual

Tells decoder that it should play next track. By default this function does nothing. Reimplemet it if your decoder can play next track without stop/start cycle. This may be useful for multitrack formats like cue or cda.

virtual const QString Decoder::nextURL ( ) const
virtual

Returns url which decoder can play without stop/start cycle. By default this function does nothing. Reimplemet it if your decoder can play next track without stop/start cycle.

QMap<Qmmp::TrackProperty, QString> Decoder::properties ( ) const

Returns track properties

static QStringList Decoder::protocols ( )
static

Returns a list of supported protocols (including meta-protocols). This fuction ignores disabled decoders.

virtual qint64 Decoder::read ( unsigned char *  data,
qint64  maxSize 
)
pure virtual

Reads up to maxSize bytes of decoded audio to data Returns the number of bytes read, or -1 if an error occurred. Subclass should reimplement this function.

const QMap<Qmmp::ReplayGainKey, double>& Decoder::replayGainInfo ( ) const

Returns ReplayGain information.

virtual void Decoder::seek ( qint64  time)
pure virtual

Requests a seek to the time time indicated, specified in milliseconds. Subclass should reimplement this function.

static void Decoder::setEnabled ( DecoderFactory factory,
bool  enable = true 
)
static

Sets whether the input plugin is enabled.

Parameters
factoryDecoder plugin factory.
enablePlugin enable state (true - enable, false - disable)

Referenced by MusicPluginItem::setEnabled().

void Decoder::setProperties ( const QMap< Qmmp::TrackProperty, QString > &  properties)

Updates all extra track properties.

Parameters
propertiesNew track properties.
void Decoder::setProperty ( Qmmp::TrackProperty  key,
const QVariant &  value 
)

Sets extra track property.

Parameters
keyProperty key.
valueProperty value.
void Decoder::setReplayGainInfo ( const QMap< Qmmp::ReplayGainKey, double > &  rg)

Sets ReplayGain information. Use this function before playback.

Parameters
rgReplayGain information
QMap<Qmmp::MetaData, QString> Decoder::takeMetaData ( )

Takes metadata out of decoder and returns it. Attention: hasMetaData() should return true before using of this fuction.

virtual qint64 Decoder::totalTime ( ) const
pure virtual

Returns the total time in milliseconds. Subclass should reimplement this function.

Member Data Documentation

QList<QmmpPluginCache*>* Decoder::m_cache
staticprivate

Definition at line 222 of file decoder.h.

QStringList Decoder::m_disabledNames
staticprivate

Definition at line 223 of file decoder.h.

bool Decoder::m_hasMetaData = false
private

Definition at line 228 of file decoder.h.

QIODevice* Decoder::m_input = nullptr
private

Definition at line 227 of file decoder.h.

QMap<Qmmp::MetaData, QString> Decoder::m_metaData
private

Definition at line 229 of file decoder.h.

AudioParameters Decoder::m_parameters
private

Definition at line 225 of file decoder.h.

QMap<Qmmp::TrackProperty, QString> Decoder::m_properties
private

Definition at line 226 of file decoder.h.

QMap<Qmmp::ReplayGainKey, double> Decoder::m_rg
private

Definition at line 230 of file decoder.h.


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