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); 00059 void dispatch(qint64 length); 00063 void dispatch(const QMap<Qmmp::MetaData, QString> &metaData); 00067 void dispatch(const QHash<QString, QString> &info); 00071 void dispatch(Qmmp::State state); 00076 void dispatchBuffer(int percent); 00080 qint64 elapsed(); 00084 qint64 totalTime(); 00088 int bitrate(); 00092 int frequency(); 00096 int sampleSize(); 00100 int channels(); 00104 Qmmp::State state(); 00108 void sendNextTrackRequest(); 00112 void sendFinished(); 00116 static StateHandler* instance(); 00117 00118 signals: 00123 void elapsedChanged(qint64 time); 00128 void bitrateChanged(int bitrate); 00133 void frequencyChanged(quint32 frequency); 00138 void sampleSizeChanged(int size); 00143 void channelsChanged(int channels); 00148 void bufferingProgress(int progress); 00149 00150 00151 private: 00152 qint64 m_elapsed; 00153 qint64 m_length; 00154 quint32 m_frequency; 00155 bool m_sendAboutToFinish; 00156 int m_bitrate, m_precision, m_channels; 00157 static StateHandler* m_instance; 00158 QMap <Qmmp::MetaData, QString> m_metaData; 00159 QHash <QString, QString> m_streamInfo; 00160 Qmmp::State m_state; 00161 QMutex m_mutex; 00162 }; 00163 00164 #endif