home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / devtools / files / borland_ccompiler55.exe / Include / mspterm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-27  |  8.1 KB  |  251 lines

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