bundles/PlayerMPD/PlayerMPD.h

00001 /**
00002  * @class   PlayerMPD
00003  * @brief   Interface for PlayerMPD implementations.
00004  *
00005  * @see     IPlayerMPDListener
00006  ****************************************************************************
00007  * @version 0.8.471 $Id: PlayerMPD.h 3775 2011-01-01 16:38:17Z alex $
00008  * @author  Alessandro Polo
00009  ****************************************************************************/
00010 /* Copyright (c) 2007-2011, WOSH - Wide Open Smart Home 
00011  * by Alessandro Polo - OpenSmartHome.com
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *     * Redistributions of source code must retain the above copyright
00017  *       notice, this list of conditions and the following disclaimer.
00018  *     * Redistributions in binary form must reproduce the above copyright
00019  *       notice, this list of conditions and the following disclaimer in the
00020  *       documentation and/or other materials provided with the distribution.
00021  *     * Neither the name of the OpenSmartHome.com WOSH nor the
00022  *       names of its contributors may be used to endorse or promote products
00023  *       derived from this software without specific prior written permission.
00024  *
00025  * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
00026  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00027  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00028  * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
00029  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00030  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00032  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00033  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00034  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 /** @name Playlist management
00096  * @{
00097  ******************************************************************************/
00098     public:
00099     //  virtual WRESULT play() = 0;
00100     //  virtual WRESULT play( unsigned int index ) = 0;
00101     //  virtual WRESULT play( const std::string& file_url, int volume = -1, bool override_current = false ) = 0;
00102         virtual WRESULT playSearch( const std::string& query ) = 0;
00103     //  virtual WRESULT pause() = 0;
00104     //  virtual WRESULT stop() = 0;
00105 
00106     //  virtual WRESULT enqueue( const std::string& file_url ) = 0;
00107     //  virtual WRESULT remove( unsigned int index ) = 0;
00108     //  virtual WRESULT remove( const std::string& file_url ) = 0;
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     //  virtual WRESULT clear() = 0;
00112 
00113     //  virtual WRESULT first() = 0;
00114     //  virtual WRESULT next() = 0;
00115     //  virtual WRESULT prev() = 0;
00116     //  virtual WRESULT last() = 0;
00117 
00118 //@}
00119 /** @name Getters
00120  * @{
00121  ******************************************************************************/
00122     public:
00123     //  virtual bool isPlaying() const = 0;
00124     //  virtual long getPlayListIndex() const = 0;
00125     //  virtual long getPlayListLength() const = 0;
00126 
00127     //  virtual int getVolume() const = 0;
00128     //  virtual bool isMuted() const = 0;
00129     //  virtual int getCrossfade() const = 0;
00130     //  virtual short getRepeat() const = 0;
00131     //  virtual short getRandom() const = 0;
00132 
00133     //  virtual float getPosition() const = 0;
00134     //  virtual std::string getPositionStr() const = 0;
00135     //  virtual int64 getPositionMs() const = 0;
00136 
00137     //  virtual int64 getLengthMs() const = 0;
00138     //  virtual std::string getLengthStr() const = 0;
00139 
00140         virtual int getBitRate() const = 0;     ///< current bit rate in kbs
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 /** @name Setters
00153  * @{
00154  ******************************************************************************/
00155     public:
00156         virtual inline void setPlayerListener( IPlayerMPDListener* Listener ) {
00157             this->playerListener = Listener;
00158          }
00159 
00160     //  virtual WRESULT setVolume( int newVolume ) = 0;
00161     //  virtual WRESULT setVolumeOffset( int volume_span ) = 0;
00162     //  virtual WRESULT setMute( bool on ) = 0;
00163     //  virtual WRESULT setRepeat( short value ) = 0;
00164     //  virtual WRESULT setRandom( short value ) = 0;
00165     //  virtual WRESULT setCrossfade( int seconds ) = 0;
00166 
00167     //  virtual WRESULT setPosition( float position_rate ) = 0;
00168     //  virtual WRESULT setPositionOffset( float position_rate_offset ) = 0;
00169     //  virtual WRESULT setPositionMs( int64 position_ms ) = 0;
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 /** @name Server management
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 }; // class def
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 }; // class def
00230 
00231 
00232 #endif //__WOSH_DEVICES_PlayerMPD_H__

Generated on Tue Feb 8 2011 09:33:00 for WOSH system 0.8.888 [wolf] by Alessandro Polo, using DoxyGen 1.7.2 hosted by WOSH Framework