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.

175 lines
5.2 KiB

  1. //==========================================================================;
  2. // MSVidFilePlayback.h : Declaration of the CMSVidFilePlayback class
  3. // copyright (c) Microsoft Corp. 1998-1999.
  4. //==========================================================================;
  5. #ifndef __MSVidFILEPLAYBACK_H_
  6. #define __MSVidFILEPLAYBACK_H_
  7. #pragma once
  8. #include <algorithm>
  9. #include <objectwithsiteimplsec.h>
  10. #include "pbsegimpl.h"
  11. #include "fileplaybackimpl.h"
  12. #include "fileplaybackcp.h"
  13. #include "seg.h"
  14. #include "resource.h" // main symbols
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMSVidFilePlayback
  17. class ATL_NO_VTABLE __declspec(uuid("37B0353C-A4C8-11d2-B634-00C04F79498E")) CMSVidFilePlayback :
  18. public CComObjectRootEx<CComSingleThreadModel>,
  19. public CComCoClass<CMSVidFilePlayback, &__uuidof(CMSVidFilePlayback)>,
  20. public IObjectWithSiteImplSec<CMSVidFilePlayback>,
  21. public ISupportErrorInfo,
  22. public IConnectionPointContainerImpl<CMSVidFilePlayback>,
  23. public CProxy_FilePlaybackEvent<CMSVidFilePlayback>,
  24. public IMSVidPBGraphSegmentImpl<CMSVidFilePlayback, MSVidSEG_SOURCE, &GUID_NULL>,
  25. public IMSVidFilePlaybackImpl<CMSVidFilePlayback, &LIBID_MSVidCtlLib, &GUID_NULL, IMSVidFilePlayback>,
  26. public IProvideClassInfo2Impl<&CLSID_MSVidFilePlaybackDevice, &IID_IMSVidFilePlaybackEvent, &LIBID_MSVidCtlLib>
  27. {
  28. public:
  29. CMSVidFilePlayback()
  30. {
  31. m_fEnableResetOnStop = true;
  32. }
  33. REGISTER_AUTOMATION_OBJECT(IDS_PROJNAME,
  34. IDS_REG_FILEPLAYBACK_PROGID,
  35. IDS_REG_FILEPLAYBACK_DESC,
  36. LIBID_MSVidCtlLib,
  37. __uuidof(CMSVidFilePlayback));
  38. DECLARE_PROTECT_FINAL_CONSTRUCT()
  39. BEGIN_COM_MAP(CMSVidFilePlayback)
  40. COM_INTERFACE_ENTRY(IMSVidFilePlayback)
  41. COM_INTERFACE_ENTRY(IDispatch)
  42. COM_INTERFACE_ENTRY(IObjectWithSite)
  43. COM_INTERFACE_ENTRY(IMSVidGraphSegment)
  44. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  45. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  46. COM_INTERFACE_ENTRY(IMSVidPlayback)
  47. COM_INTERFACE_ENTRY(IMSVidInputDevice)
  48. COM_INTERFACE_ENTRY(IMSVidDevice)
  49. COM_INTERFACE_ENTRY(IPersist)
  50. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  51. COM_INTERFACE_ENTRY(IProvideClassInfo)
  52. END_COM_MAP()
  53. BEGIN_CATEGORY_MAP(CMSVidFilePlayback)
  54. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  55. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  56. IMPLEMENTED_CATEGORY(CATID_PersistsToPropertyBag)
  57. END_CATEGORY_MAP()
  58. BEGIN_CONNECTION_POINT_MAP(CMSVidFilePlayback)
  59. CONNECTION_POINT_ENTRY(IID_IMSVidFilePlaybackEvent)
  60. END_CONNECTION_POINT_MAP()
  61. // ISupportsErrorInfo
  62. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  63. public:
  64. STDMETHOD(put_Rate)(double lRate);
  65. STDMETHOD(get_Rate)(double *lRate);
  66. STDMETHOD(PostStop)();
  67. STDMETHOD(PostRun)();
  68. STDMETHOD(PreStop)();
  69. // DON'T addref the container. we're guaranteed nested lifetimes
  70. // and an addref creates circular refcounts so we never unload.
  71. CComBSTR __declspec(property(get=GetName)) m_Name;
  72. CComBSTR GetName(void) {
  73. CString csName;
  74. if(m_iReader != -1){
  75. csName = (m_Filters[m_iReader]).GetName();
  76. }
  77. if (csName.IsEmpty()) {
  78. csName = _T("File Playback");
  79. }
  80. return CComBSTR(csName);
  81. }
  82. HRESULT Unload(void) {
  83. HRESULT hr = IMSVidGraphSegmentImpl<CMSVidFilePlayback, MSVidSEG_SOURCE, &GUID_NULL>::Unload();
  84. m_iReader = -1;
  85. return hr;
  86. }
  87. virtual ~CMSVidFilePlayback() {}
  88. // IMSVidGraphSegment
  89. STDMETHOD(put_Init)(IUnknown *pInit)
  90. {
  91. HRESULT hr = IMSVidGraphSegmentImpl<CMSVidFilePlayback, MSVidSEG_SOURCE, &GUID_NULL>::put_Init(pInit);
  92. if (FAILED(hr)) {
  93. return hr;
  94. }
  95. if (pInit) {
  96. m_fInit = false;
  97. return E_NOTIMPL;
  98. }
  99. return NOERROR;
  100. }
  101. STDMETHOD(Build)();
  102. STDMETHOD(put_Container)(IMSVidGraphSegmentContainer *pVal);
  103. STDMETHOD(OnEventNotify)(long lEvent, LONG_PTR lParam1, LONG_PTR lParam2);
  104. // IMSVidDevice
  105. STDMETHOD(get_Name)(BSTR * Name)
  106. {
  107. if (!m_fInit) {
  108. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidFilePlayback), CO_E_NOTINITIALIZED);
  109. }
  110. if (Name == NULL)
  111. return E_POINTER;
  112. try {
  113. *Name = m_Name.Copy();
  114. } catch(...) {
  115. return E_POINTER;
  116. }
  117. return NOERROR;
  118. }
  119. // IMSVidInputDevice
  120. STDMETHOD(IsViewable)(VARIANT* pv, VARIANT_BOOL *pfViewable)
  121. {
  122. if (!m_fInit) {
  123. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidFilePlayback), CO_E_NOTINITIALIZED);
  124. }
  125. if (!pv) {
  126. return E_POINTER;
  127. }
  128. return E_NOTIMPL;
  129. }
  130. STDMETHOD(View)(VARIANT* pv) {
  131. if (!m_fInit) {
  132. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidFilePlayback), CO_E_NOTINITIALIZED);
  133. }
  134. if (!pv) {
  135. return E_POINTER;
  136. }
  137. if (pv->vt != VT_BSTR) {
  138. return E_INVALIDARG;
  139. }
  140. // if its a string then its either a dvd url or a filename
  141. // we don't do dvd urls
  142. if (!_wcsnicmp(pv->bstrVal, L"DVD:", 4)) {
  143. return E_FAIL;
  144. }
  145. if (m_pGraph && !m_pGraph.IsStopped()) {
  146. return Error(IDS_INVALID_STATE, __uuidof(IMSVidFilePlayback), HRESULT_FROM_WIN32(ERROR_INVALID_STATE));
  147. }
  148. return put_FileName(pv->bstrVal);
  149. }
  150. // IMSVidPlayback
  151. // IMSVidFilePlayback
  152. };
  153. #endif //__MSVidFILEPLAYBACK_H_