Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2006-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 SOUNDCORE_H 00021 #define SOUNDCORE_H 00022 00023 #include <QObject> 00024 #include <QString> 00025 #include <QQueue> 00026 #include <QHash> 00027 #include "decoder.h" 00028 #include "output.h" 00029 #include "visual.h" 00030 #include "qmmp.h" 00031 #include "qmmpsettings.h" 00032 #include "eqsettings.h" 00033 00034 class QIODevice; 00035 class VolumeControl; 00036 class AbstractEngine; 00037 class InputSource; 00038 00042 class SoundCore : public QObject 00043 { 00044 Q_OBJECT 00045 public: 00050 SoundCore(QObject *parent = 0); 00054 ~SoundCore(); 00058 qint64 totalTime() const; 00062 EqSettings eqSettings() const; 00066 void setEqSettings(const EqSettings &settings); 00070 int leftVolume(); 00074 int rightVolume(); 00078 qint64 elapsed(); 00082 int bitrate(); 00086 quint32 frequency(); 00090 int sampleSize(); 00094 int channels(); 00098 Qmmp::State state() const; 00102 QMap <Qmmp::MetaData, QString> metaData() const; 00106 QString metaData(Qmmp::MetaData key) const; 00110 QHash<QString, QString> streamInfo() const; 00114 static SoundCore* instance(); 00115 00116 public slots: 00122 void setVolume(int left, int right); 00128 bool play(const QString &source, bool queue = false, qint64 offset = -1); 00132 void stop(); 00136 void pause(); 00140 void seek(qint64 pos); 00144 const QString url() const; 00149 bool nextTrackAccepted() const; 00150 00151 signals: 00156 void bufferingProgress(int progress); 00161 void elapsedChanged(qint64 time); 00166 void bitrateChanged(int bitrate); 00171 void frequencyChanged(quint32 frequency); 00176 void sampleSizeChanged(int size); 00181 void channelsChanged(int channels); 00185 void metaDataChanged (); 00189 void streamInfoChanged(); 00193 void stateChanged (Qmmp::State newState); 00197 void finished(); 00203 void volumeChanged(int left, int right); 00207 void eqSettingsChanged(); 00211 void nextTrackRequest(); 00212 00213 private slots: 00214 void startNextSource(); 00215 void startNextEngine(); 00216 00217 private: 00218 bool event(QEvent *e); 00219 enum NextEngineState 00220 { 00221 NO_ENGINE = 0, 00222 SAME_ENGINE, 00223 ANOTHER_ENGINE, 00224 INVALID_SOURCE 00225 }; 00226 QMap <Qmmp::MetaData, QString> m_metaData; 00227 QHash <QString, QString> m_streamInfo; 00228 Decoder* m_decoder; 00229 QString m_url; 00230 QList <Visual*> m_visuals; 00231 QWidget *m_parentWidget; 00232 static SoundCore* m_instance; 00233 StateHandler *m_handler; 00234 VolumeControl *m_volumeControl; 00235 AbstractEngine *m_engine; 00236 QQueue<InputSource *> m_sources; 00237 int m_nextState; 00238 }; 00239 00240 #endif