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.

163 lines
4.7 KiB

  1. //==========================================================================;
  2. // MSVidDataServices.h : Declaration of the CMSVidDataServices
  3. // copyright (c) Microsoft Corp. 1998-1999.
  4. /////////////////////////////////////////////////////////////////////////////
  5. #pragma once
  6. #ifndef __MSVidDataServices_H_
  7. #define __MSVidDataServices_H_
  8. #include <algorithm>
  9. #include <tchar.h>
  10. #include <objectwithsiteimplsec.h>
  11. #include "segimpl.h"
  12. #include "dataserviceimpl.h"
  13. #include "seg.h"
  14. typedef CComQIPtr<ITuner> PQMSVidDataServices;
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMSVidDataServices
  17. class ATL_NO_VTABLE __declspec(uuid("334125C0-77E5-11d3-B653-00C04F79498E")) CDataServices :
  18. public CComObjectRootEx<CComSingleThreadModel>,
  19. public CComCoClass<CDataServices, &__uuidof(CDataServices)>,
  20. public IObjectWithSiteImplSec<CDataServices>,
  21. public ISupportErrorInfo,
  22. public IConnectionPointContainerImpl<CDataServices>,
  23. public IMSVidGraphSegmentImpl<CDataServices, MSVidSEG_XFORM, &GUID_NULL>,
  24. public IMSVidDataServicesImpl<CDataServices, &LIBID_MSVidCtlLib, &GUID_NULL, IMSVidDataServices>
  25. {
  26. public:
  27. CDataServices() : m_iIPSink(-1) {
  28. }
  29. REGISTER_AUTOMATION_OBJECT(IDS_PROJNAME,
  30. IDS_REG_DATASERVICES_PROGID,
  31. IDS_REG_DATASERVICES_DESC,
  32. LIBID_MSVidCtlLib,
  33. __uuidof(CDataServices));
  34. DECLARE_PROTECT_FINAL_CONSTRUCT()
  35. BEGIN_COM_MAP(CDataServices)
  36. COM_INTERFACE_ENTRY(IMSVidGraphSegment)
  37. COM_INTERFACE_ENTRY(IMSVidDataServices)
  38. COM_INTERFACE_ENTRY(IDispatch)
  39. COM_INTERFACE_ENTRY(IObjectWithSite)
  40. COM_INTERFACE_ENTRY(IMSVidFeature)
  41. COM_INTERFACE_ENTRY(IMSVidDevice)
  42. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  43. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  44. COM_INTERFACE_ENTRY(IPersist)
  45. END_COM_MAP()
  46. BEGIN_CATEGORY_MAP(CDataServices)
  47. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  48. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  49. IMPLEMENTED_CATEGORY(CATID_PersistsToPropertyBag)
  50. END_CATEGORY_MAP()
  51. BEGIN_CONNECTION_POINT_MAP(CDataServices)
  52. END_CONNECTION_POINT_MAP()
  53. // ISupportsErrorInfo
  54. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  55. public:
  56. PQCreateDevEnum m_pSystemEnum;
  57. int m_iIPSink;
  58. HRESULT Unload(void) {
  59. IMSVidGraphSegmentImpl<CDataServices, MSVidSEG_XFORM, &GUID_NULL>::Unload();
  60. m_iIPSink = -1;
  61. return NOERROR;
  62. }
  63. // IMSVidGraphSegment
  64. STDMETHOD(Build)() {
  65. return NOERROR;
  66. }
  67. STDMETHOD(PreRun)() {
  68. return NOERROR;
  69. }
  70. STDMETHOD(put_Container)(IMSVidGraphSegmentContainer *pCtl)
  71. {
  72. if (!m_fInit) {
  73. return CO_E_NOTINITIALIZED;
  74. }
  75. try {
  76. if (!pCtl) {
  77. return Unload();
  78. }
  79. if (m_pContainer) {
  80. if (!m_pContainer.IsEqualObject(VWSegmentContainer(pCtl))) {
  81. return Error(IDS_OBJ_ALREADY_INIT, __uuidof(IMSVidDataServices), CO_E_ALREADYINITIALIZED);
  82. } else {
  83. return NO_ERROR;
  84. }
  85. }
  86. // DON'T addref the container. we're guaranteed nested lifetimes
  87. // and an addref creates circular refcounts so we never unload.
  88. m_pContainer.p = pCtl;
  89. m_pGraph = m_pContainer.GetGraph();
  90. // bring in all bda renderers
  91. m_pSystemEnum = PQCreateDevEnum(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER);
  92. DSDevices pe(m_pSystemEnum, KSCATEGORY_IP_SINK);
  93. DSDevices::iterator pit = pe.begin();
  94. if (!*pe.begin()) {
  95. TRACELM(TRACE_ERROR, "CMSVidDataServices::put_Container() missing ipsink category, drivers not installed");
  96. return E_FAIL;
  97. }
  98. for (; pit != pe.end(); ++pit) {
  99. DSFilter ipsink(m_pGraph.AddMoniker(*pe.begin()));
  100. if (!ipsink) {
  101. TRACELM(TRACE_ERROR, "CMSVidDataServices::put_Container() can't load ip sink");
  102. return E_FAIL;
  103. }
  104. m_Filters.push_back(ipsink);
  105. }
  106. m_iIPSink = 0; // assume ipsink was first in category
  107. return NOERROR;
  108. } catch (ComException &e) {
  109. return e;
  110. } catch(...) {
  111. return E_UNEXPECTED;
  112. }
  113. return NOERROR;
  114. }
  115. // IMSVidDevice
  116. STDMETHOD(get_Name)(BSTR * Name)
  117. {
  118. if (!m_fInit) {
  119. return CO_E_NOTINITIALIZED;
  120. }
  121. try {
  122. return GetName(((m_iIPSink > -1) ? (m_Filters[m_iIPSink]) : DSFilter()), m_pDev, CComBSTR(_T("BDA IPSink"))).CopyTo(Name);
  123. } catch(...) {
  124. return E_POINTER;
  125. }
  126. }
  127. };
  128. STDMETHODIMP CDataServices::InterfaceSupportsErrorInfo(REFIID riid)
  129. {
  130. static const IID* arr[] =
  131. {
  132. &IID_IMSVidDataServices
  133. };
  134. for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
  135. {
  136. if (InlineIsEqualGUID(*arr[i],riid))
  137. return S_OK;
  138. }
  139. return S_FALSE;
  140. }
  141. #endif //__MSVidDataServices_H_