Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2008-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 #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 "qmmp.h" 00029 00033 class StateHandler : public QObject 00034 { 00035 Q_OBJECT 00036 public: 00041 StateHandler(QObject *parent = 0); 00045 ~StateHandler(); 00054 void dispatch(qint64 elapsed, int bitrate, quint32 frequency, int precision, int channels); 00058 void dispatch(const QMap<Qmmp::MetaData, QString> &metaData); 00062 void dispatch(const QHash<QString, QString> &info); 00066 void dispatch(Qmmp::State state); 00071 void dispatchBuffer(int percent); 00075 qint64 elapsed(); 00079 int bitrate(); 00083 int frequency(); 00087 int sampleSize(); 00091 int channels(); 00095 Qmmp::State state() const; 00099 void sendNextTrackRequest(); 00103 void sendFinished(); 00107 static StateHandler* instance(); 00108 00109 signals: 00114 void elapsedChanged(qint64 time); 00119 void bitrateChanged(int bitrate); 00124 void frequencyChanged(quint32 frequency); 00129 void sampleSizeChanged(int size); 00134 void channelsChanged(int channels); 00139 void bufferingProgress(int progress); 00140 00141 00142 private: 00143 qint64 m_elapsed; 00144 quint32 m_frequency; 00145 bool m_sendAboutToFinish; 00146 int m_bitrate, m_precision, m_channels; 00147 static StateHandler* m_instance; 00148 QMap <Qmmp::MetaData, QString> m_metaData; 00149 QHash <QString, QString> m_streamInfo; 00150 Qmmp::State m_state; 00151 QMutex m_mutex; 00152 }; 00153 00154 #endif