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.

381 lines
13 KiB

  1. /*
  2. * Copyright Microsoft Corporation, 1993 - 1995. All Rights Reserved.
  3. */
  4. /*
  5. * vcuser.h
  6. *
  7. * 32-bit Video Capture driver
  8. * User-mode support library
  9. *
  10. * define functions providing access to video capture hardware. On NT,
  11. * these functions will interface to the kernel-mode driver.
  12. *
  13. * include vcstruct.h before this.
  14. *
  15. * Geraint Davies, Feb 93
  16. */
  17. #ifndef _VCUSER_H_
  18. #define _VCUSER_H_
  19. /*
  20. * capture device handle. This structure is opaque to the caller
  21. */
  22. typedef struct _VCUSER_HANDLE * VCUSER_HANDLE;
  23. /*
  24. * these are the parameters we need to issue a DriverCallback. A
  25. * pointer to one of these structs is passed on StreamInit
  26. * If the pointer is null, we don't need callbacks.
  27. */
  28. typedef struct _VCCALLBACK {
  29. DWORD dwCallback;
  30. DWORD dwFlags;
  31. HDRVR hDevice;
  32. DWORD dwUser;
  33. } VCCALLBACK, * PVCCALLBACK;
  34. /*
  35. * open the device and return a capture device handle that can be used
  36. * in future calls.
  37. * The device index is 0 for the first capture device up to N for the
  38. * Nth installed capture device.
  39. *
  40. * If pDriverName is non-null, then we will open the Nth device handled
  41. * by this driver. (Current implementation supports only one device per
  42. * drivername.)
  43. *
  44. * This function returns NULL if it is not able to open the device.
  45. */
  46. VCUSER_HANDLE VC_OpenDevice(PTCHAR pDriverName, int DeviceIndex);
  47. /*
  48. * close a capture device. This will abort any operation in progress and
  49. * render the device handle invalid.
  50. */
  51. VOID VC_CloseDevice(VCUSER_HANDLE vh);
  52. /*
  53. * Configuration.
  54. *
  55. * These functions perform device-dependent setup affecting the
  56. * target format, the source acquisition or the display (overlay).
  57. *
  58. * The structures passed are not interpreted by the vcuser and vckernel
  59. * libraries except that the first ulong of the struct must contain the
  60. * size in bytes of the entire structure (see vcstruct.h). It is assumed
  61. * that the structures are defined and agreed between the user-mode
  62. * hardware-specific code and the kernel-mode hardware specific code
  63. */
  64. BOOL VC_ConfigFormat(VCUSER_HANDLE, PCONFIG_INFO);
  65. BOOL VC_ConfigSource(VCUSER_HANDLE, PCONFIG_INFO);
  66. BOOL VC_ConfigDisplay(VCUSER_HANDLE, PCONFIG_INFO);
  67. /*
  68. * overlay and keying
  69. *
  70. * Several different methods are used by devices to locate the overlay
  71. * area on the screen: colour (either rgb or palette index) and/or
  72. * either a single rectangle, or a series of rectangles defining a complex
  73. * region. Call GetOverlayMode first to find out which type of overlay
  74. * keying is available. If this returns 0, this hardware is not capable
  75. * of overlay.
  76. */
  77. /*
  78. * find out the overlay keying method
  79. */
  80. ULONG VC_GetOverlayMode(VCUSER_HANDLE);
  81. /*
  82. * set the key colour to a specified RGB colour. This function will only
  83. * succeed if GetOverlayMode returned VCO_KEYCOLOUR and VCO_KEYCOLOUR_RGB
  84. * and not VCO_KEYCOLOUR_FIXED
  85. */
  86. BOOL VC_SetKeyColourRGB(VCUSER_HANDLE, PRGBQUAD);
  87. /*
  88. * set the key colour to a specified palette index. This function will only
  89. * succeed if GetOverlayMode returned VCO_KEYCOLOUR and not either
  90. * VCO_KEYCOLOUR_RGB or VCO_KEYCOLOUR_FIXED
  91. */
  92. BOOL VC_SetKeyColourPalIdx(VCUSER_HANDLE, WORD);
  93. /*
  94. * get the current key colour. This 32-bit value should be interpreted
  95. * as either a palette index or an RGB value according to the
  96. * VCO_KEYCOLOUR_RGB flag returned from VC_GetOverlayMode.
  97. */
  98. DWORD VC_GetKeyColour(VCUSER_HANDLE vh);
  99. /*
  100. * set the overlay rectangle(s). This rectangle marks the area in device
  101. * co-ordinates where the overlay video will appear. The video will be
  102. * panned so that pixel (0,0) will appear at the top-left of this rectangle,
  103. * and the video will be cropped at the bottom and right. The video
  104. * stream will not normally be scaled to fit this window: scaling is normally
  105. * determined by the destination format set by VC_ConfigFormat.
  106. *
  107. * If VCO_KEYCOLOUR was returned, the video
  108. * will only be shown at those pixels within the rectangle for which the
  109. * vga display has the key colour (VC_GetKeyColour() for this).
  110. *
  111. * Some devices may support complex regions (VCO_COMPLEX_RECT). In that case,
  112. * the first rectangle in the area must be the bounding rectangle for
  113. * the overlay area, followed by one rectangle for each region within it in
  114. * which the overlay should appear.
  115. */
  116. BOOL VC_SetOverlayRect(VCUSER_HANDLE, POVERLAY_RECTS);
  117. /*
  118. * set the offset of the overlay. This changes the panning - ie which
  119. * source co-ordinate appears as the top left pixel in the overlay rectangle.
  120. * Initially after a call to VC_SetOverlayRect, the source image will be panned
  121. * so that the top-left of the source image is aligned with the top-left of the
  122. * overlay rectangle. This call aligns the top-left of the source image
  123. * with the top-left of this offset rectangle.
  124. */
  125. BOOL VC_SetOverlayOffset(VCUSER_HANDLE, PRECT);
  126. /* enable or disable overlay. if the BOOL bOverlay is TRUE, and the overlay
  127. * key colour and rectangle have been set, overlay will be enabled.
  128. */
  129. BOOL VC_Overlay(VCUSER_HANDLE, BOOL);
  130. /*
  131. * enable or disable acquisition.
  132. * If acquisition is disabled, the overlay image will be frozen.
  133. *
  134. * this function will have no effect during capture since the acquisition
  135. * flag is toggled at each frame capture.
  136. */
  137. BOOL VC_Capture(VCUSER_HANDLE, BOOL);
  138. /*
  139. * capture a single frame, synchronously. the video header must point
  140. * to a data buffer large enough to hold one frame of the format set by
  141. * VC_ConfigFormat.
  142. */
  143. // BOOL VC_Frame(VCUSER_HANDLE, LPVIDEOHDR);
  144. /*
  145. * data streaming.
  146. *
  147. * Call VC_StreamInit to prepare for streaming.
  148. * Call VC_StreamStart to initiate capture.
  149. * Call VC_AddBuffer to add a capture buffer to the list. As each
  150. * frame capture completes, the callback function specified in
  151. * VC_StreamInit will be called with the buffer that has completed.
  152. *
  153. * If there is no buffer ready when it is time to capture a frame,
  154. * a callback will occur. In addition, VC_StreamGetError will return
  155. * a count of the frames missed this session. VC_StreamGetPos will return
  156. * the position (in millisecs) reached so far.
  157. *
  158. * Call VC_StreamStop to terminate streaming. Any buffer currently in
  159. * progress may still complete. Uncompleted buffers will remain in the
  160. * queue. Call VC_Reset to release all buffers from the queue.
  161. *
  162. * Finally call VC_StreamFini to tidy up.
  163. */
  164. /*
  165. * prepare to start capturing frames
  166. */
  167. BOOL VC_StreamInit(VCUSER_HANDLE,
  168. PVCCALLBACK, // pointer to callback function
  169. ULONG // desired capture rate: microseconds per frame
  170. );
  171. /*
  172. * clean up after capturing. You must have stopped capturing first.
  173. */
  174. BOOL VC_StreamFini(VCUSER_HANDLE);
  175. /*
  176. * initiate capturing of frames. Must have called VC_StreamInit first.
  177. */
  178. BOOL VC_StreamStart(VCUSER_HANDLE);
  179. /*
  180. * stop capturing frames. Current frame may still complete. All other buffers
  181. * will remain in the queue until capture is re-started, or they are released
  182. * by VC_StreamReset.
  183. */
  184. BOOL VC_StreamStop(VCUSER_HANDLE);
  185. /*
  186. * cancel all buffers that have been 'add-buffered' but have not
  187. * completed. This will also force VC_StreamStop if it hasn't already been
  188. * called.
  189. */
  190. BOOL VC_StreamReset(VCUSER_HANDLE);
  191. /*
  192. * get the count of frames that have been skipped since the last call
  193. * to VC_StreamInit.
  194. */
  195. ULONG VC_GetStreamError(VCUSER_HANDLE);
  196. /*
  197. * get the current position within the capture stream (ie time
  198. * in millisecs since capture began)
  199. */
  200. BOOL VC_GetStreamPos(VCUSER_HANDLE, LPMMTIME);
  201. /*
  202. * add a buffer to the queue. The buffer should be large enough
  203. * to hold one frame of the format specified by VC_ConfigFormat.
  204. */
  205. // BOOL VC_StreamAddBuffer(VCUSER_HANDLE, LPVIDEOHDR);
  206. /*
  207. * playback
  208. *
  209. * Call VC_DrawFrame to draw a frame into the frame buffer. You should
  210. * call VC_Overlay functions to arrange for the frame buffer to appear
  211. * on screen.
  212. */
  213. BOOL VC_DrawFrame(VCUSER_HANDLE, PDRAWBUFFER);
  214. /*
  215. * installation/configuration
  216. *
  217. * on NT, the following functions will start and stop the
  218. * kernel driver. The callback function can write profile information
  219. * to the registry between stopping the driver (if already running) and
  220. * re-starting the driver. The kernel driver DriverEntry routine is responsible
  221. * for reading these values from the registry before calling VC_Init().
  222. *
  223. * The win-16 implementation will (?) call the callback to write
  224. * values to the profile, and then call the HW_Startup function. This function
  225. * is responsible for calling VC_Init, initialising the callback table and
  226. * initialising the hardware.
  227. */
  228. /*
  229. * opaque pointer to the information we need to access the registry/profile.
  230. */
  231. typedef struct _VC_PROFILE_INFO * PVC_PROFILE_INFO;
  232. /*
  233. * open a handle to whatever functions are needed to access the registry,
  234. * service controller or profile. Must call this function before
  235. * calls to the other VC_ configuration routines.
  236. *
  237. * The argument is the name of the driver. This should be the name of
  238. * the kernel driver file (without path or extension). It will also be used
  239. * as the registry key name or profile section name.
  240. */
  241. PVC_PROFILE_INFO VC_OpenProfileAccess(PTCHAR DriverName);
  242. /*
  243. * close a profile access handle
  244. */
  245. VOID VC_CloseProfileAccess(PVC_PROFILE_INFO);
  246. /*
  247. * takes a PVC_PROFILE_INFO returned from VC_OpenProfileAccess, and
  248. * returns TRUE if we currently have sufficient privilege to perform
  249. * driver configuration operations.
  250. */
  251. BOOL VC_ConfigAccess(PVC_PROFILE_INFO);
  252. /*
  253. * This function is called once the driver has definitely been unloaded, and
  254. * the profile entry created, but before the driver is re-loaded. It can write
  255. * any configuration information to the registry. It should return TRUE if
  256. * it is ok to load and start the kernel-mode driver, or false if some
  257. * error has occured.
  258. */
  259. typedef BOOL (*PPROFILE_CALLBACK)(PVOID);
  260. /*
  261. * start the hardware-access portion of the driver. Call the callback
  262. * function at a moment when it is possible to write configuration information
  263. * to the profile using VC_WriteProfile.
  264. * Returns DRVCNF_OK if all is ok, DRVCNF_CANCEL for failure, or DRVCNF_RESTART if
  265. * all is ok but a system-restart is needed before the driver will load correctly.
  266. */
  267. LRESULT VC_InstallDriver(
  268. PVC_PROFILE_INFO pProfile, // access info returned by OpenProfileAccess
  269. PPROFILE_CALLBACK pCallback, // callback function
  270. PVOID pContext // context info for callback
  271. );
  272. /*
  273. * Write a single string keyword and DWORD value to the registry or profile
  274. * for this driver.
  275. * This can be re-read from the h/w driver using VC_ReadProfile (in either
  276. * the kernel-mode vckernel.lib version or user mode in the vcuser version).
  277. *
  278. * return TRUE for success or FALSE for failure.
  279. */
  280. BOOL VC_WriteProfile(PVC_PROFILE_INFO pProfile, PTCHAR ValueName, DWORD Value);
  281. /*
  282. * Write a single string keyword and DWORD value to the registry or profile
  283. * for this driver.
  284. * This writes to HKEY_CURRENT_USER and is typically used to store user defaults.
  285. *
  286. * return TRUE for success or FALSE for failure.
  287. */
  288. BOOL VC_WriteProfileUser(PVC_PROFILE_INFO pProfile, PTCHAR ValueName, DWORD Value);
  289. /*
  290. * read back a driver-specific DWORD profile parameter that was written with
  291. * VC_WriteProfile. If the valuename cannot be found, the default is returned.
  292. */
  293. DWORD VC_ReadProfile(PVC_PROFILE_INFO pProfile, PTCHAR ValueName, DWORD dwDefault);
  294. /*
  295. * read back a driver-specific DWORD profile parameter that was written with
  296. * VC_WriteProfileUser. If the valuename cannot be found, the default is returned.
  297. * This reads from HKEY_CURRENT_USER and is typically used to store user defaults.
  298. */
  299. DWORD VC_ReadProfileUser(PVC_PROFILE_INFO pProfile, PTCHAR ValueName, DWORD dwDefault);
  300. /*
  301. * read a string parameter from the device's profile. returns FALSE
  302. * if it fails to read the string.
  303. */
  304. BOOL VC_ReadProfileString(
  305. PVC_PROFILE_INFO pProfile, // access info from OpenProfile
  306. PTCHAR ValueName, // name of value to read
  307. PTCHAR ValueString, // put value here
  308. DWORD ValueLength // size of ValueString in bytes
  309. );
  310. /*
  311. * unload a driver. On NT, this stops and removes the kernel-mode driver.
  312. * On win-16, this calls the Cleanup callback.
  313. *
  314. * return DRVCNF_OK if the unload was successful, DRVCNF_CANCEL if it failed, and
  315. * DRVCNF_RESTART if a system-restart is needed before the removal takes effect.
  316. *
  317. * note that after this operation, the PVC_PROFILE_INFO information is still held
  318. * open. A call to VC_CloseProfileAccess is still needed before exiting.
  319. */
  320. LRESULT VC_RemoveDriver(PVC_PROFILE_INFO pProfile);
  321. #endif //_VCUSER_H_