Qmmp
Loading...
Searching...
No Matches
inputsource.h
1/***************************************************************************
2 * Copyright (C) 2009-2022 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
33class QmmpPluginCache;
34
38class QMMP_EXPORT InputSource : public QObject
39{
40Q_OBJECT
41public:
47 explicit InputSource(const QString &path, QObject *parent = nullptr);
52 virtual QIODevice *ioDevice() const = 0;
57 virtual bool initialize() = 0;
61 virtual bool isReady() const = 0;
67 virtual bool isWaiting() const;
71 virtual QString contentType() const;
76 virtual void stop();
80 const QString path() const;
84 qint64 offset() const;
88 void setOffset(qint64 offset);
94 void addMetaData(const QMap<Qmmp::MetaData, QString> &metaData);
98 bool hasMetaData() const;
103 QMap<Qmmp::MetaData, QString> takeMetaData();
109 void setProperty(Qmmp::TrackProperty key, const QVariant &value);
114 void setProperties(const QMap<Qmmp::TrackProperty, QString> &properties);
118 const QMap<Qmmp::TrackProperty, QString> &properties() const;
124 void addStreamInfo(const QHash<QString, QString> &info);
128 bool hasStreamInfo() const;
133 QHash<QString, QString> takeStreamInfo();
140 static InputSource *create(const QString &path, QObject *parent = nullptr);
144 static QList<InputSourceFactory *> factories();
148 static QList<InputSourceFactory *> enabledFactories();
153 static QString file(const InputSourceFactory *factory);
157 static QStringList protocols();
161 static QList<QRegularExpression> regExps();
165 static InputSourceFactory *findByUrl(const QString &url);
171 static void setEnabled(InputSourceFactory *factory, bool enable = true);
176 static bool isEnabled(const InputSourceFactory* factory);
177
178signals:
182 void ready();
186 void error();
187
188private:
189 QString m_path;
190 qint64 m_offset = -1;
191 QMap<Qmmp::MetaData, QString> m_metaData;
192 QMap<Qmmp::TrackProperty, QString> m_properties;
193 QHash<QString, QString> m_streamInfo;
194 bool m_hasMetaData = false, m_hasStreamInfo = false;
195 static void loadPlugins();
196 static QList<QmmpPluginCache*> *m_cache;
197 static QStringList m_disabledNames;
198};
199
200#endif // INPUTSOURCE_H
Transport plugin interface.
Definition inputsourcefactory.h:50
The InputSource class provides the base interface class of transports.
Definition inputsource.h:39
static void setEnabled(InputSourceFactory *factory, bool enable=true)
void setProperties(const QMap< Qmmp::TrackProperty, QString > &properties)
const QMap< Qmmp::TrackProperty, QString > & properties() const
static QStringList protocols()
virtual QString contentType() const
virtual bool isReady() const =0
void setOffset(qint64 offset)
void setProperty(Qmmp::TrackProperty key, const QVariant &value)
static QList< InputSourceFactory * > factories()
virtual bool initialize()=0
static InputSourceFactory * findByUrl(const QString &url)
void addMetaData(const QMap< Qmmp::MetaData, QString > &metaData)
virtual QIODevice * ioDevice() const =0
static QList< QRegularExpression > regExps()
bool hasMetaData() const
qint64 offset() const
void ready()
static InputSource * create(const QString &path, QObject *parent=nullptr)
void error()
static QList< InputSourceFactory * > enabledFactories()
virtual bool isWaiting() const
InputSource(const QString &path, QObject *parent=nullptr)
void addStreamInfo(const QHash< QString, QString > &info)
QMap< Qmmp::MetaData, QString > takeMetaData()
static QString file(const InputSourceFactory *factory)
const QString path() const
QHash< QString, QString > takeStreamInfo()
bool hasStreamInfo() const
static bool isEnabled(const InputSourceFactory *factory)
virtual void stop()
TrackProperty
Definition qmmp.h:91