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.

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