00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 VolumeControl;
00035 class AbstractEngine;
00036 class InputSource;
00037 class StateHandler;
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() const;
00074 int rightVolume() const;
00078 int volume() const;
00082 int balance() const;
00086 bool isMuted() const;
00090 qint64 elapsed();
00094 int bitrate();
00098 quint32 frequency();
00102 int sampleSize();
00106 int channels();
00110 Qmmp::State state() const;
00114 QMap <Qmmp::MetaData, QString> metaData() const;
00118 QString metaData(Qmmp::MetaData key) const;
00122 QHash<QString, QString> streamInfo() const;
00127 bool nextTrackAccepted() const;
00131 static SoundCore* instance();
00132
00133 public slots:
00139 void setVolume(int left, int right);
00144 void setMuted(bool mute);
00148 void changeVolume(int delta);
00153 void setVolume(int volume);
00154 void volumeUp();
00155 void volumeDown();
00156
00161 void setBalance(int balance);
00167 bool play(const QString &source, bool queue = false, qint64 offset = -1);
00171 void stop();
00175 void pause();
00179 void seek(qint64 pos);
00183 const QString url() const;
00184
00185 signals:
00190 void bufferingProgress(int progress);
00195 void elapsedChanged(qint64 time);
00200 void bitrateChanged(int bitrate);
00205 void frequencyChanged(quint32 frequency);
00210 void sampleSizeChanged(int size);
00215 void channelsChanged(int channels);
00219 void metaDataChanged ();
00223 void streamInfoChanged();
00227 void stateChanged (Qmmp::State newState);
00231 void finished();
00237 void volumeChanged(int left, int right);
00242 void mutedChanged(bool muted);
00247 void volumeChanged(int volume);
00252 void balanceChanged(int balance);
00256 void eqSettingsChanged();
00260 void nextTrackRequest();
00261
00262 private slots:
00263 void startNextSource();
00264 void startNextEngine();
00265
00266 private:
00267 bool event(QEvent *e);
00268 enum NextEngineState
00269 {
00270 NO_ENGINE = 0,
00271 SAME_ENGINE,
00272 ANOTHER_ENGINE,
00273 INVALID_SOURCE
00274 };
00275 QMap <Qmmp::MetaData, QString> m_metaData;
00276 QHash <QString, QString> m_streamInfo;
00277 QString m_url;
00278 static SoundCore* m_instance;
00279 StateHandler *m_handler;
00280 VolumeControl *m_volumeControl;
00281 AbstractEngine *m_engine;
00282 QQueue<InputSource *> m_sources;
00283 int m_nextState;
00284 bool m_muted;
00285 };
00286
00287 #endif