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.

293 lines
9.6 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. mspterm.h
  5. Abstract:
  6. Definitions for the CBaseTerminal and CSingleFilterTerminal classes.
  7. --*/
  8. #ifndef _MSPTERM_H_
  9. #define _MSPTERM_H_
  10. template <class T>
  11. class ITTerminalVtblBase : public ITTerminal
  12. {
  13. };
  14. /////////////////////////////////////////////////////////////////////////////
  15. /////////////////////////////////////////////////////////////////////////////
  16. //
  17. // CBaseTerminal
  18. //
  19. // This is the base terminal implementation. All terminals must derive
  20. // from this class.
  21. //
  22. /////////////////////////////////////////////////////////////////////////////
  23. /////////////////////////////////////////////////////////////////////////////
  24. class CBaseTerminal :
  25. virtual public CComObjectRootEx<CComMultiThreadModelNoCS>, // we have our own CS implementation
  26. public IDispatchImpl<ITTerminalVtblBase<CBaseTerminal>, &IID_ITTerminal, &LIBID_TAPI3Lib>,
  27. public ITTerminalControl
  28. {
  29. BEGIN_COM_MAP(CBaseTerminal)
  30. COM_INTERFACE_ENTRY(IDispatch)
  31. COM_INTERFACE_ENTRY(ITTerminal)
  32. COM_INTERFACE_ENTRY(ITTerminalControl)
  33. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  34. END_COM_MAP()
  35. DECLARE_VQI()
  36. DECLARE_GET_CONTROLLING_UNKNOWN()
  37. public:
  38. CBaseTerminal();
  39. virtual ~CBaseTerminal();
  40. // ITTerminal -- COM interface for use by MSP or application
  41. public:
  42. STDMETHOD(get_TerminalClass)(OUT BSTR *pVal);
  43. STDMETHOD(get_TerminalType) (OUT TERMINAL_TYPE *pVal);
  44. STDMETHOD(get_State) (OUT TERMINAL_STATE *pVal);
  45. STDMETHOD(get_Name) (OUT BSTR *pVal);
  46. STDMETHOD(get_MediaType) (OUT long * plMediaType);
  47. STDMETHOD(get_Direction) (OUT TERMINAL_DIRECTION *pDirection);
  48. public:
  49. // Public methods that the MSP implementation calls.
  50. virtual HRESULT Initialize (
  51. IN IID iidTerminalClass,
  52. IN DWORD dwMediaType,
  53. IN TERMINAL_DIRECTION Direction,
  54. IN MSP_HANDLE htAddress
  55. );
  56. public:
  57. // ITTerminalControl -- COM interface for use by MSP only
  58. // This has to be a COM interface rather than a set of public methods because
  59. // the MSP needs to be able to call them for dynamic terminals as well.
  60. //
  61. // We implement get_AddressHandle, ConnectTerminal and DisconnectTerminal
  62. // The derived classes must implement RunRenderFilter and
  63. // StopRenderFilter (implementation depends on # of filters)
  64. //
  65. STDMETHOD (get_AddressHandle) (
  66. OUT MSP_HANDLE * phtAddress
  67. );
  68. //
  69. // enters each of the internal filters into the filter graph
  70. // connects the internal filters together (if applicable)
  71. // and returns all the filters to be used as connection points
  72. //
  73. STDMETHOD (ConnectTerminal) (
  74. IN IGraphBuilder * pGraph,
  75. IN DWORD dwTerminalDirection,
  76. IN OUT DWORD * pdwNumPins,
  77. OUT IPin ** ppPins
  78. );
  79. //
  80. // CompleteConnectTerminal -- called after a successful ConnectTerminal
  81. // so that the terminal can do post-connection intitialization
  82. //
  83. STDMETHOD (CompleteConnectTerminal) (void);
  84. //
  85. // disconnects the internal filters from each other (if applicable)
  86. // and removes them from the filter graph (thus breaking connections to
  87. // the stream).
  88. // Filter graph parameter is used for validation, to make sure the terminal
  89. // is disconnected from the same graph that it was originally connected to.
  90. //
  91. STDMETHOD (DisconnectTerminal) (
  92. IN IGraphBuilder * pGraph,
  93. IN DWORD dwReserved
  94. );
  95. //
  96. // stops the rightmost render filter in the terminal
  97. // (needed for dynamic filter graphs)
  98. //
  99. STDMETHOD (RunRenderFilter) (void) = 0;
  100. //
  101. // stops the rightmost render filter in the terminal
  102. // (needed for dynamic filter graphs)
  103. //
  104. STDMETHOD (StopRenderFilter) (void) = 0;
  105. protected:
  106. // The lock that protects the data members.
  107. CMSPCritSection m_CritSec;
  108. public:
  109. TERMINAL_DIRECTION m_TerminalDirection;
  110. TERMINAL_TYPE m_TerminalType;
  111. TERMINAL_STATE m_TerminalState;
  112. TCHAR m_szName[MAX_PATH + 1];
  113. IID m_TerminalClassID;
  114. DWORD m_dwMediaType;
  115. MSP_HANDLE m_htAddress;
  116. // Pointer to the free threaded marshaler.
  117. IUnknown * m_pFTM;
  118. // stores the filter graph builder (derives from IFilterGraph)
  119. CComPtr<IGraphBuilder> m_pGraph;
  120. // The following functions are to be implemented by the derived terminals
  121. virtual HRESULT AddFiltersToGraph() = 0;
  122. // By default terminals do nothing for preconnect
  123. virtual HRESULT ConnectFilters() { return S_OK; }
  124. // Returns the number of pins that will be exposed by
  125. // GetExposedPins(). The implementation can use pGraph
  126. // to actually mess with filters in a graph if it needs to
  127. // do so in order to figure out how many pins it has, but normally
  128. // that's not the case.
  129. // Arguments are checked by the caller.
  130. virtual HRESULT GetNumExposedPins(
  131. IN IGraphBuilder * pGraph,
  132. OUT DWORD * pdwNumPins
  133. ) = 0;
  134. // Returns an array of pins that the stream can connect to.
  135. // Arguments are checked by the caller.
  136. virtual HRESULT GetExposedPins(
  137. OUT IPin ** ppPins
  138. ) = 0;
  139. virtual DWORD GetSupportedMediaTypes(void) = 0;
  140. virtual HRESULT RemoveFiltersFromGraph() = 0;
  141. // Do we support this media?
  142. BOOL MediaTypeSupported(long lMediaType);
  143. };
  144. /////////////////////////////////////////////////////////////////////////////
  145. /////////////////////////////////////////////////////////////////////////////
  146. // //
  147. // CSingleFilterTerminal //
  148. // //
  149. // This is a base class for a terminal with a single filter and pin. The //
  150. // terminal could be any direction or media type, and it could be static //
  151. // or dynamic. //
  152. // //
  153. /////////////////////////////////////////////////////////////////////////////
  154. /////////////////////////////////////////////////////////////////////////////
  155. class CSingleFilterTerminal :
  156. public CBaseTerminal
  157. {
  158. // If we add any additional interfaces to this class then
  159. // we must uncomment and expand the following.
  160. //
  161. // BEGIN_COM_MAP(CSingleFilterTerminal)
  162. // COM_INTERFACE_ENTRY_CHAIN(CBaseTerminal)
  163. // END_COM_MAP()
  164. public:
  165. // Implementation: We know we have a single filter.
  166. CComPtr<IPin> m_pIPin;
  167. CComPtr<IBaseFilter> m_pIFilter;
  168. public:
  169. // ITCoreTerminal
  170. // the rest of this interface is implemented by CBaseTerminal
  171. // stops the rightmost render filter in the terminal
  172. // (needed for dynamic filter graphs)
  173. STDMETHOD(RunRenderFilter)(void);
  174. // stops the rightmost render filter in the terminal
  175. // (needed for dynamic filter graphs)
  176. STDMETHOD(StopRenderFilter)(void);
  177. // CBaseTerminal overrides for non-COM methods
  178. // AddFiltersToGraph cannot be implemented here because of the various
  179. // hacks regarding their names
  180. virtual HRESULT GetNumExposedPins(
  181. IN IGraphBuilder * pGraph,
  182. OUT DWORD * pdwNumPins
  183. );
  184. virtual HRESULT GetExposedPins(
  185. OUT IPin ** ppPins
  186. );
  187. virtual HRESULT RemoveFiltersFromGraph();
  188. };
  189. /////////////////////////////////////////////////////////////////////////////
  190. /////////////////////////////////////////////////////////////////////////////
  191. // //
  192. // CSingleFilterStaticTerminal //
  193. // //
  194. // This is a base class for a static terminal with a single filter and //
  195. // pin. The terminal could be any direction or media type. //
  196. // //
  197. // //
  198. /////////////////////////////////////////////////////////////////////////////
  199. /////////////////////////////////////////////////////////////////////////////
  200. class CSingleFilterStaticTerminal :
  201. public CSingleFilterTerminal
  202. {
  203. // If we add any additional interfaces to this class then
  204. // we must uncomment and expand the following.
  205. //
  206. // BEGIN_COM_MAP(CSingleFilterStaticTerminal)
  207. // COM_INTERFACE_ENTRY_CHAIN(CSingleFilterTerminal)
  208. // END_COM_MAP()
  209. public:
  210. // public because CreateTerminal and CMSPAddress::UpdateTerminalListForPnp accesses it
  211. CComPtr<IMoniker> m_pMoniker;
  212. // this flag allows CMSPAddress::UpdateTerminalListForPnp to perform a mark and sweep
  213. // on the terminal list
  214. BOOL m_bMark;
  215. //
  216. // Compares this terminal's moniker to pMoniker, returns S_OK if they match, S_FALSE if they don't
  217. //
  218. virtual HRESULT CompareMoniker(
  219. IMoniker *pMoniker
  220. );
  221. };
  222. #endif // _MSPTERM_H_