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.

360 lines
13 KiB

  1. /*****************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1999 - 2000
  4. *
  5. * TITLE: vstiusd.h
  6. *
  7. * VERSION: 1.1
  8. *
  9. * AUTHOR: WilliamH (original for Twain)
  10. * RickTu (port for WIA)
  11. *
  12. * DATE: 9/16/99
  13. *
  14. * DESCRIPTION: Header file that decalres CVideoSTiUsd class and other
  15. * needed classes.
  16. *
  17. *****************************************************************************/
  18. #ifndef _WIA_STILL_DRIVER_VSTIUSD_H_
  19. #define _WIA_STILL_DRIVER_VSTIUSD_H_
  20. extern HINSTANCE g_hInstance;
  21. extern ULONG g_cDllRef;
  22. #define NUM_WIA_FORMAT_INFO 5
  23. HRESULT FindEncoder(const GUID &guidFormat, CLSID *pClsid);
  24. //
  25. // Base class for supporting non-delegating IUnknown for contained objects
  26. //
  27. struct INonDelegatingUnknown
  28. {
  29. // *** IUnknown-like methods ***
  30. STDMETHOD(NonDelegatingQueryInterface)( THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  31. STDMETHOD_(ULONG,NonDelegatingAddRef)(THIS) PURE;
  32. STDMETHOD_(ULONG,NonDelegatingRelease)( THIS) PURE;
  33. };
  34. ///////////////////////////////
  35. // CVideoUsdClassFactory
  36. //
  37. class CVideoUsdClassFactory : public IClassFactory
  38. {
  39. private:
  40. ULONG m_cRef;
  41. public:
  42. CVideoUsdClassFactory();
  43. //
  44. // Declare IUnknown methods
  45. //
  46. STDMETHODIMP_(ULONG) AddRef(void);
  47. STDMETHODIMP_(ULONG) Release(void);
  48. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  49. //
  50. // IClassFactory implemenation
  51. //
  52. STDMETHODIMP LockServer(BOOL fLock);
  53. STDMETHODIMP CreateInstance(IUnknown *pOuterUnk, REFIID riid, void **ppv);
  54. static HRESULT GetClassObject(REFCLSID rclsid, REFIID riid, void **ppv);
  55. static HRESULT CanUnloadNow();
  56. };
  57. ///////////////////////////////
  58. // CVideoStiUsd
  59. //
  60. class CVideoStiUsd : public IStiUSD,
  61. public IWiaMiniDrv,
  62. public INonDelegatingUnknown
  63. {
  64. public:
  65. CVideoStiUsd(IUnknown * pUnkOuter);
  66. HRESULT PrivateInitialize();
  67. ~CVideoStiUsd();
  68. //
  69. // Real IUnknown methods
  70. //
  71. STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, LPVOID * ppvObj);
  72. STDMETHODIMP_(ULONG) NonDelegatingAddRef();
  73. STDMETHODIMP_(ULONG) NonDelegatingRelease();
  74. //
  75. // Aggregate IUnknown methods
  76. //
  77. STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  78. STDMETHODIMP_(ULONG) AddRef(void);
  79. STDMETHODIMP_(ULONG) Release(void);
  80. //
  81. // IStillUsd implementation
  82. //
  83. STDMETHODIMP Initialize(PSTIDEVICECONTROL pDcb, DWORD dwStiVersion, HKEY hParameterKey);
  84. STDMETHODIMP GetCapabilities(PSTI_USD_CAPS pDevCaps);
  85. STDMETHODIMP GetStatus(PSTI_DEVICE_STATUS pDevStatus);
  86. STDMETHODIMP DeviceReset();
  87. STDMETHODIMP Diagnostic(LPSTI_DIAG pBuffer);
  88. STDMETHODIMP Escape(STI_RAW_CONTROL_CODE Function, LPVOID DataIn, DWORD DataInSize, LPVOID DataOut, DWORD DataOutSize, DWORD *pActualSize);
  89. STDMETHODIMP GetLastError(LPDWORD pLastError);
  90. STDMETHODIMP LockDevice();
  91. STDMETHODIMP UnLockDevice();
  92. STDMETHODIMP RawReadData(LPVOID Buffer, LPDWORD BufferSize, LPOVERLAPPED lpOverlapped);
  93. STDMETHODIMP RawWriteData(LPVOID Buffer, DWORD BufferSize, LPOVERLAPPED lpOverlapped);
  94. STDMETHODIMP RawReadCommand(LPVOID Buffer, LPDWORD BufferSize, LPOVERLAPPED lpOverlapped);
  95. STDMETHODIMP RawWriteCommand(LPVOID Buffer, DWORD BufferSize, LPOVERLAPPED lpOverlapped);
  96. STDMETHODIMP SetNotificationHandle(HANDLE hEvent);
  97. STDMETHODIMP GetNotificationData(LPSTINOTIFY lpNotify);
  98. STDMETHODIMP GetLastErrorInfo(STI_ERROR_INFO *pLastErrorInfo);
  99. //
  100. // IWiaMiniDrv methods
  101. //
  102. STDMETHOD(drvInitializeWia)(THIS_
  103. BYTE* pWiasContext,
  104. LONG lFlags,
  105. BSTR bstrDeviceID,
  106. BSTR bstrRootFullItemName,
  107. IUnknown *pStiDevice,
  108. IUnknown *pIUnknownOuter,
  109. IWiaDrvItem **ppIDrvItemRoot,
  110. IUnknown **ppIUnknownInner,
  111. LONG *plDevErrVal);
  112. STDMETHOD(drvGetDeviceErrorStr)(THIS_
  113. LONG lFlags,
  114. LONG lDevErrVal,
  115. LPOLESTR *ppszDevErrStr,
  116. LONG *plDevErr);
  117. STDMETHOD(drvDeviceCommand)(THIS_
  118. BYTE *pWiasContext,
  119. LONG lFlags,
  120. const GUID *pGUIDCommand,
  121. IWiaDrvItem **ppMiniDrvItem,
  122. LONG *plDevErrVal);
  123. STDMETHOD(drvAcquireItemData)(THIS_
  124. BYTE *pWiasContext,
  125. LONG lFlags,
  126. PMINIDRV_TRANSFER_CONTEXT pDataContext,
  127. LONG *plDevErrVal);
  128. STDMETHOD(drvInitItemProperties)(THIS_
  129. BYTE *pWiasContext,
  130. LONG lFlags,
  131. LONG *plDevErrVal);
  132. STDMETHOD(drvValidateItemProperties)(THIS_
  133. BYTE *pWiasContext,
  134. LONG lFlags,
  135. ULONG nPropSpec,
  136. const PROPSPEC *pPropSpec,
  137. LONG *plDevErrVal);
  138. STDMETHOD(drvWriteItemProperties)(THIS_
  139. BYTE *pWiasContext,
  140. LONG lFLags,
  141. PMINIDRV_TRANSFER_CONTEXT pmdtc,
  142. LONG *plDevErrVal);
  143. STDMETHOD(drvReadItemProperties)(THIS_
  144. BYTE *pWiaItem,
  145. LONG lFlags,
  146. ULONG nPropSpec,
  147. const PROPSPEC *pPropSpec,
  148. LONG *plDevErrVal);
  149. STDMETHOD(drvLockWiaDevice)(THIS_
  150. BYTE *pWiasContext,
  151. LONG lFlags,
  152. LONG *plDevErrVal);
  153. STDMETHOD(drvUnLockWiaDevice)(THIS_
  154. BYTE *pWiasContext,
  155. LONG lFlags,
  156. LONG *plDevErrVal );
  157. STDMETHOD(drvAnalyzeItem)(THIS_
  158. BYTE *pWiasContext,
  159. LONG lFlags,
  160. LONG *plDevErrVal);
  161. STDMETHOD(drvDeleteItem)(THIS_
  162. BYTE *pWiasContext,
  163. LONG lFlags,
  164. LONG *plDevErrVal);
  165. STDMETHOD(drvFreeDrvItemContext)(THIS_
  166. LONG lFlags,
  167. BYTE *pDevContext,
  168. LONG *plDevErrVal);
  169. STDMETHOD(drvGetCapabilities)(THIS_
  170. BYTE *pWiasContext,
  171. LONG lFlags,
  172. LONG *pCelt,
  173. WIA_DEV_CAP_DRV **ppCapabilities,
  174. LONG *plDevErrVal);
  175. STDMETHOD(drvGetWiaFormatInfo)(THIS_
  176. BYTE *pWiasContext,
  177. LONG lFlags,
  178. LONG *pCelt,
  179. WIA_FORMAT_INFO **ppwfi,
  180. LONG *plDevErrVal);
  181. STDMETHOD(drvNotifyPnpEvent)(THIS_
  182. const GUID *pEventGUID,
  183. BSTR bstrDeviceID,
  184. ULONG ulReserved);
  185. STDMETHOD(drvUnInitializeWia)(THIS_
  186. BYTE*);
  187. //
  188. // Utility functions
  189. //
  190. STDMETHOD(BuildItemTree)(IWiaDrvItem **ppIDrvItemRoot, LONG *plDevErrVal);
  191. STDMETHOD(RefreshTree)(IWiaDrvItem *pIDrvItemRoot, LONG *plDevErrVal);
  192. STDMETHOD(EnumSavedImages)(IWiaDrvItem *pRootItem);
  193. STDMETHOD(CreateItemFromFileName)(LONG FolderType,LPCTSTR pszPath,LPCTSTR pszName,IWiaDrvItem **ppNewFolder);
  194. STDMETHOD(InitDeviceProperties)(BYTE *pWiasContext, LONG *plDevErrVal);
  195. STDMETHOD(InitImageInformation)(BYTE *pWiasContext, PSTILLCAM_IMAGE_CONTEXT pContext, LONG *plDevErrVal);
  196. STDMETHOD(SendBitmapHeader)( IWiaDrvItem *pDrvItem, PMINIDRV_TRANSFER_CONTEXT pTranCtx);
  197. STDMETHOD(ValidateDataTransferContext)(PMINIDRV_TRANSFER_CONTEXT pDataTransferContext);
  198. STDMETHOD(LoadImageCB)(STILLCAM_IMAGE_CONTEXT *pContext,MINIDRV_TRANSFER_CONTEXT *pTransCtx, PLONG plDevErrVal);
  199. STDMETHOD(LoadImage)(STILLCAM_IMAGE_CONTEXT *pContext,MINIDRV_TRANSFER_CONTEXT *pTransCtx, PLONG plDevErrVal);
  200. STDMETHODIMP_(VOID) HandleNewBits(HGLOBAL hDib,IWiaDrvItem **ppItem);
  201. STDMETHOD(DoBandedTransfer)(MINIDRV_TRANSFER_CONTEXT *pTransCtx,PBYTE pSrc,LONG lBytesToTransfer);
  202. STDMETHOD(DoTransfer)(MINIDRV_TRANSFER_CONTEXT *pTransCtx,PBYTE pSrc,LONG lBytesToTransfer);
  203. STDMETHOD(StreamJPEGBits)(STILLCAM_IMAGE_CONTEXT *pContext, MINIDRV_TRANSFER_CONTEXT *pTransCtx, BOOL bBanded);
  204. STDMETHOD(StreamBMPBits)(STILLCAM_IMAGE_CONTEXT *pContext, MINIDRV_TRANSFER_CONTEXT *pTransCtx, BOOL bBanded);
  205. private:
  206. //
  207. // IStiUSD stuff
  208. //
  209. HRESULT OpenDevice(LPCWSTR DeviceName);
  210. HRESULT CloseDevice();
  211. //
  212. // Misc functions
  213. //
  214. HRESULT VerifyCorrectImagePath(BSTR bstrNewImageFullPath);
  215. HRESULT SignalNewImage(BSTR bstrNewImageFullPath);
  216. BOOL FindCaptureFilter( LPCTSTR pszDeviceId,
  217. CComPtr<IMoniker> & pCaptureFilterMoniker );
  218. BOOL DoesFileExist(BSTR bstrFileName);
  219. BOOL IsFileAlreadyInTree( IWiaDrvItem * pRootItem,
  220. LPCTSTR pszFileName );
  221. HRESULT PruneTree( IWiaDrvItem * pRootItem,
  222. BOOL * pbTreeChanged );
  223. HRESULT AddNewFilesToTree( IWiaDrvItem * pRootItem,
  224. BOOL * pbTreeChanged );
  225. HRESULT AddTreeItem(CSimpleString *pstrFullImagePath,
  226. IWiaDrvItem **ppDrvItem);
  227. HRESULT SetImagesDirectory(BSTR bstrNewImagesDirectory,
  228. BYTE *pWiasContext,
  229. IWiaDrvItem **ppIDrvItemRoot,
  230. LONG *plDevErrVal);
  231. HRESULT ValidateItemProperties(BYTE * pWiasContext,
  232. LONG lFlags,
  233. ULONG nPropSpec,
  234. const PROPSPEC * pPropSpec,
  235. LONG * plDevErrVal,
  236. IWiaDrvItem * pDrvItem);
  237. HRESULT ValidateDeviceProperties(BYTE * pWiasContext,
  238. LONG lFlags,
  239. ULONG nPropSpec,
  240. const PROPSPEC * pPropSpec,
  241. LONG * plDevErrVal,
  242. IWiaDrvItem * pDrvItem);
  243. HRESULT ReadItemProperties(BYTE * pWiasContext,
  244. LONG lFlags,
  245. ULONG nPropSpec,
  246. const PROPSPEC * pPropSpec,
  247. LONG * plDevErrVal,
  248. IWiaDrvItem * pDrvItem);
  249. HRESULT ReadDeviceProperties(BYTE * pWiasContext,
  250. LONG lFlags,
  251. ULONG nPropSpec,
  252. const PROPSPEC * pPropSpec,
  253. LONG * plDevErrVal,
  254. IWiaDrvItem * pDrvItem);
  255. HRESULT EnableTakePicture(BYTE *pTakePictureOwner);
  256. HRESULT TakePicture(BYTE *pTakePictureOwner, IWiaDrvItem ** ppNewDrvItem);
  257. HRESULT DisableTakePicture(BYTE *pTakePictureOwner, BOOL bShuttingDown);
  258. //
  259. // IWiaMiniDrv stuff
  260. //
  261. CSimpleStringWide m_strDeviceId;
  262. CSimpleStringWide m_strRootFullItemName;
  263. CSimpleStringWide m_strStillPath;
  264. CSimpleStringWide m_strDShowDeviceId;
  265. CSimpleStringWide m_strLastPictureTaken;
  266. CRITICAL_SECTION m_csItemTree;
  267. CComPtr<IWiaDrvItem> m_pRootItem;
  268. CComPtr<IStiDevice> m_pStiDevice;
  269. WIA_FORMAT_INFO * m_wfi;
  270. LONG m_lPicsTaken;
  271. HANDLE m_hTakePictureEvent;
  272. HANDLE m_hPictureReadyEvent;
  273. ULONG_PTR m_ulGdiPlusToken;
  274. IWiaDrvItem * m_pLastItemCreated; // only valid while inside m_csSnapshot
  275. BYTE * m_pTakePictureOwner;
  276. DWORD m_dwConnectedApps;
  277. //
  278. // IUnknown stuff
  279. //
  280. ULONG m_cRef; // Device object reference count.
  281. LPUNKNOWN m_pUnkOuter; // Pointer to outer unknown.
  282. //
  283. // IStiUSD stuff
  284. //
  285. BOOL m_bDeviceIsOpened;
  286. };
  287. #endif