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.

355 lines
9.3 KiB

  1. //
  2. // FPTerm.h
  3. //
  4. #ifndef __FPTERMINAL__
  5. #define __FPTERMINAL__
  6. #include "MultiTrackTerminal.h"
  7. #include "..\terminals\Storage\FPUnit.h"
  8. #include "fpbridge.h"
  9. extern const CLSID CLSID_FilePlaybackTerminalCOMClass;
  10. typedef enum
  11. {
  12. TCS_NONE = 0,
  13. TCS_TOBECREATED,
  14. TCS_CREATED
  15. } TRACK_CREATIONSTATE;
  16. typedef struct
  17. {
  18. TRACK_CREATIONSTATE CreationState;
  19. AM_MEDIA_TYPE* pMediaType;
  20. } TRACK_INFO;
  21. typedef enum
  22. {
  23. TRACK_AUDIO = 0,
  24. TRACK_VIDEO
  25. } TRACK_MEDIATYPE;
  26. //
  27. // FilePlayback Terminal
  28. // This is the class that implements the multitrack termnal
  29. //
  30. /////////////////////////////////////////////////////////////////
  31. // Intermediate classes used for DISPID encoding
  32. template <class T>
  33. class ITMediaPlaybackVtbl : public ITMediaPlayback
  34. {
  35. };
  36. template <class T>
  37. class ITTerminalVtbl : public ITTerminal
  38. {
  39. };
  40. template <class T>
  41. class ITMediaControlVtbl : public ITMediaControl
  42. {
  43. };
  44. //
  45. // FilePlayback Terminal
  46. // This is the class that implements the multitrack termnal
  47. //
  48. class CFPTerminal :
  49. public CComCoClass<CFPTerminal, &CLSID_FilePlaybackTerminal>,
  50. public IDispatchImpl<ITMediaPlaybackVtbl<CFPTerminal>, &IID_ITMediaPlayback, &LIBID_TAPI3Lib>,
  51. public IDispatchImpl<ITTerminalVtbl<CFPTerminal>, &IID_ITTerminal, &LIBID_TAPI3Lib>,
  52. public ITPluggableTerminalInitialization,
  53. public ITPluggableTerminalEventSinkRegistration,
  54. public IFPBridge,
  55. public IDispatchImpl<ITMediaControlVtbl<CFPTerminal>, &IID_ITMediaControl, &LIBID_TAPI3Lib>,
  56. public CMSPObjectSafetyImpl,
  57. public CMultiTrackTerminal
  58. {
  59. public:
  60. //
  61. // Constructor / Destructor
  62. //
  63. CFPTerminal();
  64. ~CFPTerminal();
  65. DECLARE_NOT_AGGREGATABLE(CFPTerminal)
  66. DECLARE_GET_CONTROLLING_UNKNOWN()
  67. virtual HRESULT FinalConstruct(void);
  68. public:
  69. DECLARE_REGISTRY_RESOURCEID(IDR_FILE_PLAYBACK)
  70. BEGIN_COM_MAP(CFPTerminal)
  71. COM_INTERFACE_ENTRY2(IDispatch, ITTerminal)
  72. COM_INTERFACE_ENTRY(ITMediaPlayback)
  73. COM_INTERFACE_ENTRY(ITTerminal)
  74. COM_INTERFACE_ENTRY(ITPluggableTerminalInitialization)
  75. COM_INTERFACE_ENTRY(IObjectSafety)
  76. COM_INTERFACE_ENTRY(ITMediaControl)
  77. COM_INTERFACE_ENTRY(ITPluggableTerminalEventSinkRegistration)
  78. COM_INTERFACE_ENTRY(IFPBridge)
  79. COM_INTERFACE_ENTRY_CHAIN(CMultiTrackTerminal)
  80. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  81. END_COM_MAP()
  82. // --- ITTeminal ---
  83. STDMETHOD(get_TerminalClass)(
  84. OUT BSTR *pVal);
  85. STDMETHOD(get_TerminalType)(
  86. OUT TERMINAL_TYPE *pVal);
  87. STDMETHOD(get_State)(
  88. OUT TERMINAL_STATE *pVal);
  89. STDMETHOD(get_Name)(
  90. OUT BSTR *pVal);
  91. STDMETHOD(get_MediaType)(
  92. OUT long * plMediaType);
  93. STDMETHOD(get_Direction)(
  94. OUT TERMINAL_DIRECTION *pDirection);
  95. // --- ITMediaPlayback ---
  96. virtual HRESULT STDMETHODCALLTYPE put_PlayList(
  97. IN VARIANTARG PlayListVariant
  98. );
  99. virtual HRESULT STDMETHODCALLTYPE get_PlayList(
  100. OUT VARIANTARG* pPlayListVariant
  101. );
  102. // --- ITPluggableTerminalInitialization ---
  103. virtual HRESULT STDMETHODCALLTYPE InitializeDynamic (
  104. IN IID iidTerminalClass,
  105. IN DWORD dwMediaType,
  106. IN TERMINAL_DIRECTION Direction,
  107. IN MSP_HANDLE htAddress);
  108. // --- ITMediaControl ---
  109. virtual HRESULT STDMETHODCALLTYPE Start( void);
  110. virtual HRESULT STDMETHODCALLTYPE Stop( void);
  111. virtual HRESULT STDMETHODCALLTYPE Pause( void);
  112. virtual HRESULT STDMETHODCALLTYPE get_MediaState(
  113. OUT TERMINAL_MEDIA_STATE *pTerminalMediaState);
  114. // --- CMultiTrackTerminal ---
  115. virtual HRESULT STDMETHODCALLTYPE CreateTrackTerminal(
  116. IN long MediaType,
  117. IN TERMINAL_DIRECTION TerminalDirection,
  118. OUT ITTerminal **ppTerminal
  119. );
  120. // this function is not accessible on the playback terminal
  121. // so override it to retutn E_NOTSUPPORTED
  122. virtual HRESULT STDMETHODCALLTYPE RemoveTrackTerminal(
  123. IN ITTerminal * pTrackTerminalToRemove
  124. );
  125. // --- ITPluggableTerminalEventSinkRegistration ---
  126. STDMETHOD(RegisterSink)(
  127. IN ITPluggableTerminalEventSink *pSink
  128. );
  129. STDMETHOD(UnregisterSink)();
  130. // --- IFPBridge ---
  131. STDMETHOD(Deliver)(
  132. IN long nMediaType,
  133. IN IMediaSample* pSample
  134. );
  135. //
  136. // IDispatch methods
  137. //
  138. STDMETHOD(GetIDsOfNames)(REFIID riid,
  139. LPOLESTR* rgszNames,
  140. UINT cNames,
  141. LCID lcid,
  142. DISPID* rgdispid
  143. );
  144. STDMETHOD(Invoke)(DISPID dispidMember,
  145. REFIID riid,
  146. LCID lcid,
  147. WORD wFlags,
  148. DISPPARAMS* pdispparams,
  149. VARIANT* pvarResult,
  150. EXCEPINFO* pexcepinfo,
  151. UINT* puArgErr
  152. );
  153. public:
  154. //
  155. // overriding IObjectSafety methods. we are only safe if properly
  156. // initialized by terminal manager, so these methods will fail if this
  157. // is not the case.
  158. //
  159. STDMETHOD(SetInterfaceSafetyOptions)(REFIID riid,
  160. DWORD dwOptionSetMask,
  161. DWORD dwEnabledOptions);
  162. STDMETHOD(GetInterfaceSafetyOptions)(REFIID riid,
  163. DWORD *pdwSupportedOptions,
  164. DWORD *pdwEnabledOptions);
  165. private:
  166. // --- Memebers --
  167. TERMINAL_MEDIA_STATE m_State; // Terminal current state
  168. CMSPCritSection m_Lock; // Critical section
  169. ITPluggableTerminalEventSink* m_pEventSink; // Fire events to client
  170. // --- Terminal attributes ---
  171. MSP_HANDLE m_htAddress; // MSP address handle
  172. IID m_TerminalClassID; // TerminalClass
  173. TERMINAL_DIRECTION m_Direction; // Direction
  174. TERMINAL_STATE m_TerminalState; // Terminal State
  175. DWORD m_dwMediaTypes; // Media types supported
  176. TCHAR m_szName[MAX_PATH+1]; // Terminal friendly name
  177. int m_nPlayIndex; // Index of playing storage
  178. VARIANT m_varPlayList; // The playlist
  179. IUnknown* m_pFTM; // pointer to the free threaded marshaler
  180. CPlaybackUnit* m_pPlaybackUnit; // The playback graph
  181. HRESULT ValidatePlayList(
  182. IN VARIANTARG varPlayList,
  183. OUT long* pnLeftBound,
  184. OUT long* pnRightBound
  185. );
  186. HRESULT RollbackTrackInfo();
  187. //
  188. // uninitialize all tracks and remove them from the list of managed tracks
  189. //
  190. HRESULT ShutdownTracks();
  191. //
  192. // uninitialize a given track and remove it from the list of managed tracks
  193. //
  194. HRESULT InternalRemoveTrackTerminal(
  195. IN ITTerminal *pTrackTerminalToRemove
  196. );
  197. //
  198. // a helper method that fires events on one of the tracks
  199. //
  200. HRESULT FireEvent(
  201. TERMINAL_MEDIA_STATE tmsState,
  202. FT_STATE_EVENT_CAUSE ftecEventCause,
  203. HRESULT hrErrorCode
  204. );
  205. //
  206. // a helper method that attempts to stop all tracks
  207. //
  208. HRESULT StopAllTracks();
  209. BSTR GetFileNameFromPlayList(
  210. IN VARIANTARG varPlayList,
  211. IN long nIndex
  212. );
  213. //
  214. // Create the playback graph
  215. //
  216. HRESULT CreatePlaybackUnit(
  217. IN BSTR bstrFileName
  218. );
  219. //
  220. // Play a file from the list
  221. //
  222. HRESULT ConfigurePlaybackUnit(
  223. IN BSTR bstrFileName
  224. );
  225. //
  226. // Helper method that causes a state transition
  227. //
  228. HRESULT DoStateTransition(
  229. IN TERMINAL_MEDIA_STATE tmsDesiredState
  230. );
  231. //
  232. // Create a track for a specific media
  233. //
  234. HRESULT CreateMediaTracks(
  235. IN long nMediaType
  236. );
  237. HRESULT NextPlayIndex(
  238. );
  239. public:
  240. //
  241. // Returns a track for a media type
  242. //
  243. int TracksCreated(
  244. IN long lMediaType
  245. );
  246. //
  247. // a helper method called by tracks when they decide to make a state change.
  248. //
  249. HRESULT TrackStateChange(TERMINAL_MEDIA_STATE tmsState,
  250. FT_STATE_EVENT_CAUSE ftecEventCause,
  251. HRESULT hrErrorCode);
  252. HRESULT PlayItem(
  253. IN int nItem
  254. );
  255. private:
  256. //
  257. // this terminal should only be instantiated in the context of terminal
  258. // manager. the object will only be safe for scripting if it has been
  259. // InitializeDynamic'ed.
  260. //
  261. // this flag will be set when InitializeDynamic succeeds
  262. //
  263. BOOL m_bKnownSafeContext;
  264. };
  265. #endif
  266. //eof