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.

118 lines
3.0 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. blbmeco.h
  5. Abstract:
  6. Definition of the MEDIA_COLLECTION class
  7. Author:
  8. */
  9. #if !defined(AFX_BLBMECO_H__0CC1F04D_CAEB_11D0_8D58_00C04FD91AC0__INCLUDED_)
  10. #define AFX_BLBMECO_H__0CC1F04D_CAEB_11D0_8D58_00C04FD91AC0__INCLUDED_
  11. #if _MSC_VER >= 1000
  12. #pragma once
  13. #endif // _MSC_VER >= 1000
  14. #include "resource.h" // main symbols
  15. #include "blbgen.h"
  16. #include "blbsdp.h"
  17. #include "blbcoen.h"
  18. #include "blbmedia.h"
  19. /////////////////////////////////////////////////////////////////////////////
  20. // MEDIA_COLLECTION
  21. typedef IDispatchImpl<MY_COLL_IMPL<MEDIA>, &IID_ITMediaCollection, &LIBID_SDPBLBLib> MY_MEDIA_COLL_DISPATCH_IMPL;
  22. class ATL_NO_VTABLE MEDIA_COLLECTION :
  23. public MY_MEDIA_COLL_DISPATCH_IMPL,
  24. public CComObjectRootEx<CComObjectThreadModel>,
  25. public CObjectSafeImpl
  26. {
  27. public:
  28. BEGIN_COM_MAP(MEDIA_COLLECTION)
  29. COM_INTERFACE_ENTRY2(IDispatch, ITMediaCollection)
  30. COM_INTERFACE_ENTRY(ITMediaCollection)
  31. COM_INTERFACE_ENTRY(IObjectSafety)
  32. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  33. END_COM_MAP()
  34. DECLARE_NOT_AGGREGATABLE(MEDIA_COLLECTION)
  35. DECLARE_GET_CONTROLLING_UNKNOWN()
  36. STDMETHODIMP get_EnumerationIf(
  37. /*[out, retval]*/ ENUM_IF **pVal
  38. )
  39. {
  40. CLock Lock(g_DllLock);
  41. ASSERT(NULL != m_IfArray);
  42. BAIL_IF_NULL(m_IfArray, E_FAIL);
  43. BAIL_IF_NULL(pVal, E_INVALIDARG);
  44. CComObject<CSafeComEnum<ENUM_IF, &IID_IEnumMedia , ELEM_IF *, COPY_ELEM_IF> > * EnumComObject;
  45. HRESULT HResult = CComObject<CSafeComEnum<ENUM_IF, &IID_IEnumMedia , ELEM_IF *, COPY_ELEM_IF> >::
  46. CreateInstance(&EnumComObject);
  47. BAIL_ON_FAILURE(HResult);
  48. HResult = EnumComObject->Init(
  49. m_IfArray->GetElemIfArrayData(),
  50. m_IfArray->GetElemIfArrayData() + m_IfArray->GetSize(),
  51. NULL, // no owner pUnk
  52. AtlFlagCopy // copy the array data
  53. );
  54. if ( FAILED(HResult) )
  55. {
  56. delete EnumComObject;
  57. return HResult;
  58. }
  59. // query for the ENUM_IF interface and return it
  60. HResult = EnumComObject->_InternalQueryInterface(IID_IEnumMedia, (void**)pVal);
  61. if ( FAILED(HResult) )
  62. {
  63. delete EnumComObject;
  64. return HResult;
  65. }
  66. return S_OK;
  67. }
  68. MEDIA_COLLECTION() : m_pFTM(NULL) { }
  69. ~MEDIA_COLLECTION() { if ( m_pFTM ) m_pFTM->Release(); }
  70. inline HRESULT FinalConstruct(void);
  71. protected:
  72. IUnknown * m_pFTM; // pointer to the free threaded marshaler
  73. };
  74. inline
  75. HRESULT MEDIA_COLLECTION::FinalConstruct(void)
  76. {
  77. HRESULT HResult = CoCreateFreeThreadedMarshaler( GetControllingUnknown(),
  78. & m_pFTM );
  79. if ( FAILED(HResult) )
  80. {
  81. return HResult;
  82. }
  83. return S_OK;
  84. }
  85. #endif // !defined(AFX_BLBMECO_H__0CC1F04D_CAEB_11D0_8D58_00C04FD91AC0__INCLUDED_)