home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / C_C++ / BorlandCompiler / freecommandLinetools.exe / Include / mspcall.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-27  |  6.5 KB  |  253 lines

  1. /*++
  2.  
  3. Copyright (c) 1998-1999 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     MSPCall.h
  8.  
  9. Abstract:
  10.  
  11.     Definitions for CMSPCall class.
  12.  
  13. --*/
  14.  
  15. #ifndef __MSPCALL_H_
  16. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  17. #define __MSPCALL_H_
  18.  
  19.  
  20. /*++
  21.  
  22. Class Description:
  23.  
  24.     Represents a active call that has media streams.
  25.  
  26. --*/
  27.  
  28. class ATL_NO_VTABLE CMSPCallBase : 
  29.     public CComObjectRootEx<CComMultiThreadModelNoCS>,
  30.     public IDispatchImpl<ITStreamControl, &IID_ITStreamControl, &LIBID_TAPI3Lib>
  31. {
  32. public:
  33.  
  34. // No need for free thread marshaling, because the MSP call object is
  35. // always aggregated by the TAPI3 call object.
  36.  
  37. DECLARE_POLY_AGGREGATABLE(CMSPCallBase)
  38.  
  39. BEGIN_COM_MAP(CMSPCallBase)
  40.     COM_INTERFACE_ENTRY(IDispatch)
  41.     COM_INTERFACE_ENTRY(ITStreamControl)
  42. END_COM_MAP()
  43.  
  44. DECLARE_GET_CONTROLLING_UNKNOWN()
  45.  
  46. DECLARE_VQI()
  47.  
  48.     CMSPCallBase();
  49.     
  50.     virtual ~CMSPCallBase();
  51.  
  52. //
  53. // Private addref and release for the MSP call. See Platform SDK documentation.
  54. //
  55.     virtual ULONG MSPCallAddRef  (void) = 0;
  56.     virtual ULONG MSPCallRelease (void) = 0;
  57.  
  58. // ITStreamControl methods, called by the app.
  59.     STDMETHOD (CreateStream) (
  60.         IN      long                lMediaType,
  61.         IN      TERMINAL_DIRECTION  Direction,
  62.         IN OUT  ITStream **         ppStream
  63.         );
  64.     
  65.     STDMETHOD (EnumerateStreams) (
  66.         OUT     IEnumStream **      ppEnumStream
  67.         );
  68.  
  69.     STDMETHOD (RemoveStream) (
  70.         IN      ITStream *          pStream
  71.         ) = 0;                      
  72.  
  73.     STDMETHOD (get_Streams) (
  74.         OUT     VARIANT *           pStreams
  75.         );
  76.  
  77. // methods called by the MSPAddress object.
  78.     virtual HRESULT Init(
  79.         IN      CMSPAddress *       pMSPAddress,
  80.         IN      MSP_HANDLE          htCall,
  81.         IN      DWORD               dwReserved,
  82.         IN      DWORD               dwMediaType
  83.         ) = 0;
  84.  
  85.     virtual HRESULT ShutDown(
  86.         ) = 0;
  87.  
  88.     virtual HRESULT ReceiveTSPCallData(
  89.         IN      PBYTE               pBuffer,
  90.         IN      DWORD               dwSize
  91.         );
  92.  
  93. // methods called by the MSPstream object.
  94.     HRESULT HandleStreamEvent(
  95.         IN      MSPEVENTITEM *      EventItem
  96.         ) const;
  97.  
  98. protected:
  99.     virtual HRESULT InternalCreateStream(
  100.         IN      DWORD               dwMediaType,
  101.         IN      TERMINAL_DIRECTION  Direction,
  102.         IN OUT  ITStream **         ppStream
  103.         ) = 0;
  104.     
  105.     virtual HRESULT CreateStreamObject(
  106.         IN      DWORD               dwMediaType,
  107.         IN      TERMINAL_DIRECTION  Direction,
  108.         IN      IMediaEvent *       pGraph,
  109.         IN      ITStream **         ppStream
  110.         ) = 0;
  111.  
  112. protected:
  113.  
  114.     // The pointer to the address object. It is used to post events to TAPI3. 
  115.     // It also carries a refcount so that the address will not go away while 
  116.     // the call is still alive.
  117.     CMSPAddress*                m_pMSPAddress;
  118.  
  119.     // The handle to the call in TAPI3. Used in firing call events.
  120.     MSP_HANDLE                  m_htCall;
  121.  
  122.     // The media type of this call. It is a bitmask of media types.
  123.     DWORD                       m_dwMediaType;
  124.  
  125.     // The list of stream objects in the call.
  126.     CMSPArray <ITStream *>      m_Streams;
  127.  
  128.     // The lock that protects the stream lists. 
  129.     CMSPCritSection             m_lock;
  130. };
  131.  
  132.  
  133. /*++
  134.  
  135. Class Description:
  136.  
  137.     Represents a call that uses one DirectShow filter graph for each stream.
  138.  
  139. --*/
  140.  
  141. class ATL_NO_VTABLE CMSPCallMultiGraph : public CMSPCallBase
  142. {
  143.     typedef struct 
  144.     {
  145.         CMSPCallMultiGraph *    pMSPCall;
  146.         ITStream *              pITStream;
  147.         IMediaEvent *           pIMediaEvent;
  148.  
  149.     } MSPSTREAMCONTEXT, *PMSPSTREAMCONTEXT;
  150.  
  151.     typedef struct _THREADPOOLWAITBLOCK
  152.     {
  153.         HANDLE              hWaitHandle;
  154.         MSPSTREAMCONTEXT *  pContext;
  155.  
  156.         BOOL operator ==(struct _THREADPOOLWAITBLOCK &t)
  157.         {
  158.             return ((hWaitHandle == t.hWaitHandle)
  159.                 && (pContext == t.pContext));
  160.         }
  161.  
  162.     } THREADPOOLWAITBLOCK, *PTHREADPOOLWAITBLOCK;
  163.  
  164. public:
  165.     CMSPCallMultiGraph();
  166.     
  167.     virtual ~CMSPCallMultiGraph();
  168.  
  169. // ITStreamControl methods (overriden)
  170.     
  171.     STDMETHOD (RemoveStream) (
  172.         IN      ITStream *          ppStream
  173.         );                      
  174.  
  175. // methods called by the MSPAddress object. (overriden)
  176.     HRESULT Init(
  177.         IN      CMSPAddress *       pMSPAddress,
  178.         IN      MSP_HANDLE          htCall,
  179.         IN      DWORD               dwReserved,
  180.         IN      DWORD               dwMediaType
  181.         );
  182.  
  183.     HRESULT ShutDown(
  184.         );
  185.  
  186. // methods called by the thread pool
  187.     static VOID NTAPI DispatchGraphEvent(
  188.         IN      VOID *              pContext,
  189.         IN      BOOLEAN             bFlag
  190.         );
  191.  
  192.     virtual VOID HandleGraphEvent(
  193.         IN      MSPSTREAMCONTEXT *  pContext
  194.     );
  195.  
  196.     virtual HRESULT ProcessGraphEvent(
  197.         IN      ITStream *          pITStream,
  198.         IN      long                lEventCode,
  199.         IN      long                lParam1,
  200.         IN      long                lParam2
  201.     );
  202.  
  203. // methods of the CComObject
  204.     void FinalRelease();
  205.  
  206. protected:
  207. // helper function:
  208.     HRESULT RegisterWaitEvent(
  209.         IN      IMediaEvent *       pIMediaEvent,
  210.         IN      ITStream *           pITStream
  211.         );
  212.  
  213.     HRESULT UnregisterWaitEvent(
  214.         IN      int                 index
  215.         );
  216.  
  217.     virtual HRESULT InternalCreateStream(
  218.         IN      DWORD               dwMediaType,
  219.         IN      TERMINAL_DIRECTION  Direction,
  220.         IN OUT  ITStream **         ppStream
  221.         );
  222.     
  223. protected:
  224.  
  225.     // The wait blocks store the information about the wait registered to
  226.     // the thread pool. It includes the wait handles returned by the 
  227.     // RegisterWaitForSingleObject() call and a pointer to the context 
  228.     // structure. Each block in the array is for a graph in one of the 
  229.     // stream objects. The offset of a block in this array is the same 
  230.     // as the offset of the stream that owns the graph.
  231.     CMSPArray <THREADPOOLWAITBLOCK>      m_ThreadPoolWaitBlocks;
  232.  
  233. };
  234.  
  235. //
  236. // Event handling definitions.
  237. //
  238.  
  239. typedef struct
  240. {
  241.     CMSPCallMultiGraph * pCall;
  242.     ITStream           * pITStream;
  243.     long                 lEventCode;
  244.     long                 lParam1;
  245.     long                 lParam2;
  246.  
  247. } MULTI_GRAPH_EVENT_DATA;
  248.  
  249. DWORD WINAPI AsyncMultiGraphEvent(LPVOID pVoid);
  250.  
  251. #pragma option pop /*P_O_Pop*/
  252. #endif // __MSPCALL_H_
  253.