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.

118 lines
3.8 KiB

  1. //==========================================================================;
  2. //
  3. // Composition.h : Declaration of the custom composition class for gluing mpeg2
  4. // decoder to closed caption
  5. // Copyright (c) Microsoft Corporation 1999.
  6. //
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef MP2CCCOMP_H
  9. #define MP2CCCOMP_H
  10. #pragma once
  11. #include <winerror.h>
  12. #include <algorithm>
  13. #include <compimpl.h>
  14. #include <seg.h>
  15. #include <objectwithsiteimplsec.h>
  16. #include "resource.h" // main symbols
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CMP2CCComp
  19. class ATL_NO_VTABLE __declspec(uuid("6AD28EE1-5002-4e71-AAF7-BD077907B1A4")) CMP2CCComp :
  20. public CComObjectRootEx<CComSingleThreadModel>,
  21. public CComCoClass<CMP2CCComp, &__uuidof(CMP2CCComp)>,
  22. public IObjectWithSiteImplSec<CMP2CCComp>,
  23. public IMSVidCompositionSegmentImpl<CMP2CCComp>
  24. {
  25. public:
  26. CMP2CCComp() {}
  27. virtual ~CMP2CCComp() {}
  28. REGISTER_NONAUTOMATION_OBJECT(IDS_PROJNAME,
  29. IDS_REG_MP2CCCOMP_DESC,
  30. LIBID_MSVidCtlLib,
  31. __uuidof(CMP2CCComp));
  32. DECLARE_PROTECT_FINAL_CONSTRUCT()
  33. BEGIN_COM_MAP(CMP2CCComp)
  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, "CMP2CCComp::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, "CMP2CCComp::Compose() can't compose empty up segment");
  57. return E_INVALIDARG;
  58. }
  59. if (down.begin() == down.end()) {
  60. TRACELM(TRACE_ERROR, "CMP2CCComp::Compose() can't compose empty down segment");
  61. return E_INVALIDARG;
  62. }
  63. #if 0
  64. VWGraphSegment::iterator iMP2 = std::find_if(up.begin(),
  65. up.end(),
  66. arity1_pointer(&IsMP2Demux));
  67. #endif
  68. VWGraphSegment::iterator iMP2;
  69. int i;
  70. for (i = 0 , iMP2 = up.begin(); iMP2 != up.end(); ++iMP2, ++i);
  71. for (iMP2 = up.begin(); iMP2 != up.end() && --i; ++iMP2);
  72. if (iMP2 == up.end()) {
  73. TRACELM(TRACE_ERROR, "CMP2CCComp::Compose() upstream segment has no MPEG2 Decoder");
  74. return E_FAIL;
  75. }
  76. ASSERT((*iMP2).GetGraph() == m_pGraph);
  77. VWGraphSegment::iterator iL21 = std::find_if(down.begin(),
  78. down.end(),
  79. arity1_pointer(&IsL21Decoder));
  80. if (iL21 == down.end()) {
  81. TRACELM(TRACE_ERROR, "CMP2CCComp::Compose() downstream segment has no l21Decoder");
  82. return E_FAIL;
  83. }
  84. ASSERT((*iL21).GetGraph() == m_pGraph);
  85. DSFilter pMP2(*iMP2);
  86. DSFilter pL21(*iL21);
  87. HRESULT hr = m_pGraph.Connect(pMP2, pL21, m_Filters, DSGraph::RENDER_ALL_PINS, DOWNSTREAM);
  88. if (FAILED(hr)) {
  89. TRACELSM(TRACE_ERROR, (dbgDump << "CMP2CCComp::Compose() FAILED connect hr = " << hexdump(hr)), "");
  90. return hr;
  91. }
  92. m_fComposed = true;
  93. return NOERROR;
  94. } catch (ComException &e) {
  95. return e;
  96. } catch (...) {
  97. return E_UNEXPECTED;
  98. }
  99. }
  100. };
  101. #endif // MP2CCCOMP_H
  102. // end of file - MP2CCComp.h