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.

125 lines
4.2 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 WEBDVDCOMPAR_H
  8. #define WEBDVDCOMPAR_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. /////////////////////////////////////////////////////////////////////////////
  17. // CAnaCapComp
  18. class ATL_NO_VTABLE __declspec(uuid("8D04238E-9FD1-41c6-8DE3-9E1EE309E935")) CWebDVDARComp :
  19. public CComObjectRootEx<CComSingleThreadModel>,
  20. public CComCoClass<CWebDVDARComp, &__uuidof(CWebDVDARComp)>,
  21. public IObjectWithSiteImplSec<CWebDVDARComp>,
  22. public IMSVidCompositionSegmentImpl<CWebDVDARComp>
  23. {
  24. public:
  25. CWebDVDARComp() {}
  26. virtual ~CWebDVDARComp() {}
  27. REGISTER_NONAUTOMATION_OBJECT(IDS_PROJNAME,
  28. IDS_REG_WEBDVDARCOMP_DESC,
  29. LIBID_MSVidCtlLib,
  30. __uuidof(CWebDVDARComp));
  31. DECLARE_PROTECT_FINAL_CONSTRUCT()
  32. BEGIN_COM_MAP(CWebDVDARComp)
  33. COM_INTERFACE_ENTRY(IMSVidCompositionSegment)
  34. COM_INTERFACE_ENTRY(IMSVidGraphSegment)
  35. COM_INTERFACE_ENTRY(IPersist)
  36. COM_INTERFACE_ENTRY(IObjectWithSite)
  37. END_COM_MAP()
  38. // IMSVidComposition
  39. public:
  40. // IMSVidGraphSegment
  41. // IMSVidCompositionSegment
  42. STDMETHOD(Compose)(IMSVidGraphSegment * upstream, IMSVidGraphSegment * downstream)
  43. {
  44. TRACELM(TRACE_DEBUG, "CWebDVDARComp::Compose()");
  45. if (m_fComposed) {
  46. return NOERROR;
  47. }
  48. ASSERT(m_pGraph);
  49. try {
  50. VWGraphSegment up(upstream);
  51. ASSERT(up.Graph() == m_pGraph);
  52. VWGraphSegment down(downstream);
  53. ASSERT(down.Graph() == m_pGraph);
  54. if (up.begin() == up.end()) {
  55. TRACELM(TRACE_ERROR, "CWebDVDARComp::Compose() can't compose empty up segment");
  56. return E_INVALIDARG;
  57. }
  58. if (down.begin() == down.end()) {
  59. TRACELM(TRACE_ERROR, "CWebDVDARComp::Compose() can't compose empty down segment");
  60. return E_INVALIDARG;
  61. }
  62. VWGraphSegment::iterator iNav = std::find_if(up.begin(),
  63. up.end(),
  64. arity1_pointer(&IsDVDNavigator));
  65. if (iNav == up.end()) {
  66. TRACELM(TRACE_ERROR, "CWebDVDARComp::Compose() upstream segment has no DVD Navigator");
  67. return E_FAIL;
  68. }
  69. ASSERT((*iNav).GetGraph() == m_pGraph);
  70. DSFilter pNav(*iNav);
  71. #if 1
  72. // Code to add mpeg2 video decoder
  73. CComBSTR decoder(L"{7E2E0DC1-31FD-11D2-9C21-00104B3801F6}");
  74. CComBSTR decoderName(L"InterVideo Audio Decoder");
  75. GUID2 decoderGuid(decoder);
  76. DSFilter pfr(decoderGuid);
  77. if (!pfr) {
  78. ASSERT(false);
  79. return Error(IDS_CANT_CREATE_FILTER, __uuidof(IMSVidWebDVD), E_UNEXPECTED);
  80. }
  81. HRESULT hr = m_pGraph->AddFilter(pfr, decoderName);
  82. if (FAILED(hr)) {
  83. TRACELSM(TRACE_ERROR, (dbgDump << "IMSVidWebDVD::Load() hr = " << std::hex << hr), "");
  84. return Error(IDS_CANT_ADD_FILTER, __uuidof(IMSVidWebDVD), hr);
  85. }
  86. m_Filters.push_back(pfr);
  87. #endif
  88. // video
  89. hr = m_pGraph.Connect(pNav, pfr, m_Filters);
  90. if (FAILED(hr)) {
  91. TRACELM(TRACE_DETAIL, "CWebDVDARComp::Compose() SUCCEEDED");
  92. return hr;
  93. }
  94. for (VWGraphSegment::iterator iStop = down.begin(); iStop != down.end(); ++iStop){
  95. DSFilter pStop(*iStop);
  96. hr = m_pGraph.Connect(pfr, pStop, m_Filters, DSGraph::RENDER_ALL_PINS | DSGraph::IGNORE_EXISTING_CONNECTIONS | DSGraph::DO_NOT_LOAD);
  97. if(SUCCEEDED(hr)){
  98. m_fComposed = true;
  99. return NOERROR;
  100. }
  101. }
  102. return NOERROR;
  103. } catch (ComException &e) {
  104. return e;
  105. } catch (...) {
  106. return E_UNEXPECTED;
  107. }
  108. }
  109. };
  110. #endif // WEBDVDCOMPAR_H
  111. // end of file - WebDVDARComp.h