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.

134 lines
4.3 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 SBES2CC_H
  8. #define SBES2CC_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. // CSbeS2CCComp
  19. class ATL_NO_VTABLE __declspec(uuid("9193A8F9-0CBA-400e-AA97-EB4709164576")) CSbeS2CCComp :
  20. public CComObjectRootEx<CComSingleThreadModel>,
  21. public CComCoClass<CSbeS2CCComp, &__uuidof(CSbeS2CCComp)>,
  22. public IObjectWithSiteImplSec<CSbeS2CCComp>,
  23. public IMSVidCompositionSegmentImpl<CSbeS2CCComp>
  24. {
  25. public:
  26. CSbeS2CCComp() {}
  27. virtual ~CSbeS2CCComp() {}
  28. REGISTER_NONAUTOMATION_OBJECT(IDS_PROJNAME,
  29. IDS_REG_SBES2CC_DESC,
  30. LIBID_MSVidCtlLib,
  31. __uuidof(CSbeS2CCComp));
  32. DECLARE_PROTECT_FINAL_CONSTRUCT()
  33. BEGIN_COM_MAP(CSbeS2CCComp)
  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. VIDPERF_FUNC;
  47. if (m_fComposed) {
  48. return NOERROR;
  49. }
  50. ASSERT(m_pGraph);
  51. try {
  52. TRACELM(TRACE_ERROR, "CSbeS2CCComp::Compose()");
  53. VWGraphSegment up(upstream);
  54. ASSERT(up.Graph() == m_pGraph);
  55. VWGraphSegment down(downstream);
  56. ASSERT(down.Graph() == m_pGraph);
  57. if (upstream == downstream) {
  58. return Error(IDS_CANT_COMPOSE_WITH_SELF, __uuidof(CSbeS2CCComp), E_INVALIDARG);
  59. }
  60. if (up.begin() == up.end()) {
  61. TRACELM(TRACE_ERROR, "CSbeS2CCComp::Compose() can't compose empty up segment");
  62. return NOERROR;
  63. }
  64. if (down.begin() == down.end()) {
  65. TRACELM(TRACE_ERROR, "CSbeS2CCComp::Compose() can't compose empty down segment");
  66. // this is not an error, for example, CA is an empty segment.
  67. return NOERROR;
  68. }
  69. // do the list backwards
  70. DSFilterList upF;
  71. /* for(VWGraphSegment::iterator upStart = up.begin(); upStart != up.end(); ++upStart){
  72. upF.push_back(*upStart);
  73. }
  74. */
  75. DSMediaType mtL21(MEDIATYPE_AUXLine21Data, MEDIASUBTYPE_Line21_BytePair);
  76. for (VWGraphSegment::iterator iStart = up.begin(); iStart != up.end(); ++iStart) {
  77. ASSERT((*iStart).GetGraph() == m_pGraph);
  78. DSFilter::iterator iPins;
  79. for(iPins = (*iStart).begin(); iPins != (*iStart).end(); ++iPins){
  80. DSPin::iterator iMedias;
  81. for(iMedias = (*iPins).begin(); iMedias != (*iPins).end(); ++iMedias){
  82. if(mtL21 == (*iMedias)){
  83. break;
  84. }
  85. }
  86. if(iMedias != (*iPins).end()){
  87. break;
  88. }
  89. }
  90. if(iPins == (*iStart).end()){
  91. continue;
  92. }
  93. for (VWGraphSegment::iterator iStop = down.begin(); iStop != down.end(); ++iStop) {
  94. ASSERT((*iStop).GetGraph() == m_pGraph);
  95. DSFilter pStart(*iStart);
  96. DSFilter pStop(*iStop);
  97. HRESULT hr = m_pGraph.Connect(pStart, pStop, m_Filters);
  98. if (SUCCEEDED(hr)) {
  99. m_Segments.push_back(up);
  100. m_Segments.push_back(down);
  101. m_pDown = m_Segments.end();
  102. --m_pDown;
  103. m_pUp = m_pDown;
  104. --m_pUp;
  105. m_fComposed = true;
  106. return NOERROR;
  107. }
  108. }
  109. }
  110. TRACELM(TRACE_ERROR, "CSbeS2CCComp::Compose() compose didn't connect anything");
  111. return S_FALSE;
  112. } catch (ComException &e) {
  113. return e;
  114. } catch (...) {
  115. return E_UNEXPECTED;
  116. }
  117. }
  118. };
  119. #endif // SBES2CC_H
  120. // end of file - SBES2CC.h