TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
decoder.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2014-2024 by Ilya Kotov *
3  * forkotov02@ya.ru *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef DECODER_H
22 #define DECODER_H
23 
24 #include <QStringList>
25 #include <QMap>
26 #include <QIODevice>
27 #include "audioparameters.h"
28 #include "channelmap.h"
29 #include "regularexpression.h"
30 
31 class QmmpPluginCache;
32 class DecoderFactory;
33 
39 {
40 public:
45  explicit Decoder(QIODevice *input = nullptr);
49  virtual ~Decoder() = default;
50 
55  virtual bool initialize() = 0;
60  virtual qint64 totalTime() const = 0;
65  virtual void seek(qint64 time) = 0;
71  virtual qint64 read(unsigned char *data, qint64 maxSize) = 0;
76  virtual int bitrate() const = 0;
83  virtual void next();
89  virtual const QString nextURL() const;
93  const AudioParameters &audioParameters() const;
97  const QMap<Qmmp::ReplayGainKey, double> &replayGainInfo() const;
102  void setReplayGainInfo(const QMap<Qmmp::ReplayGainKey,double> &rg);
106  QIODevice *input();
112  void addMetaData(const QMap<Qmmp::MetaData, QString> &metaData);
116  bool hasMetaData() const;
121  QMap<Qmmp::MetaData, QString> takeMetaData();
127  void setProperty(Qmmp::TrackProperty key, const QVariant &value);
132  void setProperties(const QMap<Qmmp::TrackProperty, QString> &properties);
136  QMap<Qmmp::TrackProperty, QString> properties() const;
142  static DecoderFactory *findByFilePath(const QString &path, bool useContent = false);
146  static DecoderFactory *findByMime(const QString &mime);
151  static DecoderFactory *findByContent(QIODevice *input);
155  static DecoderFactory *findByProtocol(const QString &p);
160  static QList<DecoderFactory *> findByFileExtension(const QString &path);
164  static QList<DecoderFactory*> factories();
168  static QList<DecoderFactory*> enabledFactories();
172  static QStringList nameFilters();
176  static QStringList contentTypes();
181  static QString file(const DecoderFactory *factory);
186  static QStringList protocols();
192  static void setEnabled(DecoderFactory *factory, bool enable = true);
197  static bool isEnabled(const DecoderFactory* factory);
198 
199 protected:
206  void configure(quint32 srate, const ChannelMap &map, Qmmp::AudioFormat f = Qmmp::PCM_S16LE);
213  void configure(quint32 srate, int channels, Qmmp::AudioFormat f = Qmmp::PCM_S16LE);
218  void configure(const AudioParameters &p);
219 
220 private:
221  static void loadPlugins();
222  static QList<QmmpPluginCache*> *m_cache;
223  static QStringList m_disabledNames;
224 
226  QMap<Qmmp::TrackProperty, QString> m_properties;
227  QIODevice *m_input = nullptr;
228  bool m_hasMetaData = false;
229  QMap<Qmmp::MetaData, QString> m_metaData;
230  QMap<Qmmp::ReplayGainKey, double> m_rg; //replay gain information
231 
232 };
233 
234 #endif
static constexpr wchar_t key[]
TrackProperty
Definition: qmmp.h:105
The AudioParameters class keeps information about audio settings.
Input plugin interface (decoder factory).
static QStringList m_disabledNames
Definition: decoder.h:223
This class represents audio channel mapping.
Definition: channelmap.h:30
QMap< Qmmp::ReplayGainKey, double > m_rg
Definition: decoder.h:230
The Decoder class provides the base interface class of audio decoders.
Definition: decoder.h:38
QMap< Qmmp::TrackProperty, QString > m_properties
Definition: decoder.h:226
#define QMMP_EXPORT
Definition: qmmp_export.h:29
QMap< Qmmp::MetaData, QString > m_metaData
Definition: decoder.h:229
AudioParameters m_parameters
Definition: decoder.h:225
static QList< QmmpPluginCache * > * m_cache
Definition: decoder.h:222
AudioFormat
Definition: qmmp.h:129