00001 /*************************************************************************** 00002 * Copyright (C) 2006-2011 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #ifndef SOUNDCORE_H 00021 #define SOUNDCORE_H 00022 00023 #include <QObject> 00024 #include <QString> 00025 #include <QQueue> 00026 #include "decoder.h" 00027 #include "output.h" 00028 #include "visual.h" 00029 #include "qmmp.h" 00030 #include "qmmpsettings.h" 00031 #include "eqsettings.h" 00032 00033 class QIODevice; 00034 class VolumeControl; 00035 class AbstractEngine; 00036 class InputSource; 00037 00041 class SoundCore : public QObject 00042 { 00043 Q_OBJECT 00044 public: 00049 SoundCore(QObject *parent = 0); 00053 ~SoundCore(); 00057 qint64 totalTime() const; 00061 EqSettings eqSettings() const; 00065 void setEqSettings(const EqSettings &settings); 00069 int leftVolume(); 00073 int rightVolume(); 00077 qint64 elapsed(); 00081 int bitrate(); 00085 quint32 frequency(); 00089 int sampleSize(); 00093 int channels(); 00097 Qmmp::State state() const; 00101 QMap <Qmmp::MetaData, QString> metaData(); 00105 QString metaData(Qmmp::MetaData key); 00109 static SoundCore* instance(); 00110 00111 public slots: 00117 void setVolume(int left, int right); 00123 bool play(const QString &source, bool queue = false, qint64 offset = -1); 00127 void stop(); 00131 void pause(); 00135 void seek(qint64 pos); 00139 const QString url() const; 00144 bool nextTrackAccepted() const; 00145 00146 signals: 00151 void bufferingProgress(int progress); 00156 void elapsedChanged(qint64 time); 00161 void bitrateChanged(int bitrate); 00166 void frequencyChanged(quint32 frequency); 00171 void sampleSizeChanged(int size); 00176 void channelsChanged(int channels); 00180 void metaDataChanged (); 00184 void stateChanged (Qmmp::State newState); 00188 void finished(); 00194 void volumeChanged(int left, int right); 00198 void eqSettingsChanged(); 00202 void nextTrackRequest(); 00203 00204 private slots: 00205 void startNextSource(); 00206 void startNextEngine(); 00207 void updateVolume(); 00208 00209 private: 00210 bool event(QEvent *e); 00211 enum NextEngineState 00212 { 00213 NO_ENGINE = 0, 00214 SAME_ENGINE, 00215 ANOTHER_ENGINE, 00216 INVALID_SOURCE 00217 }; 00218 QMap <Qmmp::MetaData, QString> m_metaData; 00219 Decoder* m_decoder; 00220 QString m_url; 00221 QList <Visual*> m_visuals; 00222 QWidget *m_parentWidget; 00223 static SoundCore* m_instance; 00224 StateHandler *m_handler; 00225 VolumeControl *m_volumeControl; 00226 AbstractEngine *m_engine; 00227 QQueue<InputSource *> m_sources; 00228 int m_nextState; 00229 }; 00230 00231 #endif