|
Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2008-2018 by Ilya Kotov * 00003 * forkotov02@ya.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 #ifndef STATEHANDLER_H 00021 #define STATEHANDLER_H 00022 00023 #include <QObject> 00024 #include <QMap> 00025 #include <QHash> 00026 #include <QMutex> 00027 #include "abstractengine.h" 00028 #include "audioparameters.h" 00029 #include "qmmp.h" 00030 00034 class StateHandler : public QObject 00035 { 00036 Q_OBJECT 00037 public: 00042 StateHandler(QObject *parent = 0); 00046 ~StateHandler(); 00052 void dispatch(qint64 elapsed, int bitrate); 00057 void dispatch(const AudioParameters &p); 00062 void dispatch(qint64 length); 00067 bool dispatch(const QMap<Qmmp::MetaData, QString> &metaData); 00071 void dispatch(const QHash<QString, QString> &info); 00075 void dispatch(Qmmp::State state); 00080 void dispatchBuffer(int percent); 00084 qint64 elapsed() const; 00088 qint64 totalTime() const; 00092 int bitrate() const; 00096 AudioParameters audioParameters() const; 00100 Qmmp::State state() const; 00104 void sendNextTrackRequest(); 00108 void sendFinished(); 00112 static StateHandler* instance(); 00113 00114 signals: 00119 void elapsedChanged(qint64 time); 00124 void bitrateChanged(int bitrate); 00129 void audioParametersChanged(const AudioParameters &p); 00134 void bufferingProgress(int progress); 00135 00136 00137 private: 00138 qint64 m_elapsed; 00139 qint64 m_length; 00140 bool m_sendAboutToFinish; 00141 int m_bitrate; 00142 static StateHandler* m_instance; 00143 QMap <Qmmp::MetaData, QString> m_metaData; 00144 QHash <QString, QString> m_streamInfo; 00145 Qmmp::State m_state; 00146 AudioParameters m_audioParameters; 00147 mutable QMutex m_mutex; 00148 }; 00149 00150 #endif
1.7.6.1