MicrophoneServer.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_MicrophoneServer_h_
00003 #define INCLUDED_MicrophoneServer_h_
00004
00005 #include "Events/EventBase.h"
00006 #include "Behaviors/BehaviorBase.h"
00007
00008
00009 class MicrophoneServer : public BehaviorBase {
00010 public:
00011
00012 static MicrophoneServer& getInstance();
00013 virtual ~MicrophoneServer();
00014
00015 virtual void doStart();
00016 virtual void doStop();
00017 virtual void doEvent();
00018
00019
00020 static bool SetMicrophoneUnidirectional(bool unidirectional);
00021
00022 static bool SetMicrophoneAlcEnabled(bool enabled);
00023
00024 private:
00025
00026 static const unsigned int SEND_BUFFER_SIZE = 2048 + 16;
00027
00028 MicrophoneServer();
00029 MicrophoneServer(const MicrophoneServer& rhs);
00030 MicrophoneServer& operator=(const MicrophoneServer& rhs);
00031 static MicrophoneServer* instance;
00032
00033
00034 unsigned int GetResampledFrameSize(
00035 unsigned int samplesSize,
00036 unsigned int newSampleRate,
00037 unsigned int newSampleBits,
00038 bool newStereo);
00039
00040
00041 unsigned int ResampleFrame(
00042 const char* samples,
00043 unsigned int samplesSize,
00044 unsigned int& newSampleRate,
00045 unsigned int& newSampleBits,
00046 bool& newStereo,
00047 void* newSamples,
00048 unsigned int newSamplesSize);
00049
00050
00051 static const char* const MIC_LOCATOR;
00052
00053
00054 class Socket *socket;
00055
00056
00057 template<class T>
00058 inline static void encode(char **dst, const T& value) {
00059 memcpy(*dst, &value, sizeof(T));
00060 (*dst) += sizeof(T);
00061 }
00062
00063
00064 template<class T>
00065 inline static void encode(char **dst, const T * src, int num) {
00066 memcpy(*dst, src, num*sizeof(T));
00067 (*dst) += num*sizeof(T);
00068 }
00069 };
00070 #endif