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.

498 lines
19 KiB

  1. /****************************************************************************
  2. *
  3. * avicapi.h
  4. *
  5. * Internal, private definitions.
  6. *
  7. * Microsoft Video for Windows Sample Capture Class
  8. *
  9. * Copyright (c) 1992-1995 Microsoft Corporation. All Rights Reserved.
  10. *
  11. * You have a royalty-free right to use, modify, reproduce and
  12. * distribute the Sample Files (and/or any modified version) in
  13. * any way you find useful, provided that you agree that
  14. * Microsoft has no warranty obligations or liability for any
  15. * Sample Application Files which are modified.
  16. *
  17. ***************************************************************************/
  18. // This stuff is not going to work 64-bit
  19. #pragma warning(disable:4312)
  20. #ifndef _INC_AVICAP_INTERNAL
  21. #define _INC_AVICAP_INTERNAL
  22. #define ASYNCIO_PORT
  23. #include <vfw.h>
  24. #include <mmreg.h>
  25. #include "iaverage.h"
  26. #ifdef __cplusplus
  27. extern "C" { /* Assume C declarations for C++ */
  28. #endif /* __cplusplus */
  29. #ifndef RC_INVOKED
  30. #pragma pack(1) /* Assume byte packing throughout */
  31. #endif /* RC_INVOKED */
  32. /* c8 uses underscores on all defines */
  33. #if defined DEBUG && !defined _DEBUG
  34. #define _DEBUG
  35. #elif defined _DEBUG && !defined DEBUG
  36. #define DEBUG
  37. #endif
  38. #ifdef ASYNCIO_PORT
  39. extern HINSTANCE hmodKernel;
  40. extern HANDLE (WINAPI *pfnCreateIoCompletionPort)(
  41. HANDLE FileHandle,
  42. HANDLE ExistingCompletionPort,
  43. DWORD CompletionKey,
  44. DWORD NumberOfConcurrentThreads
  45. );
  46. extern BOOL (WINAPI *pfnGetQueuedCompletionStatus)(
  47. HANDLE CompletionPort,
  48. LPDWORD lpNumberOfBytesTransferred,
  49. LPDWORD lpCompletionKey,
  50. LPOVERLAPPED *lpOverlapped,
  51. DWORD dwMilliseconds
  52. );
  53. #endif
  54. #if !defined NUMELMS
  55. #define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
  56. #define FIELDOFF(type,field) (&(((type)0)->field))
  57. #define FIELDSIZ(type,field) (sizeof(((type)0)->field))
  58. #endif
  59. //
  60. // use the registry - not WIN.INI
  61. //
  62. #if defined(_WIN32) && defined(UNICODE)
  63. #include "profile.h"
  64. #endif
  65. // switch off all references to the new vfw1.1 compman interfaces until we
  66. // have the new compman ported to NT
  67. #define NEW_COMPMAN
  68. #ifndef _LPHISTOGRAM_DEFINED
  69. #define _LPHISTOGRAM_DEFINED
  70. typedef DWORD HUGE * LPHISTOGRAM;
  71. #endif
  72. #define WIDTHBYTES(i) ((unsigned)((i+31)&(~31))/8) /* ULONG aligned ! */
  73. #define DIBWIDTHBYTES(bi) ((int)WIDTHBYTES((int)(bi).biWidth * (int)(bi).biBitCount))
  74. // Swap palette entries around
  75. #ifdef DEBUG
  76. #define SWAPTYPE(x,y, type) { type _temp_; _temp_=(x); (x)=(y), (y)=_temp_;}
  77. #else
  78. #define SWAPTYPE(x,y, type) ( (x)^=(y), (y)^=(x), (x)^=(y) )
  79. #endif
  80. #define ROUNDUPTOSECTORSIZE(dw, align) ((((DWORD_PTR)dw) + ((DWORD_PTR)align)-1) & ~(((DWORD_PTR)(align))-1))
  81. #define MAX_VIDEO_BUFFERS 400 // By using this number the CAPSTREAM structure fits into a page
  82. #define MIN_VIDEO_BUFFERS 5
  83. #define DEF_WAVE_BUFFERS 4
  84. #define MAX_WAVE_BUFFERS 10
  85. // MCI Capture state machine
  86. enum mcicapstates {
  87. CAPMCI_STATE_Uninitialized = 0,
  88. CAPMCI_STATE_Initialized,
  89. CAPMCI_STATE_StartVideo,
  90. CAPMCI_STATE_CapturingVideo,
  91. CAPMCI_STATE_VideoFini,
  92. CAPMCI_STATE_StartAudio,
  93. CAPMCI_STATE_CapturingAudio,
  94. CAPMCI_STATE_AudioFini,
  95. CAPMCI_STATE_AllFini
  96. };
  97. // -------------------------
  98. // CAPSTREAM structure
  99. // -------------------------
  100. #define CAPSTREAM_VERSION 3 // Increment whenever struct changes
  101. #define DEFAULT_BYTESPERSECTOR 512
  102. // This structure is GlobalAlloc'd for each capture window instance.
  103. // A pointer to the structure is stored in the Window extra bytes.
  104. // Applications can retrieve a pointer to the stucture using
  105. // the WM_CAP_GET_CAPSTREAMPTR message.
  106. // I: internal variables which the client app should not modify
  107. // M: variables which the client app can set via Send/PostMessage
  108. typedef struct tagCAPSTREAM {
  109. DWORD dwSize; // I: size of structure
  110. UINT uiVersion; // I: version of structure
  111. HINSTANCE hInst; // I: our instance
  112. HANDLE hThreadCapture; // I: capture task handle
  113. DWORD dwReturn; // I: capture task return value
  114. HWND hwnd; // I: our hwnd
  115. // Use MakeProcInstance to create all callbacks !!!
  116. // Status, error callbacks
  117. CAPSTATUSCALLBACK CallbackOnStatus; // M: Status callback
  118. CAPERRORCALLBACK CallbackOnError; // M: Error callback
  119. #ifdef UNICODE
  120. DWORD fUnicode; // I:
  121. // definitions for fUnicode
  122. #define VUNICODE_ERRORISANSI 0x00000001 // set if error msg thunking required
  123. #define VUNICODE_STATUSISANSI 0x00000002 // set if status msg thunking required
  124. #endif
  125. // event used in capture loop to avoid polling
  126. HANDLE hCaptureEvent; // I:
  127. #ifdef ASYNCIO_PORT
  128. HANDLE heSyncWrite; // I: Create an event for sync write
  129. #endif
  130. #ifdef CHICAGO
  131. DWORD hRing0CapEvt; // I:
  132. #else
  133. #ifdef ASYNCIO_PORT
  134. HANDLE pfnIOCompletionPort; // I: NT: async IO completion port creation
  135. HANDLE hCompletionPort;
  136. #endif
  137. #endif
  138. // Allows client to process messages during capture if set
  139. CAPYIELDCALLBACK CallbackOnYield; // M: Yield processing
  140. // Video and wave callbacks for Network or other specialized xfers
  141. CAPVIDEOCALLBACK CallbackOnVideoFrame; // M: Only during preview
  142. CAPVIDEOCALLBACK CallbackOnVideoStream; // M: Video buffer ready
  143. CAPWAVECALLBACK CallbackOnWaveStream; // M: Wave buffer ready
  144. CAPCONTROLCALLBACK CallbackOnControl; // M: External Start/Stop ctrl
  145. // Open channels on the video hardware device
  146. // and hardware capabilies
  147. CAPDRIVERCAPS sCapDrvCaps; // M: What can the driver do
  148. HVIDEO hVideoIn; // I: In channel
  149. HVIDEO hVideoCapture; // I: Ext In channel
  150. HVIDEO hVideoDisplay; // I: Ext Out channel
  151. BOOL fHardwareConnected; // I: ANY open channel?
  152. // Flags indicating whether dialog boxes are currently displayed
  153. #define VDLG_VIDEOSOURCE 0x00000001 // Video Source dialog
  154. #define VDLG_VIDEOFORMAT 0x00000002 // Video Format dialog
  155. #define VDLG_VIDEODISPLAY 0x00000004 // Video Display dialog
  156. #define VDLG_COMPRESSION 0x00000008 // Video Compression dialog
  157. DWORD dwDlgsActive; // I: state of dialogs
  158. // Window to display video
  159. BOOL fLiveWindow; // M: Preview video
  160. BOOL fOverlayWindow; // M: Overlay video
  161. BOOL fScale; // M: Scale image to client
  162. POINT ptScroll; // I: Scroll position
  163. HANDLE hdd; // I: hDrawDib access handle
  164. HCURSOR hWaitCursor; // I: hourglass
  165. UINT uiRegion; // I: CheckWindowMove
  166. RECT rcRegionRect; // I: CheckWindowMove
  167. POINT ptRegionOrigin;
  168. // Window update timer
  169. UINT_PTR idTimer; // I: ID of preview timer
  170. UINT uTimeout; // M: Preview rate in mS. (not used after setting the timer)
  171. // Capture destination and control
  172. CAPTUREPARMS sCapParms; // M: how to capture
  173. BOOL fCaptureFlags; // state of capture
  174. // definitions of fCaptureFlags
  175. #define CAP_fCapturingToDisk 0x0001 // M: if capturing to disk
  176. #define CAP_fCapturingNow 0x0002 // I: if performing capture
  177. #define CAP_fStepCapturingNow 0x0004 // I: if performing MCI step capture
  178. #define CAP_fFrameCapturingNow 0x0008 // I: if performing single frame capture
  179. #define CAP_fStopCapture 0x0010 // M: if stop requested
  180. #define CAP_fAbortCapture 0x0020 // M: if abort requested
  181. #define CAP_fDefaultVideoBuffers 0x0040 // using default number of video buffers
  182. #define CAP_fDefaultAudioBuffers 0x0080 // using default number of audio buffers
  183. DWORD dwTimeElapsedMS; // I: Capture time in millisec
  184. // Index
  185. HGLOBAL hIndex; // I: handle to index mem
  186. DWORD dwIndex; // I: index index
  187. DWORD dwVideoChunkCount; // I: # of video frames cap'd
  188. DWORD dwWaveChunkCount; // I: # of audio buffers cap'd
  189. LPDWORD lpdwIndexStart; // I: index start ptr
  190. LPDWORD lpdwIndexEntry; // I: index current ptr
  191. // Video format
  192. DWORD dwActualMicroSecPerFrame; // I: Actual cap rate
  193. LPBITMAPINFO lpBitsInfo; // I: Video format
  194. int dxBits; // I: video size x
  195. int dyBits; // I: video size y
  196. LPBYTE lpBits; // I: Single frame capture buf
  197. LPBYTE lpBitsUnaligned; // I: Single frame capture buf
  198. VIDEOHDR VidHdr; // I: Single frame header
  199. #ifdef NEW_COMPMAN
  200. COMPVARS CompVars; // M: Set by ICCompressorChoose
  201. #endif
  202. LPIAVERAGE lpia; // I: Image averaging struct
  203. VIDEOHDR VidHdr2x; // I: VideoHeader at 2x
  204. LPBITMAPINFOHEADER lpbmih2x; // I: lpbi at 2x
  205. // Video Buffer management
  206. DWORD cbVideoAllocation; // I: size of non-comp buffer incl chunk (not used)
  207. int iNumVideo; // I: Number of actual video buffers
  208. int iNextVideo; // I: index into video buffers
  209. DWORD dwFramesDropped; // I: number of frames dropped
  210. LPVIDEOHDR alpVideoHdr[MAX_VIDEO_BUFFERS]; // I: array of video buffer headers
  211. BOOL fBuffersOnHardware; // I: if driver all'd buffers
  212. LPSTR lpDropFrame;
  213. // Palettes
  214. HPALETTE hPalCurrent; // I: handle of current pal
  215. BOOL fUsingDefaultPalette; // I: no user defined pal
  216. int nPaletteColors; // M: only changed by UI
  217. LPVOID lpCapPal; // I: LPCAPPAL manual pals
  218. LPVOID lpCacheXlateTable; // I: 32KB xlate table cached
  219. // Audio Capture Format
  220. BOOL fAudioHardware; // I: if audio hardware present
  221. LPWAVEFORMATEX lpWaveFormat; // I: wave format
  222. WAVEHDR WaveHdr; // I: Wave header
  223. HWAVEIN hWaveIn; // I: Wave input channel
  224. DWORD dwWaveBytes; // I: Total wave bytes cap'd
  225. DWORD dwWaveSize; // I: wave buffer size
  226. // Audio Buffer management
  227. LPWAVEHDR alpWaveHdr[MAX_WAVE_BUFFERS]; // I: wave buff array
  228. int iNextWave; // I: Index into wave buffers
  229. int iNumAudio; // I: Number of actual audio buffers
  230. BOOL fAudioYield; // I: ACM audio yield required
  231. BOOL fAudioBreak; // I: Audio underflow
  232. // MCI Capture
  233. TCHAR achMCIDevice[MAX_PATH]; // MCI device name
  234. DWORD dwMCIError; // I: Last MCI error value
  235. enum mcicapstates MCICaptureState; // I: MCI State machine
  236. DWORD dwMCICurrentMS; // I: Current MCI position
  237. DWORD dwMCIActualStartMS; // I: Actual MCI start MS
  238. DWORD dwMCIActualEndMS; // I: Actual MCI end position
  239. // Output file
  240. TCHAR achFile [MAX_PATH]; // M: name of capture file
  241. TCHAR achSaveAsFile [MAX_PATH]; // M: name of saveas file
  242. LONG lCapFileSize; // M: in bytes
  243. BOOL fCapFileExists; // I: if have a capture file
  244. BOOL fFileCaptured; // I: if we've cap'd to file
  245. // async file io
  246. //
  247. DWORD dwAsyncWriteOffset; // I: last file write offset
  248. UINT iNextAsync; // I: next async io header to be done
  249. UINT iLastAsync; // I: last async io header to be written
  250. UINT iNumAsync; // I: number of async io headers
  251. struct _avi_async {
  252. OVERLAPPED ovl; // I: for WriteFile call
  253. UINT uType; // I: write type (Video/Wave/Drop)
  254. UINT uIndex; // I: index into alpWaveHdr or alpVideoHdr
  255. } * pAsync; // I: ptr to array of async io headers
  256. #define ASYNCIOPENDING 0x80000000 // or'ed to uType for pending IO
  257. #ifdef USE_AVIFILE
  258. // these 4 fields when using avifile
  259. //
  260. BOOL bUseAvifile;
  261. PAVISTREAM pvideo;
  262. PAVISTREAM paudio;
  263. PAVIFILE pavifile;
  264. #endif
  265. HMMIO hmmio; // I: MMIO handle for writing
  266. HANDLE hFile; // I: write via CreateFile
  267. DWORD dwBytesPerSector; // I: bytes per sector
  268. BOOL fUsingNonBufferedIO; // I: FILE_FLAG_NO_BUFFERING
  269. DWORD dwAVIHdrSize; // I: size of header
  270. DWORD dwAVIHdrPos; // I: file offset of hdr
  271. LPARAM lUser; // M: Data for the user
  272. LPVOID lpInfoChunks; // M: information chunks
  273. LONG cbInfoChunks; // M: sizeof information chks
  274. BOOL fLastStatusWasNULL; // I: don't repeat null msgs
  275. BOOL fLastErrorWasNULL; // I: don't repeat null msgs
  276. } CAPSTREAM;
  277. typedef CAPSTREAM FAR * LPCAPSTREAM;
  278. // values for capstream.pAsync[nn].wType field
  279. //
  280. #define ASYNC_BUF_VIDEO 1
  281. #define ASYNC_BUF_AUDIO 2
  282. #define ASYNC_BUF_DROP 3
  283. // -------------------------
  284. // Full color log palette
  285. // -------------------------
  286. typedef struct tagFCLOGPALETTE {
  287. WORD palVersion;
  288. WORD palNumEntries;
  289. PALETTEENTRY palPalEntry[256];
  290. } FCLOGPALETTE;
  291. typedef struct {
  292. DWORD dwType;
  293. DWORD dwSize;
  294. } RIFF, *PRIFF, FAR *LPRIFF;
  295. extern HINSTANCE ghInstDll;
  296. #define IDS_CAP_RTL 10000
  297. extern BOOL gfIsRTL;
  298. // capinit.c
  299. BOOL CapWinDisconnectHardware(LPCAPSTREAM lpcs);
  300. BOOL CapWinConnectHardware (LPCAPSTREAM lpcs, UINT wDeviceIndex);
  301. BOOL capInternalGetDriverDesc (UINT wDriverIndex,
  302. LPTSTR lpszName, int cbName,
  303. LPTSTR lpszVer, int cbVer);
  304. BOOL capInternalGetDriverDescA(UINT wDriverIndex,
  305. LPSTR lpszName, int cbName,
  306. LPSTR lpszVer, int cbVer);
  307. // capwin.c
  308. LRESULT FAR PASCAL LOADDS EXPORT CapWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  309. #if defined CHICAGO
  310. VOID WINAPI OpenMMDEVLDR(
  311. void);
  312. VOID WINAPI CloseMMDEVLDR(
  313. void);
  314. VOID FreeContigMem (
  315. DWORD hMemContig);
  316. LPVOID AllocContigMem (
  317. DWORD cbSize,
  318. LPDWORD phMemContig);
  319. #endif
  320. // capavi.c
  321. LPVOID FAR PASCAL AllocSectorAlignedMem (DWORD dwRequest, DWORD dwAlign);
  322. void FAR PASCAL FreeSectorAlignedMem(LPVOID p);
  323. DWORDLONG GetFreePhysicalMemory(void);
  324. DWORD CalcWaveBufferSize (LPCAPSTREAM lpcs);
  325. BOOL AVIFileFini (LPCAPSTREAM lpcs, BOOL fWroteJunkChunks, BOOL fAbort);
  326. UINT AVIAudioInit (LPCAPSTREAM lpcs);
  327. UINT AVIAudioFini (LPCAPSTREAM lpcs);
  328. UINT AVIAudioPrepare (LPCAPSTREAM lpcs);
  329. UINT AVIAudioUnPrepare (LPCAPSTREAM lpcs);
  330. UINT AVIVideoInit (LPCAPSTREAM lpcs);
  331. UINT AVIVideoPrepare (LPCAPSTREAM lpcs);
  332. UINT AVIVideoUnPrepare (LPCAPSTREAM lpcs);
  333. void AVIFini(LPCAPSTREAM lpcs);
  334. UINT AVIInit (LPCAPSTREAM lpcs);
  335. BOOL FAR PASCAL SetInfoChunk(LPCAPSTREAM lpcs, LPCAPINFOCHUNK lpcic);
  336. BOOL AVICapture (LPCAPSTREAM lpcs);
  337. // capio.c
  338. //
  339. BOOL InitIndex (LPCAPSTREAM lpcs);
  340. void FiniIndex (LPCAPSTREAM lpcs);
  341. BOOL WriteIndex (LPCAPSTREAM lpcs, BOOL fJunkChunkWritten);
  342. BOOL CapFileInit(LPCAPSTREAM lpcs);
  343. BOOL WINAPI AVIWriteAudio (
  344. LPCAPSTREAM lpcs,
  345. LPWAVEHDR lpwh,
  346. UINT uIndex,
  347. LPUINT lpuError,
  348. LPBOOL pbPending);
  349. BOOL WINAPI AVIWriteVideoFrame (
  350. LPCAPSTREAM lpcs,
  351. LPBYTE lpData,
  352. DWORD dwBytesUsed,
  353. BOOL fKeyFrame,
  354. UINT uIndex,
  355. UINT nDropped,
  356. LPUINT lpuError,
  357. LPBOOL pbPending);
  358. BOOL WINAPI AVIWriteDummyFrames (
  359. LPCAPSTREAM lpcs,
  360. UINT nCount,
  361. LPUINT lpuError,
  362. LPBOOL pbPending);
  363. VOID WINAPI AVIPreloadFat (LPCAPSTREAM lpcs);
  364. // capfile.c
  365. BOOL FAR PASCAL fileCapFileIsAVI (LPTSTR lpsz);
  366. BOOL FAR PASCAL fileAllocCapFile(LPCAPSTREAM lpcs, DWORD dwNewSize);
  367. BOOL FAR PASCAL fileSaveCopy(LPCAPSTREAM lpcs);
  368. BOOL FAR PASCAL fileSavePalette(LPCAPSTREAM lpcs, LPTSTR lpszFileName);
  369. BOOL FAR PASCAL fileOpenPalette(LPCAPSTREAM lpcs, LPTSTR lpszFileName);
  370. //capmisc.c
  371. UINT GetKey(BOOL fWait);
  372. void errorDriverID (LPCAPSTREAM lpcs, DWORD dwError);
  373. void FAR CDECL statusUpdateStatus (LPCAPSTREAM lpcs, UINT wID, ...);
  374. void FAR CDECL errorUpdateError (LPCAPSTREAM lpcs, UINT wID, ...);
  375. //capFrame.c
  376. BOOL FAR PASCAL SingleFrameCaptureOpen (LPCAPSTREAM lpcs);
  377. BOOL FAR PASCAL SingleFrameCaptureClose (LPCAPSTREAM lpcs);
  378. BOOL FAR PASCAL SingleFrameCapture (LPCAPSTREAM lpcs);
  379. BOOL SingleFrameWrite (
  380. LPCAPSTREAM lpcs, // capture stream
  381. LPVIDEOHDR lpVidHdr, // input header
  382. BOOL FAR *pfKey, // did it end up being a key frame?
  383. LONG FAR *plSize); // size of returned image
  384. //capMCI.c
  385. void FAR PASCAL TimeMSToSMPTE (DWORD dwMS, LPSTR lpTime);
  386. int CountMCIDevicesByType ( UINT wType );
  387. void MCIDeviceClose (LPCAPSTREAM lpcs);
  388. BOOL MCIDeviceOpen (LPCAPSTREAM lpcs);
  389. BOOL FAR PASCAL MCIDeviceGetPosition (LPCAPSTREAM lpcs, LPDWORD lpdwPos);
  390. BOOL FAR PASCAL MCIDeviceSetPosition (LPCAPSTREAM lpcs, DWORD dwPos);
  391. BOOL FAR PASCAL MCIDevicePlay (LPCAPSTREAM lpcs);
  392. BOOL FAR PASCAL MCIDevicePause (LPCAPSTREAM lpcs);
  393. BOOL FAR PASCAL MCIDeviceStop (LPCAPSTREAM lpcs);
  394. BOOL FAR PASCAL MCIDeviceStep (LPCAPSTREAM lpcs, BOOL fForward);
  395. void FAR PASCAL _LOADDS MCIStepCapture (LPCAPSTREAM lpcs);
  396. #define AnsiToWide(lpwsz,lpsz,nChars) MultiByteToWideChar(CP_ACP, 0, lpsz, nChars, lpwsz, nChars)
  397. #define WideToAnsi(lpsz,lpwsz,nChars) WideCharToMultiByte(CP_ACP, 0, lpwsz, nChars, lpsz, nChars, NULL, NULL)
  398. #ifdef CHICAGO
  399. // chicago internal api to get a vxd visible alias for Win32 handle
  400. // this is used on the hCaptureEvent handle so that it can be signaled
  401. // from within 16 bit code.
  402. DWORD WINAPI OpenVxDHandle (HANDLE);
  403. #endif
  404. #ifdef _DEBUG
  405. BOOL FAR PASCAL _Assert(BOOL f, LPSTR szFile, int iLine);
  406. #define WinAssert(exp) (_Assert(exp, (LPSTR) __FILE__, __LINE__))
  407. extern void FAR CDECL dprintf(LPSTR, ...);
  408. #define DPF dprintf
  409. #else
  410. #define dprintf ; / ## /
  411. #define DPF ; / ## /
  412. #define WinAssert(exp) 0
  413. #endif
  414. #ifndef RC_INVOKED
  415. #pragma pack() /* Revert to default packing */
  416. #endif /* RC_INVOKED */
  417. #ifdef __cplusplus
  418. } /* End of extern "C" { */
  419. #endif /* __cplusplus */
  420. #endif /* INC_AVICAP_INTERNAL */