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.

285 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. H323addr.cpp
  5. Abstract:
  6. This module contains implementation of CH323MSP.
  7. Author:
  8. Mu Han (muhan) 5-September-1997
  9. --*/
  10. #include "stdafx.h"
  11. #include "common.h"
  12. STDMETHODIMP CH323MSP::CreateTerminal(
  13. IN BSTR pTerminalClass,
  14. IN long lMediaType,
  15. IN TERMINAL_DIRECTION Direction,
  16. OUT ITTerminal ** ppTerminal
  17. )
  18. /*++
  19. Routine Description:
  20. This method is called by TAPI3 to create a dynamic terminal. It asks the
  21. terminal manager to create a dynamic terminal.
  22. Arguments:
  23. iidTerminalClass
  24. IID of the terminal class to be created.
  25. dwMediaType
  26. TAPI media type of the terminal to be created.
  27. Direction
  28. Terminal direction of the terminal to be created.
  29. ppTerminal
  30. Returned created terminal object
  31. Return Value:
  32. S_OK
  33. E_OUTOFMEMORY
  34. TAPI_E_INVALIDMEDIATYPE
  35. TAPI_E_INVALIDTERMINALDIRECTION
  36. TAPI_E_INVALIDTERMINALCLASS
  37. --*/
  38. {
  39. LOG((MSP_TRACE,
  40. "CH323MSP::CreateTerminal - enter"));
  41. //
  42. // Check if initialized.
  43. //
  44. // lock the event related data
  45. m_EventDataLock.Lock();
  46. if ( m_htEvent == NULL )
  47. {
  48. // unlock the event related data
  49. m_EventDataLock.Unlock();
  50. LOG((MSP_ERROR,
  51. "CH323MSP::CreateTerminal - "
  52. "not initialized - returning E_UNEXPECTED"));
  53. return E_UNEXPECTED;
  54. }
  55. // unlock the event related data
  56. m_EventDataLock.Unlock();
  57. //
  58. // Get the IID from the BSTR representation.
  59. //
  60. HRESULT hr;
  61. IID iidTerminalClass;
  62. hr = CLSIDFromString(pTerminalClass, &iidTerminalClass);
  63. if ( FAILED(hr) )
  64. {
  65. LOG((MSP_ERROR, "CH323MSP::CreateTerminal - "
  66. "bad CLSID string - returning E_INVALIDARG"));
  67. return E_INVALIDARG;
  68. }
  69. //
  70. // we don't have any specific req's to terminal's media type.
  71. // termmgr will check if the media type is valid at all.
  72. //
  73. //
  74. // The terminal manager checks the terminal class, terminal direction,
  75. // and return pointer.
  76. //
  77. //
  78. // Use the terminal manager to create the dynamic terminal.
  79. //
  80. _ASSERTE( m_pITTerminalManager != NULL );
  81. hr = m_pITTerminalManager->CreateDynamicTerminal(NULL,
  82. iidTerminalClass,
  83. (DWORD) lMediaType,
  84. Direction,
  85. (MSP_HANDLE) this,
  86. ppTerminal);
  87. if ( FAILED(hr) )
  88. {
  89. LOG((MSP_ERROR, "CH323MSP::CreateTerminal - "
  90. "create dynamic terminal failed - returning 0x%08x", hr));
  91. return hr;
  92. }
  93. if ((iidTerminalClass == CLSID_MediaStreamTerminal)
  94. && (lMediaType == TAPIMEDIATYPE_AUDIO))
  95. {
  96. // Set the format of the audio to 8KHZ, 16Bit/Sample, MONO.
  97. hr = ::SetAudioFormat(
  98. *ppTerminal,
  99. g_wAudioCaptureBitPerSample,
  100. g_dwAudioSampleRate
  101. );
  102. if (FAILED(hr))
  103. {
  104. LOG((MSP_WARN, "can't set audio format, %x", hr));
  105. }
  106. }
  107. LOG((MSP_TRACE, "CH323MSP::CreateTerminal - exit S_OK"));
  108. return S_OK;
  109. }
  110. STDMETHODIMP CH323MSP::CreateMSPCall(
  111. IN MSP_HANDLE htCall,
  112. IN DWORD dwReserved,
  113. IN DWORD dwMediaType,
  114. IN IUnknown * pOuterUnknown,
  115. OUT IUnknown ** ppMSPCall
  116. )
  117. /*++
  118. Routine Description:
  119. This method is called by TAPI3 before a call is made or answered. It creates
  120. a aggregated MSPCall object and returns the IUnknown pointer. It calls the
  121. helper template function defined in mspaddress.h to handle the real creation.
  122. Arguments:
  123. htCall
  124. TAPI 3.0's identifier for this call. Returned in events passed back
  125. to TAPI.
  126. dwReserved
  127. Reserved parameter. Not currently used.
  128. dwMediaType
  129. Media type of the call being created. These are TAPIMEDIATYPES and more
  130. than one mediatype can be selected (bitwise).
  131. pOuterUnknown
  132. pointer to the IUnknown interface of the containing object.
  133. ppMSPCall
  134. Returned MSP call that the MSP fills on on success.
  135. Return Value:
  136. S_OK
  137. E_OUTOFMEMORY
  138. E_POINTER
  139. TAPI_E_INVALIDMEDIATYPE
  140. --*/
  141. {
  142. LOG((MSP_TRACE,
  143. "CreateMSPCall entered. htCall:%x, dwMediaType:%x, ppMSPCall:%x",
  144. htCall, dwMediaType, ppMSPCall
  145. ));
  146. CH323MSPCall * pMSPCall = NULL;
  147. // This function does all the parameter checkings.
  148. HRESULT hr = ::CreateMSPCallHelper(
  149. this,
  150. htCall,
  151. dwReserved,
  152. dwMediaType,
  153. pOuterUnknown,
  154. ppMSPCall,
  155. &pMSPCall
  156. );
  157. if (FAILED(hr))
  158. {
  159. LOG((MSP_ERROR, "CreateMSPCallHelper failed:%x", hr));
  160. return hr;
  161. }
  162. return hr;
  163. }
  164. STDMETHODIMP CH323MSP::ShutdownMSPCall(
  165. IN IUnknown * pUnknown
  166. )
  167. /*++
  168. Routine Description:
  169. This method is called by TAPI3 to shutdown a MSPCall. It calls the helper
  170. function defined in MSPAddress to to the real job.
  171. Arguments:
  172. pUnknown
  173. pointer to the IUnknown interface of the contained object. It is a
  174. CComAggObject that contains our call object.
  175. Return Value:
  176. S_OK
  177. E_POINTER
  178. TAPI_E_INVALIDMEDIATYPE
  179. --*/
  180. {
  181. LOG((MSP_TRACE, "ShutDownMSPCall entered. pUnknown:%x", pUnknown));
  182. if (IsBadReadPtr(pUnknown, sizeof(VOID *) * 3))
  183. {
  184. LOG((MSP_ERROR, "ERROR:pUnknow is a bad pointer"));
  185. return E_POINTER;
  186. }
  187. CH323MSPCall * pMSPCall = NULL;
  188. HRESULT hr = ::ShutdownMSPCallHelper(pUnknown, &pMSPCall);
  189. if (FAILED(hr))
  190. {
  191. LOG((MSP_ERROR, "ShutDownMSPCallhelper failed:: %x", hr));
  192. return hr;
  193. }
  194. return hr;
  195. }
  196. DWORD CH323MSP::GetCallMediaTypes(void)
  197. {
  198. return H323CALLMEDIATYPES;
  199. }
  200. ULONG CH323MSP::MSPAddressAddRef(void)
  201. {
  202. return MSPAddRefHelper(this);
  203. }
  204. ULONG CH323MSP::MSPAddressRelease(void)
  205. {
  206. return MSPReleaseHelper(this);
  207. }