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.

258 lines
6.3 KiB

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