SoundIn.h
上传用户:onsales
上传日期:2010-01-31
资源大小:224k
文件大小:2k
源码类别:

网络编程

开发平台:

Visual C++

  1. // SoundIn.h: interface for the CSoundIn class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_SOUNDIN_H__8F8DC634_0576_11D4_8D3A_000021E6766A__INCLUDED_)
  5. #define AFX_SOUNDIN_H__8F8DC634_0576_11D4_8D3A_000021E6766A__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "mmsystem.h"
  10. #include "soundout.h"
  11. #include "winsock.h"
  12. #include "compression.h"
  13. class CSoundIn  
  14. {
  15. public:
  16. MMRESULT OpenMic();
  17. void     AddBuffer();
  18. void     StopMic();
  19. void  CloseMic();
  20. void     SetBits(int bits){m_nBits=bits;}
  21. void     SetBuffer(char *pBuffer){m_pInputBuffer=pBuffer;}
  22. void     SetBlockProp(long samples,int num){m_nBlock=samples;m_nBlockNum=num;}
  23. void     SetSampleRate(UINT nSampleRate){m_WaveInSampleRate=nSampleRate;}
  24. void  SetTestProp(BOOL test){m_bTest=test;}
  25. void  SetSoundOut(CSoundOut* sndOut){m_sndOut=sndOut;}
  26. void     SetSocketParam(SOCKET s,SOCKADDR_IN addr){m_sSend=s;m_addrTo=addr;}
  27. void     SetCompressionObject(CCompression* c){m_cpSend=c;}
  28. CSoundIn();
  29. virtual ~CSoundIn();
  30. private:
  31. void WaveInitFormat(WORD    nCh, // number of channels (mono, stereo)
  32. DWORD   nSampleRate, // sample rate
  33. WORD    BitsPerSample);
  34. char * m_pInputBuffer;
  35. WAVEINCAPS m_WaveInDevCaps;
  36.     HWAVEIN m_WaveIn;
  37. WAVEHDR* m_WaveHeader;
  38.     WAVEFORMATEX m_WaveFormat;
  39. BOOL m_bTest;
  40. int m_nCurrent;
  41. UINT            m_WaveInSampleRate;
  42. long            m_nBlock;
  43. int m_nBlockNum;
  44. int m_nBits;
  45. SOCKET m_sSend;
  46. SOCKADDR_IN     m_addrTo;
  47. CSoundOut* m_sndOut;       
  48. CCompression*   m_cpSend;
  49. public:
  50. BOOL            m_TerminateThread;
  51. HANDLE          m_WaveInEvent;
  52. CWinThread*     m_WaveInThread;
  53. };
  54. #endif // !defined(AFX_SOUNDIN_H__8F8DC634_0576_11D4_8D3A_000021E6766A__INCLUDED_)