Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2009-2012 by Ilya Kotov * 00003 * forkotov02@hotmail.ru * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00019 ***************************************************************************/ 00020 00021 #ifndef INPUTSOURCE_H 00022 #define INPUTSOURCE_H 00023 00024 #include <QObject> 00025 #include <QString> 00026 #include <QStringList> 00027 #include <QIODevice> 00028 #include <QMap> 00029 #include <QHash> 00030 #include "qmmp.h" 00031 #include "inputsourcefactory.h" 00032 00036 class InputSource : public QObject 00037 { 00038 Q_OBJECT 00039 public: 00045 InputSource(const QString &url, QObject *parent = 0); 00050 virtual QIODevice *ioDevice() = 0; 00055 virtual bool initialize() = 0; 00059 virtual bool isReady() = 0; 00063 virtual QString contentType() const; 00067 const QString url() const; 00071 qint64 offset() const; 00075 void setOffset(qint64 offset); 00081 void addMetaData(const QMap<Qmmp::MetaData, QString> &metaData); 00085 bool hasMetaData() const; 00090 QMap<Qmmp::MetaData, QString> takeMetaData(); 00096 void addStreamInfo(const QHash<QString, QString> &info); 00100 bool hasStreamInfo() const; 00105 QHash<QString, QString> takeStreamInfo(); 00112 static InputSource *create(const QString &url, QObject *parent = 0); 00116 static QList<InputSourceFactory *> *factories(); 00121 static QString file(InputSourceFactory *factory); 00125 static QStringList protocols(); 00126 00127 signals: 00131 void ready(); 00135 void error(); 00136 00137 private: 00138 QString m_url; 00139 qint64 m_offset; 00140 QMap<Qmmp::MetaData, QString> m_metaData; 00141 QHash<QString, QString> m_streamInfo; 00142 bool m_hasMetaData, m_hasStreamInfo; 00143 static void checkFactories(); 00144 static QList<InputSourceFactory*> *m_factories; 00145 static QHash <InputSourceFactory*, QString> *m_files; 00146 }; 00147 00148 #endif // INPUTSOURCE_H