Qmmp
inputsource.h
1 /***************************************************************************
2  * Copyright (C) 2009-2020 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 <QObject>
25 #include <QString>
26 #include <QStringList>
27 #include <QIODevice>
28 #include <QMap>
29 #include <QHash>
30 #include "qmmp.h"
31 #include "inputsourcefactory.h"
32 
33 class QmmpPluginCache;
34 
38 class QMMP_EXPORT InputSource : public QObject
39 {
40 Q_OBJECT
41 public:
47  InputSource(const QString &path, QObject *parent = nullptr);
52  virtual QIODevice *ioDevice() = 0;
57  virtual bool initialize() = 0;
61  virtual bool isReady() = 0;
67  virtual bool isWaiting();
71  virtual QString contentType() const;
75  const QString path() const;
79  qint64 offset() const;
83  void setOffset(qint64 offset);
89  void addMetaData(const QMap<Qmmp::MetaData, QString> &metaData);
93  bool hasMetaData() const;
98  QMap<Qmmp::MetaData, QString> takeMetaData();
104  void setProperty(Qmmp::TrackProperty key, const QVariant &value);
109  void setProperties(const QMap<Qmmp::TrackProperty, QString> &properties);
113  const QMap<Qmmp::TrackProperty, QString> &properties() const;
119  void addStreamInfo(const QHash<QString, QString> &info);
123  bool hasStreamInfo() const;
128  QHash<QString, QString> takeStreamInfo();
135  static InputSource *create(const QString &path, QObject *parent = nullptr);
139  static QList<InputSourceFactory *> factories();
143  static QList<InputSourceFactory *> enabledFactories();
148  static QString file(const InputSourceFactory *factory);
152  static QStringList protocols();
156  static QList<QRegularExpression> regExps();
160  static InputSourceFactory *findByUrl(const QString &url);
166  static void setEnabled(InputSourceFactory *factory, bool enable = true);
171  static bool isEnabled(const InputSourceFactory* factory);
172 
173 signals:
177  void ready();
181  void error();
182 
183 private:
184  QString m_path;
185  qint64 m_offset;
186  QMap<Qmmp::MetaData, QString> m_metaData;
187  QMap<Qmmp::TrackProperty, QString> m_properties;
188  QHash<QString, QString> m_streamInfo;
189  bool m_hasMetaData, m_hasStreamInfo;
190  static void loadPlugins();
191  static QList<QmmpPluginCache*> *m_cache;
192  static QStringList m_disabledNames;
193 };
194 
195 #endif // INPUTSOURCE_H
Transport plugin interface.
Definition: inputsourcefactory.h:49
The InputSource class provides the base interface class of transports.
Definition: inputsource.h:38
TrackProperty
Definition: qmmp.h:90