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.

253 lines
6.3 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: unk.cpp
  6. * Content: IUnknown implementation
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 10/27/99 rodtoll Created (Modified from dxvoice project)
  11. * 12/16/99 rodtoll Bug #123250 - Insert proper names/descriptions for codecs
  12. * Codec names now based on resource entries for format and
  13. * names are constructed using ACM names + bitrate
  14. * 03/03/2000 rodtoll Updated to handle alternative gamevoice build.
  15. * 04/11/00 rodtoll Added code for redirection for custom builds if registry bit is set
  16. * 04/21/2000 rodtoll Bug #32889 - Does not run on Win2k on non-admin account
  17. * 06/09/00 rmt Updates to split CLSID and allow whistler compat and support external create funcs
  18. * 08/23/2000 rodtoll DllCanUnloadNow always returning TRUE!
  19. * 08/28/2000 masonb Voice Merge: Removed dvosal.h
  20. * 06/27/2001 rodtoll RC2: DPVOICE: DPVACM's DllMain calls into acm -- potential hang
  21. * Move global initialization to first object creation
  22. *
  23. ***************************************************************************/
  24. #include "dpvacmpch.h"
  25. #define EXP __declspec(dllexport)
  26. LPVOID dvcpvACMInterface[] =
  27. {
  28. (LPVOID)CDPVCPI::QueryInterface,
  29. (LPVOID)CDPVCPI::AddRef,
  30. (LPVOID)CDPVCPI::Release,
  31. (LPVOID)CDPVCPI::EnumCompressionTypes,
  32. (LPVOID)CDPVCPI::IsCompressionSupported,
  33. (LPVOID)CDPVCPI::I_CreateCompressor,
  34. (LPVOID)CDPVCPI::I_CreateDeCompressor,
  35. (LPVOID)CDPVCPI::GetCompressionInfo
  36. };
  37. LPVOID dvconvACMInterface[] =
  38. {
  39. (LPVOID)CDPVACMConv::I_QueryInterface,
  40. (LPVOID)CDPVACMConv::I_AddRef,
  41. (LPVOID)CDPVACMConv::I_Release,
  42. (LPVOID)CDPVACMConv::I_InitDeCompress,
  43. (LPVOID)CDPVACMConv::I_InitCompress,
  44. (LPVOID)CDPVACMConv::I_IsValid,
  45. (LPVOID)CDPVACMConv::I_GetUnCompressedFrameSize,
  46. (LPVOID)CDPVACMConv::I_GetCompressedFrameSize,
  47. (LPVOID)CDPVACMConv::I_GetNumFramesPerBuffer,
  48. (LPVOID)CDPVACMConv::I_Convert
  49. };
  50. #undef DPF_MODNAME
  51. #define DPF_MODNAME "DoCreateInstance"
  52. // these two functions are required by the generic class factory file
  53. extern "C" HRESULT DoCreateInstance(LPCLASSFACTORY This, LPUNKNOWN pUnkOuter, REFCLSID rclsid, REFIID riid,
  54. LPVOID *ppvObj)
  55. {
  56. HRESULT hr;
  57. if( ppvObj == NULL ||
  58. !DNVALID_WRITEPTR( ppvObj, sizeof(LPVOID) ) )
  59. {
  60. DPFX(DPFPREP, DVF_ERRORLEVEL, "Invalid pointer passed for object" );
  61. return DVERR_INVALIDPOINTER;
  62. }
  63. if( pUnkOuter != NULL )
  64. {
  65. DPFX(DPFPREP, DVF_ERRORLEVEL, "Object does not support aggregation" );
  66. return CLASS_E_NOAGGREGATION;
  67. }
  68. if( IsEqualGUID(riid,IID_IDPVCompressionProvider) )
  69. {
  70. PDPVCPIOBJECT pObject;
  71. pObject = new DPVCPIOBJECT;
  72. if( pObject == NULL )
  73. {
  74. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  75. return DVERR_OUTOFMEMORY;
  76. }
  77. pObject->pObject = new CDPVACMI;
  78. if( pObject->pObject == NULL )
  79. {
  80. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  81. delete pObject;
  82. return DVERR_OUTOFMEMORY;
  83. }
  84. if (!pObject->pObject->InitClass())
  85. {
  86. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  87. delete pObject->pObject;
  88. delete pObject;
  89. return DVERR_OUTOFMEMORY;
  90. }
  91. pObject->lpvVtble = &dvcpvACMInterface;
  92. hr = CDPVACMI::QueryInterface( pObject, riid, ppvObj );
  93. if (FAILED(hr))
  94. {
  95. DPFX(DPFPREP, DVF_ERRORLEVEL, "QI failed" );
  96. delete pObject->pObject;
  97. delete pObject;
  98. }
  99. }
  100. else if( IsEqualGUID(riid,IID_IDPVConverter) )
  101. {
  102. PDPVACMCONVOBJECT pObject;
  103. pObject = new DPVACMCONVOBJECT;
  104. if( pObject == NULL )
  105. {
  106. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  107. return DVERR_OUTOFMEMORY;
  108. }
  109. pObject->pObject = new CDPVACMConv;
  110. if( pObject->pObject == NULL )
  111. {
  112. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  113. delete pObject;
  114. return DVERR_OUTOFMEMORY;
  115. }
  116. if (!pObject->pObject->InitClass())
  117. {
  118. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  119. delete pObject->pObject;
  120. delete pObject;
  121. return DVERR_OUTOFMEMORY;
  122. }
  123. pObject->lpvVtble = &dvconvACMInterface;
  124. hr = CDPVACMConv::I_QueryInterface( pObject, riid, ppvObj );
  125. if (FAILED(hr))
  126. {
  127. DPFX(DPFPREP, DVF_ERRORLEVEL, "QI failed" );
  128. delete pObject->pObject;
  129. delete pObject;
  130. }
  131. }
  132. else if( IsEqualGUID(riid,IID_IUnknown ) )
  133. {
  134. if( rclsid == CLSID_DPVCPACM )
  135. {
  136. PDPVCPIOBJECT pObject;
  137. pObject = new DPVCPIOBJECT;
  138. if( pObject == NULL )
  139. {
  140. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  141. return DVERR_OUTOFMEMORY;
  142. }
  143. pObject->pObject = new CDPVACMI;
  144. if(pObject->pObject == NULL)
  145. {
  146. delete pObject;
  147. return DVERR_OUTOFMEMORY;
  148. }
  149. pObject->lpvVtble = &dvcpvACMInterface;
  150. if (!pObject->pObject->InitClass())
  151. {
  152. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  153. delete pObject->pObject;
  154. delete pObject;
  155. return DVERR_OUTOFMEMORY;
  156. }
  157. hr = CDPVACMI::QueryInterface( pObject, riid, ppvObj );
  158. if (FAILED(hr))
  159. {
  160. DPFX(DPFPREP, DVF_ERRORLEVEL, "QI failed" );
  161. delete pObject->pObject;
  162. delete pObject;
  163. }
  164. }
  165. else
  166. {
  167. PDPVACMCONVOBJECT pObject;
  168. pObject = new DPVACMCONVOBJECT;
  169. if( pObject == NULL )
  170. {
  171. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  172. return DVERR_OUTOFMEMORY;
  173. }
  174. pObject->pObject = new CDPVACMConv;
  175. if(pObject->pObject == NULL)
  176. {
  177. delete pObject;
  178. return DVERR_OUTOFMEMORY;
  179. }
  180. pObject->lpvVtble = &dvconvACMInterface;
  181. if (!pObject->pObject->InitClass())
  182. {
  183. DPFX(DPFPREP, DVF_ERRORLEVEL, "Memory alloc failure" );
  184. delete pObject->pObject;
  185. delete pObject;
  186. return DVERR_OUTOFMEMORY;
  187. }
  188. hr = CDPVACMConv::I_QueryInterface( pObject, riid, ppvObj );
  189. if (FAILED(hr))
  190. {
  191. DPFX(DPFPREP, DVF_ERRORLEVEL, "QI failed" );
  192. delete pObject->pObject;
  193. delete pObject;
  194. }
  195. }
  196. }
  197. else
  198. {
  199. return E_NOINTERFACE;
  200. }
  201. if (SUCCEEDED(hr))
  202. {
  203. IncrementObjectCount();
  204. }
  205. return hr;
  206. }
  207. #undef DPF_MODNAME
  208. #define DPF_MODNAME "IsClassImplemented"
  209. extern "C" BOOL IsClassImplemented(REFCLSID rclsid)
  210. {
  211. return (IsEqualCLSID(rclsid, CLSID_DPVCPACM) || rclsid == CLSID_DPVCPACM_CONVERTER);
  212. }