Leaked source code of windows server 2003
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.

303 lines
8.0 KiB

  1. // FileRecordingTerminal.h: interface for the CFileRecordingTerminal class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_FILERECORDINGTERMINAL_H__A8DDD920_08D7_4CE8_AB7F_9AD202D4E6B0__INCLUDED_)
  5. #define AFX_FILERECORDINGTERMINAL_H__A8DDD920_08D7_4CE8_AB7F_9AD202D4E6B0__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "MultiTrackTerminal.h"
  10. #include "..\terminals\Storage\RecordUnit.h"
  11. #include "..\termmgr\resource.h"
  12. #define MAX_MEDIA_TRACKS (16)
  13. extern const CLSID CLSID_FileRecordingTerminalCOMClass;
  14. /////////////////////////////////////////////////////////////////
  15. // Intermediate classes used for DISPID encoding
  16. template <class T>
  17. class ITMediaRecordVtbl : public ITMediaRecord
  18. {
  19. };
  20. template <class T>
  21. class ITTerminalVtblFR : public ITTerminal
  22. {
  23. };
  24. template <class T>
  25. class ITMediaControlVtblFR : public ITMediaControl
  26. {
  27. };
  28. class CFileRecordingTerminal :
  29. public CComCoClass<CFileRecordingTerminal, &CLSID_FileRecordingTerminal>,
  30. public IDispatchImpl<ITMediaRecordVtbl<CFileRecordingTerminal>, &IID_ITMediaRecord, &LIBID_TAPI3Lib>,
  31. public IDispatchImpl<ITMediaControlVtblFR<CFileRecordingTerminal>, &IID_ITMediaControl, &LIBID_TAPI3Lib>,
  32. public IDispatchImpl<ITTerminalVtblFR<CFileRecordingTerminal>, &IID_ITTerminal, &LIBID_TAPI3Lib>,
  33. public ITPluggableTerminalInitialization,
  34. public CMSPObjectSafetyImpl,
  35. public CMultiTrackTerminal
  36. {
  37. public:
  38. DECLARE_REGISTRY_RESOURCEID(IDR_FILE_RECORDING)
  39. BEGIN_COM_MAP(CFileRecordingTerminal)
  40. COM_INTERFACE_ENTRY2(IDispatch, ITTerminal)
  41. COM_INTERFACE_ENTRY(ITMediaRecord)
  42. COM_INTERFACE_ENTRY(ITMediaControl)
  43. COM_INTERFACE_ENTRY(ITTerminal)
  44. COM_INTERFACE_ENTRY(ITPluggableTerminalInitialization)
  45. COM_INTERFACE_ENTRY(IObjectSafety)
  46. COM_INTERFACE_ENTRY_CHAIN(CMultiTrackTerminal)
  47. END_COM_MAP()
  48. //
  49. // ITTerminal methods
  50. //
  51. STDMETHOD(get_TerminalClass)(OUT BSTR *pbstrTerminalClass);
  52. STDMETHOD(get_TerminalType) (OUT TERMINAL_TYPE *pTerminalType);
  53. STDMETHOD(get_State) (OUT TERMINAL_STATE *pTerminalState);
  54. STDMETHOD(get_Name) (OUT BSTR *pVal);
  55. STDMETHOD(get_MediaType) (OUT long * plMediaType);
  56. STDMETHOD(get_Direction) (OUT TERMINAL_DIRECTION *pDirection);
  57. //
  58. // ITMediaRecord methods
  59. //
  60. virtual HRESULT STDMETHODCALLTYPE put_FileName(
  61. IN BSTR bstrFileName
  62. );
  63. virtual HRESULT STDMETHODCALLTYPE get_FileName(
  64. OUT BSTR *pbstrFileName);
  65. //
  66. // ITPluggableTerminalInitialization methods
  67. //
  68. virtual HRESULT STDMETHODCALLTYPE InitializeDynamic (
  69. IN IID iidTerminalClass,
  70. IN DWORD dwMediaType,
  71. IN TERMINAL_DIRECTION Direction,
  72. IN MSP_HANDLE htAddress
  73. );
  74. //
  75. // ITMultiTrackTerminal methods
  76. //
  77. virtual HRESULT STDMETHODCALLTYPE CreateTrackTerminal(
  78. IN long MediaType,
  79. IN TERMINAL_DIRECTION TerminalDirection,
  80. OUT ITTerminal ** ppTerminal
  81. );
  82. virtual HRESULT STDMETHODCALLTYPE RemoveTrackTerminal(
  83. IN ITTerminal * pTrackTerminalToRemove
  84. );
  85. //
  86. // ITMediaControl methods
  87. //
  88. virtual HRESULT STDMETHODCALLTYPE Start( void);
  89. virtual HRESULT STDMETHODCALLTYPE Stop( void);
  90. virtual HRESULT STDMETHODCALLTYPE Pause( void);
  91. virtual HRESULT STDMETHODCALLTYPE get_MediaState(
  92. OUT TERMINAL_MEDIA_STATE *pFileTerminalState);
  93. //
  94. // IDispatch methods
  95. //
  96. STDMETHOD(GetIDsOfNames)(REFIID riid,
  97. LPOLESTR* rgszNames,
  98. UINT cNames,
  99. LCID lcid,
  100. DISPID* rgdispid
  101. );
  102. STDMETHOD(Invoke)(DISPID dispidMember,
  103. REFIID riid,
  104. LCID lcid,
  105. WORD wFlags,
  106. DISPPARAMS* pdispparams,
  107. VARIANT* pvarResult,
  108. EXCEPINFO* pexcepinfo,
  109. UINT* puArgErr
  110. );
  111. public:
  112. //
  113. // overriding IObjectSafety methods. we are only safe if properly
  114. // initialized by terminal manager, so these methods will fail if this
  115. // is not the case.
  116. //
  117. STDMETHOD(SetInterfaceSafetyOptions)(REFIID riid,
  118. DWORD dwOptionSetMask,
  119. DWORD dwEnabledOptions);
  120. STDMETHOD(GetInterfaceSafetyOptions)(REFIID riid,
  121. DWORD *pdwSupportedOptions,
  122. DWORD *pdwEnabledOptions);
  123. public:
  124. CFileRecordingTerminal();
  125. virtual ~CFileRecordingTerminal();
  126. //
  127. // cleanup before destructor to make sure cleanup is done by the time the
  128. // derived ccomobject is going away.
  129. //
  130. void FinalRelease();
  131. //
  132. // the derived class, CComObject, implements these. Here declare as pure
  133. // virtual so we can refer to these methods from ChildRelease and
  134. // ChildAddRef()
  135. //
  136. virtual ULONG STDMETHODCALLTYPE AddRef() = 0;
  137. virtual ULONG STDMETHODCALLTYPE Release() = 0;
  138. //
  139. // these methods are called by the track terminals when they need to notify
  140. // us when their refcount changes. the implementation is in the Multitrack class
  141. // but we also need this here, so we can prevent calling base class if
  142. // destructor are being executed. otherwise, CComObject's addref and release
  143. // might be called from ~CRecordingTerminal, at which point CComObject is
  144. // already gone, which is not good.
  145. //
  146. virtual void ChildAddRef();
  147. virtual void ChildRelease();
  148. //
  149. // each track calls this method after it has been selected
  150. //
  151. HRESULT OnFilterConnected(CBRenderFilter *pRenderingFilter);
  152. //
  153. // this function is called whevever there is an event from the recording filter graph
  154. //
  155. HRESULT HandleFilterGraphEvent(long lEventCode, ULONG_PTR lParam1, ULONG_PTR lParam2);
  156. private:
  157. //
  158. // a helper method that removes all the tracks. not thread safe.
  159. //
  160. HRESULT ShutdownTracks();
  161. //
  162. // a helper method that fires events on one of the tracks
  163. //
  164. HRESULT FireEvent(
  165. TERMINAL_MEDIA_STATE tmsState,
  166. FT_STATE_EVENT_CAUSE ftecEventCause,
  167. HRESULT hrErrorCode
  168. );
  169. //
  170. // a helper method that causes a state transition
  171. //
  172. HRESULT DoStateTransition(TERMINAL_MEDIA_STATE tmsDesiredState);
  173. private:
  174. //
  175. // storage used for recording
  176. //
  177. CRecordingUnit *m_pRecordingUnit;
  178. //
  179. // the name of the file that is currently playing
  180. //
  181. BSTR m_bstrFileName;
  182. //
  183. // current terminal state
  184. //
  185. TERMINAL_MEDIA_STATE m_enState;
  186. //
  187. // current terminal state (selected?)
  188. //
  189. BOOL m_TerminalInUse;
  190. //
  191. // address handle
  192. //
  193. MSP_HANDLE m_mspHAddress;
  194. //
  195. // this terminal should only be instantiated in the context of terminal
  196. // manager. the object will only be safe for scripting if it has been
  197. // InitializeDynamic'ed.
  198. //
  199. // this flag will be set when InitializeDynamic succeeds
  200. //
  201. BOOL m_bKnownSafeContext;
  202. //
  203. // this flag is set when the object is going away to prevent problems with
  204. // tracks notifying the parent of addref/release after CComObject's
  205. // desctructor completed
  206. //
  207. BOOL m_bInDestructor;
  208. };
  209. #endif // !defined(AFX_FILERECORDINGTERMINAL_H__A8DDD920_08D7_4CE8_AB7F_9AD202D4E6B0__INCLUDED_)