Source code of Windows XP (NT5)
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.

245 lines
5.3 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_G721 = 2;
  15. const DWORD PAYLOAD_GSM = 3;
  16. const DWORD PAYLOAD_G723 = 4;
  17. const DWORD PAYLOAD_DVI4_8 = 5;
  18. const DWORD PAYLOAD_DVI4_16 = 6;
  19. const DWORD PAYLOAD_G711A = 8;
  20. const DWORD PAYLOAD_MSAUDIO = 66;
  21. const DWORD PAYLOAD_H261 = 31;
  22. const DWORD PAYLOAD_H263 = 34;
  23. const WCHAR gszMSPLoopback[] = L"Loopback";
  24. const WCHAR gszAEC[] = L"AEC";
  25. const WCHAR gszNumVideoCaptureBuffers[] = L"NumVideoCaptureBuffers";
  26. const TCHAR gszSDPMSPKey[] =
  27. _T("Software\\Microsoft\\Windows\\CurrentVersion\\IPConfMSP\\");
  28. HRESULT
  29. FindPin(
  30. IN IBaseFilter * pIFilter,
  31. OUT IPin ** ppIPin,
  32. IN PIN_DIRECTION direction,
  33. IN BOOL bFree = TRUE
  34. );
  35. HRESULT
  36. PinSupportsMediaType(
  37. IN IPin * pIPin,
  38. IN const GUID & MediaType
  39. );
  40. HRESULT
  41. AddFilter(
  42. IN IGraphBuilder * pIGraph,
  43. IN const CLSID & Clsid,
  44. IN LPCWSTR pwstrName,
  45. OUT IBaseFilter ** ppIBaseFilter
  46. );
  47. HRESULT
  48. SetLoopbackOption(
  49. IN IBaseFilter *pIBaseFilter,
  50. IN MULTICAST_LOOPBACK_MODE LoopbackMode
  51. );
  52. HRESULT
  53. SetQOSOption(
  54. IN IBaseFilter * pIBaseFilter,
  55. IN DWORD dwPayloadType,
  56. IN DWORD dwMaxBitRate,
  57. IN BOOL bFailIfNoQOS,
  58. IN BOOL bReceive = FALSE,
  59. IN DWORD dwNumStreams = 1,
  60. IN BOOL bCIF = FALSE
  61. );
  62. HRESULT
  63. ConnectFilters(
  64. IN IGraphBuilder * pIGraph,
  65. IN IBaseFilter * pIFilter1,
  66. IN IBaseFilter * pIFilter2,
  67. IN BOOL fDirect = TRUE,
  68. IN AM_MEDIA_TYPE * pmt = NULL
  69. );
  70. HRESULT
  71. ConnectFilters(
  72. IN IGraphBuilder * pIGraph,
  73. IN IPin * pIPinOutput,
  74. IN IBaseFilter * pIFilter,
  75. IN BOOL fDirect = TRUE,
  76. IN AM_MEDIA_TYPE * pmt = NULL
  77. );
  78. HRESULT
  79. ConnectFilters(
  80. IN IGraphBuilder * pIGraph,
  81. IN IBaseFilter * pIFilter,
  82. IN IPin * pIPinInput,
  83. IN BOOL fDirect = TRUE,
  84. IN AM_MEDIA_TYPE * pmt = NULL
  85. );
  86. HRESULT
  87. EnableRTCPEvents(
  88. IN IBaseFilter *pIBaseFilter
  89. );
  90. void WINAPI MSPDeleteMediaType(AM_MEDIA_TYPE *pmt);
  91. BOOL
  92. GetRegValue(
  93. IN LPCWSTR szName,
  94. OUT DWORD *pdwValue
  95. );
  96. HRESULT
  97. FindACMAudioCodec(
  98. IN DWORD dwPayloadType,
  99. OUT IBaseFilter **ppIBaseFilter
  100. );
  101. HRESULT SetAudioFormat(
  102. IN IUnknown* pIUnknown,
  103. IN WORD wBitPerSample,
  104. IN DWORD dwSampleRate
  105. );
  106. HRESULT SetAudioBufferSize(
  107. IN IUnknown* pIUnknown,
  108. IN DWORD dwNumBuffers,
  109. IN DWORD dwBufferSize
  110. );
  111. template <class T>
  112. HRESULT CreateCComObjectInstance (
  113. CComObject<T> **ppObject
  114. )
  115. /*++
  116. Create a new CComObject instance. Use try/except to catch exception.
  117. --*/
  118. {
  119. HRESULT hr;
  120. __try
  121. {
  122. hr = CComObject<T>::CreateInstance(ppObject);
  123. }
  124. __except (EXCEPTION_EXECUTE_HANDLER)
  125. {
  126. *ppObject = NULL;
  127. return E_OUTOFMEMORY;
  128. }
  129. return hr;
  130. }
  131. inline DWORD FindSampleRate(AM_MEDIA_TYPE *pMediaType)
  132. {
  133. _ASSERT(!IsBadReadPtr(pMediaType, sizeof(AM_MEDIA_TYPE)));
  134. if (pMediaType->majortype == MEDIATYPE_Audio &&
  135. pMediaType->formattype == FORMAT_WaveFormatEx &&
  136. pMediaType->pbFormat != NULL &&
  137. pMediaType->cbFormat != 0)
  138. {
  139. WAVEFORMATEX *pWaveFormatEx = (WAVEFORMATEX *) pMediaType->pbFormat;
  140. return pWaveFormatEx->nSamplesPerSec;
  141. }
  142. return 90000; // default media clock rate, including video.
  143. }
  144. class ATL_NO_VTABLE CMSPStreamClock :
  145. public CComObjectRootEx<CComMultiThreadModelNoCS>,
  146. public IReferenceClock
  147. {
  148. private:
  149. LONGLONG m_lPerfFrequency;
  150. union {
  151. LONGLONG m_lRtpRefTime;
  152. DWORD m_dwRtpRefTime;
  153. };
  154. public:
  155. BEGIN_COM_MAP(CMSPStreamClock)
  156. COM_INTERFACE_ENTRY(IReferenceClock)
  157. END_COM_MAP()
  158. void InitReferenceTime(void);
  159. HRESULT GetTimeOfDay(OUT REFERENCE_TIME *pTime);
  160. CMSPStreamClock()
  161. {
  162. InitReferenceTime();
  163. }
  164. STDMETHOD (GetTime) (
  165. OUT REFERENCE_TIME *pTime
  166. )
  167. {
  168. return(GetTimeOfDay(pTime));
  169. }
  170. STDMETHOD (AdviseTime) (
  171. IN REFERENCE_TIME baseTime, // base reference time
  172. IN REFERENCE_TIME streamTime, // stream offset time
  173. IN HEVENT hEvent, // advise via this event
  174. OUT DWORD_PTR *pdwAdviseCookie // where your cookie goes
  175. )
  176. {
  177. _ASSERT(!"AdviseTime is called");
  178. return E_NOTIMPL;
  179. }
  180. STDMETHOD (AdvisePeriodic) (
  181. IN REFERENCE_TIME StartTime, // starting at this time
  182. IN REFERENCE_TIME PeriodTime, // time between notifications
  183. IN HSEMAPHORE hSemaphore, // advise via a semaphore
  184. OUT DWORD_PTR *pdwAdviseCookie // where your cookie goes
  185. )
  186. {
  187. _ASSERT(!"AdvisePeriodic is called");
  188. return E_NOTIMPL;
  189. }
  190. STDMETHOD (Unadvise) (
  191. IN DWORD_PTR dwAdviseCookie
  192. )
  193. {
  194. _ASSERT(!"Unadvise is called");
  195. return E_NOTIMPL;
  196. }
  197. };
  198. #endif