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.

116 lines
3.7 KiB

  1. //==========================================================================;
  2. //
  3. // Composition.h : Declaration of the custom composition class for gluing analog capture to ovmixer
  4. // Copyright (c) Microsoft Corporation 1999.
  5. //
  6. /////////////////////////////////////////////////////////////////////////////
  7. #ifndef ANA2ENC_H
  8. #define ANA2ENC_H
  9. #pragma once
  10. #include <winerror.h>
  11. #include <algorithm>
  12. #include <compimpl.h>
  13. #include <seg.h>
  14. #include "resource.h" // main symbols
  15. #include <objectwithsiteimplsec.h>
  16. #include "dsextend.h"
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CAna2EncComp
  19. class ATL_NO_VTABLE __declspec(uuid("28953661-0231-41db-8986-21FF4388EE9B")) CAna2EncComp :
  20. public CComObjectRootEx<CComSingleThreadModel>,
  21. public CComCoClass<CAna2EncComp, &__uuidof(CAna2EncComp)>,
  22. public IObjectWithSiteImplSec<CAna2EncComp>,
  23. public IMSVidCompositionSegmentImpl<CAna2EncComp>
  24. {
  25. public:
  26. CAna2EncComp() {}
  27. virtual ~CAna2EncComp() {}
  28. REGISTER_NONAUTOMATION_OBJECT(IDS_PROJNAME,
  29. IDS_REG_ANA2ENCCOMP_DESC,
  30. LIBID_MSVidCtlLib,
  31. __uuidof(CAna2EncComp));
  32. DECLARE_PROTECT_FINAL_CONSTRUCT()
  33. BEGIN_COM_MAP(CAna2EncComp)
  34. COM_INTERFACE_ENTRY(IMSVidCompositionSegment)
  35. COM_INTERFACE_ENTRY(IMSVidGraphSegment)
  36. COM_INTERFACE_ENTRY(IObjectWithSite)
  37. COM_INTERFACE_ENTRY(IPersist)
  38. END_COM_MAP()
  39. public:
  40. PQCreateDevEnum m_pSystemEnum;
  41. //////////////
  42. // IMSVidGraphSegment
  43. // IMSVidCompositionSegment
  44. STDMETHOD(Compose)(IMSVidGraphSegment * upstream, IMSVidGraphSegment * downstream)
  45. {
  46. if (m_fComposed) {
  47. return NOERROR;
  48. }
  49. ASSERT(m_pGraph);
  50. try {
  51. TRACELM(TRACE_ERROR, "CVidCtl::Ana2Enc() Compose");
  52. VWGraphSegment up(upstream);
  53. ASSERT(up.Graph() == m_pGraph);
  54. VWGraphSegment down(downstream);
  55. ASSERT(down.Graph() == m_pGraph);
  56. if (upstream == downstream) {
  57. return Error(IDS_CANT_COMPOSE_WITH_SELF, __uuidof(IMSVidCompositionSegment), E_INVALIDARG);
  58. }
  59. if (up.begin() == up.end()) {
  60. TRACELM(TRACE_ERROR, "CComposition::Compose() can't compose empty up segment");
  61. return NOERROR;
  62. }
  63. if (down.begin() == down.end()) {
  64. TRACELM(TRACE_ERROR, "CComposition::Compose() can't compose empty down segment");
  65. // this is not an error, for example, CA is an empty segment.
  66. return NOERROR;
  67. }
  68. // do the list backwards
  69. DSFilterList upF;
  70. for(VWGraphSegment::iterator upStart = up.begin(); upStart != up.end(); ++upStart){
  71. upF.push_back(*upStart);
  72. }
  73. for (DSFilterList::reverse_iterator iStart = upF.rbegin(); iStart != upF.rend(); ++iStart) {
  74. ASSERT((*iStart).GetGraph() == m_pGraph);
  75. for (VWGraphSegment::iterator iStop = down.begin(); iStop != down.end(); ++iStop) {
  76. ASSERT((*iStop).GetGraph() == m_pGraph);
  77. DSFilter pStart(*iStart);
  78. DSFilter pStop(*iStop);
  79. HRESULT hr = m_pGraph.Connect(pStart, pStop, m_Filters, 0x10);
  80. if (SUCCEEDED(hr)) {
  81. m_Segments.push_back(up);
  82. m_Segments.push_back(down);
  83. m_pDown = m_Segments.end();
  84. --m_pDown;
  85. m_pUp = m_pDown;
  86. --m_pUp;
  87. m_fComposed = true;
  88. return NOERROR;
  89. }
  90. }
  91. }
  92. TRACELM(TRACE_ERROR, "CComposition::Compose() compose didn't connect anything");
  93. return Error(IDS_CANT_COMPOSE, __uuidof(IMSVidCompositionSegment), E_FAIL);
  94. } catch (ComException &e) {
  95. return e;
  96. } catch (...) {
  97. return E_UNEXPECTED;
  98. }
  99. }
  100. };
  101. #endif // ANA2ENC_H
  102. // end of file - ANA2ENC.h