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.

338 lines
15 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, 1993 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 <mmreg.h>
  21. #include <compman.h>
  22. #include "iaverage.h"
  23. #ifdef __cplusplus
  24. extern "C" { /* Assume C declarations for C++ */
  25. #endif /* __cplusplus */
  26. #ifndef RC_INVOKED
  27. #pragma pack(1) /* Assume byte packing throughout */
  28. #endif /* RC_INVOKED */
  29. /* c8 uses underscores on all defines */
  30. #ifdef DEBUG
  31. #ifndef _DEBUG
  32. #define _DEBUG
  33. #endif
  34. #endif
  35. #define IDS_CAP_RTL 10000
  36. #ifndef LPHISTOGRAM
  37. typedef DWORD huge * LPHISTOGRAM;
  38. #endif
  39. #define WIDTHBYTES(i) ((unsigned)((i+31)&(~31))/8) /* ULONG aligned ! */
  40. #define DIBWIDTHBYTES(bi) ((int)WIDTHBYTES((int)(bi).biWidth * (int)(bi).biBitCount))
  41. #define SWAP(x,y) ((x)^=(y)^=(x)^=(y))
  42. #define AVICAP DWORD FAR PASCAL
  43. #define DROP_BUFFER_SIZE 2048
  44. #define MAX_VIDEO_BUFFERS 1000
  45. #define MIN_VIDEO_BUFFERS 5
  46. #define DEF_WAVE_BUFFERS 4
  47. #define MAX_WAVE_BUFFERS 10
  48. #define _MAX_CAP_PATH MAX_PATH /* 260 */
  49. // MCI Capture state machine
  50. enum mcicapstates {
  51. CAPMCI_STATE_Uninitialized = 0,
  52. CAPMCI_STATE_Initialized,
  53. CAPMCI_STATE_StartVideo,
  54. CAPMCI_STATE_CapturingVideo,
  55. CAPMCI_STATE_VideoFini,
  56. CAPMCI_STATE_StartAudio,
  57. CAPMCI_STATE_CapturingAudio,
  58. CAPMCI_STATE_AudioFini,
  59. CAPMCI_STATE_AllFini
  60. };
  61. // -------------------------
  62. // CAPSTREAM structure
  63. // -------------------------
  64. #define CAPSTREAM_VERSION 1 // Increment whenever struct changes
  65. // This structure is GlobalAlloc'd for each capture window instance.
  66. // A pointer to the structure is stored in the Window extra bytes.
  67. // Applications can retrieve a pointer to the stucture using
  68. // the WM_CAP_GET_CAPSTREAMPTR message.
  69. // I: internal variables which the client app should not modify
  70. // M: variables which the client app can set via Send/PostMessage
  71. typedef struct tagCAPSTREAM {
  72. DWORD dwSize; // I: size of structure
  73. UINT uiVersion; // I: version of structure
  74. HINSTANCE hInst; // I: our instance
  75. HTASK hTaskCapture; // I: capture task handle
  76. DWORD dwReturn; // I: capture task return val
  77. HWND hwnd; // I: our hwnd
  78. // Use MakeProcInstance to create all callbacks !!!
  79. // Status, error callbacks
  80. CAPSTATUSCALLBACK CallbackOnStatus; // M: Status callback
  81. CAPERRORCALLBACK CallbackOnError; // M: Error callback
  82. // Allows client to process messages during capture if set
  83. CAPYIELDCALLBACK CallbackOnYield; // M: Yield processing
  84. // Video and wave callbacks for Network or other specialized xfers
  85. CAPVIDEOCALLBACK CallbackOnVideoFrame; // M: Only during preview
  86. CAPVIDEOCALLBACK CallbackOnVideoStream; // M: Video buffer ready
  87. CAPWAVECALLBACK CallbackOnWaveStream; // M: Wave buffer ready
  88. CAPCONTROLCALLBACK CallbackOnControl; // M: External Start/Stop ctrl
  89. // Open channels on the video hardware device
  90. // and hardware capabilies
  91. CAPDRIVERCAPS sCapDrvCaps; // M: What can the driver do
  92. HVIDEO hVideoIn; // I: In channel
  93. HVIDEO hVideoCapture; // I: Ext In channel
  94. HVIDEO hVideoDisplay; // I: Ext Out channel
  95. BOOL fHardwareConnected; // I: ANY open channel?
  96. // Window to display video
  97. BOOL fLiveWindow; // M: Preview video
  98. BOOL fOverlayWindow; // M: Overlay video
  99. BOOL fScale; // M: Scale image to client
  100. POINT ptScroll; // I: Scroll position
  101. HANDLE hdd; // I: hDrawDib access handle
  102. HCURSOR hWaitCursor; // I: hourglass
  103. UINT uiRegion; // I: CheckWindowMove
  104. RECT rcRegionRect; // I: CheckWindowMove
  105. DWORD dwRegionOrigin; // I: CheckWindowMove
  106. // Window update timer
  107. UINT idTimer; // I: ID of preview timer
  108. UINT uTimeout; // M: Preview rate in mS.
  109. // Capture destination and control
  110. CAPTUREPARMS sCapParms; // M: how to capture
  111. BOOL fCapturingToDisk; // M: if capturing to disk
  112. BOOL fCapturingNow; // I: if performing capture
  113. BOOL fStepCapturingNow; // I: if performing MCI step capture
  114. BOOL fFrameCapturingNow; // I: if performing single frame capture
  115. BOOL fStopCapture; // M: if stop requested
  116. BOOL fAbortCapture; // M: if abort requested
  117. DWORD dwTimeElapsedMS; // I: Capture time in millisec
  118. // Index
  119. HGLOBAL hIndex; // I: handle to index mem
  120. DWORD dwIndex; // I: index index
  121. DWORD dwVideoChunkCount; // I: # of video frames cap'd
  122. DWORD dwWaveChunkCount; // I: # of audio buffers cap'd
  123. DWORD _huge * lpdwIndexStart; // I: index start ptr
  124. DWORD _huge * lpdwIndexEntry; // I: index current ptr
  125. LPBYTE lpDOSWriteBuffer; // I: ptr to DOS buffer
  126. DWORD dwDOSBufferSize; // I: DOS buffer size
  127. // Video format
  128. DWORD dwActualMicroSecPerFrame; // I: Actual cap rate
  129. LPBITMAPINFO lpBitsInfo; // I: Video format
  130. int dxBits; // I: video size x
  131. int dyBits; // I: video size y
  132. LPSTR lpBits; // I: Single frame capture buf
  133. VIDEOHDR VidHdr; // I: Single frame header
  134. COMPVARS CompVars; // M: Set by ICCompressorChoose
  135. LPIAVERAGE lpia; // I: Image averaging struct
  136. VIDEOHDR VidHdr2x; // I: VideoHeader at 2x
  137. LPBITMAPINFOHEADER lpbmih2x; // I: lpbi at 2x
  138. // Video Buffer management
  139. BOOL fVideoDataIsCompressed; // I: if don't use dwVideoSize
  140. DWORD dwVideoSize; // I: size of non-comp buffer incl chunk
  141. DWORD dwVideoJunkSize; // I: Initial non-comp. junk size
  142. int iNumVideo; // I: Number of actual video buffers
  143. int iNextVideo; // I: index into video buffers
  144. DWORD dwFramesDropped; // I: number of frames dropped
  145. BYTE DropFrame[DROP_BUFFER_SIZE]; // I: Create a Dummy VideoHdr
  146. LPVIDEOHDR alpVideoHdr[MAX_VIDEO_BUFFERS]; // I: array of buf ptrs
  147. BOOL fBuffersOnHardware; // I: if driver all'd buffers
  148. // Palettes
  149. HPALETTE hPalCurrent; // I: handle of current pal
  150. BOOL fUsingDefaultPalette; // I: no user defined pal
  151. int nPaletteColors; // M: only changed by UI
  152. LPVOID lpCapPal; // I: LPCAPPAL manual pals
  153. // Audio Capture Format
  154. BOOL fAudioHardware; // I: if audio hardware present
  155. LPWAVEFORMATEX lpWaveFormat; // I: wave format
  156. WAVEHDR WaveHdr; // I: Wave header
  157. HWAVE hWaveIn; // I: Wave input channel
  158. DWORD dwWaveBytes; // I: Total wave bytes cap'd
  159. DWORD dwWaveSize; // I: wave buffer size
  160. // Audio Buffer management
  161. LPWAVEHDR alpWaveHdr[MAX_WAVE_BUFFERS]; // I: wave buff array
  162. int iNextWave; // I: Index into wave buffers
  163. int iNumAudio; // I: Number of actual audio buffers
  164. BOOL fAudioYield; // I: ACM audio yield required
  165. BOOL fAudioBreak; // I: Audio underflow
  166. // MCI Capture
  167. char achMCIDevice[_MAX_CAP_PATH];// MCI device name
  168. DWORD dwMCIError; // I: Last MCI error value
  169. enum mcicapstates MCICaptureState; // I: MCI State machine
  170. DWORD dwMCICurrentMS; // I: Current MCI position
  171. DWORD dwMCIActualStartMS; // I: Actual MCI start MS
  172. DWORD dwMCIActualEndMS; // I: Actual MCI end position
  173. // Output file
  174. char achFile [_MAX_CAP_PATH]; // M: name of capture file
  175. char achSaveAsFile [_MAX_CAP_PATH]; // M: name of saveas file
  176. BOOL fCapFileExists; // I: if have a capture file
  177. LONG lCapFileSize; // M: in bytes
  178. BOOL fFileCaptured; // I: if we've cap'd to file
  179. HMMIO hmmio; // I: MMIO handle for writing
  180. DWORD dwAVIHdrSize; // I: size of header
  181. DWORD dwAVIHdrPos; // I: file offset of hdr
  182. LONG lUser; // M: Data for the user
  183. LPVOID lpInfoChunks; // M: information chunks
  184. LONG cbInfoChunks; // M: sizeof information chks
  185. BOOL fLastStatusWasNULL; // I: don't repeat null msgs
  186. BOOL fLastErrorWasNULL; // I: don't repeat null msgs
  187. } CAPSTREAM;
  188. typedef CAPSTREAM FAR * LPCAPSTREAM;
  189. // -------------------------
  190. // Full color log palette
  191. // -------------------------
  192. typedef struct tagFCLOGPALETTE {
  193. WORD palVersion;
  194. WORD palNumEntries;
  195. PALETTEENTRY palPalEntry[256];
  196. } FCLOGPALETTE;
  197. typedef struct {
  198. DWORD dwType;
  199. DWORD dwSize;
  200. } RIFF, *PRIFF, FAR *LPRIFF;
  201. extern HINSTANCE ghInst;
  202. extern BOOL gfIsRTL;
  203. // capinit.c
  204. BOOL CapWinDisconnectHardware(LPCAPSTREAM lpcs);
  205. BOOL CapWinConnectHardware (LPCAPSTREAM lpcs, WORD wDeviceIndex);
  206. BOOL capInternalGetDriverDesc (WORD wDriverIndex,
  207. LPSTR lpszName, int cbName,
  208. LPSTR lpszVer, int cbVer);
  209. // capwin.c
  210. LONG FAR PASCAL _loadds CapWndProc (HWND hwnd, unsigned msg, WORD wParam, LONG lParam);
  211. // capavi.c
  212. BOOL InitIndex (LPCAPSTREAM lpcs);
  213. void FiniIndex (LPCAPSTREAM lpcs);
  214. BOOL IndexVideo (LPCAPSTREAM lpcs, DWORD dwSize, BOOL bKeyFrame);
  215. BOOL IndexAudio (LPCAPSTREAM lpcs, DWORD dwSize);
  216. BOOL WriteIndex (LPCAPSTREAM lpcs, BOOL fJunkChunkWritten);
  217. DWORD GetFreePhysicalMemory(void);
  218. DWORD CalcWaveBufferSize (LPCAPSTREAM lpcs);
  219. BOOL AVIFileInit(LPCAPSTREAM lpcs);
  220. BOOL AVIFileFini (LPCAPSTREAM lpcs, BOOL fWroteJunkChunks, BOOL fAbort);
  221. WORD AVIAudioInit (LPCAPSTREAM lpcs);
  222. WORD AVIAudioFini (LPCAPSTREAM lpcs);
  223. WORD AVIAudioPrepare (LPCAPSTREAM lpcs, HWND hWndCallback);
  224. WORD AVIAudioUnPrepare (LPCAPSTREAM lpcs);
  225. WORD AVIVideoInit (LPCAPSTREAM lpcs);
  226. WORD AVIVideoPrepare (LPCAPSTREAM lpcs);
  227. WORD AVIVideoUnPrepare (LPCAPSTREAM lpcs);
  228. void AVIFini(LPCAPSTREAM lpcs);
  229. WORD AVIInit (LPCAPSTREAM lpcs);
  230. BOOL NEAR PASCAL AVIWrite(LPCAPSTREAM lpcs, LPVOID p, DWORD dwSize);
  231. BOOL AVIWriteDummyFrames (LPCAPSTREAM lpcs, int nCount);
  232. BOOL AVIWriteVideoFrame (LPCAPSTREAM lpcs, LPVIDEOHDR lpVidHdr);
  233. BOOL FAR PASCAL SetInfoChunk(LPCAPSTREAM lpcs, LPCAPINFOCHUNK lpcic);
  234. BOOL AVICapture (LPCAPSTREAM lpcs);
  235. // capfile.c
  236. BOOL FAR PASCAL fileCapFileIsAVI (LPSTR lpsz);
  237. BOOL FAR PASCAL fileAllocCapFile(LPCAPSTREAM lpcs, DWORD dwNewSize);
  238. BOOL FAR PASCAL fileSaveCopy(LPCAPSTREAM lpcs);
  239. BOOL FAR PASCAL fileSavePalette(LPCAPSTREAM lpcs, LPSTR lpszFileName);
  240. BOOL FAR PASCAL fileOpenPalette(LPCAPSTREAM lpcs, LPSTR lpszFileName);
  241. //capmisc.c
  242. WORD GetKey(BOOL fWait);
  243. void errorDriverID (LPCAPSTREAM lpcs, DWORD dwError);
  244. void FAR _cdecl statusUpdateStatus (LPCAPSTREAM lpcs, WORD wID, ...);
  245. void FAR _cdecl errorUpdateError (LPCAPSTREAM lpcs, WORD wID, ...);
  246. //capFrame.c
  247. BOOL FAR PASCAL SingleFrameCaptureOpen (LPCAPSTREAM lpcs);
  248. BOOL FAR PASCAL SingleFrameCaptureClose (LPCAPSTREAM lpcs);
  249. BOOL FAR PASCAL SingleFrameCapture (LPCAPSTREAM lpcs);
  250. BOOL SingleFrameWrite (
  251. LPCAPSTREAM lpcs, // capture stream
  252. LPVIDEOHDR lpVidHdr, // input header
  253. BOOL FAR *pfKey, // did it end up being a key frame?
  254. LONG FAR *plSize); // size of returned image
  255. //capMCI.c
  256. void FAR PASCAL TimeMSToSMPTE (DWORD dwMS, LPSTR lpTime);
  257. int CountMCIDevicesByType ( WORD wType );
  258. void MCIDeviceClose (LPCAPSTREAM lpcs);
  259. BOOL MCIDeviceOpen (LPCAPSTREAM lpcs);
  260. BOOL FAR PASCAL MCIDeviceGetPosition (LPCAPSTREAM lpcs, LPDWORD lpdwPos);
  261. BOOL FAR PASCAL MCIDeviceSetPosition (LPCAPSTREAM lpcs, DWORD dwPos);
  262. BOOL FAR PASCAL MCIDevicePlay (LPCAPSTREAM lpcs);
  263. BOOL FAR PASCAL MCIDevicePause (LPCAPSTREAM lpcs);
  264. BOOL FAR PASCAL MCIDeviceStop (LPCAPSTREAM lpcs);
  265. BOOL FAR PASCAL MCIDeviceStep (LPCAPSTREAM lpcs, BOOL fForward);
  266. void FAR PASCAL _loadds MCIStepCapture (LPCAPSTREAM lpcs);
  267. long FAR PASCAL muldiv32(long, long, long);
  268. #ifdef _DEBUG
  269. BOOL FAR PASCAL _Assert(BOOL f, LPSTR szFile, int iLine);
  270. #define WinAssert(exp) (_Assert(exp, (LPSTR) __FILE__, __LINE__))
  271. extern void FAR CDECL dprintf(LPSTR, ...);
  272. #define DPF dprintf
  273. #else
  274. #define dprintf ; / ## /
  275. #define DPF ; / ## /
  276. #define WinAssert(exp) 0
  277. #endif
  278. #ifndef RC_INVOKED
  279. #pragma pack() /* Revert to default packing */
  280. #endif /* RC_INVOKED */
  281. #ifdef __cplusplus
  282. } /* End of extern "C" { */
  283. #endif /* __cplusplus */
  284. #endif /* INC_AVICAP_INTERNAL */
  285.