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
5.1 KiB

  1. //==========================================================================;
  2. //
  3. // dat2xds.h : Declaration of the custom composition class for gluing sbe source to vmr
  4. // TODO: Need to update header file and change classids
  5. // Copyright (c) Microsoft Corporation 1999.
  6. //
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef DAT2XDS_H
  9. #define DAT2XDS_H
  10. #pragma once
  11. #include <uuids.h>
  12. #include "bdamedia.h"
  13. #include "MSVidEncoder.h"
  14. #include "resource.h" // main symbols
  15. #include <winerror.h>
  16. #include <algorithm>
  17. #include <compimpl.h>
  18. #include <seg.h>
  19. #include <objectwithsiteimplsec.h>
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CDat2XDSComp
  22. class ATL_NO_VTABLE __declspec(uuid("0429EC6E-1144-4bed-B88B-2FB9899A4A3D")) CDat2XDSComp :
  23. public CComObjectRootEx<CComSingleThreadModel>,
  24. public CComCoClass<CDat2XDSComp, &__uuidof(CDat2XDSComp)>,
  25. public IObjectWithSiteImplSec<CDat2XDSComp>,
  26. public IMSVidCompositionSegmentImpl<CDat2XDSComp>
  27. {
  28. public:
  29. CDat2XDSComp() {}
  30. virtual ~CDat2XDSComp() {}
  31. REGISTER_NONAUTOMATION_OBJECT(IDS_PROJNAME,
  32. IDS_REG_DAT2XDSCOMP_DESC,
  33. LIBID_MSVidCtlLib,
  34. __uuidof(CDat2XDSComp));
  35. DECLARE_PROTECT_FINAL_CONSTRUCT()
  36. BEGIN_COM_MAP(CDat2XDSComp)
  37. COM_INTERFACE_ENTRY(IMSVidCompositionSegment)
  38. COM_INTERFACE_ENTRY(IMSVidGraphSegment)
  39. COM_INTERFACE_ENTRY(IObjectWithSite)
  40. COM_INTERFACE_ENTRY(IPersist)
  41. END_COM_MAP()
  42. // IMSVidComposition
  43. public:
  44. // IMSVidGraphSegment
  45. // IMSVidCompositionSegment
  46. STDMETHOD(Compose)(IMSVidGraphSegment * upstream, IMSVidGraphSegment * downstream)
  47. {
  48. if (m_fComposed) {
  49. return NOERROR;
  50. }
  51. ASSERT(m_pGraph);
  52. try {
  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(IMSVidCompositionSegment), E_INVALIDARG);
  59. }
  60. if (up.begin() == up.end()) {
  61. TRACELM(TRACE_ERROR, "CComposition::Compose() can't compose empty up segment");
  62. return NOERROR;
  63. }
  64. if (down.begin() == down.end()) {
  65. TRACELM(TRACE_ERROR, "CComposition::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. bool vidFound = false;
  70. // VMR has a bug so we need to connect the video before the cc or no cc will be displayed
  71. DSMediaType mtVideo(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO, FORMAT_MPEG2Video);
  72. for (VWGraphSegment::iterator iStart = up.begin(); iStart != up.end(); ++iStart) {
  73. ASSERT((*iStart).GetGraph() == m_pGraph);
  74. if(!vidFound){
  75. for(DSFilter::iterator i = (*iStart).begin(); i != (*iStart).end(); ++i){
  76. if((*i).GetDirection() == DOWNSTREAM){
  77. for(DSPin::iterator p = (*i).begin(); p != (*i).end(); ++p){
  78. if((*p) == mtVideo){
  79. for (VWGraphSegment::iterator iStop = down.begin(); iStop != down.end(); ++ iStop) {
  80. ASSERT((*iStop).GetGraph() == m_pGraph);
  81. DSFilter pStop(*iStop);
  82. (*i).IntelligentConnect(pStop, m_Filters);
  83. }
  84. vidFound = true;
  85. iStart = up.begin();
  86. }
  87. }
  88. }
  89. }
  90. }
  91. else{
  92. for (VWGraphSegment::iterator iStop = down.begin(); iStop != down.end(); ++ iStop) {
  93. ASSERT((*iStop).GetGraph() == m_pGraph);
  94. DSFilter pStart(*iStart);
  95. DSFilter pStop(*iStop);
  96. HRESULT hr = m_pGraph.Connect(pStart, pStop, m_Filters);
  97. if (SUCCEEDED(hr)) {
  98. m_Segments.push_back(up);
  99. m_Segments.push_back(down);
  100. m_pDown = m_Segments.end();
  101. --m_pDown;
  102. m_pUp = m_pDown;
  103. --m_pUp;
  104. m_fComposed = true;
  105. return NOERROR;
  106. }
  107. }
  108. }
  109. }
  110. TRACELM(TRACE_ERROR, "CComposition::Compose() compose didn't connect anything");
  111. return VFW_E_NO_DECOMPRESSOR;
  112. } catch (ComException &e) {
  113. return e;
  114. } catch (...) {
  115. return E_UNEXPECTED;
  116. }
  117. }
  118. };
  119. #endif // Dat2XDS_H
  120. // end of file - Dat2XDS.h