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.

143 lines
5.6 KiB

  1. //==========================================================================;
  2. //
  3. // Composition.h : Declaration of the custom composition class for gluing WebDVD to ovmixer
  4. // Copyright (c) Microsoft Corporation 1999.
  5. //
  6. /////////////////////////////////////////////////////////////////////////////
  7. #ifndef WEBDVDCOMP_H
  8. #define WEBDVDCOMP_H
  9. #pragma once
  10. #include <winerror.h>
  11. #include <algorithm>
  12. #include <objectwithsiteimplsec.h>
  13. #include <compimpl.h>
  14. #include <seg.h>
  15. #include "resource.h" // main symbols
  16. #include "perfcntr.h"
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CAnaCapComp
  19. class ATL_NO_VTABLE __declspec(uuid("267db0b3-55e3-4902-949b-df8f5cec0191")) CWebDVDComp :
  20. public CComObjectRootEx<CComSingleThreadModel>,
  21. public CComCoClass<CWebDVDComp, &__uuidof(CWebDVDComp)>,
  22. public IObjectWithSiteImplSec<CWebDVDComp>,
  23. public IMSVidCompositionSegmentImpl<CWebDVDComp>
  24. {
  25. public:
  26. CWebDVDComp() {}
  27. virtual ~CWebDVDComp() {}
  28. REGISTER_NONAUTOMATION_OBJECT(IDS_PROJNAME,
  29. IDS_REG_WEBDVDCOMP_DESC,
  30. LIBID_MSVidCtlLib,
  31. __uuidof(CWebDVDComp));
  32. DECLARE_PROTECT_FINAL_CONSTRUCT()
  33. BEGIN_COM_MAP(CWebDVDComp)
  34. COM_INTERFACE_ENTRY(IMSVidCompositionSegment)
  35. COM_INTERFACE_ENTRY(IMSVidGraphSegment)
  36. COM_INTERFACE_ENTRY(IPersist)
  37. COM_INTERFACE_ENTRY(IObjectWithSite)
  38. END_COM_MAP()
  39. // IMSVidComposition
  40. public:
  41. // IMSVidGraphSegment
  42. // IMSVidCompositionSegment
  43. STDMETHOD(Compose)(IMSVidGraphSegment * upstream, IMSVidGraphSegment * downstream)
  44. {
  45. TRACELM(TRACE_DEBUG, "CWebDVDComp::Compose()");
  46. if (m_fComposed) {
  47. return NOERROR;
  48. }
  49. ASSERT(m_pGraph);
  50. try {
  51. VWGraphSegment up(upstream);
  52. ASSERT(up.Graph() == m_pGraph);
  53. VWGraphSegment down(downstream);
  54. ASSERT(down.Graph() == m_pGraph);
  55. if (up.begin() == up.end()) {
  56. TRACELM(TRACE_ERROR, "CWebDVDComp::Compose() can't compose empty up segment");
  57. return E_INVALIDARG;
  58. }
  59. if (down.begin() == down.end()) {
  60. TRACELM(TRACE_ERROR, "CWebDVDComp::Compose() can't compose empty down segment");
  61. return E_INVALIDARG;
  62. }
  63. VWGraphSegment::iterator iNav = std::find_if(up.begin(),
  64. up.end(),
  65. arity1_pointer(&IsDVDNavigator));
  66. if (iNav == up.end()) {
  67. TRACELM(TRACE_ERROR, "CWebDVDComp::Compose() upstream segment has no DVD Navigator");
  68. return E_FAIL;
  69. }
  70. ASSERT((*iNav).GetGraph() == m_pGraph);
  71. VWGraphSegment::iterator iOv = std::find_if(down.begin(),
  72. down.end(),
  73. arity1_pointer(&IsVideoRenderer));
  74. if (iOv == down.end()) {
  75. TRACELM(TRACE_ERROR, "CWebDVDComp::Compose() downstream segment has no ov mixer filter");
  76. return E_FAIL;
  77. }
  78. ASSERT((*iOv).GetGraph() == m_pGraph);
  79. DSFilter pNav(*iNav);
  80. DSFilter pOv(*iOv);
  81. // video
  82. CPerfCounter pCounterDecoder;
  83. pCounterDecoder.Reset();
  84. DSFilter::iterator iNavVideoPin = std::find_if(pNav.begin(),
  85. pNav.end(),
  86. arity1_pointer(&IsDVDNavigatorVideoOutPin));
  87. if (iNavVideoPin == pNav.end()) {
  88. TRACELM(TRACE_ERROR, "CWebDVDComp::Compose() no video pin on DVD Navigator");
  89. return E_FAIL;
  90. }
  91. DSPin pNavVideoPin(*iNavVideoPin);
  92. HRESULT hr = pNavVideoPin.IntelligentConnect(pOv, m_Filters);
  93. if (FAILED(hr)) {
  94. TRACELM(TRACE_DETAIL, "CWebDVDComp::Compose() SUCCEEDED");
  95. return hr;
  96. }
  97. pCounterDecoder.Stop();
  98. TRACELSM(TRACE_ERROR, (dbgDump << "CVidCtl:: Compose() connect decoder video: " << (unsigned long)(pCounterDecoder.GetLastTime() / _100NS_IN_MS) << "." << (unsigned long)(pCounterDecoder.GetLastTime() % _100NS_IN_MS) << " ms"), "");
  99. // subpicture
  100. pCounterDecoder.Reset();
  101. iNavVideoPin = std::find_if(pNav.begin(),
  102. pNav.end(),
  103. arity1_pointer(&IsDVDNavigatorSubpictureOutPin));
  104. if (iNavVideoPin == pNav.end()) {
  105. TRACELM(TRACE_ERROR, "CWebDVDComp::Compose() no subpicture pin on DVD Navigator");
  106. return E_FAIL;
  107. }
  108. pNavVideoPin = *iNavVideoPin;
  109. hr = pNavVideoPin.IntelligentConnect(pOv, m_Filters, DSGraph::RENDER_ALL_PINS | DSGraph::IGNORE_EXISTING_CONNECTIONS | DSGraph::DO_NOT_LOAD);
  110. if (FAILED(hr)) {
  111. TRACELSM(TRACE_ERROR, (dbgDump << "CWebDVDComp::Compose() FAILED hr = " << hexdump(hr)), "");
  112. return hr;
  113. }
  114. pCounterDecoder.Stop();
  115. TRACELSM(TRACE_ERROR, (dbgDump << "CVidCtl:: Compose() connect decoder subpicture: " << (unsigned long)(pCounterDecoder.GetLastTime() / _100NS_IN_MS) << "." << (unsigned long)(pCounterDecoder.GetLastTime() % _100NS_IN_MS) << " ms"), "");
  116. m_fComposed = true;
  117. return NOERROR;
  118. } catch (ComException &e) {
  119. return e;
  120. } catch (...) {
  121. return E_UNEXPECTED;
  122. }
  123. }
  124. };
  125. #endif // WEBDVDCOMP_H
  126. // end of file - WebDVDComp.h