CGraphBuilderCB.cpp
上传用户:hhs829
上传日期:2022-06-17
资源大小:586k
文件大小:2k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. //
  2. // CGraphBuilderCB.cpp
  3. //
  4. #include "stdafx.h"
  5. #include <streams.h>
  6. #include "CGraphBuilderCB.h"
  7. #include "CSupported.h"
  8. //////////////////////////////////////////////////////////////////////////////
  9. CGraphBuilderCB::CGraphBuilderCB() :
  10. CUnknown(NAME("Callbacker"), NULL)
  11. {
  12. mSupported = new CSupported();
  13. }
  14. CGraphBuilderCB::~CGraphBuilderCB()
  15. {
  16. if (mSupported)
  17. {
  18. delete mSupported;
  19. mSupported = NULL;
  20. }
  21. }
  22. STDMETHODIMP CGraphBuilderCB::NonDelegatingQueryInterface(REFIID riid, void** ppv)
  23. {
  24.     if (riid == __uuidof(IAMGraphBuilderCallback)) 
  25. {
  26.         return GetInterface((IAMGraphBuilderCallback*)this, ppv);
  27.     }
  28.     return CUnknown::NonDelegatingQueryInterface(riid,ppv);
  29. }
  30. //////////////////////////////////////////////////////////////////////////////
  31. //
  32. // IAMGraphBuilderCallback-overriden functions
  33. //////////////////////////////////////////////////////////////////////////////
  34. //----------------------------------------------------------------------------
  35. // SelectedFilter
  36. //
  37. //----------------------------------------------------------------------------
  38. STDMETHODIMP CGraphBuilderCB::SelectedFilter(IMoniker *pMon)
  39. {
  40. if (!pMon)
  41. {
  42. return E_POINTER;
  43. }
  44. IBindCtx * pBCtx = NULL;
  45. HRESULT hr = CreateBindCtx(0, (LPBC*)&pBCtx );
  46. if (!pBCtx || FAILED(hr))
  47. {
  48. return E_UNEXPECTED;
  49. }
  50. IBaseFilter * pBf = NULL;
  51.     hr = pMon->BindToObject(pBCtx, NULL, __uuidof(IBaseFilter), (void**)&pBf);
  52.     pBCtx->Release();
  53.     if (FAILED(hr) || !pBf)
  54.     {
  55.         return E_UNEXPECTED;
  56.     }
  57. // Get filter's CLSID
  58. IPersist * pPersist = NULL;
  59. hr = pBf->QueryInterface( __uuidof(IPersist), (void**)&pPersist);
  60. pBf->Release();
  61. if (SUCCEEDED(hr))
  62. {
  63. CLSID  clsid = GUID_NULL;
  64. pPersist->GetClassID(&clsid);
  65. pPersist->Release();
  66. if (CSupported::IsGUIDSupported(clsid))
  67. {
  68. return S_OK;
  69. }
  70. }
  71. return E_FAIL;
  72. }
  73. //----------------------------------------------------------------------------
  74. // CreatedFilter
  75. //
  76. //----------------------------------------------------------------------------
  77. STDMETHODIMP CGraphBuilderCB::CreatedFilter(IBaseFilter *pBf)
  78. {
  79.     return S_OK;
  80. }