Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.7 KiB

  1. #ifndef SEND_DSC_STREAM_H
  2. #define SEND_DSC_STREAM_H
  3. #include "agc.h"
  4. #include <pshpack8.h> /* Assume 8 byte packing throughout */
  5. #define MAX_DSC_DESCRIPTION_STRING 200
  6. #define MAX_NUMBER_DSCAPTURE_DEVICES 16
  7. #define NUM_AUDIOPACKETS 2
  8. #define MIN_NUM_DSC_SEGMENTS 5
  9. #define DSOUND_DLL "dsound.dll"
  10. #define DISABLE_DSC_REGKEY "Software\\Microsoft\\Internet Audio\\NacObject"
  11. #define DISABLE_DSC_REGVALUE "DisableDirectSoundCapture"
  12. typedef HRESULT (WINAPI *DS_CAP_CREATE)(LPGUID, LPDIRECTSOUNDCAPTURE *, LPUNKNOWN);
  13. typedef HRESULT (WINAPI *DS_CAP_ENUM)(LPDSENUMCALLBACKA, LPVOID);
  14. struct DSC_CAPTURE_INFO
  15. {
  16. GUID guid;
  17. char szDescription[MAX_DSC_DESCRIPTION_STRING];
  18. UINT uWaveId;
  19. BOOL bAllocated;
  20. };
  21. // really a namespace
  22. class DSC_Manager
  23. {
  24. public:
  25. static HRESULT Initialize();
  26. static HRESULT MapWaveIdToGuid(UINT uwaveId, GUID *pGuid);
  27. static HRESULT CreateInstance(GUID *pGuid, IDirectSoundCapture **pDSC);
  28. private:
  29. static BOOL s_bInitialized;
  30. static DSC_CAPTURE_INFO s_aDSC[MAX_NUMBER_DSCAPTURE_DEVICES];
  31. static int s_nCaptureDevices; // number in array
  32. static BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCSTR lpcstrDescription,
  33. LPCSTR lpcstrModule, LPVOID lpContext);
  34. static HINSTANCE s_hDSCLib;
  35. static DS_CAP_CREATE s_pDSCapCreate;
  36. static DS_CAP_ENUM s_pDSCapEnum;
  37. };
  38. class SendDSCStream : public SendMediaStream, public IAudioChannel, public IDTMFSend
  39. {
  40. private:
  41. AcmFilter *m_pAudioFilter; // encapsulates codec
  42. WAVEFORMATEX m_wfPCM; // uncompressed recording format
  43. WAVEFORMATEX m_wfCompressed; // compressed format
  44. AudioSilenceDetector m_AudioMonitor;
  45. MMIOSRC m_mmioSrc; // handle to input file
  46. static DWORD CALLBACK StartRecordingThread (LPVOID pVoid);
  47. DWORD RecordingThread();
  48. STDMETHODIMP_(void) UnConfigure(void);
  49. LONG m_lRefCount;
  50. IDirectSoundCapture *m_pDSC; // DSC device object
  51. IDirectSoundCaptureBuffer *m_pDSCBuffer; // the capture buffer
  52. HANDLE m_hEvent; // DSC Notify Event
  53. DWORD m_dwSamplesPerFrame; // number of PCM samples represented in a frame
  54. DWORD m_dwNumFrames; // number of individual frames in the DSC Buffer
  55. DWORD m_dwFrameSize; // the size of a PCM frame in bytes
  56. DWORD m_dwDSCBufferSize; // the size of the DSC Buffer (== m_dwFrameSize * m_dwNumFrames)
  57. DWORD m_dwSilenceTime; // amount of silence accumulated so far in Milliseconds
  58. DWORD m_dwFrameTimeMS; // the length of a frame in milliseconds
  59. HRESULT CreateAudioPackets(MEDIAPACKETINIT *mpi);
  60. HRESULT ReleaseAudioPackets();
  61. AudioPacket *m_aPackets[NUM_AUDIOPACKETS];
  62. // private methods that the thread uses
  63. HRESULT CreateDSCBuffer();
  64. HRESULT ReleaseDSCBuffer();
  65. DWORD ProcessFrame(DWORD dwBufferPos, BOOL fMark);
  66. DWORD WaitForControl();
  67. DWORD YieldControl();
  68. BOOL ThreadExitCheck();
  69. void UpdateTimestamp();
  70. HRESULT SendPacket(AudioPacket *pAP);
  71. BOOL UpdateQosStats(UINT uStatType, UINT uStatValue1, UINT uStatValue2);
  72. // members used primarily by the recording thread
  73. BOOL m_bFullDuplex;
  74. BOOL m_bJammed; // set by the recording thread to indicate an error on the device
  75. BOOL m_bCanSignalOpen;
  76. BOOL m_bCanSignalFail;
  77. int m_nFailCount;
  78. AGC m_agc; // thread uses AGC object for AutoMix
  79. BOOL m_bAutoMix; // indicates if AutoMixing is turned off or on
  80. // DTMF stuff
  81. DTMFQueue *m_pDTMF;
  82. HRESULT __stdcall SendDTMF();
  83. public:
  84. SendDSCStream();
  85. virtual ~SendDSCStream();
  86. // IUnknown
  87. virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
  88. virtual ULONG STDMETHODCALLTYPE AddRef(void);
  89. virtual ULONG STDMETHODCALLTYPE Release(void);
  90. // IMediaChannel
  91. virtual STDMETHODIMP GetProperty(DWORD dwProp, PVOID pBuf, LPUINT pcbBuf);
  92. virtual STDMETHODIMP SetProperty(DWORD dwProp, PVOID pBuf, UINT cbBuf);
  93. virtual HRESULT STDMETHODCALLTYPE Configure(
  94. BYTE *pFormat,
  95. UINT cbFormat,
  96. BYTE *pChannelParams,
  97. UINT cbParams,
  98. IUnknown *pUnknown);
  99. HRESULT STDMETHODCALLTYPE SetNetworkInterface(IUnknown *pUnknown)
  100. {
  101. return SendMediaStream::SetNetworkInterface(pUnknown);
  102. }
  103. virtual STDMETHODIMP Start(void);
  104. virtual STDMETHODIMP Stop(void);
  105. STDMETHODIMP_(DWORD) GetState()
  106. {
  107. return SendMediaStream::GetState();
  108. }
  109. virtual HRESULT STDMETHODCALLTYPE SetMaxBitrate(UINT uMaxBitrate);
  110. // IAudioChannel
  111. virtual STDMETHODIMP GetSignalLevel(UINT *pSignalStrength);
  112. // IDTMFSend
  113. virtual HRESULT __stdcall AddDigit(int nDigit);
  114. virtual HRESULT __stdcall ResetDTMF();
  115. // Other virtual methods
  116. virtual HRESULT Initialize(DataPump *pdp);
  117. virtual DWORD Send();
  118. virtual void EndSend();
  119. };
  120. #include <poppack.h> /* End byte packing */
  121. #endif