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.

319 lines
7.2 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. MSPCall.h
  5. Abstract:
  6. Definitions for MSP utililty functions. There are all related to
  7. active movie filter manipulation.
  8. Author:
  9. Mu Han (muhan) 1-November-1997
  10. --*/
  11. #ifndef __MSPUTIL_H
  12. #define __MSPUTIL_H
  13. const DWORD PAYLOAD_G711U = 0;
  14. const DWORD PAYLOAD_G723 = 4;
  15. const DWORD PAYLOAD_G711A = 8;
  16. const DWORD PAYLOAD_H261 = 31;
  17. const DWORD PAYLOAD_H263 = 34;
  18. const TCHAR gszMSPKey[] =
  19. L"Software\\Microsoft\\Windows\\CurrentVersion\\H323MSP\\";
  20. const TCHAR gszAEC[] = L"AEC";
  21. HRESULT
  22. FindPin(
  23. IN IBaseFilter * pInterfaceilter,
  24. OUT IPin ** ppIPin,
  25. IN PIN_DIRECTION direction,
  26. IN BOOL bFree = TRUE
  27. );
  28. HRESULT
  29. PinSupportsMediaType(
  30. IN IPin * pIPin,
  31. IN const GUID & MediaType
  32. );
  33. HRESULT
  34. AddFilter(
  35. IN IGraphBuilder * pIGraph,
  36. IN const CLSID & Clsid,
  37. IN LPCWSTR pwstrName,
  38. OUT IBaseFilter ** ppIBaseFilter
  39. );
  40. HRESULT
  41. SetQOSOption(
  42. IN IBaseFilter * pIBaseFilter,
  43. IN DWORD dwPayloadType,
  44. IN DWORD dwMaxBandwidth,
  45. IN BOOL bReceive,
  46. IN BOOL bCIF = FALSE
  47. );
  48. HRESULT
  49. ConnectFilters(
  50. IN IGraphBuilder * pIGraph,
  51. IN IBaseFilter * pInterfaceilter1,
  52. IN IBaseFilter * pInterfaceilter2,
  53. IN BOOL fDirect = TRUE,
  54. IN AM_MEDIA_TYPE * pmt = NULL
  55. );
  56. HRESULT
  57. ConnectFilters(
  58. IN IGraphBuilder * pIGraph,
  59. IN IPin * pIPinOutput,
  60. IN IBaseFilter * pInterfaceilter,
  61. IN BOOL fDirect = TRUE,
  62. IN AM_MEDIA_TYPE * pmt = NULL
  63. );
  64. HRESULT
  65. ConnectFilters(
  66. IN IGraphBuilder * pIGraph,
  67. IN IBaseFilter * pInterfaceilter,
  68. IN IPin * pIPinInput,
  69. IN BOOL fDirect = TRUE,
  70. IN AM_MEDIA_TYPE * pmt = NULL
  71. );
  72. HRESULT
  73. EnableRTCPEvents(
  74. IN IBaseFilter *pIBaseFilter,
  75. IN BOOL fDirectRTP
  76. );
  77. void WINAPI H323DeleteMediaType(AM_MEDIA_TYPE *pmt);
  78. BOOL
  79. GetRegValue(
  80. IN LPCWSTR szName,
  81. OUT DWORD *pdwValue
  82. );
  83. HRESULT SetAudioFormat(
  84. IN IUnknown* pIUnknown,
  85. IN WORD wBitPerSample,
  86. IN DWORD dwSampleRate
  87. );
  88. HRESULT SetAudioBufferSize(
  89. IN IUnknown* pIUnknown,
  90. IN DWORD dwNumBuffers,
  91. IN DWORD dwBufferSize
  92. );
  93. HRESULT GetFormatHelper(
  94. IN IPin *pPin,
  95. OUT AM_MEDIA_TYPE **ppMediaType
  96. );
  97. HRESULT SetFormatHelper(
  98. IN IPin *pPin,
  99. IN AM_MEDIA_TYPE *pMediaType
  100. );
  101. HRESULT GetNumberOfCapabilitiesHelper(
  102. IN IPin *pPin,
  103. OUT DWORD *pdwCount
  104. );
  105. HRESULT GetStreamCapsHelper(
  106. IN IPin *pPin,
  107. IN DWORD dwIndex,
  108. OUT AM_MEDIA_TYPE **ppMediaType,
  109. OUT TAPI_STREAM_CONFIG_CAPS *pStreamConfigCaps,
  110. OUT BOOL *pfEnabled
  111. );
  112. template <class TInterface, class TEnum, class Flag>
  113. HRESULT GetRangeHelper(
  114. IN TInterface * pInterface,
  115. IN TEnum Property,
  116. OUT long *plMin,
  117. OUT long *plMax,
  118. OUT long *plSteppingDelta,
  119. OUT long *plDefault,
  120. OUT Flag *plFlags
  121. )
  122. {
  123. ENTER_FUNCTION("GetRangeHelper");
  124. if (IsBadWritePtr(plMin, sizeof(long)) ||
  125. IsBadWritePtr(plMax, sizeof(long)) ||
  126. IsBadWritePtr(plSteppingDelta, sizeof(long)) ||
  127. IsBadWritePtr(plDefault, sizeof(long)) ||
  128. IsBadWritePtr(plFlags, sizeof(long)))
  129. {
  130. LOG((MSP_ERROR, "%s, bad pointer", __fxName));
  131. return E_POINTER;
  132. }
  133. HRESULT hr = pInterface->GetRange(
  134. Property,
  135. plMin,
  136. plMax,
  137. plSteppingDelta,
  138. plDefault,
  139. plFlags
  140. );
  141. return hr;
  142. }
  143. template <class T>
  144. HRESULT CreateCComObjectInstance (
  145. CComObject<T> **ppObject
  146. )
  147. /*++
  148. Create a new CComObject instance. Use try/except to catch exception.
  149. --*/
  150. {
  151. HRESULT hr;
  152. __try
  153. {
  154. hr = CComObject<T>::CreateInstance(ppObject);
  155. }
  156. __except (EXCEPTION_EXECUTE_HANDLER)
  157. {
  158. *ppObject = NULL;
  159. return E_OUTOFMEMORY;
  160. }
  161. return hr;
  162. }
  163. template <class TInterface, class TEnum, class Flag>
  164. HRESULT GetHelper(
  165. IN TInterface * pInterface,
  166. IN TEnum Property,
  167. OUT long *plValue,
  168. OUT Flag *plFlags
  169. )
  170. {
  171. ENTER_FUNCTION("GetHelper");
  172. if (IsBadWritePtr(plValue, sizeof(long)) ||
  173. IsBadWritePtr(plFlags, sizeof(long)))
  174. {
  175. LOG((MSP_ERROR, "%s, bad pointer", __fxName));
  176. return E_POINTER;
  177. }
  178. HRESULT hr = pInterface->Get(
  179. Property,
  180. plValue,
  181. plFlags
  182. );
  183. return hr;
  184. }
  185. inline DWORD FindSampleRate(AM_MEDIA_TYPE *pMediaType)
  186. {
  187. _ASSERT(!IsBadReadPtr(pMediaType, sizeof(AM_MEDIA_TYPE)));
  188. if (pMediaType->majortype == MEDIATYPE_Audio &&
  189. pMediaType->formattype == FORMAT_WaveFormatEx &&
  190. pMediaType->pbFormat != NULL &&
  191. pMediaType->cbFormat != 0)
  192. {
  193. WAVEFORMATEX *pWaveFormatEx = (WAVEFORMATEX *) pMediaType->pbFormat;
  194. return pWaveFormatEx->nSamplesPerSec;
  195. }
  196. return 90000; // default media clock rate, including video.
  197. }
  198. HRESULT ConfigureRTPFormats(
  199. IN IBaseFilter * pIRTPFilter,
  200. IN IStreamConfig * pIStreamConfig
  201. );
  202. HRESULT
  203. H323DetermineLinkSpeed(
  204. IN DWORD dwHostAddr,
  205. OUT DWORD *dwInterfaceLinkSpeed
  206. );
  207. class ATL_NO_VTABLE CMSPStreamClock :
  208. public CComObjectRootEx<CComMultiThreadModelNoCS>,
  209. public IReferenceClock
  210. {
  211. private:
  212. LONGLONG m_lPerfFrequency;
  213. union {
  214. LONGLONG m_lRtpRefTime;
  215. DWORD m_dwRtpRefTime;
  216. };
  217. public:
  218. BEGIN_COM_MAP(CMSPStreamClock)
  219. COM_INTERFACE_ENTRY(IReferenceClock)
  220. END_COM_MAP()
  221. void InitReferenceTime(void);
  222. HRESULT GetTimeOfDay(OUT REFERENCE_TIME *pTime);
  223. CMSPStreamClock()
  224. {
  225. InitReferenceTime();
  226. }
  227. STDMETHOD (GetTime) (
  228. OUT REFERENCE_TIME *pTime
  229. )
  230. {
  231. return(GetTimeOfDay(pTime));
  232. }
  233. STDMETHOD (AdviseTime) (
  234. IN REFERENCE_TIME baseTime, // base reference time
  235. IN REFERENCE_TIME streamTime, // stream offset time
  236. IN HEVENT hEvent, // advise via this event
  237. OUT DWORD_PTR *pdwAdviseCookie // where your cookie goes
  238. )
  239. {
  240. _ASSERT(!"AdviseTime is called");
  241. return E_NOTIMPL;
  242. }
  243. STDMETHOD (AdvisePeriodic) (
  244. IN REFERENCE_TIME StartTime, // starting at this time
  245. IN REFERENCE_TIME PeriodTime, // time between notifications
  246. IN HSEMAPHORE hSemaphore, // advise via a semaphore
  247. OUT DWORD_PTR *pdwAdviseCookie // where your cookie goes
  248. )
  249. {
  250. _ASSERT(!"AdvisePeriodic is called");
  251. return E_NOTIMPL;
  252. }
  253. STDMETHOD (Unadvise) (
  254. IN DWORD_PTR dwAdviseCookie
  255. )
  256. {
  257. _ASSERT(!"Unadvise is called");
  258. return E_NOTIMPL;
  259. }
  260. };
  261. #endif