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.

172 lines
4.8 KiB

  1. //==========================================================================;
  2. //
  3. // seg.h : additional infrastructure to support using IMSVidGraphSegment nicely from c++
  4. // Copyright (c) Microsoft Corporation 1999.
  5. //
  6. /////////////////////////////////////////////////////////////////////////////
  7. #pragma once
  8. #ifndef SEG_H
  9. #define SEG_H
  10. #include <segment.h>
  11. #include <fwdseq.h>
  12. #include <devseq.h>
  13. #include <dsextend.h>
  14. #include <objectwithsiteimplsec.h>
  15. namespace MSVideoControl {
  16. typedef CComQIPtr<IMSVidGraphSegment, &__uuidof(IMSVidGraphSegment)> PQGraphSegment;
  17. typedef Forward_Sequence<
  18. PQGraphSegment,
  19. PQEnumFilters,
  20. DSFilter,
  21. IMSVidGraphSegment,
  22. IEnumFilters,
  23. IBaseFilter*> VWGraphSegmentSequence;
  24. class VWSegmentContainer;
  25. class VWGraphSegment : public VWGraphSegmentSequence {
  26. public:
  27. inline VWGraphSegment() {}
  28. virtual ~VWGraphSegment() {}
  29. inline VWGraphSegment(const PQGraphSegment &a) : VWGraphSegmentSequence(a) {}
  30. inline VWGraphSegment(IMSVidGraphSegment *p) : VWGraphSegmentSequence(p) {}
  31. inline VWGraphSegment(IUnknown *p) : VWGraphSegmentSequence(p) {}
  32. inline VWGraphSegment(const VWGraphSegment &a) : VWGraphSegmentSequence(a) {}
  33. inline VWGraphSegment(const CComVariant &v) : VWGraphSegmentSequence(((v.vt == VT_UNKNOWN) ? v.punkVal : (v.vt == VT_DISPATCH ? v.pdispVal : NULL))) {}
  34. VWSegmentContainer Container(void);
  35. MSVidSegmentType Type(void);
  36. DSGraph Graph(void);
  37. GUID2 Category();
  38. GUID2 ClassID();
  39. };
  40. typedef CComQIPtr<IMSVidGraphSegmentContainer, &__uuidof(IMSVidGraphSegmentContainer)> PQSegmentContainer;
  41. class VWSegmentContainer : public PQSegmentContainer {
  42. public:
  43. inline VWSegmentContainer() {}
  44. inline VWSegmentContainer(const PQSegmentContainer &a) : PQSegmentContainer(a) {}
  45. inline VWSegmentContainer(IUnknown *p) : PQSegmentContainer(p) {}
  46. inline VWSegmentContainer(IMSVidGraphSegmentContainer *p) : PQSegmentContainer(p) {}
  47. inline VWSegmentContainer(const VWSegmentContainer &a) : PQSegmentContainer(a) {}
  48. virtual ~VWSegmentContainer() {}
  49. DSGraph GetGraph(void) {
  50. DSGraph g;
  51. IMSVidGraphSegmentContainer* p = (*this);
  52. if (p) {
  53. p->get_Graph(&g);
  54. }
  55. return g;
  56. }
  57. };
  58. typedef std::vector<VWGraphSegment> VWSegmentList;
  59. typedef CComQIPtr<IEnumMSVidGraphSegment, &__uuidof(IEnumMSVidGraphSegment)> PQEnumSegment;
  60. void CtorStaticVWSegmentFwdSeqPMFs(void);
  61. void DtorStaticVWSegmentFwdSeqPMFs(void);
  62. class ATL_NO_VTABLE CSegEnumBase : public CComObjectRootEx<CComSingleThreadModel>,
  63. public IEnumMSVidGraphSegment,
  64. public IObjectWithSiteImplSec<CSegEnumBase>
  65. {
  66. BEGIN_COM_MAP(CSegEnumBase)
  67. COM_INTERFACE_ENTRY(IEnumMSVidGraphSegment)
  68. COM_INTERFACE_ENTRY(IObjectWithSite)
  69. END_COM_MAP()
  70. DECLARE_PROTECT_FINAL_CONSTRUCT()
  71. virtual ~CSegEnumBase() {}
  72. };
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CSegEnum
  75. class CSegEnum : public CComObject<CSegEnumBase>
  76. {
  77. public:
  78. CSegEnum(DeviceCollection &d) {
  79. for (DeviceCollection::iterator i = d.begin(); i != d.end(); ++i) {
  80. VWGraphSegment seg(*i);
  81. ASSERT(seg);
  82. m_pSegments.push_back(seg);
  83. }
  84. }
  85. CSegEnum(VWSegmentList &s) : m_pSegments(s), i(s.begin()) {
  86. }
  87. CSegEnum(CSegEnum &orig) : m_pSegments(orig.m_pSegments) {
  88. i = m_pSegments.begin();
  89. VWSegmentList::iterator i2 = orig.m_pSegments.end();
  90. for (;i2 != orig.i; ++i2, ++i);
  91. }
  92. virtual ~CSegEnum() {
  93. i = m_pSegments.end();
  94. m_pSegments.clear();
  95. }
  96. // ISegEnum
  97. public:
  98. VWSegmentList m_pSegments;
  99. VWSegmentList::iterator i;
  100. // IEnumMSVidGraphSegment
  101. STDMETHOD(Next)(ULONG celt, IMSVidGraphSegment **rgvar, ULONG * pceltFetched)
  102. {
  103. // pceltFetched can legally == 0
  104. //
  105. if (pceltFetched != NULL) {
  106. try {
  107. *pceltFetched = 0;
  108. } catch(...) {
  109. return E_POINTER;
  110. }
  111. }
  112. // Retrieve the next celt elements.
  113. HRESULT hr = NOERROR ;
  114. for (ULONG l = 0;i != m_pSegments.end() && celt != 0 ; ++i, ++l, --celt) {
  115. (*i).CopyTo(&rgvar[l]);
  116. if (pceltFetched != NULL) {
  117. (*pceltFetched)++ ;
  118. }
  119. }
  120. if (celt != 0) {
  121. hr = ResultFromScode( S_FALSE ) ;
  122. }
  123. return hr ;
  124. }
  125. STDMETHOD(Skip)(ULONG celt)
  126. {
  127. for (;i != m_pSegments.end() && celt--; ++i);
  128. return (celt == 0 ? NOERROR : ResultFromScode( S_FALSE )) ;
  129. }
  130. STDMETHOD(Reset)()
  131. {
  132. i = m_pSegments.begin();
  133. return NOERROR;
  134. }
  135. STDMETHOD(Clone)(IEnumMSVidGraphSegment * * ppenum)
  136. {
  137. PQEnumSegment temp;
  138. try {
  139. temp = new CSegEnum(*this);
  140. } catch(...) {
  141. return E_OUTOFMEMORY;
  142. }
  143. try {
  144. *ppenum = temp.Detach();
  145. } catch(...) {
  146. return E_POINTER;
  147. }
  148. return NOERROR;
  149. }
  150. };
  151. };
  152. #endif
  153. // end of file seg.h