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.

167 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name:
  4. medistrm.h
  5. Abstract:
  6. Contains constants and class declarations for the abstract MediaStream object. A MediaStream
  7. represents a single unidirectional stream, such as a received Video channel.
  8. --*/
  9. #ifndef _DSSTREAM_H_
  10. #define _DSSTREAM_H_
  11. class DataPump;
  12. #include <pshpack8.h> /* Assume 8 byte packing throughout */
  13. struct DSINFO;
  14. extern GUID myNullGuid; // a zero guid
  15. typedef HRESULT (WINAPI *LPFNDSCREATE)(const GUID * , LPDIRECTSOUND * , IUnknown FAR * );
  16. typedef HRESULT (WINAPI *LPFNDSENUM)(LPDSENUMCALLBACK , LPVOID );
  17. class DirectSoundMgr {
  18. public:
  19. static HRESULT Initialize();
  20. static HRESULT MapWaveIdToGuid(UINT waveId, GUID *pGuid); // kludge!!
  21. static HRESULT Instance(LPGUID pDeviceGuid,LPDIRECTSOUND *ppDS, HWND hwnd, WAVEFORMATEX *pwf);
  22. static HRESULT ReleaseInstance(LPDIRECTSOUND pDS);
  23. static HRESULT UnInitialize();
  24. private:
  25. static HINSTANCE m_hDS; // handle to DSOUND.DLL
  26. static LPFNDSCREATE m_pDirectSoundCreate; // used for dynamic linking to DSOUND.DLL
  27. static LPFNDSENUM m_pDirectSoundEnumerate; // used for dynamic linking
  28. static BOOL __stdcall DSEnumCallback(LPGUID, LPCSTR, LPCSTR, LPVOID);
  29. static DSINFO *m_pDSInfoList;
  30. static BOOL m_fInitialized ;
  31. };
  32. class DSTimeout : public TTimeout {
  33. public:
  34. void SetDSStream(class RecvDSAudioStream *pDSS) {m_pRDSStream = pDSS;}
  35. protected:
  36. class RecvDSAudioStream *m_pRDSStream;
  37. virtual void TimeoutIndication();
  38. };
  39. class RecvDSAudioStream : public RecvMediaStream, public IAudioChannel {
  40. friend class DataPump;
  41. friend BOOL RTPRecvDSCallback(DWORD ,WSABUF * );
  42. private:
  43. WAVEFORMATEX m_fDevRecv;
  44. CRITICAL_SECTION m_crsAudQoS; // Allows QoS thread to read the audio statistics while recording and compression are running
  45. BOOL m_fEmpty;
  46. DWORD m_NextTimeT;
  47. DWORD m_BufSizeT;
  48. DWORD m_NextPosT;
  49. DWORD m_PlayPosT;
  50. DWORD m_SilenceDurationT; // tracks "silence" periods in the received stream
  51. // used for adaptive delay calculations
  52. DWORD m_DelayT;
  53. DWORD m_MinDelayT; // constant lower limit on playback delay
  54. DWORD m_MaxDelayT; // constant upper limit on playback delay
  55. DWORD m_ArrT; // local (pseudo)timestamp
  56. DWORD m_SendT0; // m_SendT0 is the send timestamp of the packet with the shortest trip delay. We could have just stored (m_ArrivalT0 - m_SendT0) but since the local and remote clocks are completely unsynchronized, there would be signed/unsigned complications.
  57. DWORD m_ArrivalT0; // m_ArrivalT0 is the arrival timestamp of the packet with the shortest trip delay. We could have just stored (m_ArrivalT0 - m_SendT0) but since the local and remote clocks are completely unsynchronized, there would be signed/unsigned complications.
  58. LONG m_ScaledAvgVarDelay; // Average Variable Delay according to m_ScaledAvgVarDelay = m_ScaledAvgVarDelay + (delay - m_ScaledAvgVarDelay/16). This is the m_DelayPos jitter.
  59. int m_nFailCount; // number of consecutive times the device failed to open
  60. GUID m_DSguid;
  61. LPDIRECTSOUND m_pDS;
  62. LPDIRECTSOUNDBUFFER m_pDSBuf;
  63. DSBUFFERDESC m_DSBufDesc;
  64. DWORD m_DSFlags; // from DSCAPS.dwFlags
  65. AcmFilter *m_pAudioFilter;
  66. ACMSTREAMHEADER m_StrmConvHdr;
  67. HANDLE m_hStrmConv;
  68. DSTimeout m_TimeoutObj;
  69. AudioSilenceDetector m_AudioMonitor;
  70. BOOL m_bJammed;
  71. BOOL m_bCanSignalOpen;
  72. // Non virtual methods
  73. void UpdateVariableDelay(DWORD timestamp, DWORD curPlayT);
  74. DWORD GetSignalStrength();
  75. HRESULT CreateDSBuffer();
  76. HRESULT ReleaseDSBuffer();
  77. HRESULT Decode(UCHAR *pData, UINT cbData);
  78. HRESULT PlayBuf(DWORD timestamp, UINT seq, BOOL fMark);
  79. LONG m_lRefCount;
  80. public:
  81. RecvDSAudioStream() :RecvMediaStream() {m_Net=NULL; m_lRefCount=0; m_TimeoutObj.SetDSStream(this);};
  82. ~RecvDSAudioStream();
  83. // IUnknown
  84. virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
  85. virtual ULONG STDMETHODCALLTYPE AddRef(void);
  86. virtual ULONG STDMETHODCALLTYPE Release(void);
  87. // IMediaChannel APIs
  88. HRESULT STDMETHODCALLTYPE Configure(
  89. BYTE *pFormat,
  90. UINT cbFormat,
  91. BYTE *pChannelParams,
  92. UINT cbParams,
  93. IUnknown *pUnknown);
  94. STDMETHODIMP Start(void);
  95. STDMETHODIMP Stop(void);
  96. STDMETHODIMP_(void) UnConfigure(void);
  97. HRESULT STDMETHODCALLTYPE SetNetworkInterface(IUnknown *pUnknown)
  98. {
  99. return RecvMediaStream::SetNetworkInterface(pUnknown);
  100. }
  101. STDMETHODIMP_(DWORD) GetState()
  102. {
  103. return RecvMediaStream::GetState();
  104. }
  105. HRESULT STDMETHODCALLTYPE SetMaxBitrate(UINT uMaxBitrate)
  106. {
  107. return E_NOTIMPL;
  108. }
  109. // IAudioChannel
  110. STDMETHODIMP GetSignalLevel(UINT *pSignalStrength);
  111. // IProperty methods
  112. STDMETHODIMP GetProperty(DWORD dwProp, PVOID pBuf, LPUINT pcbBuf);
  113. STDMETHODIMP SetProperty(DWORD dwProp, PVOID pBuf, UINT cbBuf);
  114. // Other virtual inherited methods
  115. virtual HRESULT Initialize(DataPump *);
  116. virtual BOOL IsEmpty();
  117. HRESULT GetCurrentPlayNTPTime(NTP_TS *);
  118. virtual HRESULT StartRecv(HWND);
  119. virtual HRESULT StopRecv();
  120. HRESULT DTMFBeep();
  121. HRESULT OnDTMFBeep();
  122. void RecvTimeout();
  123. virtual HRESULT RTPCallback(WSABUF *pWsaBuf, DWORD timestamp, UINT seq, UINT fMark);
  124. };
  125. #include <poppack.h> /* End byte packing */
  126. #endif // _MEDISTRM_H_