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.

188 lines
4.3 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. blbmedia.h:
  5. Abstract:
  6. Definition of the MEDIA class
  7. Author:
  8. */
  9. #if !defined(AFX_MEDIA_H__0CC1F057_CAEB_11D0_8D58_00C04FD91AC0__INCLUDED_)
  10. #define AFX_MEDIA_H__0CC1F057_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 "blbcoen.h"
  16. #include "blbsdp.h"
  17. #include "blbconn.h"
  18. #include "blbatt.h"
  19. /////////////////////////////////////////////////////////////////////////////
  20. // MEDIA
  21. const USHORT MAX_PORT_STRLEN = 5;
  22. template <class T>
  23. class ITMediaVtbl : public ITMedia
  24. {
  25. };
  26. class ATL_NO_VTABLE MEDIA :
  27. public ENUM_ELEMENT<SDP_MEDIA>,
  28. public CComObjectRootEx<CComObjectThreadModel>,
  29. public CComDualImpl<ITMediaVtbl<MEDIA>, &IID_ITMedia, &LIBID_SDPBLBLib>,
  30. public ITConnectionImpl,
  31. public ITAttributeListImpl,
  32. public CObjectSafeImpl
  33. {
  34. protected:
  35. friend class MY_COLL_IMPL<MEDIA>;
  36. public:
  37. typedef ITMedia ELEM_IF;
  38. typedef IEnumMedia ENUM_IF;
  39. typedef ITMediaCollection COLL_IF;
  40. typedef SDP_MEDIA SDP_TYPE;
  41. typedef SDP_MEDIA_LIST SDP_LIST;
  42. static const IID &ELEM_IF_ID;
  43. public:
  44. inline MEDIA();
  45. inline ~MEDIA();
  46. inline HRESULT FinalConstruct();
  47. HRESULT Init(
  48. IN CSdpConferenceBlob &ConfBlob
  49. );
  50. inline void SuccessInit(
  51. IN CSdpConferenceBlob &ConfBlob,
  52. IN SDP_MEDIA &SdpMedia
  53. );
  54. inline void ClearSdpBlobRefs();
  55. BEGIN_COM_MAP(MEDIA)
  56. COM_INTERFACE_ENTRY2(IDispatch, ITMedia)
  57. COM_INTERFACE_ENTRY(ITMedia)
  58. COM_INTERFACE_ENTRY(ITConnection)
  59. COM_INTERFACE_ENTRY(ITAttributeList)
  60. COM_INTERFACE_ENTRY(IObjectSafety)
  61. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  62. END_COM_MAP()
  63. DECLARE_NOT_AGGREGATABLE(MEDIA)
  64. DECLARE_GET_CONTROLLING_UNKNOWN()
  65. // ITMedia
  66. STDMETHOD(get_MediaTitle)(/*[out, retval]*/ BSTR *ppMediaTitle);
  67. STDMETHOD(put_MediaTitle)(/*[in]*/ BSTR pMediaTitle);
  68. STDMETHOD(get_FormatCodes)(/*[out, retval]*/ VARIANT /*SAFEARRAY (BSTR)*/ *pVal);
  69. STDMETHOD(put_FormatCodes)(/*[in]*/ VARIANT /*SAFEARRAY (BSTR)*/ NewVal);
  70. STDMETHOD(get_TransportProtocol)(/*[out, retval]*/ BSTR *ppProtocol);
  71. STDMETHOD(put_TransportProtocol)(/*[in]*/ BSTR pProtocol);
  72. STDMETHOD(get_NumPorts)(/*[out, retval]*/ LONG *pNumPorts);
  73. STDMETHOD(get_StartPort)(/*[out, retval]*/ LONG *pStartPort);
  74. STDMETHOD(get_MediaName)(/*[out, retval]*/ BSTR *ppMediaName);
  75. STDMETHOD(put_MediaName)(/*[in]*/ BSTR pMediaName);
  76. STDMETHOD(SetPortInfo)(/*[in]*/ LONG StartPort, /*[in]*/ LONG NumPorts);
  77. //
  78. // IDispatch methods
  79. //
  80. STDMETHOD(GetIDsOfNames)(REFIID riid,
  81. LPOLESTR* rgszNames,
  82. UINT cNames,
  83. LCID lcid,
  84. DISPID* rgdispid
  85. );
  86. STDMETHOD(Invoke)(DISPID dispidMember,
  87. REFIID riid,
  88. LCID lcid,
  89. WORD wFlags,
  90. DISPPARAMS* pdispparams,
  91. VARIANT* pvarResult,
  92. EXCEPINFO* pexcepinfo,
  93. UINT* puArgErr
  94. );
  95. protected:
  96. CSdpConferenceBlob * m_ConfBlob;
  97. IUnknown * m_pFTM; // pointer to the free threaded marshaler
  98. virtual CSdpConferenceBlob *GetConfBlob();
  99. };
  100. inline
  101. MEDIA::MEDIA(
  102. )
  103. : m_ConfBlob(NULL),
  104. m_pFTM(NULL)
  105. {
  106. }
  107. inline
  108. MEDIA::~MEDIA()
  109. {
  110. if ( m_pFTM )
  111. {
  112. m_pFTM->Release();
  113. }
  114. }
  115. inline
  116. HRESULT MEDIA::FinalConstruct()
  117. {
  118. HRESULT HResult = CoCreateFreeThreadedMarshaler( GetControllingUnknown(),
  119. & m_pFTM );
  120. if ( FAILED(HResult) )
  121. {
  122. return HResult;
  123. }
  124. return S_OK;
  125. }
  126. inline void
  127. MEDIA::SuccessInit(
  128. IN CSdpConferenceBlob &ConfBlob,
  129. IN SDP_MEDIA &SdpMedia
  130. )
  131. {
  132. m_ConfBlob = &ConfBlob;
  133. ENUM_ELEMENT<SDP_MEDIA>::SuccessInit(SdpMedia, FALSE);
  134. ITConnectionImpl::SuccessInit(SdpMedia);
  135. ITAttributeListImpl::SuccessInit(SdpMedia.GetAttributeList());
  136. }
  137. inline void
  138. MEDIA::ClearSdpBlobRefs(
  139. )
  140. {
  141. m_ConfBlob = NULL;
  142. }
  143. #endif // !defined(AFX_MEDIA_H__0CC1F057_CAEB_11D0_8D58_00C04FD91AC0__INCLUDED_)