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.

106 lines
3.6 KiB

  1. //==========================================================================;
  2. //
  3. // Composition.h : Declaration of the CComposition class
  4. // Copyright (c) Microsoft Corporation 1999.
  5. //
  6. /////////////////////////////////////////////////////////////////////////////
  7. #ifndef __COMPOSITION_H_
  8. #define __COMPOSITION_H_
  9. #include <winerror.h>
  10. #include <algorithm>
  11. #include <objectwithsiteimplsec.h>
  12. #include <compimpl.h>
  13. #include <seg.h>
  14. #include "resource.h" // main symbols
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CComposition
  17. class ATL_NO_VTABLE __declspec(uuid("2764BCE5-CC39-11D2-B639-00C04F79498E")) CComposition :
  18. public CComObjectRootEx<CComMultiThreadModel>,
  19. public CComCoClass<CComposition, &__uuidof(CComposition)>,
  20. public IObjectWithSiteImplSec<CComposition>,
  21. public IMSVidCompositionSegmentImpl<CComposition>
  22. {
  23. public:
  24. CComposition() {}
  25. virtual ~CComposition() {}
  26. REGISTER_NONAUTOMATION_OBJECT_WITH_TM(IDS_PROJNAME,
  27. IDS_REG_COMPOSITION_DESC,
  28. LIBID_MSVidCtlLib,
  29. __uuidof(CComposition), tvBoth);
  30. DECLARE_PROTECT_FINAL_CONSTRUCT()
  31. BEGIN_COM_MAP(CComposition)
  32. COM_INTERFACE_ENTRY(IMSVidCompositionSegment)
  33. COM_INTERFACE_ENTRY(IMSVidGraphSegment)
  34. COM_INTERFACE_ENTRY(IPersist)
  35. COM_INTERFACE_ENTRY(IObjectWithSite)
  36. END_COM_MAP_WITH_FTM()
  37. // IMSVidComposition
  38. public:
  39. // IMSVidGraphSegment
  40. // IMSVidCompositionSegment
  41. STDMETHOD(Compose)(IMSVidGraphSegment * upstream, IMSVidGraphSegment * downstream)
  42. {
  43. if (m_fComposed) {
  44. return NOERROR;
  45. }
  46. ASSERT(m_pGraph);
  47. try {
  48. VWGraphSegment up(upstream);
  49. ASSERT(up.Graph() == m_pGraph);
  50. VWGraphSegment down(downstream);
  51. ASSERT(down.Graph() == m_pGraph);
  52. if (upstream == downstream) {
  53. return Error(IDS_CANT_COMPOSE_WITH_SELF, __uuidof(IMSVidCompositionSegment), E_INVALIDARG);
  54. }
  55. if (up.begin() == up.end()) {
  56. TRACELM(TRACE_ERROR, "CComposition::Compose() can't compose empty up segment");
  57. return NOERROR;
  58. }
  59. if (down.begin() == down.end()) {
  60. TRACELM(TRACE_ERROR, "CComposition::Compose() can't compose empty down segment");
  61. // this is not an error, for example, CA is an empty segment.
  62. return NOERROR;
  63. }
  64. for (VWGraphSegment::iterator iStart = up.begin(); iStart != up.end(); ++iStart) {
  65. ASSERT((*iStart).GetGraph() == m_pGraph);
  66. for (VWGraphSegment::iterator iStop = down.begin(); iStop != down.end(); ++ iStop) {
  67. ASSERT((*iStop).GetGraph() == m_pGraph);
  68. DSFilter pStart(*iStart);
  69. DSFilter pStop(*iStop);
  70. HRESULT hr = m_pGraph.Connect(pStart, pStop, m_Filters);
  71. if (SUCCEEDED(hr)) {
  72. m_Segments.push_back(up);
  73. m_Segments.push_back(down);
  74. m_pDown = m_Segments.end();
  75. --m_pDown;
  76. m_pUp = m_pDown;
  77. --m_pUp;
  78. m_fComposed = true;
  79. return NOERROR;
  80. }
  81. }
  82. }
  83. TRACELM(TRACE_ERROR, "CComposition::Compose() compose didn't connect anything");
  84. // return Error(IDS_CANT_COMPOSE, __uuidof(IMSVidCompositionSegment), E_FAIL);
  85. // bda tuner input doesn't compose with anything in CC. rather, line 21 decoder is
  86. // picked up when bda tuner is connected with video renderer.
  87. // But we do need to know that some cases fail such as dvd to vmr
  88. // so in those cases we return s_false
  89. return S_FALSE;
  90. } catch (ComException &e) {
  91. return e;
  92. } catch (...) {
  93. return E_UNEXPECTED;
  94. }
  95. }
  96. };
  97. #endif //__COMPOSITION_H_