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.

441 lines
10 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. Confvid.h
  5. Abstract:
  6. Definitions for video streams
  7. Author:
  8. Mu Han (muhan) 15-September-1998
  9. --*/
  10. #ifndef __CONFVID_H_
  11. #define __CONFVID_H_
  12. const DWORD LAYERID = 0;
  13. const int IFRAMEINTERVAL = 15; // in seconds.
  14. const int MINIFRAMEINTERVAL = 1; // in seconds
  15. typedef enum _PERIODICIFRAMEMODE
  16. {
  17. PIF_ON,
  18. PIF_HOLD,
  19. PIF_OFF
  20. } PERIODICIFRAMEMODE;
  21. // assert IFrame related variable being in valid state
  22. #define AssertPeriodicIFrameMode _ASSERT (\
  23. /* enabled and running */ \
  24. (PIF_ON == m_PeriodicIFrameMode && \
  25. NULL != m_hTimerQueue && \
  26. NULL != m_hIFrameTimer && \
  27. MINIFRAMEINTERVAL <= m_dwIFrameInterval && \
  28. (STRM_RUNNING & m_dwState)) || \
  29. /* enabled but not running */ \
  30. (PIF_HOLD == m_PeriodicIFrameMode && \
  31. NULL != m_hTimerQueue && \
  32. NULL == m_hIFrameTimer && \
  33. MINIFRAMEINTERVAL <= m_dwIFrameInterval && \
  34. (STRM_RUNNING & m_dwState)) || \
  35. /* diabled */ \
  36. (PIF_OFF == m_PeriodicIFrameMode && \
  37. NULL == m_hTimerQueue && \
  38. NULL == m_hIFrameTimer))
  39. class CStreamVideoRecv :
  40. public CH323MSPStream,
  41. public IKeyFrameControl
  42. {
  43. BEGIN_COM_MAP(CStreamVideoRecv)
  44. COM_INTERFACE_ENTRY(IKeyFrameControl)
  45. COM_INTERFACE_ENTRY_CHAIN(CH323MSPStream)
  46. END_COM_MAP()
  47. public:
  48. CStreamVideoRecv();
  49. ~CStreamVideoRecv();
  50. STDMETHOD (SC_Start) (BOOL fRequestedByApplication);
  51. STDMETHOD (SC_Pause) ();
  52. STDMETHOD (SC_Stop) (BOOL fRequestedByApplication);
  53. HRESULT ShutDown();
  54. //
  55. // ITFormatControl
  56. //
  57. STDMETHOD (GetCurrentFormat) (
  58. OUT AM_MEDIA_TYPE **ppMediaType
  59. );
  60. //
  61. // IKeyFrameControl methods
  62. //
  63. STDMETHOD (UpdatePicture)();
  64. STDMETHOD (PeriodicUpdatePicture) (
  65. IN BOOL fEnable,
  66. IN DWORD dwInterval
  67. );
  68. //
  69. // ITStreamQualityControl methods
  70. //
  71. STDMETHOD (Set) (
  72. IN StreamQualityProperty Property,
  73. IN long lValue,
  74. IN TAPIControlFlags lFlags
  75. );
  76. //
  77. //IInnerStreamQualityControl methods
  78. //
  79. STDMETHOD (GetRange) (
  80. IN InnerStreamQualityProperty property,
  81. OUT LONG *plMin,
  82. OUT LONG *plMax,
  83. OUT LONG *plSteppingDelta,
  84. OUT LONG *plDefault,
  85. OUT TAPIControlFlags *plFlags
  86. );
  87. STDMETHOD (Get) (
  88. IN InnerStreamQualityProperty property,
  89. OUT LONG *plValue,
  90. OUT TAPIControlFlags *plFlags
  91. );
  92. protected:
  93. HRESULT SetUpInternalFilters(
  94. IN IPin * pVideoInputPin,
  95. IN BOOL fDirectRTP
  96. );
  97. HRESULT ConnectTerminal(
  98. IN ITTerminal * pITTerminal
  99. );
  100. HRESULT DisconnectTerminal(
  101. IN ITTerminal * pITTerminal
  102. );
  103. HRESULT InitializeH245CapabilityTable();
  104. HRESULT ReCreateIFrameTimer(
  105. IN PERIODICIFRAMEMODE mode,
  106. IN DWORD dwInterval
  107. );
  108. static VOID CALLBACK TimerCallback(
  109. IN PVOID lpContext,
  110. IN BOOLEAN TimerOrWaitFired
  111. );
  112. static DWORD CALLBACK IFrameCallback(
  113. IN PVOID lpContext
  114. );
  115. protected:
  116. IBaseFilter * m_pDecoderFilter;
  117. IBitrateControl * m_pRenderBitrateControl;
  118. IFrameRateControl * m_pRenderFrameRateControl;
  119. // members for IKeyFrameControl interface.
  120. PERIODICIFRAMEMODE m_PeriodicIFrameMode;
  121. DWORD m_dwIFrameInterval;
  122. DWORD m_dwLastIFrameRequestedTime;
  123. DWORD m_dwIFramePending;
  124. HANDLE m_hTimerQueue;
  125. HANDLE m_hIFrameTimer;
  126. };
  127. class ATL_NO_VTABLE CSubStreamVideoPreview;
  128. class CStreamVideoSend :
  129. public CH323MSPStream,
  130. public IVidEncChannelControl,
  131. public IDispatchImpl<ITSubStreamControl, &IID_ITSubStreamControl, &LIBID_TAPI3Lib>
  132. {
  133. BEGIN_COM_MAP(CStreamVideoSend)
  134. COM_INTERFACE_ENTRY(ITSubStreamControl)
  135. COM_INTERFACE_ENTRY(IVidEncChannelControl)
  136. COM_INTERFACE_ENTRY_CHAIN(CH323MSPStream)
  137. END_COM_MAP()
  138. public:
  139. CStreamVideoSend();
  140. ~CStreamVideoSend();
  141. HRESULT ShutDown ();
  142. STDMETHOD (SC_Start) (BOOL fRequestedByApplication);
  143. //
  144. // ITSubStreamControl methods
  145. //
  146. STDMETHOD (CreateSubStream) (
  147. IN OUT ITSubStream ** ppSubStream
  148. );
  149. STDMETHOD (RemoveSubStream) (
  150. IN ITSubStream * pSubStream
  151. );
  152. STDMETHOD (EnumerateSubStreams) (
  153. OUT IEnumSubStream ** ppEnumSubStream
  154. );
  155. STDMETHOD (get_SubStreams) (
  156. OUT VARIANT * pSubStreams
  157. );
  158. //
  159. // ITFormatControl
  160. //
  161. STDMETHOD (GetCurrentFormat) (
  162. OUT AM_MEDIA_TYPE **ppMediaType
  163. );
  164. //
  165. //IInnerStreamQualityControl methods
  166. //
  167. STDMETHOD (GetRange) (
  168. IN InnerStreamQualityProperty property,
  169. OUT LONG *plMin,
  170. OUT LONG *plMax,
  171. OUT LONG *plSteppingDelta,
  172. OUT LONG *plDefault,
  173. OUT TAPIControlFlags *plFlags
  174. );
  175. STDMETHOD (Get) (
  176. IN InnerStreamQualityProperty property,
  177. OUT LONG *plValue,
  178. OUT TAPIControlFlags *plFlags
  179. );
  180. STDMETHOD (Set) (
  181. IN InnerStreamQualityProperty property,
  182. IN LONG lValue,
  183. IN TAPIControlFlags lFlags
  184. );
  185. //
  186. //IVidEncChannelControl methods
  187. //
  188. STDMETHOD (VideoFastUpdatePicture)(VOID);
  189. STDMETHOD (VideoFastUpdateGOB)(
  190. IN DWORD dwFirstGOB,
  191. IN DWORD dwNumberOfGOBs
  192. );
  193. STDMETHOD (VideoFastUpdateMB)(
  194. IN DWORD dwFirstGOB,
  195. IN DWORD dwFirstMB,
  196. IN DWORD dwNumberOfMBs
  197. );
  198. STDMETHOD (VideoSendSyncEveryGOB)(
  199. IN BOOL fEnable
  200. );
  201. STDMETHOD (VideoNotDecodedMBs)(
  202. IN DWORD dwFirstMB,
  203. IN DWORD dwNumberOfMBs,
  204. IN DWORD dwTemporalReference
  205. );
  206. STDMETHOD (VideoEncTemporalSpatialTradeoff)(
  207. IN USHORT uTSValue
  208. );
  209. public:
  210. HRESULT GetPreviewTerminal(
  211. OUT ITTerminal ** ppTerminal
  212. );
  213. HRESULT GetPreviewPin(
  214. OUT IPin ** ppPin
  215. );
  216. protected:
  217. HRESULT CheckTerminalTypeAndDirection(
  218. IN ITTerminal * pTerminal
  219. );
  220. HRESULT GetVideoCapturePins(
  221. IN ITTerminalControl* pTerminal,
  222. OUT BOOL *pfDirectRTP
  223. );
  224. HRESULT ConnectCaptureTerminal(
  225. IN ITTerminal * pITTerminal
  226. );
  227. HRESULT ConnectPreviewTerminal(
  228. IN ITTerminal * pITTerminal
  229. );
  230. HRESULT ConnectTerminal(
  231. IN ITTerminal * pITTerminal
  232. );
  233. HRESULT DisconnectTerminal(
  234. IN ITTerminal * pITTerminal
  235. );
  236. HRESULT CreateSendFilters(
  237. IN IPin *pCapturePin,
  238. IN IPin *pRTPPin,
  239. IN BOOL fDirectRTP
  240. );
  241. HRESULT ConnectRTPFilter(
  242. IN IGraphBuilder *pIGraphBuilder,
  243. IN IPin *pCapturePin,
  244. IN IPin *pRTPPin,
  245. IN IBaseFilter *pRTPFilter
  246. );
  247. HRESULT ConnectPreview(
  248. IN IPin *pPreviewInputPin
  249. );
  250. HRESULT FindPreviewInputPin(
  251. IN ITTerminalControl* pTerminal,
  252. OUT IPin ** ppIpin
  253. );
  254. HRESULT GetPreviewSubStream(
  255. OUT ITSubStream ** ppITSubStream
  256. );
  257. void CleanupCachedInterface();
  258. protected:
  259. ITSubStream * m_pPreviewSubStream;
  260. ITTerminal * m_pCaptureTerminal;
  261. ITTerminal * m_pPreviewTerminal;
  262. BOOL m_fPreviewConnected;
  263. IBaseFilter * m_pCaptureFilter;
  264. IPin * m_pCapturePin;
  265. IFrameRateControl * m_pCaptureFrameRateControl;
  266. IBitrateControl * m_pCaptureBitrateControl;
  267. IPin * m_pPreviewPin;
  268. IFrameRateControl * m_pPreviewFrameRateControl;
  269. IPin * m_pRTPPin;
  270. // this filter is used to answer the H245 questions when the terminal
  271. // can't answer them. This is a hack to support legacy terminals. The
  272. // app needs to select the right format to make it work.
  273. IBaseFilter * m_pEncoder;
  274. };
  275. class ATL_NO_VTABLE CSubStreamVideoPreview :
  276. public CComObjectRootEx<CComMultiThreadModelNoCS>,
  277. public ITFormatControl,
  278. public IDispatchImpl<ITSubStream, &IID_ITSubStream, &LIBID_TAPI3Lib>
  279. {
  280. public:
  281. BEGIN_COM_MAP(CSubStreamVideoPreview)
  282. COM_INTERFACE_ENTRY(IDispatch)
  283. COM_INTERFACE_ENTRY(ITSubStream)
  284. COM_INTERFACE_ENTRY(ITFormatControl)
  285. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  286. END_COM_MAP()
  287. DECLARE_GET_CONTROLLING_UNKNOWN()
  288. CSubStreamVideoPreview();
  289. // methods of the CComObject
  290. void FinalRelease();
  291. // ITSubStream methods, called by the app.
  292. STDMETHOD (SelectTerminal) (
  293. IN ITTerminal * pTerminal
  294. );
  295. STDMETHOD (UnselectTerminal) (
  296. IN ITTerminal * pTerminal
  297. );
  298. STDMETHOD (EnumerateTerminals) (
  299. OUT IEnumTerminal ** ppEnumTerminal
  300. );
  301. STDMETHOD (get_Terminals) (
  302. OUT VARIANT * pTerminals
  303. );
  304. STDMETHOD (get_Stream) (
  305. OUT ITStream ** ppITStream
  306. );
  307. STDMETHOD (StartSubStream) ();
  308. STDMETHOD (PauseSubStream) ();
  309. STDMETHOD (StopSubStream) ();
  310. //
  311. // ITFormatControl
  312. //
  313. STDMETHOD (GetCurrentFormat) (
  314. OUT AM_MEDIA_TYPE **ppMediaType
  315. );
  316. STDMETHOD (ReleaseFormat) (
  317. IN AM_MEDIA_TYPE *pMediaType
  318. );
  319. STDMETHOD (GetNumberOfCapabilities) (
  320. OUT DWORD *pdwCount
  321. );
  322. STDMETHOD (GetStreamCaps) (
  323. IN DWORD dwIndex,
  324. OUT AM_MEDIA_TYPE **ppMediaType,
  325. OUT TAPI_STREAM_CONFIG_CAPS *pStreamConfigCaps,
  326. OUT BOOL *pfEnabled
  327. );
  328. STDMETHOD (ReOrderCapabilities) (
  329. IN DWORD *pdwIndices,
  330. IN BOOL *pfEnabled,
  331. IN BOOL *pfPublicize,
  332. IN DWORD dwNumIndices
  333. );
  334. // methods called by the stream object.
  335. virtual HRESULT Init(
  336. IN CStreamVideoSend * pStream
  337. );
  338. protected:
  339. // Pointer to the free threaded marshaler.
  340. IUnknown * m_pFTM;
  341. CStreamVideoSend * m_pStream;
  342. };
  343. #endif