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.

114 lines
3.5 KiB

  1. //==========================================================================;
  2. //
  3. // fp2ar.h : Declaration of the custom composition class for gluing file
  4. // playback to the audio renderer
  5. //
  6. // Copyright (c) Microsoft Corporation 1999.
  7. //
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef FP2ARCOMP_H
  10. #define FP2ARCOMP_H
  11. #pragma once
  12. #include <winerror.h>
  13. #include <algorithm>
  14. #include <compimpl.h>
  15. #include <seg.h>
  16. #include <objectwithsiteimplsec.h>
  17. #include "resource.h" // main symbols
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CAnaCapComp
  20. class ATL_NO_VTABLE __declspec(uuid("CC23F537-18D4-4ece-93BD-207A84726979")) CFP2ARComp :
  21. public CComObjectRootEx<CComSingleThreadModel>,
  22. public CComCoClass<CFP2ARComp, &__uuidof(CFP2ARComp)>,
  23. public IObjectWithSiteImplSec<CFP2ARComp>,
  24. public IMSVidCompositionSegmentImpl<CFP2ARComp>
  25. {
  26. public:
  27. CFP2ARComp() {}
  28. virtual ~CFP2ARComp() {}
  29. REGISTER_NONAUTOMATION_OBJECT(IDS_PROJNAME,
  30. IDS_REG_FP2ARCOMP_DESC,
  31. LIBID_MSVidCtlLib,
  32. __uuidof(CFP2ARComp));
  33. DECLARE_PROTECT_FINAL_CONSTRUCT()
  34. BEGIN_COM_MAP(CFP2ARComp)
  35. COM_INTERFACE_ENTRY(IMSVidCompositionSegment)
  36. COM_INTERFACE_ENTRY(IMSVidGraphSegment)
  37. COM_INTERFACE_ENTRY(IPersist)
  38. COM_INTERFACE_ENTRY(IObjectWithSite)
  39. END_COM_MAP()
  40. // IMSVidComposition
  41. public:
  42. // IMSVidGraphSegment
  43. // IMSVidCompositionSegment
  44. STDMETHOD(Compose)(IMSVidGraphSegment * upstream, IMSVidGraphSegment * downstream)
  45. {
  46. TRACELM(TRACE_DEBUG, "CFP2ARComp::Compose()");
  47. if (m_fComposed) {
  48. return NOERROR;
  49. }
  50. ASSERT(m_pGraph);
  51. try {
  52. VWGraphSegment up(upstream);
  53. ASSERT(up.Graph() == m_pGraph);
  54. VWGraphSegment down(downstream);
  55. ASSERT(down.Graph() == m_pGraph);
  56. if (up.begin() == up.end()) {
  57. TRACELM(TRACE_ERROR, "CFP2ARComp::Compose() can't compose empty up segment");
  58. return E_INVALIDARG;
  59. }
  60. if (down.begin() == down.end()) {
  61. TRACELM(TRACE_ERROR, "CFP2ARComp::Compose() can't compose empty down segment");
  62. return E_INVALIDARG;
  63. }
  64. DSFilter pFP(*up.begin());
  65. ASSERT(!!pFP);
  66. ASSERT(pFP.GetGraph() == m_pGraph);
  67. VWGraphSegment::iterator iAR;
  68. DSFilter pAR;
  69. for (iAR = down.begin(); iAR != down.end(); ++iAR) {
  70. pAR = *iAR;
  71. if (IsDigitalAudioRenderer(pAR)) {
  72. break;
  73. }
  74. }
  75. if (iAR == down.end()) {
  76. TRACELM(TRACE_ERROR, "CFP2ARComp::Compose() FAILED to find AR ");
  77. return E_UNEXPECTED;
  78. }
  79. ASSERT(!!pAR);
  80. ASSERT(pAR.GetGraph() == m_pGraph);
  81. HRESULT hr = m_pGraph.Connect(pFP, pAR, m_Filters,
  82. DSGraph::ALLOW_WILDCARDS |
  83. DSGraph::DONT_TERMINATE_ON_RENDERER |
  84. DSGraph::IGNORE_MEDIATYPE_ERRORS,
  85. DOWNSTREAM);
  86. if (FAILED(hr)) {
  87. TRACELSM(TRACE_ERROR, (dbgDump << "CFP2ARComp::Compose() FAILED connect hr = " << hexdump(hr)), "");
  88. return hr;
  89. }
  90. m_fComposed = true;
  91. return NOERROR;
  92. } catch (ComException &e) {
  93. return e;
  94. } catch (...) {
  95. return E_UNEXPECTED;
  96. }
  97. }
  98. };
  99. #endif // FP2ARCOMP_H
  100. // end of file - FP2ARComp.h