TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
inputsource.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2009-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 INPUTSOURCE_H
22 #define INPUTSOURCE_H
23 
24 #include <QIODevice>
25 #include <QMap>
26 #include <QHash>
27 #include "qmmp.h"
28 #include "inputsourcefactory.h"
29 
30 class QmmpPluginCache;
31 
35 class QMMP_EXPORT InputSource : public QObject
36 {
37  Q_OBJECT
38 public:
44  explicit InputSource(const QString &path, QObject *parent = nullptr);
45 
50  virtual QIODevice *ioDevice() const = 0;
55  virtual bool initialize() = 0;
59  virtual bool isReady() const = 0;
65  virtual bool isWaiting() const;
69  virtual QString contentType() const;
74  virtual void stop();
78  QString path() const;
82  qint64 offset() const;
86  void setOffset(qint64 offset);
92  void addMetaData(const QMap<Qmmp::MetaData, QString> &metaData);
96  bool hasMetaData() const;
101  QMap<Qmmp::MetaData, QString> takeMetaData();
107  void setProperty(Qmmp::TrackProperty key, const QVariant &value);
112  void setProperties(const QMap<Qmmp::TrackProperty, QString> &properties);
116  const QMap<Qmmp::TrackProperty, QString> &properties() const;
122  void addStreamInfo(const QHash<QString, QString> &info);
126  bool hasStreamInfo() const;
131  QHash<QString, QString> takeStreamInfo();
138  static InputSource *create(const QString &path, QObject *parent = nullptr);
142  static QList<InputSourceFactory *> factories();
146  static QList<InputSourceFactory *> enabledFactories();
151  static QString file(const InputSourceFactory *factory);
155  static QStringList protocols();
159  static QList<RegularExpression> regExps();
163  static InputSourceFactory *findByUrl(const QString &url);
169  static void setEnabled(InputSourceFactory *factory, bool enable = true);
174  static bool isEnabled(const InputSourceFactory* factory);
175 
176 signals:
180  void ready();
184  void error();
185 
186 private:
187  QString m_path;
188  qint64 m_offset = -1;
189  QMap<Qmmp::MetaData, QString> m_metaData;
190  QMap<Qmmp::TrackProperty, QString> m_properties;
191  QHash<QString, QString> m_streamInfo;
192  bool m_hasMetaData = false, m_hasStreamInfo = false;
193 
194  static void loadPlugins();
195  static QList<QmmpPluginCache*> *m_cache;
196  static QStringList m_disabledNames;
197 
198 };
199 
200 #endif
Transport plugin interface.
static constexpr wchar_t key[]
TrackProperty
Definition: qmmp.h:105
The InputSource class provides the base interface class of transports.
Definition: inputsource.h:35
voidpf uLong offset
Definition: ioapi.h:142
QString m_path
Definition: inputsource.h:187
QMap< Qmmp::MetaData, QString > m_metaData
Definition: inputsource.h:189
static QList< QmmpPluginCache * > * m_cache
Definition: inputsource.h:195
QHash< QString, QString > m_streamInfo
Definition: inputsource.h:191
#define QMMP_EXPORT
Definition: qmmp_export.h:29
static QStringList m_disabledNames
Definition: inputsource.h:196
QMap< Qmmp::TrackProperty, QString > m_properties
Definition: inputsource.h:190