Leaked source code of windows server 2003
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
4.3 KiB

  1. //==========================================================================;
  2. //
  3. // Composition.h : Declaration of the custom composition class for gluing sbe source to the vmr
  4. // Copyright (c) Microsoft Corporation 1999.
  5. //
  6. /////////////////////////////////////////////////////////////////////////////
  7. #ifndef SBES2VMR_H
  8. #define SBES2VMR_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. // CSbeS2VmrComp
  19. class ATL_NO_VTABLE __declspec(uuid("3C4708DC-B181-46a8-8DA8-4AB0371758CD")) CSbeS2VmrComp :
  20. public CComObjectRootEx<CComSingleThreadModel>,
  21. public CComCoClass<CSbeS2VmrComp, &__uuidof(CSbeS2VmrComp)>,
  22. public IObjectWithSiteImplSec<CSbeS2VmrComp>,
  23. public IMSVidCompositionSegmentImpl<CSbeS2VmrComp>
  24. {
  25. public:
  26. CSbeS2VmrComp() {}
  27. virtual ~CSbeS2VmrComp() {}
  28. REGISTER_NONAUTOMATION_OBJECT(IDS_PROJNAME,
  29. IDS_REG_SBES2VMR_DESC,
  30. LIBID_MSVidCtlLib,
  31. __uuidof(CSbeS2VmrComp));
  32. DECLARE_PROTECT_FINAL_CONSTRUCT()
  33. BEGIN_COM_MAP(CSbeS2VmrComp)
  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. TRACELM(TRACE_ERROR, "CSbeS2VmrComp::Compose()");
  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, "CSbeS2VmrComp::Compose() can't compose empty up segment");
  62. return NOERROR;
  63. }
  64. if (down.begin() == down.end()) {
  65. TRACELM(TRACE_ERROR, "CSbeS2VmrComp::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);
  72. for (VWGraphSegment::iterator iStart = up.begin(); iStart != up.end(); ++iStart) {
  73. ASSERT((*iStart).GetGraph() == m_pGraph);
  74. for(DSFilter::iterator i = (*iStart).begin(); i != (*iStart).end(); ++i){
  75. if((*i).GetDirection() == DOWNSTREAM){
  76. for(DSPin::iterator p = (*i).begin(); p != (*i).end(); ++p){
  77. if((*p) == mtVideo){
  78. HRESULT hr = E_FAIL;
  79. for (VWGraphSegment::iterator iStop = down.begin(); iStop != down.end(); ++ iStop) {
  80. ASSERT((*iStop).GetGraph() == m_pGraph);
  81. DSFilter pStop(*iStop);
  82. hr = (*i).IntelligentConnect(pStop, m_Filters);
  83. if(SUCCEEDED(hr)){
  84. return NOERROR;
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. TRACELM(TRACE_ERROR, "CSbeS2VmrComp::Compose() compose didn't connect anything");
  93. return VFW_E_NO_DECOMPRESSOR;
  94. } catch (ComException &e) {
  95. return e;
  96. } catch (...) {
  97. return E_UNEXPECTED;
  98. }
  99. }
  100. };
  101. #endif // SBES2VMR_H
  102. // end of file - SBES2VMR.h