00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __WOSH_DEVICES_PlayerMPD_H__
00038 #define __WOSH_DEVICES_PlayerMPD_H__
00039
00040 #include <woshDefs.h>
00041 #include <core/Containers.h>
00042 #include <core/BundleGenericWorker.h>
00043 #include <interfaces/entertainment/PlayerAudio.h>
00044 #include <framework/entertainment/MediaTrack.h>
00045 #include <framework/entertainment/MediaList.h>
00046 #include <core/DataFields.h>
00047 #include <map>
00048
00049
00050 using namespace wosh;
00051 using namespace wosh::entertainment;
00052
00053 class IPlayerMPDListener;
00054
00055 class PlayerMpdOutput : public virtual IDataFieldRW
00056 {
00057 WOSH_DF_MEYER_RW(PlayerMpdOutput, PlayerMpdOutput)
00058
00059 public:
00060 PlayerMpdOutput() {
00061 this->index = -1;
00062 this->enabled = false;
00063 }
00064 virtual ~PlayerMpdOutput() { }
00065
00066 public:
00067 int getIndex() const { return this->index; }
00068 const std::string& getName() const { return this->name; }
00069 bool isEnabled() const { return this->enabled; }
00070
00071 public:
00072 int index;
00073 std::string name;
00074 bool enabled;
00075 };
00076
00077 std::string print_PlayerMpdOutputList( VectorT<PlayerMpdOutput*>& cont );
00078
00079
00080 class PlayerMPD : public BundleGenericWorker,
00081 public wosh::interfaces::entertainment::PlayerAudio
00082 {
00083 WOSH_CLASSNAME(PlayerMPD)
00084
00085 public:
00086 enum UPDATE_TYPE {
00087 UPDATE_NONE = 0x00,
00088 UPDATE_STATUS = 0x01,
00089 UPDATE_STATS = 0x02,
00090 UPDATE_PLAYLIST = 0x05,
00091 UPDATE_OUTPUTS = 0x08,
00092 UPDATE_ALL = 0xFF
00093 };
00094
00095
00096
00097
00098 public:
00099
00100
00101
00102 virtual WRESULT playSearch( const std::string& query ) = 0;
00103
00104
00105
00106
00107
00108
00109 virtual WRESULT move( unsigned int index_old, unsigned int index_new ) = 0;
00110 virtual WRESULT swap( unsigned int index_old, unsigned int index_new ) = 0;
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 public:
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 virtual int getBitRate() const = 0;
00141
00142 virtual const VectorT<PlayerMpdOutput*>& getOutputs() const = 0;
00143 virtual VectorT<PlayerMpdOutput*>& getOutputs() = 0;
00144
00145 virtual const wosh::entertainment::MediaTrack& getCurrentTrack() const = 0;
00146 virtual wosh::entertainment::MediaTrack& getCurrentTrack() = 0;
00147
00148 virtual const wosh::entertainment::MediaList& getPlayList() const = 0;
00149 virtual wosh::entertainment::MediaList& getPlayList() = 0;
00150
00151
00152
00153
00154
00155 public:
00156 virtual inline void setPlayerListener( IPlayerMPDListener* Listener ) {
00157 this->playerListener = Listener;
00158 }
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 virtual WRESULT switchOutput( int index, bool enable ) = 0;
00172 virtual WRESULT forceServerUpdate( const std::string& path ) = 0;
00173
00174 virtual void setRefreshPeriod( long seconds ) = 0;
00175 virtual void setRefreshFullDivider( long divider ) = 0;
00176
00177
00178
00179
00180
00181 public:
00182 virtual void setAddressPort( const std::string& add_value, int port_value ) = 0;
00183 virtual void setAddressPort( const std::string& value ) = 0;
00184
00185 virtual const std::string& getAddress() const = 0;
00186 virtual int getPort() const = 0;
00187 virtual std::string getAddressPort() const = 0;
00188
00189 virtual const std::string& getDatabasePath() const = 0;
00190 virtual void setDatabasePath( const std::string& value ) = 0;
00191
00192 virtual long getRefreshPeriod() const = 0;
00193 virtual long getRefreshFullDivider() const = 0;
00194
00195 virtual bool isServerUpdating() const = 0;
00196 virtual WRESULT getAPIInfo( std::map<std::string, std::string>& fields ) = 0;
00197
00198 virtual WRESULT updateAll( bool smart, bool callbacks = true ) = 0;
00199 virtual WRESULT updateOutputs( bool callbacks = true ) = 0;
00200 virtual WRESULT updateStatus( bool callbacks = true ) = 0;
00201 virtual WRESULT updateStats( bool callbacks = true ) = 0;
00202 virtual WRESULT updatePlaylist( bool callbacks = true ) = 0;
00203
00204
00205 public:
00206 PlayerMPD( BundleGeneric& bundle ) : BundleGenericWorker(bundle) {
00207 this->playerListener = NULL;
00208 }
00209 virtual ~PlayerMPD() { }
00210
00211 protected:
00212 IPlayerMPDListener* playerListener;
00213
00214 };
00215
00216
00217
00218 class IPlayerMPDListener : public virtual wosh::interfaces::entertainment::PlayerAudioListener
00219 {
00220 public:
00221 virtual void updated_Stats( const std::map<std::string, std::string>& fields, PlayerMPD* source ) = 0;
00222 virtual void changed_Outputs( const VectorT<PlayerMpdOutput*>& final_outputs,
00223 VectorT<PlayerMpdOutput*>& outofdate_items, VectorT<PlayerMpdOutput*>& new_items,
00224 VectorT<PlayerMpdOutput*>& changed_items,
00225 PlayerMPD* source ) = 0;
00226
00227 public:
00228 virtual ~IPlayerMPDListener() { }
00229 };
00230
00231
00232 #endif //__WOSH_DEVICES_PlayerMPD_H__