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.

280 lines
6.4 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. MSPStrm.h
  5. Abstract:
  6. Definitions for CMSPStream class.
  7. --*/
  8. #ifndef _MSPSTRM_H_
  9. #define _MSPSTRM_H_
  10. /*++
  11. Class Description:
  12. Represents a stream in a call.
  13. --*/
  14. #define STRM_INITIAL 0x00000000
  15. #define STRM_TERMINALSELECTED 0x00000001
  16. #define STRM_CONFIGURED 0x00000002
  17. #define STRM_RUNNING 0x00000004
  18. #define STRM_PAUSED 0x00000008
  19. #define STRM_STOPPED 0x00000010
  20. class CMSPStream;
  21. class ATL_NO_VTABLE CPTEventSink :
  22. public CComObjectRootEx<CComMultiThreadModel>,
  23. public ITPluggableTerminalEventSink
  24. {
  25. public:
  26. CPTEventSink();
  27. ~CPTEventSink();
  28. BEGIN_COM_MAP( CPTEventSink )
  29. COM_INTERFACE_ENTRY( ITPluggableTerminalEventSink )
  30. END_COM_MAP()
  31. public:
  32. // --- ITDTEventSink ---
  33. STDMETHOD(FireEvent)(
  34. /* in */ const MSP_EVENT_INFO *pMspEventInfo
  35. );
  36. public:
  37. //
  38. // set the stream which will be processing our events
  39. //
  40. // this method is called by the stream when it creates and initializes
  41. // the sink object, and also when the stream is going away and want to
  42. // tell us that it is no longer available to process our events.
  43. //
  44. HRESULT SetSinkStream( CMSPStream *pStream );
  45. private:
  46. //
  47. // a nested structure that is used to pass event and stream to the
  48. // asynchronous event processing routine.
  49. //
  50. struct AsyncEventStruct
  51. {
  52. //
  53. // pointer to the stream on which to fire event
  54. //
  55. CMSPStream *pMSPStream;
  56. //
  57. // pointer to the event item to be processed
  58. //
  59. MSPEVENTITEM *pEventItem;
  60. //
  61. // as a public service, initialize structure's data members
  62. //
  63. AsyncEventStruct()
  64. :pMSPStream(NULL),
  65. pEventItem(NULL)
  66. {
  67. LOG((MSP_TRACE, "AsyncEventStruct::AsyncEventStruct[%p]", this));
  68. }
  69. //
  70. // as a safety measure, set data members to NULL's in destructor
  71. // to make sure no one attemopts to use them after the strcuture is
  72. // gone.
  73. //
  74. // note: we don't free any data members here -- that's responsibility
  75. // of the structure's client
  76. //
  77. ~AsyncEventStruct()
  78. {
  79. pMSPStream = NULL;
  80. pEventItem = NULL;
  81. LOG((MSP_TRACE, "AsyncEventStruct::~AsyncEventStruct[%p]", this));
  82. }
  83. }; // AsyncEventStruct
  84. //
  85. // the callback function that is submitted to thread pool api for async
  86. // event processing. The argument is the event structure containing stream
  87. // and the actual event
  88. //
  89. static DWORD WINAPI FireEventCallBack(LPVOID pEventStructure);
  90. private:
  91. CMSPStream* m_pMSPStream;
  92. };
  93. class ATL_NO_VTABLE CMSPStream :
  94. public CComObjectRootEx<CComMultiThreadModelNoCS>,
  95. public IDispatchImpl<ITStream, &IID_ITStream, &LIBID_TAPI3Lib>
  96. {
  97. public:
  98. BEGIN_COM_MAP(CMSPStream)
  99. COM_INTERFACE_ENTRY(IDispatch)
  100. COM_INTERFACE_ENTRY(ITStream)
  101. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  102. END_COM_MAP()
  103. DECLARE_GET_CONTROLLING_UNKNOWN()
  104. CMSPStream();
  105. ~CMSPStream();
  106. // methods of the CComObject
  107. virtual void FinalRelease();
  108. // ITStream methods, called by the app.
  109. STDMETHOD (get_MediaType) (
  110. OUT long * plMediaType
  111. );
  112. STDMETHOD (get_Direction) (
  113. OUT TERMINAL_DIRECTION * pTerminalDirection
  114. );
  115. STDMETHOD (get_Name) (
  116. OUT BSTR * ppName
  117. ) = 0;
  118. STDMETHOD (SelectTerminal) (
  119. IN ITTerminal * pTerminal
  120. );
  121. STDMETHOD (UnselectTerminal) (
  122. IN ITTerminal * pTerminal
  123. );
  124. STDMETHOD (EnumerateTerminals) (
  125. OUT IEnumTerminal ** ppEnumTerminal
  126. );
  127. STDMETHOD (get_Terminals) (
  128. OUT VARIANT * pTerminals
  129. );
  130. STDMETHOD (StartStream) ();
  131. STDMETHOD (PauseStream) ();
  132. STDMETHOD (StopStream) ();
  133. // methods called by the MSPCall object.
  134. virtual HRESULT Init(
  135. IN HANDLE hAddress,
  136. IN CMSPCallBase * pMSPCall,
  137. IN IMediaEvent * pGraph,
  138. IN DWORD dwMediaType,
  139. IN TERMINAL_DIRECTION Direction
  140. );
  141. virtual HRESULT ShutDown();
  142. virtual HRESULT GetState(
  143. OUT DWORD * pdwStatus
  144. ) { return E_NOTIMPL; }
  145. virtual HRESULT HandleTSPData(
  146. IN BYTE * pData,
  147. IN DWORD dwSize
  148. );
  149. virtual HRESULT ProcessGraphEvent(
  150. IN long lEventCode,
  151. IN LONG_PTR lParam1,
  152. IN LONG_PTR lParam2
  153. );
  154. protected:
  155. // --- Helper functions ---
  156. HRESULT RegisterPluggableTerminalEventSink(
  157. /*[in]*/ ITTerminal* pTerminal
  158. );
  159. HRESULT UnregisterPluggableTerminalEventSink(
  160. /*[in]*/ ITTerminal* pTerminal
  161. );
  162. HRESULT ReleaseSink();
  163. public:
  164. //
  165. // this method is called by CPTEventSink when it has an event for us to
  166. // process
  167. //
  168. HRESULT HandleSinkEvent(MSPEVENTITEM *pEventItem);
  169. protected:
  170. // Pointer to the free threaded marshaler.
  171. IUnknown * m_pFTM;
  172. // The current state of the stream.
  173. DWORD m_dwState;
  174. // The media type of this stream. Audio, video, or others.
  175. DWORD m_dwMediaType;
  176. // The direction of this stream. Incoming or outgoing.
  177. TERMINAL_DIRECTION m_Direction;
  178. // The address on which this stream is being used.
  179. HANDLE m_hAddress;
  180. // The reference to the call object.
  181. CMSPCallBase * m_pMSPCall;
  182. // The pointers to the graph object interfaces.
  183. IGraphBuilder * m_pIGraphBuilder;
  184. IMediaControl * m_pIMediaControl;
  185. // The list of stream objects in the call.
  186. CMSPArray <ITTerminal *> m_Terminals;
  187. // The lock that protects the stream object. The stream object
  188. // should never acquire the lock and then call a MSPCall method
  189. // that might lock.
  190. CMSPCritSection m_lock;
  191. // The Event Sink for pluggable terminals
  192. ITPluggableTerminalEventSink* m_pPTEventSink;
  193. };
  194. #endif // __MSPSTRM_H_