00001 /* 00002 * Copyright (c) 2001-2007 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 #ifndef NetworkPlayer_hxx 00023 #define NetworkPlayer_hxx 00024 00025 #include "Network.hxx" 00026 #include "AudioSource.hxx" 00027 #include "AudioSink.hxx" 00028 00029 namespace CLAM 00030 { 00039 class NetworkPlayer 00040 { 00041 protected: 00042 typedef std::vector<AudioSource*> AudioSources; 00043 typedef std::vector<AudioSink*> AudioSinks; 00044 public: 00045 NetworkPlayer() 00046 { 00047 SetStopped(true); 00048 _network=NULL; 00049 } 00050 00051 virtual ~NetworkPlayer() 00052 { 00053 } 00055 virtual bool IsWorking() const = 0; 00057 virtual std::string NonWorkingReason() const = 0; 00058 00059 virtual void Start()=0; 00060 virtual void Stop()=0; 00061 virtual void Init() 00062 { 00063 std::cout << "NetworkPlayer::Init()"<<std::endl; 00064 } 00065 void SetNetworkBackLink( Network& net ) 00066 { 00067 _network=&net; 00068 } 00069 bool IsStopped() 00070 { 00071 return _stopped; 00072 } 00073 virtual unsigned BackendBufferSize() 00074 { 00075 std::cout << "NetworkPlayer::BackednBufferSize"<<std::endl; 00076 return 512; 00077 } 00078 virtual unsigned BackendSampleRate() 00079 { 00080 std::cout << "NetworkPlayer::BackednSampleRate"<<std::endl; 00081 return 44100; 00082 } 00083 std::string SourcesAndSinksToString(); 00084 protected: 00085 Network& GetNetwork() 00086 { 00087 CLAM_ASSERT( (_network!=NULL), "NetworkPlayer::GetNetwork() : NetworkPlayer does not have any Network"); 00088 return *_network; 00089 } 00090 void SetStopped(const bool val) { _stopped=val; } 00091 void CollectSourcesAndSinks(); 00092 const AudioSources& GetAudioSources() const { return _sources; } 00093 const AudioSinks& GetAudioSinks() const { return _sinks; } 00094 AudioSources& GetAudioSources() { return _sources; } 00095 AudioSinks& GetAudioSinks() { return _sinks; } 00096 00097 AudioSources _sources; 00098 AudioSinks _sinks; 00099 private: 00100 Network *_network; 00101 bool _stopped; 00102 00103 }; 00104 } //namespace CLAM 00105 00106 #endif // NetworkPlayer_hxx 00107