Qmmp
inputsource.h
1 /***************************************************************************
2  * Copyright (C) 2009-2013 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 InputSource : public QObject
39 {
40 Q_OBJECT
41 public:
47  InputSource(const QString &url, QObject *parent = 0);
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 url() 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 addStreamInfo(const QHash<QString, QString> &info);
108  bool hasStreamInfo() const;
113  QHash<QString, QString> takeStreamInfo();
120  static InputSource *create(const QString &url, QObject *parent = 0);
124  static QList<InputSourceFactory *> factories();
128  static QList<InputSourceFactory *> enabledFactories();
133  static QString file(InputSourceFactory *factory);
137  static QStringList protocols();
143  static void setEnabled(InputSourceFactory* factory, bool enable = true);
148  static bool isEnabled(InputSourceFactory* factory);
149 
150 signals:
154  void ready();
158  void error();
159 
160 private:
161  QString m_url;
162  qint64 m_offset;
163  QMap<Qmmp::MetaData, QString> m_metaData;
164  QHash<QString, QString> m_streamInfo;
165  bool m_hasMetaData, m_hasStreamInfo;
166  static void loadPlugins();
167  static QList<QmmpPluginCache*> *m_cache;
168  static QStringList m_disabledNames;
169 };
170 
171 #endif // INPUTSOURCE_H
Transport plugin interface.
Definition: inputsourcefactory.h:56
bool hasMetaData() const
virtual QIODevice * ioDevice()=0
void error()
virtual bool isReady()=0
static InputSource * create(const QString &url, QObject *parent=0)
The InputSource class provides the base interface class of transports.
Definition: inputsource.h:38
static QStringList protocols()
void ready()
void addMetaData(const QMap< Qmmp::MetaData, QString > &metaData)
bool hasStreamInfo() const
static QList< InputSourceFactory * > enabledFactories()
static void setEnabled(InputSourceFactory *factory, bool enable=true)
void addStreamInfo(const QHash< QString, QString > &info)
virtual QString contentType() const
static QString file(InputSourceFactory *factory)
virtual bool initialize()=0
const QString url() const
qint64 offset() const
virtual bool isWaiting()
QHash< QString, QString > takeStreamInfo()
QMap< Qmmp::MetaData, QString > takeMetaData()
void setOffset(qint64 offset)
InputSource(const QString &url, QObject *parent=0)
static QList< InputSourceFactory * > factories()
static bool isEnabled(InputSourceFactory *factory)