1 /***********************************************************************\
2 *                                 vfw.d                                 *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                 written in the D programming language                 *
6 *                                                                       *
7 *                       Placed into public domain                       *
8 \***********************************************************************/
9 
10 module win32.vfw;
11 version(Windows):
12 pragma(lib, "vfw32");
13 
14 private import
15 	win32.commdlg,
16 	win32.wingdi,
17 	win32.mmsystem,
18 	win32.unknwn,
19 	win32.w32api,
20 	win32.windef,
21 	win32.winuser;
22 
23 extern(Windows) {
24 	DWORD VideoForWindowsVersion();
25 	LONG InitVFW();
26 	LONG TermVFW();
27 }
28 
29 DWORD MKFOURCC(char ch0, char ch1, char ch2, char ch3) {
30 	return (cast(DWORD)ch0) | ((cast(DWORD)ch1) << 8) | ((cast(DWORD)ch2) << 16) | ((cast(DWORD)ch3) << 24);
31 }
32 
33 /**
34  * COMPMAN - Installable Compression Manager.
35  */
36 
37 const ICVERSION = 0x0104;
38 
39 alias TypeDef!(HANDLE) HIC;
40 
41 const BI_1632 = 0x32333631;
42 
43 template aviTWOCC(char c0, char c1) {
44 	const WORD aviTWOCC = c0 | (c1 << 8);
45 }
46 
47 const ICTYPE_VIDEO	= mmioFOURCC!('v', 'i', 'd', 'c');
48 const ICTYPE_AUDIO	= mmioFOURCC!('a', 'u', 'd', 'c');
49 
50 enum {
51 	ICERR_OK			= 0,
52 	ICERR_DONTDRAW		= 1,
53 	ICERR_NEWPALETTE	= 2,
54 	ICERR_GOTOKEYFRAME	= 3,
55 	ICERR_STOPDRAWING	= 4,
56 }
57 
58 const ICERR_UNSUPPORTED	= -1;
59 const ICERR_BADFORMAT	= -2;
60 const ICERR_MEMORY		= -3;
61 const ICERR_INTERNAL	= -4;
62 const ICERR_BADFLAGS	= -5;
63 const ICERR_BADPARAM	= -6;
64 const ICERR_BADSIZE		= -7;
65 const ICERR_BADHANDLE	= -8;
66 const ICERR_CANTUPDATE	= -9;
67 const ICERR_ABORT		= -10;
68 const ICERR_ERROR		= -100;
69 const ICERR_BADBITDEPTH	= -200;
70 const ICERR_BADIMAGESIZE = -201;
71 
72 const ICERR_CUSTOM = -400;
73 
74 enum {
75 	ICMODE_COMPRESS			= 1,
76 	ICMODE_DECOMPRESS,
77 	ICMODE_FASTDECOMPRESS,
78 	ICMODE_QUERY,
79 	ICMODE_FASTCOMPRESS,
80 	ICMODE_DRAW				= 8,
81 }
82 
83 const ICMODE_INTERNALF_FUNCTION32	= 0x8000;
84 const ICMODE_INTERNALF_MASK			= 0x8000;
85 
86 enum {
87 	AVIIF_LIST		= 0x00000001,
88 	AVIIF_TWOCC		= 0x00000002,
89 	AVIIF_KEYFRAME	= 0x00000010,
90 }
91 
92 const ICQUALITY_LOW		= 0;
93 const ICQUALITY_HIGH	= 10000;
94 const ICQUALITY_DEFAULT = -1;
95 
96 enum {
97 	ICM_USER			= DRV_USER + 0x0000,
98 	ICM_RESERVED_LOW	= DRV_USER + 0x1000,
99 	ICM_RESERVED_HIGH	= DRV_USER + 0x2000,
100 	ICM_RESERVED		= ICM_RESERVED_LOW,
101 }
102 
103 // messages
104 
105 enum {
106 	ICM_GETSTATE			= ICM_RESERVED + 0,
107 	ICM_SETSTATE			= ICM_RESERVED + 1,
108 	ICM_GETINFO				= ICM_RESERVED + 2,
109 	ICM_CONFIGURE			= ICM_RESERVED + 10,
110 	ICM_ABOUT				= ICM_RESERVED + 11,
111 	ICM_GETERRORTEXT		= ICM_RESERVED + 12,
112 	ICM_GETFORMATNAME		= ICM_RESERVED + 20,
113 	ICM_ENUMFORMATS			= ICM_RESERVED + 21,
114 	ICM_GETDEFAULTQUALITY	= ICM_RESERVED + 30,
115 	ICM_GETQUALITY			= ICM_RESERVED + 31,
116 	ICM_SETQUALITY			= ICM_RESERVED + 32,
117 	ICM_SET					= ICM_RESERVED + 40,
118 	ICM_GET					= ICM_RESERVED + 41,
119 }
120 
121 const ICM_FRAMERATE		= mmioFOURCC!('F','r','m','R');
122 const ICM_KEYFRAMERATE	= mmioFOURCC!('K','e','y','R');
123 
124 // ICM specific messages.
125 
126 enum {
127 	ICM_COMPRESS_GET_FORMAT		= ICM_USER + 4,
128 	ICM_COMPRESS_GET_SIZE		= ICM_USER + 5,
129 	ICM_COMPRESS_QUERY			= ICM_USER + 6,
130 	ICM_COMPRESS_BEGIN			= ICM_USER + 7,
131 	ICM_COMPRESS				= ICM_USER + 8,
132 	ICM_COMPRESS_END			= ICM_USER + 9,
133 	ICM_DECOMPRESS_GET_FORMAT	= ICM_USER + 10,
134 	ICM_DECOMPRESS_QUERY		= ICM_USER + 11,
135 	ICM_DECOMPRESS_BEGIN		= ICM_USER + 12,
136 	ICM_DECOMPRESS				= ICM_USER + 13,
137 	ICM_DECOMPRESS_END			= ICM_USER + 14,
138 	ICM_DECOMPRESS_SET_PALETTE	= ICM_USER + 29,
139 	ICM_DECOMPRESS_GET_PALETTE	= ICM_USER + 30,
140 	ICM_DRAW_QUERY				= ICM_USER + 31,
141 	ICM_DRAW_BEGIN				= ICM_USER + 15,
142 	ICM_DRAW_GET_PALETTE		= ICM_USER + 16,
143 	ICM_DRAW_UPDATE				= ICM_USER + 17,
144 	ICM_DRAW_START				= ICM_USER + 18,
145 	ICM_DRAW_STOP				= ICM_USER + 19,
146 	ICM_DRAW_BITS				= ICM_USER + 20,
147 	ICM_DRAW_END				= ICM_USER + 21,
148 	ICM_DRAW_GETTIME			= ICM_USER + 32,
149 	ICM_DRAW					= ICM_USER + 33,
150 	ICM_DRAW_WINDOW				= ICM_USER + 34,
151 	ICM_DRAW_SETTIME			= ICM_USER + 35,
152 	ICM_DRAW_REALIZE			= ICM_USER + 36,
153 	ICM_DRAW_FLUSH				= ICM_USER + 37,
154 	ICM_DRAW_RENDERBUFFER		= ICM_USER + 38,
155 	ICM_DRAW_START_PLAY			= ICM_USER + 39,
156 	ICM_DRAW_STOP_PLAY			= ICM_USER + 40,
157 	ICM_DRAW_SUGGESTFORMAT		= ICM_USER + 50,
158 	ICM_DRAW_CHANGEPALETTE		= ICM_USER + 51,
159 	ICM_DRAW_IDLE				= ICM_USER + 52,
160 	ICM_GETBUFFERSWANTED		= ICM_USER + 41,
161 	ICM_GETDEFAULTKEYFRAMERATE	= ICM_USER + 42,
162 	ICM_DECOMPRESSEX_BEGIN		= ICM_USER + 60,
163 	ICM_DECOMPRESSEX_QUERY		= ICM_USER + 61,
164 	ICM_DECOMPRESSEX			= ICM_USER + 62,
165 	ICM_DECOMPRESSEX_END		= ICM_USER + 63,
166 	ICM_COMPRESS_FRAMES_INFO	= ICM_USER + 70,
167 	ICM_COMPRESS_FRAMES			= ICM_USER + 71,
168 	ICM_SET_STATUS_PROC			= ICM_USER + 72,
169 }
170 
171 struct ICOPEN {
172 	DWORD	dwSize;
173 	DWORD	fccType;
174 	DWORD	fccHandler;
175 	DWORD	dwVersion;
176 	DWORD	dwFlags;
177 	LRESULT	dwError;
178 	LPVOID	pV1Reserved;
179 	LPVOID	pV2Reserved;
180 	DWORD	dnDevNode;
181 }
182 
183 struct ICINFO {
184 	DWORD		dwSize;
185 	DWORD		fccType;
186 	DWORD		fccHandler;
187 	DWORD		dwFlags;
188 	DWORD		dwVersion;
189 	DWORD		dwVersionICM;
190 	WCHAR[16]	szName;
191 	WCHAR[128]	szDescription;
192 	WCHAR[128]	szDriver;
193 }
194 
195 enum {
196 	VIDCF_QUALITY			= 0x0001,
197 	VIDCF_CRUNCH			= 0x0002,
198 	VIDCF_TEMPORAL			= 0x0004,
199 	VIDCF_COMPRESSFRAMES	= 0x0008,
200 	VIDCF_DRAW				= 0x0010,
201 	VIDCF_FASTTEMPORALC		= 0x0020,
202 	VIDCF_FASTTEMPORALD		= 0x0080,
203 }
204 
205 const ICCOMPRESS_KEYFRAME = 0x00000001L;
206 
207 struct ICCOMPRESS {
208 	DWORD				dwFlags;
209 	LPBITMAPINFOHEADER	lpbiOutput;
210 	LPVOID				lpOutput;
211 	LPBITMAPINFOHEADER	lpbiInput;
212 	LPVOID				lpInput;
213 	LPDWORD				lpckid;
214 	LPDWORD				lpdwFlags;
215 	LONG				lFrameNum;
216 	DWORD				dwFrameSize;
217 	DWORD				dwQuality;
218 	LPBITMAPINFOHEADER	lpbiPrev;
219 	LPVOID				lpPrev;
220 }
221 
222 const ICCOMPRESSFRAMES_PADDING = 0x00000001;
223 
224 struct ICCOMPRESSFRAMES {
225 	DWORD				dwFlags;
226 	LPBITMAPINFOHEADER	lpbiOutput;
227 	LPARAM				lOutput;
228 	LPBITMAPINFOHEADER	lpbiInput;
229 	LPARAM				lInput;
230 	LONG				lStartFrame;
231 	LONG				lFrameCount;
232 	LONG				lQuality;
233 	LONG				lDataRate;
234 	LONG				lKeyRate;
235 	DWORD				dwRate;
236 	DWORD				dwScale;    DWORD		dwOverheadPerFrame;
237 	DWORD				dwReserved2;
238 
239 	LONG function(LPARAM lInput, LONG lFrame, LPVOID lpBits, LONG len) GetData;
240 	LONG function(LPARAM lOutput, LONG lFrame, LPVOID lpBits, LONG len) PutData;
241 }
242 
243 enum {
244 	ICSTATUS_START	= 0,
245 	ICSTATUS_STATUS	= 1,
246 	ICSTATUS_END	= 2,
247 	ICSTATUS_ERROR	= 3,
248 	ICSTATUS_YIELD	= 4,
249 }
250 
251 struct ICSETSTATUSPROC {
252 	DWORD	dwFlags;
253 	LPARAM	lParam;
254 	LONG function(LPARAM lParam, UINT message, LONG l) Status;
255 }
256 
257 enum {
258 	ICDECOMPRESS_NOTKEYFRAME	= 0x08000000,
259 	ICDECOMPRESS_NULLFRAME		= 0x10000000,
260 	ICDECOMPRESS_PREROLL		= 0x20000000,
261 	ICDECOMPRESS_UPDATE			= 0x40000000,
262 	ICDECOMPRESS_HURRYUP		= 0x80000000,
263 }
264 
265 struct ICDECOMPRESS {
266 	DWORD				dwFlags;
267 	LPBITMAPINFOHEADER	lpbiInput;
268 	LPVOID				lpInput;
269 	LPBITMAPINFOHEADER	lpbiOutput;
270 	LPVOID				lpOutput;
271 	DWORD				ckid;
272 }
273 
274 struct ICDECOMPRESSEX {
275 	DWORD				dwFlags;
276 	LPBITMAPINFOHEADER  lpbiSrc;
277 	LPVOID				lpSrc;
278 	LPBITMAPINFOHEADER	lpbiDst;
279 	LPVOID				lpDst;
280 	int					xDst;
281 	int					yDst;
282 	int					dxDst;
283 	int					dyDst;
284 	int					xSrc;
285 	int					ySrc;
286 	int					dxSrc;
287 	int					dySrc;
288 }
289 
290 enum {
291 	ICDRAW_QUERY		= 0x00000001,
292 	ICDRAW_FULLSCREEN	= 0x00000002,
293 	ICDRAW_HDC			= 0x00000004,
294 	ICDRAW_ANIMATE		= 0x00000008,
295 	ICDRAW_CONTINUE		= 0x00000010,
296 	ICDRAW_MEMORYDC		= 0x00000020,
297 	ICDRAW_UPDATING		= 0x00000040,
298 	ICDRAW_RENDER		= 0x00000080,
299 	ICDRAW_BUFFER		= 0x00000100,
300 }
301 
302 struct ICDRAWBEGIN {
303 	DWORD				dwFlags;
304 	HPALETTE			hpal;
305 	HWND				hwnd;
306 	HDC					hdc;
307 	int					xDst;
308 	int					yDst;
309 	int					dxDst;
310 	int					dyDst;
311 	LPBITMAPINFOHEADER	lpbi;
312 	int					xSrc;
313 	int					ySrc;
314 	int					dxSrc;
315 	int					dySrc;
316 	DWORD				dwRate;
317 	DWORD				dwScale;
318 }
319 
320 enum {
321 	ICDRAW_NOTKEYFRAME	= 0x08000000,
322 	ICDRAW_NULLFRAME	= 0x10000000,
323 	ICDRAW_PREROLL		= 0x20000000,
324 	ICDRAW_UPDATE		= 0x40000000,
325 	ICDRAW_HURRYUP		= 0x80000000,
326 }
327 
328 struct ICDRAW {
329 	DWORD			dwFlags;
330 	LPVOID			lpFormat;
331 	LPVOID			lpData;
332 	DWORD			cbData;
333 	LONG			lTime;
334 }
335 
336 struct ICDRAWSUGGEST {
337 	LPBITMAPINFOHEADER	lpbiIn;
338 	LPBITMAPINFOHEADER	lpbiSuggest;
339 	int					dxSrc;
340 	int					dySrc;
341 	int					dxDst;
342 	int					dyDst;
343 	HIC					hicDecompressor;
344 }
345 
346 struct ICPALETTE {
347 	DWORD			dwFlags;
348 	int				iStart;
349 	int				iLen;
350 	LPPALETTEENTRY	lppe;
351 }
352 
353 
354 /**
355  * ICM function declarations
356  */
357 
358 extern (Windows) {
359 	BOOL ICInfo(DWORD fccType, DWORD fccHandler, ICINFO *lpicinfo);
360 	BOOL ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags);
361 	BOOL ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags);
362 	LRESULT ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb);
363 	HIC ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode);
364 	HIC ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler);
365 	LRESULT ICClose(HIC hic);
366 	LRESULT ICSendMessage(HIC hic, UINT msg, DWORD_PTR dw1, DWORD_PTR dw2);
367 }
368 
369 enum {
370 	ICINSTALL_FUNCTION	= 0x0001,
371 	ICINSTALL_DRIVER	= 0x0002,
372 	ICINSTALL_HDRV		= 0x0004,
373 	ICINSTALL_UNICODE	= 0x8000,
374 	ICINSTALL_DRIVERW	= 0x8002,
375 }
376 
377 // query macros
378 
379 const ICMF_CONFIGURE_QUERY	= 0x00000001;
380 const ICMF_ABOUT_QUERY		= 0x00000001;
381 
382 DWORD ICQueryAbout(HIC hic) {
383 	return ICSendMessage(hic, ICM_ABOUT, -1, ICMF_ABOUT_QUERY) == ICERR_OK;
384 }
385 
386 DWORD ICAbout(HIC hic, HWND hwnd) {
387 	return cast(DWORD) ICSendMessage(hic, ICM_ABOUT, cast(DWORD_PTR) cast(UINT_PTR) hwnd, 0);
388 }
389 
390 DWORD ICQueryConfigure(HIC hic) {
391 	return (ICSendMessage(hic, ICM_CONFIGURE, -1, ICMF_CONFIGURE_QUERY) == ICERR_OK);
392 }
393 
394 DWORD ICConfigure(HIC hic, HWND hwnd) {
395 	return cast(DWORD) ICSendMessage(hic, ICM_CONFIGURE, cast(DWORD_PTR) cast(UINT_PTR) hwnd, 0);
396 }
397 
398 DWORD ICGetState(HIC hic, LPVOID pv, DWORD_PTR cb) {
399 	return cast(DWORD) ICSendMessage(hic, ICM_GETSTATE, cast(DWORD_PTR) pv, cb);
400 }
401 
402 DWORD ICSetState(HIC hic, LPVOID pv, DWORD_PTR cb) {
403 	return cast(DWORD) ICSendMessage(hic, ICM_SETSTATE, cast(DWORD_PTR) pv, cb);
404 }
405 
406 DWORD ICGetStateSize(HIC hic) {
407 	return ICGetState(hic, null, 0);
408 }
409 
410 DWORD dwICValue;
411 
412 DWORD ICGetDefaultQuality(HIC hic) {
413 	ICSendMessage(hic, ICM_GETDEFAULTQUALITY, cast(DWORD_PTR)&dwICValue, DWORD.sizeof);
414 	return dwICValue;
415 }
416 
417 DWORD ICGetDefaultKeyFrameRate(HIC hic) {
418 	ICSendMessage(hic, ICM_GETDEFAULTKEYFRAMERATE, cast(DWORD_PTR)&dwICValue, DWORD.sizeof);
419 	return dwICValue;
420 }
421 
422 DWORD ICDrawWindow(HIC hic, LPVOID prc) {
423 	return cast(DWORD) ICSendMessage(hic, ICM_DRAW_WINDOW, cast(DWORD_PTR) prc, RECT.sizeof);
424 }
425 
426 extern (Windows) {
427 	DWORD ICCompress(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiOutput, LPVOID lpData,
428 		LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits, LPDWORD lpckid, LPDWORD lpdwFlags,
429 		LONG lFrameNum, DWORD dwFrameSize, DWORD dwQuality, LPBITMAPINFOHEADER lpbiPrev, LPVOID lpPrev);
430 }
431 
432 LRESULT ICCompressBegin(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
433 	return ICSendMessage(hic, ICM_COMPRESS_BEGIN, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
434 }
435 LRESULT ICCompressQuery(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
436 	return ICSendMessage(hic, ICM_COMPRESS_QUERY, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
437 }
438 LRESULT ICCompressGetFormat(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
439 	return ICSendMessage(hic, ICM_COMPRESS_GET_FORMAT, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
440 }
441 DWORD ICCompressGetFormatSize(HIC hic, LPVOID lpbi) {
442 	return cast(DWORD)ICCompressGetFormat(hic, lpbi, null);
443 }
444 DWORD ICCompressGetSize(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
445 	return cast(DWORD)ICSendMessage(hic, ICM_COMPRESS_GET_SIZE, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
446 }
447 LRESULT ICCompressEnd(HIC hic) {
448 	return ICSendMessage(hic, ICM_COMPRESS_END, 0, 0);
449 }
450 
451 extern (Windows) {
452 	DWORD ICDecompress(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiFormat, LPVOID lpData, LPBITMAPINFOHEADER lpbi, LPVOID lpBits);
453 }
454 
455 LRESULT ICDecompressBegin(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
456 	return ICSendMessage(hic, ICM_DECOMPRESS_BEGIN, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
457 }
458 LRESULT ICDecompressQuery(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
459 	return ICSendMessage(hic, ICM_DECOMPRESS_QUERY, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
460 }
461 LONG ICDecompressGetFormat(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
462 	return cast(LONG)ICSendMessage(hic, ICM_DECOMPRESS_GET_FORMAT, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
463 }
464 LONG ICDecompressGetFormatSize(HIC hic, LPVOID lpbi) {
465 	return ICDecompressGetFormat(hic, lpbi, null);
466 }
467 LRESULT ICDecompressGetPalette(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
468 	return ICSendMessage(hic, ICM_DECOMPRESS_GET_PALETTE, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
469 }
470 LRESULT ICDecompressSetPalette(HIC hic, LPVOID lpbiPalette) {
471 	return ICSendMessage(hic, ICM_DECOMPRESS_SET_PALETTE, cast(DWORD_PTR)lpbiPalette, 0);
472 }
473 LRESULT ICDecompressEnd(HIC hic) {
474 	return ICSendMessage(hic, ICM_DECOMPRESS_END, 0, 0);
475 }
476 
477 LRESULT ICDecompressEx(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiSrc,
478 	LPVOID lpSrc, int xSrc, int ySrc, int dxSrc, int dySrc,	LPBITMAPINFOHEADER lpbiDst,
479 	LPVOID lpDst, int xDst, int yDst, int dxDst, int dyDst) {
480 	ICDECOMPRESSEX ic;
481 
482 	ic.dwFlags = dwFlags;
483 	ic.lpbiSrc = lpbiSrc;
484 	ic.lpSrc = lpSrc;
485 	ic.xSrc = xSrc;
486 	ic.ySrc = ySrc;
487 	ic.dxSrc = dxSrc;
488 	ic.dySrc = dySrc;
489 	ic.lpbiDst = lpbiDst;
490 	ic.lpDst = lpDst;
491 	ic.xDst = xDst;
492 	ic.yDst = yDst;
493 	ic.dxDst = dxDst;
494 	ic.dyDst = dyDst;
495 
496 	return ICSendMessage(hic, ICM_DECOMPRESSEX, cast(DWORD_PTR)&ic, ic.sizeof);
497 }
498 
499 LRESULT ICDecompressExBegin(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiSrc,
500 	LPVOID lpSrc, int xSrc, int ySrc, int dxSrc, int dySrc, LPBITMAPINFOHEADER lpbiDst,
501 	LPVOID lpDst, int xDst, int yDst, int dxDst, int dyDst) {
502 	ICDECOMPRESSEX ic;
503 
504 	ic.dwFlags = dwFlags;
505 	ic.lpbiSrc = lpbiSrc;
506 	ic.lpSrc = lpSrc;
507 	ic.xSrc = xSrc;
508 	ic.ySrc = ySrc;
509 	ic.dxSrc = dxSrc;
510 	ic.dySrc = dySrc;
511 	ic.lpbiDst = lpbiDst;
512 	ic.lpDst = lpDst;
513 	ic.xDst = xDst;
514 	ic.yDst = yDst;
515 	ic.dxDst = dxDst;
516 	ic.dyDst = dyDst;
517 
518 	return ICSendMessage(hic, ICM_DECOMPRESSEX_BEGIN, cast(DWORD_PTR)&ic, ic.sizeof);
519 }
520 
521 LRESULT ICDecompressExQuery(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiSrc,
522 	LPVOID lpSrc, int xSrc, int ySrc, int dxSrc, int dySrc, LPBITMAPINFOHEADER lpbiDst,
523 	LPVOID lpDst, int xDst, int yDst, int dxDst, int dyDst) {
524 	ICDECOMPRESSEX ic;
525 
526 	ic.dwFlags = dwFlags;
527 	ic.lpbiSrc = lpbiSrc;
528 	ic.lpSrc = lpSrc;
529 	ic.xSrc = xSrc;
530 	ic.ySrc = ySrc;
531 	ic.dxSrc = dxSrc;
532 	ic.dySrc = dySrc;
533 	ic.lpbiDst = lpbiDst;
534 	ic.lpDst = lpDst;
535 	ic.xDst = xDst;
536 	ic.yDst = yDst;
537 	ic.dxDst = dxDst;
538 	ic.dyDst = dyDst;
539 
540 	return ICSendMessage(hic, ICM_DECOMPRESSEX_QUERY, cast(DWORD_PTR)&ic, ic.sizeof);
541 }
542 
543 LRESULT ICDecompressExEnd(HIC hic) {
544 	return ICSendMessage(hic, ICM_DECOMPRESSEX_END, 0, 0);
545 }
546 
547 extern (Windows) {
548 	DWORD ICDrawBegin(HIC hic, DWORD dwFlags, HPALETTE hpal, HWND hwnd, HDC hdc,
549 		int xDst, int yDst, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi,
550 		int xSrc, int ySrc, int dxSrc, int dySrc, DWORD dwRate, DWORD dwScale);
551 }
552 
553 extern (Windows) {
554 	DWORD ICDraw(HIC hic, DWORD dwFlags, LPVOID lpFormat, LPVOID lpData, DWORD cbData, LONG lTime);
555 }
556 
557 LRESULT ICDrawSuggestFormat(HIC hic, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut,
558 	int dxSrc, int dySrc, int dxDst, int dyDst, HIC hicDecomp) {
559 	ICDRAWSUGGEST ic;
560 
561 	ic.lpbiIn = lpbiIn;
562 	ic.lpbiSuggest = lpbiOut;
563 	ic.dxSrc = dxSrc;
564 	ic.dySrc = dySrc;
565 	ic.dxDst = dxDst;
566 	ic.dyDst = dyDst;
567 	ic.hicDecompressor = hicDecomp;
568 
569 	return ICSendMessage(hic, ICM_DRAW_SUGGESTFORMAT, cast(DWORD_PTR)&ic, ic.sizeof);
570 }
571 
572 LRESULT ICDrawQuery(HIC hic, LPVOID lpbiInput) {
573 	return ICSendMessage(hic, ICM_DRAW_QUERY, cast(DWORD_PTR)lpbiInput, 0L);
574 }
575 LRESULT ICDrawChangePalette(HIC hic, LPVOID lpbiInput) {
576 	return ICSendMessage(hic, ICM_DRAW_CHANGEPALETTE, cast(DWORD_PTR)lpbiInput, 0L);
577 }
578 LRESULT ICGetBuffersWanted(HIC hic, LPVOID lpdwBuffers) {
579 	return ICSendMessage(hic, ICM_GETBUFFERSWANTED, cast(DWORD_PTR)lpdwBuffers, 0);
580 }
581 LRESULT ICDrawEnd(HIC hic) {
582 	return ICSendMessage(hic, ICM_DRAW_END, 0, 0);
583 }
584 LRESULT ICDrawStart(HIC hic) {
585 	return ICSendMessage(hic, ICM_DRAW_START, 0, 0);
586 }
587 LRESULT ICDrawStartPlay(HIC hic, DWORD lFrom, DWORD lTo) {
588 	return ICSendMessage(hic, ICM_DRAW_START_PLAY, cast(DWORD_PTR)lFrom, cast(DWORD_PTR)lTo);
589 }
590 LRESULT ICDrawStop(HIC hic) {
591 	return ICSendMessage(hic, ICM_DRAW_STOP, 0, 0);
592 }
593 LRESULT ICDrawStopPlay(HIC hic) {
594 	return ICSendMessage(hic, ICM_DRAW_STOP_PLAY, 0, 0);
595 }
596 LRESULT ICDrawGetTime(HIC hic, LPVOID lplTime) {
597 	return ICSendMessage(hic, ICM_DRAW_GETTIME, cast(DWORD_PTR)lplTime, 0);
598 }
599 LRESULT ICDrawSetTime(HIC hic, DWORD lTime) {
600 	return ICSendMessage(hic, ICM_DRAW_SETTIME, cast(DWORD_PTR)lTime, 0);
601 }
602 LRESULT ICDrawRealize(HIC hic, HDC hdc, BOOL fBackground) {
603 	return ICSendMessage(hic, ICM_DRAW_REALIZE, cast(DWORD_PTR)hdc, cast(DWORD_PTR)fBackground);
604 }
605 LRESULT ICDrawFlush(HIC hic) {
606 	return ICSendMessage(hic, ICM_DRAW_FLUSH, 0, 0);
607 }
608 LRESULT ICDrawRenderBuffer(HIC hic) {
609 	return ICSendMessage(hic, ICM_DRAW_RENDERBUFFER, 0, 0);
610 }
611 
612 LRESULT ICSetStatusProc(HIC hic, DWORD dwFlags, LRESULT lParam, LONG function(LPARAM, UINT, LONG) fpfnStatus) {
613 	ICSETSTATUSPROC ic;
614 
615 	ic.dwFlags = dwFlags;
616 	ic.lParam = lParam;
617 	ic.Status = fpfnStatus;
618 
619 	return ICSendMessage(hic, ICM_SET_STATUS_PROC, cast(DWORD_PTR)&ic, ic.sizeof);
620 }
621 
622 HIC ICDecompressOpen(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut) {
623 	return ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, ICMODE_DECOMPRESS);
624 }
625 
626 HIC ICDrawOpen(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn) {
627 	return ICLocate(fccType, fccHandler, lpbiIn, null, ICMODE_DRAW);
628 }
629 
630 extern (Windows) {
631 	HIC ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, WORD wFlags);
632 	HIC ICGetDisplayFormat(HIC hic, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, int BitDepth, int dx, int dy);
633 	HANDLE ICImageCompress(HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut, LONG lQuality, LONG* plSize);
634 	HANDLE ICImageDecompress(HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut);
635 }
636 
637 struct COMPVARS {
638 	LONG		cbSize = this.sizeof;
639 	DWORD		dwFlags;
640 	HIC			hic;
641 	DWORD               fccType;
642 	DWORD               fccHandler;
643 	LPBITMAPINFO	lpbiIn;
644 	LPBITMAPINFO	lpbiOut;
645 	LPVOID		lpBitsOut;
646 	LPVOID		lpBitsPrev;
647 	LONG		lFrame;
648 	LONG		lKey;
649 	LONG		lDataRate;
650 	LONG		lQ;
651 	LONG		lKeyCount;
652 	LPVOID		lpState;
653 	LONG		cbState;
654 }
655 alias COMPVARS* PCOMPVARS;
656 
657 const ICMF_COMPVARS_VALID = 0x00000001;
658 
659 extern (Windows) {
660 	BOOL ICCompressorChoose(HWND hwnd, UINT uiFlags, LPVOID pvIn, LPVOID lpData, PCOMPVARS pc, LPSTR lpszTitle);
661 }
662 
663 enum {
664 	ICMF_CHOOSE_KEYFRAME		= 0x0001,
665 	ICMF_CHOOSE_DATARATE		= 0x0002,
666 	ICMF_CHOOSE_PREVIEW			= 0x0004,
667 	ICMF_CHOOSE_ALLCOMPRESSORS	= 0x0008,
668 }
669 
670 extern (Windows) {
671 	BOOL ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn);
672 	void ICSeqCompressFrameEnd(PCOMPVARS pc);
673 	LPVOID ICSeqCompressFrame(PCOMPVARS pc, UINT uiFlags, LPVOID lpBits, BOOL* pfKey, LONG* plSize);
674 	void ICCompressorFree(PCOMPVARS pc);
675 }
676 
677 mixin DECLARE_HANDLE!("HDRAWDIB");
678 
679 enum {
680 	DDF_0001			= 0x0001,
681 	DDF_UPDATE			= 0x0002,
682 	DDF_SAME_HDC		= 0x0004,
683 	DDF_SAME_DRAW		= 0x0008,
684 	DDF_DONTDRAW		= 0x0010,
685 	DDF_ANIMATE			= 0x0020,
686 	DDF_BUFFER			= 0x0040,
687 	DDF_JUSTDRAWIT		= 0x0080,
688 	DDF_FULLSCREEN		= 0x0100,
689 	DDF_BACKGROUNDPAL	= 0x0200,
690 	DDF_NOTKEYFRAME		= 0x0400,
691 	DDF_HURRYUP			= 0x0800,
692 	DDF_HALFTONE		= 0x1000,
693 	DDF_2000			= 0x2000,
694 	DDF_PREROLL			= DDF_DONTDRAW,
695 	DDF_SAME_DIB		= DDF_SAME_DRAW,
696 	DDF_SAME_SIZE		= DDF_SAME_DRAW,
697 }
698 
699 extern (Windows) {
700 	BOOL DrawDibInit();
701 	HDRAWDIB DrawDibOpen();
702 	BOOL DrawDibClose(HDRAWDIB hdd);
703 	LPVOID DrawDibGetBuffer(HDRAWDIB hdd, LPBITMAPINFOHEADER lpbi, DWORD dwSize, DWORD dwFlags);
704 	UINT DrawDibError(HDRAWDIB hdd);
705 	HPALETTE DrawDibGetPalette(HDRAWDIB hdd);
706 	BOOL DrawDibSetPalette(HDRAWDIB hdd, HPALETTE hpal);
707 	BOOL DrawDibChangePalette(HDRAWDIB hdd, int iStart, int iLen, LPPALETTEENTRY lppe);
708 	UINT DrawDibRealize(HDRAWDIB hdd, HDC hdc, BOOL fBackground);
709 	BOOL DrawDibStart(HDRAWDIB hdd, DWORD rate);
710 	BOOL DrawDibStop(HDRAWDIB hdd);
711 	BOOL DrawDibBegin(HDRAWDIB hdd, HDC hdc, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi, int dxSrc, int dySrc, UINT wFlags);
712 	BOOL DrawDibDraw(HDRAWDIB hdd, HDC hdc, int xDst, int yDst, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi,
713 		LPVOID lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, UINT wFlags);
714 }
715 
716 BOOL DrawDibUpdate(HDRAWDIB hdd, HDC hdc, int x, int y) {
717 	return DrawDibDraw(hdd, hdc, x, y, 0, 0, null, null, 0, 0, 0, 0, DDF_UPDATE);
718 }
719 
720 extern (Windows) {
721 	BOOL DrawDibEnd(HDRAWDIB hdd);
722 }
723 
724 struct DRAWDIBTIME {
725     LONG    timeCount;
726     LONG    timeDraw;
727     LONG    timeDecompress;
728     LONG    timeDither;
729     LONG    timeStretch;
730     LONG    timeBlt;
731     LONG    timeSetDIBits;
732 }
733 alias DRAWDIBTIME* LPDRAWDIBTIME;
734 
735 extern (Windows) {
736 	BOOL DrawDibTime(HDRAWDIB hdd, LPDRAWDIBTIME lpddtime);
737 }
738 
739 enum {
740 	PD_CAN_DRAW_DIB			= 0x0001,
741 	PD_CAN_STRETCHDIB		= 0x0002,
742 	PD_STRETCHDIB_1_1_OK	= 0x0004,
743 	PD_STRETCHDIB_1_2_OK	= 0x0008,
744 	PD_STRETCHDIB_1_N_OK	= 0x0010,
745 }
746 
747 extern (Windows) {
748 	LRESULT DrawDibProfileDisplay(LPBITMAPINFOHEADER lpbi);
749 	void StretchDIB(LPBITMAPINFOHEADER biDst, LPVOID lpDst, int	DstX, int DstY,
750 		int DstXE, int DstYE, LPBITMAPINFOHEADER biSrc, LPVOID lpSrc,
751 		int SrcX, int SrcY, int SrcXE, int SrcYE);
752 }
753 
754 alias DWORD FOURCC;
755 
756 alias WORD TWOCC;
757 
758 const formtypeAVI			= mmioFOURCC!('A', 'V', 'I', ' ');
759 const listtypeAVIHEADER		= mmioFOURCC!('h', 'd', 'r', 'l');
760 const ckidAVIMAINHDR		= mmioFOURCC!('a', 'v', 'i', 'h');
761 const listtypeSTREAMHEADER	= mmioFOURCC!('s', 't', 'r', 'l');
762 const ckidSTREAMHEADER		= mmioFOURCC!('s', 't', 'r', 'h');
763 const ckidSTREAMFORMAT		= mmioFOURCC!('s', 't', 'r', 'f');
764 const ckidSTREAMHANDLERDATA	= mmioFOURCC!('s', 't', 'r', 'd');
765 const ckidSTREAMNAME		= mmioFOURCC!('s', 't', 'r', 'n');
766 const listtypeAVIMOVIE		= mmioFOURCC!('m', 'o', 'v', 'i');
767 const listtypeAVIRECORD		= mmioFOURCC!('r', 'e', 'c', ' ');
768 const ckidAVINEWINDEX		= mmioFOURCC!('i', 'd', 'x', '1');
769 const streamtypeVIDEO		= mmioFOURCC!('v', 'i', 'd', 's');
770 const streamtypeAUDIO		= mmioFOURCC!('a', 'u', 'd', 's');
771 const streamtypeMIDI		= mmioFOURCC!('m', 'i', 'd', 's');
772 const streamtypeTEXT		= mmioFOURCC!('t', 'x', 't', 's');
773 
774 const cktypeDIBbits			= aviTWOCC!('d', 'b');
775 const cktypeDIBcompressed	= aviTWOCC!('d', 'c');
776 const cktypePALchange		= aviTWOCC!('p', 'c');
777 const cktypeWAVEbytes		= aviTWOCC!('w', 'b');
778 
779 const ckidAVIPADDING		= mmioFOURCC!('J', 'U', 'N', 'K');
780 
781 DWORD FromHex(char n) {
782 	return (n >= 'A') ? n + 10 - 'A' : n - '0';
783 }
784 
785 WORD StreamFromFOURCC(DWORD fcc) {
786 	return cast(WORD)((FromHex(LOBYTE(LOWORD(fcc))) << 4) + (FromHex(HIBYTE(LOWORD(fcc)))));
787 }
788 
789 WORD TWOCCFromFOURCC(DWORD fcc) {
790 	return HIWORD(fcc);
791 }
792 
793 BYTE ToHex(DWORD n) {
794 	return cast(BYTE)((n > 9) ? n - 10 + 'A' : n + '0');
795 }
796 
797 DWORD MAKEAVICKID(WORD tcc, WORD stream) {
798 	return MAKELONG(cast(WORD)((ToHex(stream & 0x0f) << 8) | (ToHex((stream & 0xf0) >> 4))), tcc);
799 }
800 
801 enum {
802 	AVIF_HASINDEX		= 0x00000010,
803 	AVIF_MUSTUSEINDEX	= 0x00000020,
804 	AVIF_ISINTERLEAVED	= 0x00000100,
805 	AVIF_WASCAPTUREFILE	= 0x00010000,
806 	AVIF_COPYRIGHTED	= 0x00020000,
807 }
808 
809 const AVI_HEADERSIZE = 2048;
810 
811 struct MainAVIHeader {
812 	DWORD dwMicroSecPerFrame;
813 	DWORD dwMaxBytesPerSec;
814 	DWORD dwPaddingGranularity;
815 	DWORD dwFlags;
816 	DWORD dwTotalFrames;
817 	DWORD dwInitialFrames;
818 	DWORD dwStreams;
819 	DWORD dwSuggestedBufferSize;
820 	DWORD dwWidth;
821 	DWORD dwHeight;
822 	DWORD[4] dwReserved;
823 }
824 
825 const AVISF_DISABLED = 0x00000001;
826 
827 const AVISF_VIDEO_PALCHANGES = 0x00010000;
828 
829 struct AVIStreamHeader {
830 	FOURCC		fccType;
831 	FOURCC		fccHandler;
832 	DWORD		dwFlags;
833 	WORD		wPriority;
834 	WORD		wLanguage;
835 	DWORD		dwInitialFrames;
836 	DWORD		dwScale;
837 	DWORD		dwRate;
838 	DWORD		dwStart;
839 	DWORD		dwLength;
840 	DWORD		dwSuggestedBufferSize;
841 	DWORD		dwQuality;
842 	DWORD		dwSampleSize;
843 	RECT		rcFrame;
844 }
845 
846 enum {
847 	AVIIF_FIRSTPART	= 0x00000020L,
848 	AVIIF_LASTPART	= 0x00000040L,
849 	AVIIF_MIDPART	= (AVIIF_LASTPART|AVIIF_FIRSTPART),
850 	AVIIF_NOTIME	= 0x00000100L,
851 	AVIIF_COMPUSE	= 0x0FFF0000L,
852 }
853 
854 struct AVIINDEXENTRY {
855 	DWORD		ckid;
856 	DWORD		dwFlags;
857 	DWORD		dwChunkOffset;
858 	DWORD		dwChunkLength;
859 }
860 
861 struct AVIPALCHANGE {
862 	BYTE		bFirstEntry;
863 	BYTE		bNumEntries;
864 	WORD		wFlags;
865 	PALETTEENTRY	peNew[];
866 }
867 
868 const AVIGETFRAMEF_BESTDISPLAYFMT = 1;
869 
870 struct AVISTREAMINFOW {
871 	DWORD	fccType;
872 	DWORD	fccHandler;
873 	DWORD	dwFlags;
874 	DWORD	dwCaps;
875 	WORD	wPriority;
876 	WORD	wLanguage;
877 	DWORD	dwScale;
878 	DWORD	dwRate;
879 	DWORD	dwStart;
880 	DWORD	dwLength;
881 	DWORD	dwInitialFrames;
882 	DWORD	dwSuggestedBufferSize;
883 	DWORD	dwQuality;
884 	DWORD	dwSampleSize;
885 	RECT	rcFrame;
886 	DWORD	dwEditCount;
887 	DWORD	dwFormatChangeCount;
888 	WCHAR[64]	szName;
889 }
890 alias AVISTREAMINFOW* LPAVISTREAMINFOW;
891 
892 struct AVISTREAMINFOA {
893 	DWORD	fccType;
894 	DWORD	fccHandler;
895 	DWORD	dwFlags;
896 	DWORD	dwCaps;
897 	WORD	wPriority;
898 	WORD	wLanguage;
899 	DWORD	dwScale;
900 	DWORD	dwRate;
901 	DWORD	dwStart;
902 	DWORD	dwLength;
903 	DWORD	dwInitialFrames;
904 	DWORD	dwSuggestedBufferSize;
905 	DWORD	dwQuality;
906 	DWORD	dwSampleSize;
907 	RECT	rcFrame;
908 	DWORD	dwEditCount;
909 	DWORD	dwFormatChangeCount;
910 	char[64]	szName;
911 }
912 alias AVISTREAMINFOA* LPAVISTREAMINFOA;
913 
914 version(Unicode) {
915 	alias AVISTREAMINFOW	AVISTREAMINFO;
916 	alias LPAVISTREAMINFOW	LPAVISTREAMINFO;
917 } else { // Unicode
918 	alias AVISTREAMINFOA	AVISTREAMINFO;
919 	alias LPAVISTREAMINFOA	LPAVISTREAMINFO;
920 }
921 
922 const AVISTREAMINFO_DISABLED		= 0x00000001;
923 const AVISTREAMINFO_FORMATCHANGES	= 0x00010000;
924 
925 struct AVIFILEINFOW {
926 	DWORD	dwMaxBytesPerSec;
927 	DWORD	dwFlags;
928 	DWORD	dwCaps;
929 	DWORD	dwStreams;
930 	DWORD	dwSuggestedBufferSize;
931 	DWORD	dwWidth;
932 	DWORD	dwHeight;
933 	DWORD	dwScale;
934 	DWORD	dwRate;
935 	DWORD	dwLength;
936 	DWORD	dwEditCount;
937 	WCHAR[64]	szFileType;
938 }
939 alias AVIFILEINFOW* LPAVIFILEINFOW;
940 
941 struct AVIFILEINFOA {
942 	DWORD	dwMaxBytesPerSec;
943 	DWORD	dwFlags;
944 	DWORD	dwCaps;
945 	DWORD	dwStreams;
946 	DWORD	dwSuggestedBufferSize;
947 	DWORD	dwWidth;
948 	DWORD	dwHeight;
949 	DWORD	dwScale;
950 	DWORD	dwRate;
951 	DWORD	dwLength;
952 	DWORD	dwEditCount;
953 	char[64]	szFileType;
954 }
955 alias AVIFILEINFOA* LPAVIFILEINFOA;
956 
957 version(Unicode) {
958 	alias AVIFILEINFOW	AVIFILEINFO;
959 	alias LPAVIFILEINFOW	LPAVIFILEINFO;
960 } else { // Unicode
961 	alias AVIFILEINFOA	AVIFILEINFO;
962 	alias LPAVIFILEINFOA	LPAVIFILEINFO;
963 }
964 
965 enum {
966 	AVIFILEINFO_HASINDEX		= 0x00000010,
967 	AVIFILEINFO_MUSTUSEINDEX	= 0x00000020,
968 	AVIFILEINFO_ISINTERLEAVED	= 0x00000100,
969 	AVIFILEINFO_WASCAPTUREFILE	= 0x00010000,
970 	AVIFILEINFO_COPYRIGHTED		= 0x00020000,
971 }
972 
973 enum {
974 	AVIFILECAPS_CANREAD			= 0x00000001,
975 	AVIFILECAPS_CANWRITE		= 0x00000002,
976 	AVIFILECAPS_ALLKEYFRAMES	= 0x00000010,
977 	AVIFILECAPS_NOCOMPRESSION	= 0x00000020,
978 }
979 
980 extern (Windows) {
981 	alias BOOL function(int) AVISAVECALLBACK;
982 }
983 
984 struct AVICOMPRESSOPTIONS {
985 	DWORD	fccType;
986 	DWORD	fccHandler;
987 	DWORD	dwKeyFrameEvery;
988 	DWORD	dwQuality;
989 	DWORD	dwBytesPerSecond;
990 	DWORD	dwFlags;
991 	LPVOID	lpFormat;
992 	DWORD	cbFormat;
993 	LPVOID	lpParms;
994 	DWORD	cbParms;
995 	DWORD	dwInterleaveEvery;
996 }
997 alias AVICOMPRESSOPTIONS* LPAVICOMPRESSOPTIONS;
998 
999 enum {
1000 	AVICOMPRESSF_INTERLEAVE	= 0x00000001,
1001 	AVICOMPRESSF_DATARATE	= 0x00000002,
1002 	AVICOMPRESSF_KEYFRAMES	= 0x00000004,
1003 	AVICOMPRESSF_VALID		= 0x00000008,
1004 }
1005 
1006 /+ TODO:
1007 DECLARE_INTERFACE_(IAVIStream, IUnknown)
1008 {
1009     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
1010     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
1011     STDMETHOD_(ULONG,Release) (THIS) PURE;
1012 
1013     STDMETHOD(Create)      (THIS_ LPARAM lParam1, LPARAM lParam2) PURE ;
1014     STDMETHOD(Info)        (THIS_ AVISTREAMINFOW FAR * psi, LONG lSize) PURE ;
1015     STDMETHOD_(LONG, FindSample)(THIS_ LONG lPos, LONG lFlags) PURE ;
1016     STDMETHOD(ReadFormat)  (THIS_ LONG lPos,
1017 			    LPVOID lpFormat, LONG FAR *lpcbFormat) PURE ;
1018     STDMETHOD(SetFormat)   (THIS_ LONG lPos,
1019 			    LPVOID lpFormat, LONG cbFormat) PURE ;
1020     STDMETHOD(Read)        (THIS_ LONG lStart, LONG lSamples,
1021 			    LPVOID lpBuffer, LONG cbBuffer,
1022 			    LONG FAR * plBytes, LONG FAR * plSamples) PURE ;
1023     STDMETHOD(Write)       (THIS_ LONG lStart, LONG lSamples,
1024 			    LPVOID lpBuffer, LONG cbBuffer,
1025 			    DWORD dwFlags,
1026 			    LONG FAR *plSampWritten,
1027 			    LONG FAR *plBytesWritten) PURE ;
1028     STDMETHOD(Delete)      (THIS_ LONG lStart, LONG lSamples) PURE;
1029     STDMETHOD(ReadData)    (THIS_ DWORD fcc, LPVOID lp, LONG FAR *lpcb) PURE ;
1030     STDMETHOD(WriteData)   (THIS_ DWORD fcc, LPVOID lp, LONG cb) PURE ;
1031 #ifdef _WIN32
1032     STDMETHOD(SetInfo) (THIS_ AVISTREAMINFOW FAR * lpInfo,
1033 			    LONG cbInfo) PURE;
1034 #else
1035     STDMETHOD(Reserved1)            (THIS) PURE;
1036     STDMETHOD(Reserved2)            (THIS) PURE;
1037     STDMETHOD(Reserved3)            (THIS) PURE;
1038     STDMETHOD(Reserved4)            (THIS) PURE;
1039     STDMETHOD(Reserved5)            (THIS) PURE;
1040 #endif
1041 };
1042 
1043 alias TypeDef!(IAVIStream FAR*) PAVISTREAM;
1044 
1045 #undef  INTERFACE
1046 #define INTERFACE   IAVIStreaming
1047 
1048 DECLARE_INTERFACE_(IAVIStreaming, IUnknown)
1049 {
1050     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
1051     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
1052     STDMETHOD_(ULONG,Release) (THIS) PURE;
1053 
1054     STDMETHOD(Begin) (THIS_
1055 		      LONG  lStart,
1056 		      LONG  lEnd,
1057 		      LONG  lRate) PURE;
1058     STDMETHOD(End)   (THIS) PURE;
1059 };
1060 
1061 alias TypeDef!(IAVIStreaming FAR*) PAVISTREAMING;
1062 
1063 
1064 #undef  INTERFACE
1065 #define INTERFACE   IAVIEditStream
1066 
1067 DECLARE_INTERFACE_(IAVIEditStream, IUnknown)
1068 {
1069     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
1070     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
1071     STDMETHOD_(ULONG,Release) (THIS) PURE;
1072 
1073     STDMETHOD(Cut) (THIS_ LONG FAR *plStart,
1074 			  LONG FAR *plLength,
1075 			  PAVISTREAM FAR * ppResult) PURE;
1076     STDMETHOD(Copy) (THIS_ LONG FAR *plStart,
1077 			   LONG FAR *plLength,
1078 			   PAVISTREAM FAR * ppResult) PURE;
1079     STDMETHOD(Paste) (THIS_ LONG FAR *plPos,
1080 			    LONG FAR *plLength,
1081 			    PAVISTREAM pstream,
1082 			    LONG lStart,
1083 			    LONG lEnd) PURE;
1084     STDMETHOD(Clone) (THIS_ PAVISTREAM FAR *ppResult) PURE;
1085     STDMETHOD(SetInfo) (THIS_ AVISTREAMINFOW FAR * lpInfo,
1086 			    LONG cbInfo) PURE;
1087 };
1088 
1089 alias TypeDef!(IAVIEditStream FAR*) PAVIEDITSTREAM;
1090 
1091 #undef  INTERFACE
1092 #define INTERFACE   IAVIPersistFile
1093 
1094 DECLARE_INTERFACE_(IAVIPersistFile, IPersistFile)
1095 {
1096     STDMETHOD(Reserved1)(THIS) PURE;
1097 };
1098 
1099 alias TypeDef!(IAVIPersistFile FAR*) PAVIPERSISTFILE;
1100 
1101 #undef  INTERFACE
1102 #define INTERFACE   IAVIFile
1103 #define PAVIFILE IAVIFile FAR*
1104 
1105 DECLARE_INTERFACE_(IAVIFile, IUnknown)
1106 {
1107     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
1108     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
1109     STDMETHOD_(ULONG,Release) (THIS) PURE;
1110 
1111     STDMETHOD(Info)                 (THIS_
1112                                      AVIFILEINFOW FAR * pfi,
1113                                      LONG lSize) PURE;
1114     STDMETHOD(GetStream)            (THIS_
1115                                      PAVISTREAM FAR * ppStream,
1116 				     DWORD fccType,
1117                                      LONG lParam) PURE;
1118     STDMETHOD(CreateStream)         (THIS_
1119                                      PAVISTREAM FAR * ppStream,
1120                                      AVISTREAMINFOW FAR * psi) PURE;
1121     STDMETHOD(WriteData)            (THIS_
1122                                      DWORD ckid,
1123                                      LPVOID lpData,
1124                                      LONG cbData) PURE;
1125     STDMETHOD(ReadData)             (THIS_
1126                                      DWORD ckid,
1127                                      LPVOID lpData,
1128                                      LONG FAR *lpcbData) PURE;
1129     STDMETHOD(EndRecord)            (THIS) PURE;
1130     STDMETHOD(DeleteStream)         (THIS_
1131 				     DWORD fccType,
1132                                      LONG lParam) PURE;
1133 };
1134 
1135 #undef PAVIFILE
1136 alias TypeDef!(IAVIFile FAR*) PAVIFILE;
1137 
1138 #undef  INTERFACE
1139 #define INTERFACE   IGetFrame
1140 #define PGETFRAME   IGetFrame FAR*
1141 
1142 DECLARE_INTERFACE_(IGetFrame, IUnknown)
1143 {
1144     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
1145     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
1146     STDMETHOD_(ULONG,Release) (THIS) PURE;
1147 
1148     STDMETHOD_(LPVOID,GetFrame) (THIS_ LONG lPos) PURE;
1149 
1150     STDMETHOD(Begin) (THIS_ LONG lStart, LONG lEnd, LONG lRate) PURE;
1151     STDMETHOD(End) (THIS) PURE;
1152 
1153     STDMETHOD(SetFormat) (THIS_ LPBITMAPINFOHEADER lpbi, LPVOID lpBits, int x, int y, int dx, int dy) PURE;
1154 };
1155 
1156 #undef PGETFRAME
1157 alias TypeDef!(IGetFrame FAR*) PGETFRAME;
1158 
1159 #define DEFINE_AVIGUID(name, l, w1, w2)    DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
1160 
1161 DEFINE_AVIGUID(IID_IAVIFile,            0x00020020, 0, 0);
1162 DEFINE_AVIGUID(IID_IAVIStream,          0x00020021, 0, 0);
1163 DEFINE_AVIGUID(IID_IAVIStreaming,       0x00020022, 0, 0);
1164 DEFINE_AVIGUID(IID_IGetFrame,           0x00020023, 0, 0);
1165 DEFINE_AVIGUID(IID_IAVIEditStream,      0x00020024, 0, 0);
1166 DEFINE_AVIGUID(IID_IAVIPersistFile,     0x00020025, 0, 0);
1167 #ifndef UNICODE
1168 DEFINE_AVIGUID(CLSID_AVISimpleUnMarshal,        0x00020009, 0, 0);
1169 #endif
1170 
1171 DEFINE_AVIGUID(CLSID_AVIFile,           0x00020000, 0, 0);
1172 
1173 #define	AVIFILEHANDLER_CANREAD		0x0001
1174 #define	AVIFILEHANDLER_CANWRITE		0x0002
1175 #define	AVIFILEHANDLER_CANACCEPTNONRGB	0x0004
1176 
1177 STDAPI_(void) AVIFileInit(void);
1178 STDAPI_(void) AVIFileExit(void);
1179 
1180 STDAPI_(ULONG) AVIFileAddRef       (PAVIFILE pfile);
1181 STDAPI_(ULONG) AVIFileRelease      (PAVIFILE pfile);
1182 
1183 #ifdef _WIN32
1184 STDAPI AVIFileOpenA       (PAVIFILE FAR * ppfile, LPCSTR szFile,
1185 			  UINT uMode, LPCLSID lpHandler);
1186 STDAPI AVIFileOpenW       (PAVIFILE FAR * ppfile, LPCWSTR szFile,
1187 			  UINT uMode, LPCLSID lpHandler);
1188 #ifdef UNICODE
1189 #define AVIFileOpen	  AVIFileOpenW
1190 #else
1191 #define AVIFileOpen	  AVIFileOpenA
1192 #endif
1193 #else
1194 STDAPI AVIFileOpen       (PAVIFILE FAR * ppfile, LPCSTR szFile,
1195 			  UINT uMode, LPCLSID lpHandler);
1196 #define AVIFileOpenW	AVIFileOpen
1197 #endif
1198 
1199 #ifdef _WIN32
1200 STDAPI AVIFileInfoW (PAVIFILE pfile, LPAVIFILEINFOW pfi, LONG lSize);
1201 STDAPI AVIFileInfoA (PAVIFILE pfile, LPAVIFILEINFOA pfi, LONG lSize);
1202 #ifdef UNICODE
1203 #define AVIFileInfo	AVIFileInfoW
1204 #else
1205 #define AVIFileInfo	AVIFileInfoA
1206 #endif
1207 #else
1208 STDAPI AVIFileInfo (PAVIFILE pfile, LPAVIFILEINFO pfi, LONG lSize);
1209 #define AVIFileInfoW AVIFileInfo
1210 #endif
1211 
1212 
1213 STDAPI AVIFileGetStream     (PAVIFILE pfile, PAVISTREAM FAR * ppavi, DWORD fccType, LONG lParam);
1214 
1215 
1216 #ifdef _WIN32
1217 STDAPI AVIFileCreateStreamW (PAVIFILE pfile, PAVISTREAM FAR *ppavi, AVISTREAMINFOW FAR * psi);
1218 STDAPI AVIFileCreateStreamA (PAVIFILE pfile, PAVISTREAM FAR *ppavi, AVISTREAMINFOA FAR * psi);
1219 #ifdef UNICODE
1220 #define AVIFileCreateStream	AVIFileCreateStreamW
1221 #else
1222 #define AVIFileCreateStream	AVIFileCreateStreamA
1223 #endif
1224 #else
1225 STDAPI AVIFileCreateStream(PAVIFILE pfile, PAVISTREAM FAR *ppavi, AVISTREAMINFO FAR * psi);
1226 #define AVIFileCreateStreamW AVIFileCreateStream
1227 #endif
1228 
1229 STDAPI AVIFileWriteData	(PAVIFILE pfile,
1230 					 DWORD ckid,
1231 					 LPVOID lpData,
1232 					 LONG cbData);
1233 STDAPI AVIFileReadData	(PAVIFILE pfile,
1234 					 DWORD ckid,
1235 					 LPVOID lpData,
1236 					 LONG FAR *lpcbData);
1237 STDAPI AVIFileEndRecord	(PAVIFILE pfile);
1238 
1239 STDAPI_(ULONG) AVIStreamAddRef       (PAVISTREAM pavi);
1240 STDAPI_(ULONG) AVIStreamRelease      (PAVISTREAM pavi);
1241 
1242 STDAPI AVIStreamInfoW (PAVISTREAM pavi, LPAVISTREAMINFOW psi, LONG lSize);
1243 STDAPI AVIStreamInfoA (PAVISTREAM pavi, LPAVISTREAMINFOA psi, LONG lSize);
1244 #ifdef UNICODE
1245 #define AVIStreamInfo	AVIStreamInfoW
1246 #else
1247 #define AVIStreamInfo	AVIStreamInfoA
1248 #endif
1249 
1250 STDAPI_(LONG) AVIStreamFindSample(PAVISTREAM pavi, LONG lPos, LONG lFlags);
1251 STDAPI AVIStreamReadFormat   (PAVISTREAM pavi, LONG lPos,LPVOID lpFormat,LONG FAR *lpcbFormat);
1252 STDAPI AVIStreamSetFormat    (PAVISTREAM pavi, LONG lPos,LPVOID lpFormat,LONG cbFormat);
1253 STDAPI AVIStreamReadData     (PAVISTREAM pavi, DWORD fcc, LPVOID lp, LONG FAR *lpcb);
1254 STDAPI AVIStreamWriteData    (PAVISTREAM pavi, DWORD fcc, LPVOID lp, LONG cb);
1255 
1256 STDAPI AVIStreamRead         (PAVISTREAM pavi,
1257 			      LONG lStart,
1258 			      LONG lSamples,
1259 			      LPVOID lpBuffer,
1260 			      LONG cbBuffer,
1261 			      LONG FAR * plBytes,
1262 			      LONG FAR * plSamples);
1263 #define AVISTREAMREAD_CONVENIENT	(-1L)
1264 
1265 STDAPI AVIStreamWrite        (PAVISTREAM pavi,
1266 			      LONG lStart, LONG lSamples,
1267 			      LPVOID lpBuffer, LONG cbBuffer, DWORD dwFlags,
1268 			      LONG FAR *plSampWritten,
1269 			      LONG FAR *plBytesWritten);
1270 
1271 STDAPI_(LONG) AVIStreamStart        (PAVISTREAM pavi);
1272 STDAPI_(LONG) AVIStreamLength       (PAVISTREAM pavi);
1273 STDAPI_(LONG) AVIStreamTimeToSample (PAVISTREAM pavi, LONG lTime);
1274 STDAPI_(LONG) AVIStreamSampleToTime (PAVISTREAM pavi, LONG lSample);
1275 
1276 
1277 STDAPI AVIStreamBeginStreaming(PAVISTREAM pavi, LONG lStart, LONG lEnd, LONG lRate);
1278 STDAPI AVIStreamEndStreaming(PAVISTREAM pavi);
1279 
1280 STDAPI_(PGETFRAME) AVIStreamGetFrameOpen(PAVISTREAM pavi,
1281 					 LPBITMAPINFOHEADER lpbiWanted);
1282 STDAPI_(LPVOID) AVIStreamGetFrame(PGETFRAME pg, LONG lPos);
1283 STDAPI AVIStreamGetFrameClose(PGETFRAME pg);
1284 
1285 STDAPI AVIStreamOpenFromFileA(PAVISTREAM FAR *ppavi, LPCSTR szFile,
1286 			     DWORD fccType, LONG lParam,
1287 			     UINT mode, CLSID FAR *pclsidHandler);
1288 STDAPI AVIStreamOpenFromFileW(PAVISTREAM FAR *ppavi, LPCWSTR szFile,
1289 			     DWORD fccType, LONG lParam,
1290 			     UINT mode, CLSID FAR *pclsidHandler);
1291 #ifdef UNICODE
1292 #define AVIStreamOpenFromFile	AVIStreamOpenFromFileW
1293 #else
1294 #define AVIStreamOpenFromFile	AVIStreamOpenFromFileA
1295 #endif
1296 
1297 STDAPI AVIStreamCreate(PAVISTREAM FAR *ppavi, LONG lParam1, LONG lParam2,
1298 		       CLSID FAR *pclsidHandler);
1299 
1300 
1301 
1302 #define FIND_DIR        0x0000000FL
1303 #define FIND_NEXT       0x00000001L
1304 #define FIND_PREV       0x00000004L
1305 #define FIND_FROM_START 0x00000008L
1306 
1307 #define FIND_TYPE       0x000000F0L
1308 #define FIND_KEY        0x00000010L
1309 #define FIND_ANY        0x00000020L
1310 #define FIND_FORMAT     0x00000040L
1311 
1312 #define FIND_RET        0x0000F000L
1313 #define FIND_POS        0x00000000L
1314 #define FIND_LENGTH     0x00001000L
1315 #define FIND_OFFSET     0x00002000L
1316 #define FIND_SIZE       0x00003000L
1317 #define FIND_INDEX      0x00004000L
1318 
1319 #define AVIStreamFindKeyFrame AVIStreamFindSample
1320 #define FindKeyFrame	FindSample
1321 
1322 #define AVIStreamClose AVIStreamRelease
1323 #define AVIFileClose   AVIFileRelease
1324 #define AVIStreamInit  AVIFileInit
1325 #define AVIStreamExit  AVIFileExit
1326 
1327 #define SEARCH_NEAREST  FIND_PREV
1328 #define SEARCH_BACKWARD FIND_PREV
1329 #define SEARCH_FORWARD  FIND_NEXT
1330 #define SEARCH_KEY      FIND_KEY
1331 #define SEARCH_ANY      FIND_ANY
1332 
1333 #define     AVIStreamSampleToSample(pavi1, pavi2, l)            AVIStreamTimeToSample(pavi1,AVIStreamSampleToTime(pavi2, l))
1334 
1335 #define     AVIStreamNextSample(pavi, l)            AVIStreamFindSample(pavi,l+1,FIND_NEXT|FIND_ANY)
1336 
1337 #define     AVIStreamPrevSample(pavi, l)            AVIStreamFindSample(pavi,l-1,FIND_PREV|FIND_ANY)
1338 
1339 #define     AVIStreamNearestSample(pavi, l)            AVIStreamFindSample(pavi,l,FIND_PREV|FIND_ANY)
1340 
1341 #define     AVIStreamNextKeyFrame(pavi,l)            AVIStreamFindSample(pavi,l+1,FIND_NEXT|FIND_KEY)
1342 
1343 #define     AVIStreamPrevKeyFrame(pavi, l)            AVIStreamFindSample(pavi,l-1,FIND_PREV|FIND_KEY)
1344 
1345 #define     AVIStreamNearestKeyFrame(pavi, l)            AVIStreamFindSample(pavi,l,FIND_PREV|FIND_KEY)
1346 
1347 #define     AVIStreamIsKeyFrame(pavi, l)            (AVIStreamNearestKeyFrame(pavi,l) == l)
1348 
1349 #define     AVIStreamPrevSampleTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamPrevSample(pavi,AVIStreamTimeToSample(pavi,t)))
1350 
1351 #define     AVIStreamNextSampleTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamNextSample(pavi,AVIStreamTimeToSample(pavi,t)))
1352 
1353 #define     AVIStreamNearestSampleTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamNearestSample(pavi,AVIStreamTimeToSample(pavi,t)))
1354 
1355 #define     AVIStreamNextKeyFrameTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamNextKeyFrame(pavi,AVIStreamTimeToSample(pavi, t)))
1356 
1357 #define     AVIStreamPrevKeyFrameTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamPrevKeyFrame(pavi,AVIStreamTimeToSample(pavi, t)))
1358 
1359 #define     AVIStreamNearestKeyFrameTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamNearestKeyFrame(pavi,AVIStreamTimeToSample(pavi, t)))
1360 
1361 #define     AVIStreamStartTime(pavi)            AVIStreamSampleToTime(pavi, AVIStreamStart(pavi))
1362 
1363 #define     AVIStreamLengthTime(pavi)            AVIStreamSampleToTime(pavi, AVIStreamLength(pavi))
1364 
1365 #define     AVIStreamEnd(pavi)            (AVIStreamStart(pavi) + AVIStreamLength(pavi))
1366 
1367 #define     AVIStreamEndTime(pavi)            AVIStreamSampleToTime(pavi, AVIStreamEnd(pavi))
1368 
1369 #define     AVIStreamSampleSize(pavi, lPos, plSize)	    AVIStreamRead(pavi,lPos,1,NULL,0,plSize,NULL)
1370 
1371 #define     AVIStreamFormatSize(pavi, lPos, plSize)            AVIStreamReadFormat(pavi,lPos,NULL,plSize)
1372 
1373 #define     AVIStreamDataSize(pavi, fcc, plSize)            AVIStreamReadData(pavi,fcc,NULL,plSize)
1374 
1375 #ifndef comptypeDIB
1376 #define comptypeDIB         mmioFOURCC('D', 'I', 'B', ' ')
1377 #endif
1378 
1379 STDAPI AVIMakeCompressedStream(
1380 		PAVISTREAM FAR *	    ppsCompressed,
1381 		PAVISTREAM		    ppsSource,
1382 		AVICOMPRESSOPTIONS FAR *    lpOptions,
1383 		CLSID FAR *pclsidHandler);
1384 
1385 EXTERN_C HRESULT CDECL AVISaveA (LPCSTR               szFile,
1386 		CLSID FAR *pclsidHandler,
1387 		AVISAVECALLBACK     lpfnCallback,
1388 		int                 nStreams,
1389 		PAVISTREAM	    pfile,
1390 		LPAVICOMPRESSOPTIONS lpOptions,
1391 		...);
1392 
1393 STDAPI AVISaveVA(LPCSTR               szFile,
1394 		CLSID FAR *pclsidHandler,
1395 		AVISAVECALLBACK     lpfnCallback,
1396 		int                 nStreams,
1397 		PAVISTREAM FAR *    ppavi,
1398 		LPAVICOMPRESSOPTIONS FAR *plpOptions);
1399 EXTERN_C HRESULT CDECL AVISaveW (LPCWSTR               szFile,
1400 		CLSID FAR *pclsidHandler,
1401 		AVISAVECALLBACK     lpfnCallback,
1402 		int                 nStreams,
1403 		PAVISTREAM	    pfile,
1404 		LPAVICOMPRESSOPTIONS lpOptions,
1405 		...);
1406 
1407 STDAPI AVISaveVW(LPCWSTR               szFile,
1408 		CLSID FAR *pclsidHandler,
1409 		AVISAVECALLBACK     lpfnCallback,
1410 		int                 nStreams,
1411 		PAVISTREAM FAR *    ppavi,
1412 		LPAVICOMPRESSOPTIONS FAR *plpOptions);
1413 #ifdef UNICODE
1414 #define AVISave		AVISaveW
1415 #define AVISaveV	AVISaveVW
1416 #else
1417 #define AVISave		AVISaveA
1418 #define AVISaveV	AVISaveVA
1419 #endif
1420 
1421 
1422 
1423 STDAPI_(INT_PTR) AVISaveOptions(HWND hwnd,
1424 			     UINT	uiFlags,
1425 			     int	nStreams,
1426 			     PAVISTREAM FAR *ppavi,
1427 			     LPAVICOMPRESSOPTIONS FAR *plpOptions);
1428 
1429 STDAPI AVISaveOptionsFree(int nStreams,
1430 			     LPAVICOMPRESSOPTIONS FAR *plpOptions);
1431 
1432 STDAPI AVIBuildFilterW(LPWSTR lpszFilter, LONG cbFilter, BOOL fSaving);
1433 STDAPI AVIBuildFilterA(LPSTR lpszFilter, LONG cbFilter, BOOL fSaving);
1434 #ifdef UNICODE
1435 #define AVIBuildFilter	AVIBuildFilterW
1436 #else
1437 #define AVIBuildFilter	AVIBuildFilterA
1438 #endif
1439 STDAPI AVIMakeFileFromStreams(PAVIFILE FAR *	ppfile,
1440 			       int		nStreams,
1441 			       PAVISTREAM FAR *	papStreams);
1442 
1443 STDAPI AVIMakeStreamFromClipboard(UINT cfFormat, HANDLE hGlobal, PAVISTREAM FAR *ppstream);
1444 
1445 STDAPI AVIPutFileOnClipboard(PAVIFILE pf);
1446 
1447 STDAPI AVIGetFromClipboard(PAVIFILE FAR * lppf);
1448 
1449 STDAPI AVIClearClipboard(void);
1450 
1451 STDAPI CreateEditableStream(
1452 		PAVISTREAM FAR *	    ppsEditable,
1453 		PAVISTREAM		    psSource);
1454 
1455 STDAPI EditStreamCut(PAVISTREAM pavi, LONG FAR *plStart, LONG FAR *plLength, PAVISTREAM FAR * ppResult);
1456 
1457 STDAPI EditStreamCopy(PAVISTREAM pavi, LONG FAR *plStart, LONG FAR *plLength, PAVISTREAM FAR * ppResult);
1458 
1459 STDAPI EditStreamPaste(PAVISTREAM pavi, LONG FAR *plPos, LONG FAR *plLength, PAVISTREAM pstream, LONG lStart, LONG lEnd);
1460 
1461 STDAPI EditStreamClone(PAVISTREAM pavi, PAVISTREAM FAR *ppResult);
1462 
1463 
1464 STDAPI EditStreamSetNameA(PAVISTREAM pavi, LPCSTR lpszName);
1465 STDAPI EditStreamSetNameW(PAVISTREAM pavi, LPCWSTR lpszName);
1466 STDAPI EditStreamSetInfoW(PAVISTREAM pavi, LPAVISTREAMINFOW lpInfo, LONG cbInfo);
1467 STDAPI EditStreamSetInfoA(PAVISTREAM pavi, LPAVISTREAMINFOA lpInfo, LONG cbInfo);
1468 #ifdef UNICODE
1469 #define EditStreamSetInfo	EditStreamSetInfoW
1470 #define EditStreamSetName	EditStreamSetNameW
1471 #else
1472 #define EditStreamSetInfo	EditStreamSetInfoA
1473 #define EditStreamSetName	EditStreamSetNameA
1474 #endif
1475 +/
1476 const AVIERR_OK = 0L;
1477 
1478 SCODE MAKE_AVIERR(DWORD error) {
1479 	return MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x4000 + error);
1480 }
1481 
1482 const AVIERR_UNSUPPORTED	= MAKE_AVIERR(101);
1483 const AVIERR_BADFORMAT		= MAKE_AVIERR(102);
1484 const AVIERR_MEMORY			= MAKE_AVIERR(103);
1485 const AVIERR_INTERNAL		= MAKE_AVIERR(104);
1486 const AVIERR_BADFLAGS		= MAKE_AVIERR(105);
1487 const AVIERR_BADPARAM		= MAKE_AVIERR(106);
1488 const AVIERR_BADSIZE		= MAKE_AVIERR(107);
1489 const AVIERR_BADHANDLE		= MAKE_AVIERR(108);
1490 const AVIERR_FILEREAD		= MAKE_AVIERR(109);
1491 const AVIERR_FILEWRITE		= MAKE_AVIERR(110);
1492 const AVIERR_FILEOPEN		= MAKE_AVIERR(111);
1493 const AVIERR_COMPRESSOR		= MAKE_AVIERR(112);
1494 const AVIERR_NOCOMPRESSOR	= MAKE_AVIERR(113);
1495 const AVIERR_READONLY		= MAKE_AVIERR(114);
1496 const AVIERR_NODATA			= MAKE_AVIERR(115);
1497 const AVIERR_BUFFERTOOSMALL	= MAKE_AVIERR(116);
1498 const AVIERR_CANTCOMPRESS	= MAKE_AVIERR(117);
1499 const AVIERR_USERABORT		= MAKE_AVIERR(198);
1500 const AVIERR_ERROR			= MAKE_AVIERR(199);
1501 
1502 const TCHAR[] MCIWND_WINDOW_CLASS = "MCIWndClass";
1503 
1504 extern (Windows) {
1505 	HWND MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance, DWORD dwStyle, LPCSTR szFile);
1506 	HWND MCIWndCreateW(HWND hwndParent, HINSTANCE hInstance, DWORD dwStyle, LPCWSTR szFile);
1507 }
1508 
1509 version(Unicode) {
1510 	alias MCIWndCreateW	MCIWndCreate;
1511 } else { // Unicode
1512 	alias MCIWndCreateA	MCIWndCreate;
1513 }
1514 
1515 extern(Windows) {
1516 	BOOL MCIWndRegisterClass();
1517 }
1518 
1519 enum {
1520 	MCIWNDOPENF_NEW				= 0x0001,
1521 	MCIWNDF_NOAUTOSIZEWINDOW	= 0x0001,
1522 	MCIWNDF_NOPLAYBAR			= 0x0002,
1523 	MCIWNDF_NOAUTOSIZEMOVIE		= 0x0004,
1524 	MCIWNDF_NOMENU				= 0x0008,
1525 	MCIWNDF_SHOWNAME			= 0x0010,
1526 	MCIWNDF_SHOWPOS				= 0x0020,
1527 	MCIWNDF_SHOWMODE			= 0x0040,
1528 	MCIWNDF_SHOWALL				= 0x0070,
1529 	MCIWNDF_NOTIFYMODE			= 0x0100,
1530 	MCIWNDF_NOTIFYPOS			= 0x0200,
1531 	MCIWNDF_NOTIFYSIZE			= 0x0400,
1532 	MCIWNDF_NOTIFYERROR			= 0x1000,
1533 	MCIWNDF_NOTIFYALL			= 0x1F00,
1534 	MCIWNDF_NOTIFYANSI			= 0x0080,
1535 	MCIWNDF_NOTIFYMEDIAA		= 0x0880,
1536 	MCIWNDF_NOTIFYMEDIAW		= 0x0800,
1537 }
1538 
1539 version(Unicode) {
1540 	alias MCIWNDF_NOTIFYMEDIAW	MCIWNDF_NOTIFYMEDIA;
1541 } else { // Unicode
1542 	alias MCIWNDF_NOTIFYMEDIAA	MCIWNDF_NOTIFYMEDIA;
1543 }
1544 
1545 enum {
1546 	MCIWNDF_RECORD		= 0x2000,
1547 	MCIWNDF_NOERRORDLG	= 0x4000,
1548 	MCIWNDF_NOOPEN		= 0x8000,
1549 }
1550 
1551 // can macros
1552 
1553 BOOL MCIWndCanPlay(HWND hwnd)
1554 	{ return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_PLAY, 0, 0); }
1555 BOOL MCIWndCanRecord(HWND hwnd)
1556 	{ return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_RECORD, 0, 0); }
1557 BOOL MCIWndCanSave(HWND hwnd)
1558 	{ return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_SAVE, 0, 0); }
1559 BOOL MCIWndCanWindow(HWND hwnd)
1560 	{ return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_WINDOW, 0, 0); }
1561 BOOL MCIWndCanEject(HWND hwnd)
1562 	{ return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_EJECT, 0, 0); }
1563 BOOL MCIWndCanConfig(HWND hwnd)
1564 	{ return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_CONFIG, 0, 0); }
1565 BOOL MCIWndPaletteKick(HWND hwnd)
1566 	{ return cast(BOOL)SendMessage(hwnd, MCIWNDM_PALETTEKICK, 0, 0); }
1567 LONG MCIWndSave(HWND hwnd, LPVOID szFile)
1568 	{ return cast(LONG)SendMessage(hwnd, MCI_SAVE, 0, cast(LPARAM)szFile); }
1569 LONG MCIWndSaveDialog(HWND hwnd)
1570 	{ return MCIWndSave(hwnd, cast(LPVOID)-1); }
1571 LONG MCIWndNew(HWND hwnd, LPVOID lp)
1572 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_NEW, 0, cast(LPARAM)lp); }
1573 LONG MCIWndRecord(HWND hwnd)
1574 	{ return cast(LONG)SendMessage(hwnd, MCI_RECORD, 0, 0); }
1575 LONG MCIWndOpen(HWND hwnd, LPVOID sz, UINT f)
1576 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_OPEN, cast(WPARAM)f, cast(LPARAM)sz); }
1577 LONG MCIWndOpenDialog(HWND hwnd)
1578 	{ return MCIWndOpen(hwnd, cast(LPVOID)-1, 0); }
1579 LONG MCIWndClose(HWND hwnd)
1580 	{ return cast(LONG)SendMessage(hwnd, MCI_CLOSE, 0, 0); }
1581 LONG MCIWndPlay(HWND hwnd)
1582 	{ return cast(LONG)SendMessage(hwnd, MCI_PLAY, 0, 0); }
1583 LONG MCIWndStop(HWND hwnd)
1584 	{ return cast(LONG)SendMessage(hwnd, MCI_STOP, 0, 0); }
1585 LONG MCIWndPause(HWND hwnd)
1586 	{ return cast(LONG)SendMessage(hwnd, MCI_PAUSE, 0, 0); }
1587 LONG MCIWndResume(HWND hwnd)
1588 	{ return cast(LONG)SendMessage(hwnd, MCI_RESUME, 0, 0); }
1589 LONG MCIWndSeek(HWND hwnd, LONG lPos)
1590 	{ return cast(LONG)SendMessage(hwnd, MCI_SEEK, 0, cast(LPARAM)lPos); }
1591 LONG MCIWndHome(HWND hwnd)
1592 	{ return MCIWndSeek(hwnd, MCIWND_START); }
1593 LONG MCIWndEnd(HWND hwnd)
1594 	{ return MCIWndSeek(hwnd, MCIWND_END); }
1595 LONG MCIWndEject(HWND hwnd)
1596 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_EJECT, 0, 0); }
1597 LONG MCIWndGetSource(HWND hwnd, LPRECT prc)
1598 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GET_SOURCE, 0, cast(LPARAM)prc); }
1599 LONG MCIWndPutSource(HWND hwnd, LPRECT prc)
1600 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_PUT_SOURCE, 0, cast(LPARAM)prc); }
1601 LONG MCIWndGetDest(HWND hwnd, LPRECT prc)
1602 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GET_DEST, 0, cast(LPARAM)prc); }
1603 LONG MCIWndPutDest(HWND hwnd, LPRECT prc)
1604 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_PUT_DEST, 0, cast(LPARAM)prc); }
1605 LONG MCIWndPlayReverse(HWND hwnd)
1606 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_PLAYREVERSE, 0, 0); }
1607 LONG MCIWndPlayFrom(HWND hwnd, LONG lPos)
1608 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_PLAYFROM, 0, cast(LPARAM)lPos); }
1609 LONG MCIWndPlayTo(HWND hwnd, LONG lPos)
1610 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_PLAYTO, 0, cast(LPARAM)lPos); }
1611 LONG MCIWndPlayFromTo(HWND hwnd, LONG lStart, LONG lEnd)
1612 	{ MCIWndSeek(hwnd, lStart); return MCIWndPlayTo(hwnd, lEnd); }
1613 UINT MCIWndGetDeviceID(HWND hwnd)
1614 	{ return cast(UINT)SendMessage(hwnd, MCIWNDM_GETDEVICEID, 0, 0); }
1615 UINT MCIWndGetAlias(HWND hwnd)
1616 	{ return cast(UINT)SendMessage(hwnd, MCIWNDM_GETALIAS, 0, 0); }
1617 LONG MCIWndGetMode(HWND hwnd, LPTSTR lp, UINT len)
1618 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GETMODE, cast(WPARAM)len, cast(LPARAM)lp); }
1619 LONG MCIWndGetPosition(HWND hwnd)
1620 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GETPOSITION, 0, 0); }
1621 LONG MCIWndGetPositionString(HWND hwnd, LPTSTR lp, UINT len)
1622 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GETPOSITION, cast(WPARAM)len, cast(LPARAM)lp); }
1623 LONG MCIWndGetStart(HWND hwnd)
1624 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GETSTART, 0, 0); }
1625 LONG MCIWndGetLength(HWND hwnd)
1626 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GETLENGTH, 0, 0); }
1627 LONG MCIWndGetEnd(HWND hwnd)
1628 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GETEND, 0, 0); }
1629 LONG MCIWndStep(HWND hwnd, LONG n)
1630 	{ return cast(LONG)SendMessage(hwnd, MCI_STEP, 0, cast(LPARAM)n); }
1631 void MCIWndDestroy(HWND hwnd)
1632 	{ SendMessage(hwnd, WM_CLOSE, 0, 0); }
1633 void MCIWndSetZoom(HWND hwnd, UINT iZoom)
1634 	{ SendMessage(hwnd, MCIWNDM_SETZOOM, 0, cast(LPARAM)iZoom); }
1635 UINT MCIWndGetZoom(HWND hwnd)
1636 	{ return cast(UINT)SendMessage(hwnd, MCIWNDM_GETZOOM, 0, 0); }
1637 LONG MCIWndSetVolume(HWND hwnd, UINT iVol)
1638 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_SETVOLUME, 0, cast(LPARAM)iVol); }
1639 LONG MCIWndGetVolume(HWND hwnd)
1640 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GETVOLUME, 0, 0); }
1641 LONG MCIWndSetSpeed(HWND hwnd, UINT iSpeed)
1642 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_SETSPEED, 0, cast(LPARAM)iSpeed); }
1643 LONG MCIWndGetSpeed(HWND hwnd)
1644 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GETSPEED, 0, 0); }
1645 LONG MCIWndSetTimeFormat(HWND hwnd, LPTSTR lp)
1646 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_SETTIMEFORMAT, 0, cast(LPARAM)lp); }
1647 LONG MCIWndUseFrames(HWND hwnd)
1648 	{ return MCIWndSetTimeFormat(hwnd, (cast(TCHAR[])"frames").ptr); }
1649 LONG MCIWndUseTime(HWND hwnd)
1650 	{ return MCIWndSetTimeFormat(hwnd, (cast(TCHAR[])"ms").ptr); }
1651 LONG MCIWndGetTimeFormat(HWND hwnd, LPTSTR lp, UINT len)
1652 	{ return cast(LONG)SendMessage(hwnd, MCIWNDM_GETTIMEFORMAT, cast(WPARAM)len, cast(LPARAM)lp); }
1653 void MCIWndValidateMedia(HWND hwnd)
1654 	{ SendMessage(hwnd, MCIWNDM_VALIDATEMEDIA, 0, 0); }
1655 void MCIWndSetRepeat(HWND hwnd, BOOL f)
1656 	{ SendMessage(hwnd, MCIWNDM_SETREPEAT, 0, cast(LPARAM)f); }
1657 BOOL MCIWndGetRepeat(HWND hwnd)
1658 	{ return cast(BOOL)SendMessage(hwnd, MCIWNDM_GETREPEAT, 0, 0); }
1659 void MCIWndSetActiveTimer(HWND hwnd, UINT active)
1660 	{ SendMessage(hwnd, MCIWNDM_SETACTIVETIMER, cast(WPARAM)active, 0); }
1661 void MCIWndSetInactiveTimer(HWND hwnd, UINT inactive)
1662 	{ SendMessage(hwnd, MCIWNDM_SETINACTIVETIMER, cast(WPARAM)inactive, 0); }
1663 void MCIWndSetTimers(HWND hwnd, UINT active, UINT inactive)
1664 	{ SendMessage(hwnd, MCIWNDM_SETTIMERS, cast(WPARAM)active, cast(LPARAM)inactive); }
1665 UINT MCIWndGetActiveTimer(HWND hwnd)
1666 	{ return cast(UINT)SendMessage(hwnd, MCIWNDM_GETACTIVETIMER, 0, 0); }
1667 UINT MCIWndGetInactiveTimer(HWND hwnd)
1668 	{ return cast(UINT)SendMessage(hwnd, MCIWNDM_GETINACTIVETIMER, 0, 0); }
1669 LONG MCIWndRealize(HWND hwnd, BOOL fBkgnd)
1670 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_REALIZE, cast(WPARAM)fBkgnd, 0); }
1671 LONG MCIWndSendString(HWND hwnd, LPTSTR sz)
1672 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_SENDSTRING, 0, cast(LPARAM)sz); }
1673 LONG MCIWndReturnString(HWND hwnd, LPVOID lp, UINT len)
1674 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_RETURNSTRING, cast(WPARAM)len, cast(LPARAM)lp); }
1675 LONG MCIWndGetError(HWND hwnd, LPVOID lp, UINT len)
1676 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_GETERROR, cast(WPARAM)len, cast(LPARAM)lp); }
1677 HPALETTE MCIWndGetPalette(HWND hwnd)
1678 	{ return cast(HPALETTE)SendMessage(hwnd, MCIWNDM_GETPALETTE, 0, 0); }
1679 LONG MCIWndSetPalette(HWND hwnd, HPALETTE hpal)
1680 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_SETPALETTE, cast(WPARAM)hpal, 0); }
1681 LONG MCIWndGetFileName(HWND hwnd, LPVOID lp, UINT len)
1682 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_GETFILENAME, cast(WPARAM)len, cast(LPARAM)lp); }
1683 LONG MCIWndGetDevice(HWND hwnd, LPVOID lp, UINT len)
1684 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_GETDEVICE, cast(WPARAM)len, cast(LPARAM)lp); }
1685 UINT MCIWndGetStyles(HWND hwnd)
1686 	{ return cast(UINT) SendMessage(hwnd, MCIWNDM_GETSTYLES, 0, 0); }
1687 LONG MCIWndChangeStyles(HWND hwnd, UINT mask, LONG value)
1688 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_CHANGESTYLES, cast(WPARAM)mask, cast(LPARAM)value); }
1689 LONG MCIWndOpenInterface(HWND hwnd, LPUNKNOWN pUnk)
1690 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_OPENINTERFACE, 0, cast(LPARAM)cast(void*)pUnk); }
1691 LONG MCIWndSetOwner(HWND hwnd, HWND hwndP)
1692 	{ return cast(LONG) SendMessage(hwnd, MCIWNDM_SETOWNER, cast(WPARAM)hwndP, 0); }
1693 
1694 enum {
1695 	MCIWNDM_GETDEVICEID			= WM_USER + 100,
1696 	MCIWNDM_SENDSTRINGA			= WM_USER + 101,
1697 	MCIWNDM_GETPOSITIONA		= WM_USER + 102,
1698 	MCIWNDM_GETSTART			= WM_USER + 103,
1699 	MCIWNDM_GETLENGTH			= WM_USER + 104,
1700 	MCIWNDM_GETEND				= WM_USER + 105,
1701 	MCIWNDM_GETMODEA			= WM_USER + 106,
1702 	MCIWNDM_EJECT				= WM_USER + 107,
1703 	MCIWNDM_SETZOOM				= WM_USER + 108,
1704 	MCIWNDM_GETZOOM				= WM_USER + 109,
1705 	MCIWNDM_SETVOLUME			= WM_USER + 110,
1706 	MCIWNDM_GETVOLUME			= WM_USER + 111,
1707 	MCIWNDM_SETSPEED			= WM_USER + 112,
1708 	MCIWNDM_GETSPEED			= WM_USER + 113,
1709 	MCIWNDM_SETREPEAT			= WM_USER + 114,
1710 	MCIWNDM_GETREPEAT			= WM_USER + 115,
1711 	MCIWNDM_REALIZE				= WM_USER + 118,
1712 	MCIWNDM_SETTIMEFORMATA		= WM_USER + 119,
1713 	MCIWNDM_GETTIMEFORMATA		= WM_USER + 120,
1714 	MCIWNDM_VALIDATEMEDIA		= WM_USER + 121,
1715 	MCIWNDM_PLAYFROM			= WM_USER + 122,
1716 	MCIWNDM_PLAYTO				= WM_USER + 123,
1717 	MCIWNDM_GETFILENAMEA		= WM_USER + 124,
1718 	MCIWNDM_GETDEVICEA			= WM_USER + 125,
1719 	MCIWNDM_GETPALETTE			= WM_USER + 126,
1720 	MCIWNDM_SETPALETTE			= WM_USER + 127,
1721 	MCIWNDM_GETERRORA			= WM_USER + 128,
1722 	MCIWNDM_SETTIMERS			= WM_USER + 129,
1723 	MCIWNDM_SETACTIVETIMER		= WM_USER + 130,
1724 	MCIWNDM_SETINACTIVETIMER	= WM_USER + 131,
1725 	MCIWNDM_GETACTIVETIMER		= WM_USER + 132,
1726 	MCIWNDM_GETINACTIVETIMER	= WM_USER + 133,
1727 	MCIWNDM_NEWA				= WM_USER + 134,
1728 	MCIWNDM_CHANGESTYLES		= WM_USER + 135,
1729 	MCIWNDM_GETSTYLES			= WM_USER + 136,
1730 	MCIWNDM_GETALIAS			= WM_USER + 137,
1731 	MCIWNDM_RETURNSTRINGA		= WM_USER + 138,
1732 	MCIWNDM_PLAYREVERSE			= WM_USER + 139,
1733 	MCIWNDM_GET_SOURCE			= WM_USER + 140,
1734 	MCIWNDM_PUT_SOURCE			= WM_USER + 141,
1735 	MCIWNDM_GET_DEST			= WM_USER + 142,
1736 	MCIWNDM_PUT_DEST			= WM_USER + 143,
1737 	MCIWNDM_CAN_PLAY			= WM_USER + 144,
1738 	MCIWNDM_CAN_WINDOW			= WM_USER + 145,
1739 	MCIWNDM_CAN_RECORD			= WM_USER + 146,
1740 	MCIWNDM_CAN_SAVE			= WM_USER + 147,
1741 	MCIWNDM_CAN_EJECT			= WM_USER + 148,
1742 	MCIWNDM_CAN_CONFIG			= WM_USER + 149,
1743 	MCIWNDM_PALETTEKICK			= WM_USER + 150,
1744 	MCIWNDM_OPENINTERFACE		= WM_USER + 151,
1745 	MCIWNDM_SETOWNER			= WM_USER + 152,
1746 	MCIWNDM_OPENA				= WM_USER + 153,
1747 	MCIWNDM_SENDSTRINGW			= WM_USER + 201,
1748 	MCIWNDM_GETPOSITIONW		= WM_USER + 202,
1749 	MCIWNDM_GETMODEW			= WM_USER + 206,
1750 	MCIWNDM_SETTIMEFORMATW		= WM_USER + 219,
1751 	MCIWNDM_GETTIMEFORMATW		= WM_USER + 220,
1752 	MCIWNDM_GETFILENAMEW		= WM_USER + 224,
1753 	MCIWNDM_GETDEVICEW			= WM_USER + 225,
1754 	MCIWNDM_GETERRORW			= WM_USER + 228,
1755 	MCIWNDM_NEWW				= WM_USER + 234,
1756 	MCIWNDM_RETURNSTRINGW		= WM_USER + 238,
1757 	MCIWNDM_OPENW				= WM_USER + 252,
1758 }
1759 
1760 version(Unicode) {
1761 	alias MCIWNDM_SENDSTRINGW		MCIWNDM_SENDSTRING;
1762 	alias MCIWNDM_GETPOSITIONW		MCIWNDM_GETPOSITION;
1763 	alias MCIWNDM_GETMODEW			MCIWNDM_GETMODE;
1764 	alias MCIWNDM_SETTIMEFORMATW	MCIWNDM_SETTIMEFORMAT;
1765 	alias MCIWNDM_GETTIMEFORMATW	MCIWNDM_GETTIMEFORMAT;
1766 	alias MCIWNDM_GETFILENAMEW		MCIWNDM_GETFILENAME;
1767 	alias MCIWNDM_GETDEVICEW		MCIWNDM_GETDEVICE;
1768 	alias MCIWNDM_GETERRORW			MCIWNDM_GETERROR;
1769 	alias MCIWNDM_NEWW				MCIWNDM_NEW;
1770 	alias MCIWNDM_RETURNSTRINGW		MCIWNDM_RETURNSTRING;
1771 	alias MCIWNDM_OPENW				MCIWNDM_OPEN;
1772 } else { // Unicode
1773 	alias MCIWNDM_SENDSTRINGA		MCIWNDM_SENDSTRING;
1774 	alias MCIWNDM_GETPOSITIONA		MCIWNDM_GETPOSITION;
1775 	alias MCIWNDM_GETMODEA			MCIWNDM_GETMODE;
1776 	alias MCIWNDM_SETTIMEFORMATA	MCIWNDM_SETTIMEFORMAT;
1777 	alias MCIWNDM_GETTIMEFORMATA	MCIWNDM_GETTIMEFORMAT;
1778 	alias MCIWNDM_GETFILENAMEA		MCIWNDM_GETFILENAME;
1779 	alias MCIWNDM_GETDEVICEA		MCIWNDM_GETDEVICE;
1780 	alias MCIWNDM_GETERRORA			MCIWNDM_GETERROR;
1781 	alias MCIWNDM_NEWA				MCIWNDM_NEW;
1782 	alias MCIWNDM_RETURNSTRINGA		MCIWNDM_RETURNSTRING;
1783 	alias MCIWNDM_OPENA				MCIWNDM_OPEN;
1784 }
1785 
1786 enum {
1787 	MCIWNDM_NOTIFYMODE	= WM_USER + 200,
1788 	MCIWNDM_NOTIFYPOS	= WM_USER + 201,
1789 	MCIWNDM_NOTIFYSIZE	= WM_USER + 202,
1790 	MCIWNDM_NOTIFYMEDIA	= WM_USER + 203,
1791 	MCIWNDM_NOTIFYERROR	= WM_USER + 205,
1792 }
1793 
1794 const MCIWND_START	= -1;
1795 const MCIWND_END	= -2;
1796 
1797 enum {
1798 	MCI_CLOSE	= 0x0804,
1799 	MCI_PLAY	= 0x0806,
1800 	MCI_SEEK	= 0x0807,
1801 	MCI_STOP	= 0x0808,
1802 	MCI_PAUSE	= 0x0809,
1803 	MCI_STEP	= 0x080E,
1804 	MCI_RECORD	= 0x080F,
1805 	MCI_SAVE	= 0x0813,
1806 	MCI_CUT		= 0x0851,
1807 	MCI_COPY	= 0x0852,
1808 	MCI_PASTE	= 0x0853,
1809 	MCI_RESUME	= 0x0855,
1810 	MCI_DELETE	= 0x0856,
1811 }
1812 
1813 enum {
1814 	MCI_MODE_NOT_READY	= 524,
1815 	MCI_MODE_STOP,
1816 	MCI_MODE_PLAY,
1817 	MCI_MODE_RECORD,
1818 	MCI_MODE_SEEK,
1819 	MCI_MODE_PAUSE,
1820 	MCI_MODE_OPEN,
1821 }
1822 
1823 alias TypeDef!(HANDLE) HVIDEO;
1824 alias HVIDEO* LPHVIDEO;
1825 
1826 // Error Return Values
1827 
1828 enum {
1829 	DV_ERR_OK				= 0,
1830 	DV_ERR_BASE				= 1,
1831 	DV_ERR_NONSPECIFIC		= DV_ERR_BASE,
1832 	DV_ERR_BADFORMAT		= DV_ERR_BASE + 1,
1833 	DV_ERR_STILLPLAYING		= DV_ERR_BASE + 2,
1834 	DV_ERR_UNPREPARED		= DV_ERR_BASE + 3,
1835 	DV_ERR_SYNC				= DV_ERR_BASE + 4,
1836 	DV_ERR_TOOMANYCHANNELS	= DV_ERR_BASE + 5,
1837 	DV_ERR_NOTDETECTED		= DV_ERR_BASE + 6,
1838 	DV_ERR_BADINSTALL		= DV_ERR_BASE + 7,
1839 	DV_ERR_CREATEPALETTE	= DV_ERR_BASE + 8,
1840 	DV_ERR_SIZEFIELD		= DV_ERR_BASE + 9,
1841 	DV_ERR_PARAM1			= DV_ERR_BASE + 10,
1842 	DV_ERR_PARAM2			= DV_ERR_BASE + 11,
1843 	DV_ERR_CONFIG1			= DV_ERR_BASE + 12,
1844 	DV_ERR_CONFIG2			= DV_ERR_BASE + 13,
1845 	DV_ERR_FLAGS			= DV_ERR_BASE + 14,
1846 	DV_ERR_13				= DV_ERR_BASE + 15,
1847 	DV_ERR_NOTSUPPORTED		= DV_ERR_BASE + 16,
1848 	DV_ERR_NOMEM			= DV_ERR_BASE + 17,
1849 	DV_ERR_ALLOCATED		= DV_ERR_BASE + 18,
1850 	DV_ERR_BADDEVICEID		= DV_ERR_BASE + 19,
1851 	DV_ERR_INVALHANDLE		= DV_ERR_BASE + 20,
1852 	DV_ERR_BADERRNUM		= DV_ERR_BASE + 21,
1853 	DV_ERR_NO_BUFFERS		= DV_ERR_BASE + 22,
1854 	DV_ERR_MEM_CONFLICT		= DV_ERR_BASE + 23,
1855 	DV_ERR_IO_CONFLICT		= DV_ERR_BASE + 24,
1856 	DV_ERR_DMA_CONFLICT		= DV_ERR_BASE + 25,
1857 	DV_ERR_INT_CONFLICT		= DV_ERR_BASE + 26,
1858 	DV_ERR_PROTECT_ONLY		= DV_ERR_BASE + 27,
1859 	DV_ERR_LASTERROR		= DV_ERR_BASE + 27,
1860 	DV_ERR_USER_MSG			= DV_ERR_BASE + 1000,
1861 }
1862 
1863 // Callback Messages
1864 
1865 enum {
1866 	MM_DRVM_OPEN	= 0x3D0,
1867 	MM_DRVM_CLOSE,
1868 	MM_DRVM_DATA,
1869 	MM_DRVM_ERROR,
1870 }
1871 
1872 enum {
1873 	DV_VM_OPEN	= MM_DRVM_OPEN,
1874 	DV_VM_CLOSE	= MM_DRVM_CLOSE,
1875 	DV_VM_DATA	= MM_DRVM_DATA,
1876 	DV_VM_ERROR	= MM_DRVM_ERROR,
1877 }
1878 
1879 /**
1880  * Structures
1881  */
1882 
1883 struct VIDEOHDR {
1884 	LPBYTE		lpData;
1885 	DWORD		dwBufferLength;
1886 	DWORD		dwBytesUsed;
1887 	DWORD		dwTimeCaptured;
1888 	DWORD_PTR	dwUser;
1889 	DWORD		dwFlags;
1890 	DWORD_PTR[4]	dwReserved;
1891 }
1892 alias VIDEOHDR* PVIDEOHDR, LPVIDEOHDR;
1893 
1894 enum {
1895 	VHDR_DONE		= 0x00000001,
1896 	VHDR_PREPARED	= 0x00000002,
1897 	VHDR_INQUEUE	= 0x00000004,
1898 	VHDR_KEYFRAME	= 0x00000008,
1899 	VHDR_VALID		= 0x0000000F,
1900 }
1901 
1902 struct CHANNEL_CAPS {
1903 	DWORD	dwFlags;
1904 	DWORD	dwSrcRectXMod;
1905 	DWORD	dwSrcRectYMod;
1906 	DWORD	dwSrcRectWidthMod;
1907 	DWORD	dwSrcRectHeightMod;
1908 	DWORD	dwDstRectXMod;
1909 	DWORD	dwDstRectYMod;
1910 	DWORD	dwDstRectWidthMod;
1911 	DWORD	dwDstRectHeightMod;
1912 }
1913 alias CHANNEL_CAPS* PCHANNEL_CAPS, LPCHANNEL_CAPS;
1914 
1915 enum {
1916 	VCAPS_OVERLAY		= 0x00000001,
1917 	VCAPS_SRC_CAN_CLIP	= 0x00000002,
1918 	VCAPS_DST_CAN_CLIP	= 0x00000004,
1919 	VCAPS_CAN_SCALE		= 0x00000008,
1920 }
1921 
1922 /**
1923  * API Flags
1924  */
1925 
1926 enum {
1927 	VIDEO_EXTERNALIN			= 0x0001,
1928 	VIDEO_EXTERNALOUT			= 0x0002,
1929 	VIDEO_IN					= 0x0004,
1930 	VIDEO_OUT					= 0x0008,
1931 	VIDEO_DLG_QUERY				= 0x0010,
1932 }
1933 
1934 enum {
1935 	VIDEO_CONFIGURE_QUERYSIZE	= 0x0001,
1936 	VIDEO_CONFIGURE_CURRENT		= 0x0010,
1937 	VIDEO_CONFIGURE_NOMINAL		= 0x0020,
1938 	VIDEO_CONFIGURE_MIN			= 0x0040,
1939 	VIDEO_CONFIGURE_MAX			= 0x0080,
1940 	VIDEO_CONFIGURE_SET			= 0x1000,
1941 	VIDEO_CONFIGURE_GET			= 0x2000,
1942 	VIDEO_CONFIGURE_QUERY		= 0x8000,
1943 }
1944 
1945 /**
1946  * CONFIGURE MESSAGES
1947  */
1948 
1949 enum {
1950 	DVM_USER			= 0x4000,
1951 	DVM_CONFIGURE_START	= 0x1000,
1952 	DVM_CONFIGURE_END	= 0x1FFF,
1953 	DVM_PALETTE			= DVM_CONFIGURE_START + 1,
1954 	DVM_FORMAT			= DVM_CONFIGURE_START + 2,
1955 	DVM_PALETTERGB555	= DVM_CONFIGURE_START + 3,
1956 	DVM_SRC_RECT		= DVM_CONFIGURE_START + 4,
1957 	DVM_DST_RECT		= DVM_CONFIGURE_START + 5,
1958 }
1959 
1960 /**
1961  * AVICap window class
1962  */
1963 
1964 LRESULT AVICapSM(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
1965 	if (IsWindow(hWnd)) {
1966 		return SendMessage(hWnd, msg, wParam, lParam);
1967 	}
1968 	return 0;
1969 }
1970 
1971 enum {
1972 	WM_CAP_START				= WM_USER,
1973 	WM_CAP_UNICODE_START		= WM_USER + 100,
1974 
1975 	WM_CAP_GET_CAPSTREAMPTR		= WM_CAP_START + 1,
1976 	WM_CAP_SET_CALLBACK_ERRORA	= WM_CAP_START + 2,
1977 	WM_CAP_SET_CALLBACK_STATUSA	= WM_CAP_START + 3,
1978 
1979 	WM_CAP_SET_CALLBACK_ERRORW	= WM_CAP_UNICODE_START + 2,
1980 	WM_CAP_SET_CALLBACK_STATUSW	= WM_CAP_UNICODE_START + 3,
1981 }
1982 
1983 version(Unicode) {
1984 	alias WM_CAP_SET_CALLBACK_ERRORW	WM_CAP_SET_CALLBACK_ERROR;
1985 	alias WM_CAP_SET_CALLBACK_STATUSW	WM_CAP_SET_CALLBACK_STATUS;
1986 } else { // Unicode
1987 	alias WM_CAP_SET_CALLBACK_ERRORA	WM_CAP_SET_CALLBACK_ERROR;
1988 	alias WM_CAP_SET_CALLBACK_STATUSA	WM_CAP_SET_CALLBACK_STATUS;
1989 }
1990 
1991 enum {
1992 	WM_CAP_SET_CALLBACK_YIELD		= WM_CAP_START + 4,
1993 	WM_CAP_SET_CALLBACK_FRAME		= WM_CAP_START + 5,
1994 	WM_CAP_SET_CALLBACK_VIDEOSTREAM	= WM_CAP_START + 6,
1995 	WM_CAP_SET_CALLBACK_WAVESTREAM	= WM_CAP_START + 7,
1996 	WM_CAP_GET_USER_DATA			= WM_CAP_START + 8,
1997 	WM_CAP_SET_USER_DATA			= WM_CAP_START + 9,
1998 	WM_CAP_DRIVER_CONNECT			= WM_CAP_START + 10,
1999 	WM_CAP_DRIVER_DISCONNECT		= WM_CAP_START + 11,
2000 	WM_CAP_DRIVER_GET_NAMEA			= WM_CAP_START + 12,
2001 	WM_CAP_DRIVER_GET_VERSIONA		= WM_CAP_START + 13,
2002 
2003 	WM_CAP_DRIVER_GET_NAMEW			= WM_CAP_UNICODE_START + 12,
2004 	WM_CAP_DRIVER_GET_VERSIONW		= WM_CAP_UNICODE_START + 13,
2005 }
2006 
2007 version(Unicode) {
2008 	alias WM_CAP_DRIVER_GET_NAMEW		WM_CAP_DRIVER_GET_NAME;
2009 	alias WM_CAP_DRIVER_GET_VERSIONW	WM_CAP_DRIVER_GET_VERSION;
2010 } else { // Unicode
2011 	alias WM_CAP_DRIVER_GET_NAMEA		WM_CAP_DRIVER_GET_NAME;
2012 	alias WM_CAP_DRIVER_GET_VERSIONA	WM_CAP_DRIVER_GET_VERSION;
2013 }
2014 
2015 enum {
2016 	WM_CAP_DRIVER_GET_CAPS			= WM_CAP_START + 14,
2017 	WM_CAP_FILE_SET_CAPTURE_FILEA	= WM_CAP_START + 20,
2018 	WM_CAP_FILE_GET_CAPTURE_FILEA	= WM_CAP_START + 21,
2019 	WM_CAP_FILE_SAVEASA				= WM_CAP_START + 23,
2020 	WM_CAP_FILE_SAVEDIBA			= WM_CAP_START + 25,
2021 
2022 	WM_CAP_FILE_SET_CAPTURE_FILEW	= WM_CAP_UNICODE_START + 20,
2023 	WM_CAP_FILE_GET_CAPTURE_FILEW	= WM_CAP_UNICODE_START + 21,
2024 	WM_CAP_FILE_SAVEASW				= WM_CAP_UNICODE_START + 23,
2025 	WM_CAP_FILE_SAVEDIBW			= WM_CAP_UNICODE_START + 25,
2026 }
2027 
2028 version(Unicode) {
2029 	alias WM_CAP_FILE_SET_CAPTURE_FILEW	WM_CAP_FILE_SET_CAPTURE_FILE;
2030 	alias WM_CAP_FILE_GET_CAPTURE_FILEW	WM_CAP_FILE_GET_CAPTURE_FILE;
2031 	alias WM_CAP_FILE_SAVEASW			WM_CAP_FILE_SAVEAS;
2032 	alias WM_CAP_FILE_SAVEDIBW			WM_CAP_FILE_SAVEDIB;
2033 } else { // Unicode
2034 	alias WM_CAP_FILE_SET_CAPTURE_FILEA	WM_CAP_FILE_SET_CAPTURE_FILE;
2035 	alias WM_CAP_FILE_GET_CAPTURE_FILEA	WM_CAP_FILE_GET_CAPTURE_FILE;
2036 	alias WM_CAP_FILE_SAVEASA			WM_CAP_FILE_SAVEAS;
2037 	alias WM_CAP_FILE_SAVEDIBA			WM_CAP_FILE_SAVEDIB;
2038 }
2039 
2040 enum {
2041 	WM_CAP_FILE_ALLOCATE		= WM_CAP_START + 22,
2042 	WM_CAP_FILE_SET_INFOCHUNK	= WM_CAP_START + 24,
2043 	WM_CAP_EDIT_COPY			= WM_CAP_START + 30,
2044 	WM_CAP_SET_AUDIOFORMAT		= WM_CAP_START + 35,
2045 	WM_CAP_GET_AUDIOFORMAT		= WM_CAP_START + 36,
2046 	WM_CAP_DLG_VIDEOFORMAT		= WM_CAP_START + 41,
2047 	WM_CAP_DLG_VIDEOSOURCE		= WM_CAP_START + 42,
2048 	WM_CAP_DLG_VIDEODISPLAY		= WM_CAP_START + 43,
2049 	WM_CAP_GET_VIDEOFORMAT		= WM_CAP_START + 44,
2050 	WM_CAP_SET_VIDEOFORMAT		= WM_CAP_START + 45,
2051 	WM_CAP_DLG_VIDEOCOMPRESSION	= WM_CAP_START + 46,
2052 	WM_CAP_SET_PREVIEW			= WM_CAP_START + 50,
2053 	WM_CAP_SET_OVERLAY			= WM_CAP_START + 51,
2054 	WM_CAP_SET_PREVIEWRATE		= WM_CAP_START + 52,
2055 	WM_CAP_SET_SCALE			= WM_CAP_START + 53,
2056 	WM_CAP_GET_STATUS			= WM_CAP_START + 54,
2057 	WM_CAP_SET_SCROLL			= WM_CAP_START + 55,
2058 	WM_CAP_GRAB_FRAME			= WM_CAP_START + 60,
2059 	WM_CAP_GRAB_FRAME_NOSTOP	= WM_CAP_START + 61,
2060 	WM_CAP_SEQUENCE				= WM_CAP_START + 62,
2061 	WM_CAP_SEQUENCE_NOFILE		= WM_CAP_START + 63,
2062 	WM_CAP_SET_SEQUENCE_SETUP	= WM_CAP_START + 64,
2063 	WM_CAP_GET_SEQUENCE_SETUP	= WM_CAP_START + 65,
2064 	WM_CAP_SET_MCI_DEVICEA		= WM_CAP_START + 66,
2065 	WM_CAP_GET_MCI_DEVICEA		= WM_CAP_START + 67,
2066 
2067 	WM_CAP_SET_MCI_DEVICEW		= WM_CAP_UNICODE_START + 66,
2068 	WM_CAP_GET_MCI_DEVICEW		= WM_CAP_UNICODE_START + 67,
2069 }
2070 
2071 version(Unicode) {
2072 	alias WM_CAP_SET_MCI_DEVICEW	WM_CAP_SET_MCI_DEVICE;
2073 	alias WM_CAP_GET_MCI_DEVICEW	WM_CAP_GET_MCI_DEVICE;
2074 } else { // Unicode
2075 	alias WM_CAP_SET_MCI_DEVICEA	WM_CAP_SET_MCI_DEVICE;
2076 	alias WM_CAP_GET_MCI_DEVICEA	WM_CAP_GET_MCI_DEVICE;
2077 }
2078 
2079 enum {
2080 	WM_CAP_STOP					= WM_CAP_START + 68,
2081 	WM_CAP_ABORT				= WM_CAP_START + 69,
2082 	WM_CAP_SINGLE_FRAME_OPEN	= WM_CAP_START + 70,
2083 	WM_CAP_SINGLE_FRAME_CLOSE	= WM_CAP_START + 71,
2084 	WM_CAP_SINGLE_FRAME			= WM_CAP_START + 72,
2085 	WM_CAP_PAL_OPENA			= WM_CAP_START + 80,
2086 	WM_CAP_PAL_SAVEA			= WM_CAP_START + 81,
2087 
2088 	WM_CAP_PAL_OPENW			= WM_CAP_UNICODE_START + 80,
2089 	WM_CAP_PAL_SAVEW			= WM_CAP_UNICODE_START + 81,
2090 }
2091 
2092 version(Unicode) {
2093 	alias WM_CAP_PAL_OPENW	WM_CAP_PAL_OPEN;
2094 	alias WM_CAP_PAL_SAVEW	WM_CAP_PAL_SAVE;
2095 } else { // Unicode
2096 	alias WM_CAP_PAL_OPENA	WM_CAP_PAL_OPEN;
2097 	alias WM_CAP_PAL_SAVEA	WM_CAP_PAL_SAVE;
2098 }
2099 
2100 enum {
2101 	WM_CAP_PAL_PASTE				= WM_CAP_START + 82,
2102 	WM_CAP_PAL_AUTOCREATE			= WM_CAP_START + 83,
2103 	WM_CAP_PAL_MANUALCREATE			= WM_CAP_START + 84,
2104 	WM_CAP_SET_CALLBACK_CAPCONTROL	= WM_CAP_START + 85,
2105 	WM_CAP_UNICODE_END				= WM_CAP_PAL_SAVEW,
2106 	WM_CAP_END						= WM_CAP_UNICODE_END,
2107 }
2108 
2109 /**
2110  * message wrapper
2111  */
2112 
2113 BOOL capSetCallbackOnError(HWND hWnd, LPVOID fpProc)				{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_ERROR, 0, cast(LPARAM)fpProc); }
2114 BOOL capSetCallbackOnStatus(HWND hWnd, LPVOID fpProc)				{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_STATUS, 0, cast(LPARAM)fpProc); }
2115 BOOL capSetCallbackOnYield(HWND hWnd, LPVOID fpProc)				{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_YIELD, 0, cast(LPARAM)fpProc); }
2116 BOOL capSetCallbackOnFrame(HWND hWnd, LPVOID fpProc)				{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_FRAME, 0, cast(LPARAM)fpProc); }
2117 BOOL capSetCallbackOnVideoStream(HWND hWnd, LPVOID fpProc)			{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, cast(LPARAM)fpProc); }
2118 BOOL capSetCallbackOnWaveStream(HWND hWnd, LPVOID fpProc)			{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_WAVESTREAM, 0, cast(LPARAM)fpProc); }
2119 BOOL capSetCallbackOnCapControl(HWND hWnd, LPVOID fpProc)			{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_CAPCONTROL, 0, cast(LPARAM)fpProc); }
2120 
2121 BOOL capSetUserData(HWND hWnd, LPARAM lUser)						{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_USER_DATA, 0, lUser); }
2122 BOOL capGetUserData(HWND hWnd)										{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_GET_USER_DATA, 0, 0); }
2123 
2124 BOOL capDriverConnect(HWND hWnd, WPARAM i)							{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_CONNECT, i, 0); }
2125 BOOL capDriverDisconnect(HWND hWnd)									{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_DISCONNECT, 0, 0); }
2126 BOOL capDriverGetName(HWND hWnd, LPTSTR szName, WPARAM wSize)		{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_GET_NAME, wSize, cast(LPARAM)szName); }
2127 BOOL capDriverGetVersion(HWND hWnd, LPTSTR szVer, WPARAM wSize)		{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_GET_VERSION, wSize, cast(LPARAM)szVer); }
2128 BOOL capDriverGetCaps(HWND hWnd, LPCAPDRIVERCAPS s, WPARAM wSize)	{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_GET_CAPS, wSize, cast(LPARAM)s); }
2129 
2130 BOOL capFileSetCaptureFile(HWND hWnd, LPTSTR szName)				{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_SET_CAPTURE_FILE, 0, cast(LPARAM)szName); }
2131 BOOL capFileGetCaptureFile(HWND hWnd, LPTSTR szName, WPARAM wSize)	{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_GET_CAPTURE_FILE, wSize, cast(LPARAM)szName); }
2132 BOOL capFileAlloc(HWND hWnd, WPARAM wSize)							{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_ALLOCATE, wSize, 0); }
2133 BOOL capFileSaveAs(HWND hWnd, LPTSTR szName)						{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_SAVEAS, 0, cast(LPARAM)szName); }
2134 BOOL capFileSetInfoChunk(HWND hWnd, LPCAPINFOCHUNK lpInfoChunk)		{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_SET_INFOCHUNK, 0, cast(LPARAM)lpInfoChunk); }
2135 BOOL capFileSaveDIB(HWND hWnd, LPTSTR szName)						{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_SAVEDIB, 0, cast(LPARAM)szName); }
2136 
2137 BOOL capEditCopy(HWND hWnd)											{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_EDIT_COPY, 0, 0); }
2138 
2139 BOOL capSetAudioFormat(HWND hWnd, LPWAVEFORMATEX s, WPARAM wSize)	{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_AUDIOFORMAT, wSize, cast(LPARAM)s); }
2140 DWORD capGetAudioFormat(HWND hWnd, LPWAVEFORMATEX s, WPARAM wSize)	{ return cast(DWORD)AVICapSM(hWnd, WM_CAP_GET_AUDIOFORMAT, wSize, cast(LPARAM)s); }
2141 DWORD capGetAudioFormatSize(HWND hWnd)								{ return cast(DWORD)AVICapSM(hWnd, WM_CAP_GET_AUDIOFORMAT, 0, 0); }
2142 
2143 BOOL capDlgVideoFormat(HWND hWnd)									{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0); }
2144 BOOL capDlgVideoSource(HWND hWnd)									{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0); }
2145 BOOL capDlgVideoDisplay(HWND hWnd)									{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_DLG_VIDEODISPLAY, 0, 0); }
2146 BOOL capDlgVideoCompression(HWND hWnd)								{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0); }
2147 
2148 DWORD capGetVideoFormat(HWND hWnd, void* s, WPARAM wSize)			{ return cast(DWORD)AVICapSM(hWnd, WM_CAP_GET_VIDEOFORMAT, wSize, cast(LPARAM)s); }
2149 DWORD capGetVideoFormatSize(HWND hWnd)								{ return cast(DWORD)AVICapSM(hWnd, WM_CAP_GET_VIDEOFORMAT, 0, 0); }
2150 BOOL capSetVideoFormat(HWND hWnd, void* s, WPARAM wSize)			{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_VIDEOFORMAT, wSize, cast(LPARAM)s); }
2151 
2152 BOOL capPreview(HWND hWnd, BOOL f)									{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_PREVIEW, cast(WPARAM)f, 0); }
2153 BOOL capPreviewRate(HWND hWnd, WPARAM wMS)							{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_PREVIEWRATE, wMS, 0); }
2154 BOOL capOverlay(HWND hWnd, BOOL f)									{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_OVERLAY, cast(WPARAM)f, 0); }
2155 BOOL capPreviewScale(HWND hWnd, BOOL f)								{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_SCALE, cast(WPARAM)f, 0); }
2156 BOOL capGetStatus(HWND hWnd, LPCAPSTATUS s, WPARAM wSize)			{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_GET_STATUS, wSize, cast(LPARAM)s); }
2157 BOOL capSetScrollPos(HWND hWnd, LPPOINT lpP)						{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_SCROLL, 0, cast(LPARAM)lpP); }
2158 
2159 BOOL capGrabFrame(HWND hWnd)										{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_GRAB_FRAME, 0, 0); }
2160 BOOL capGrabFrameNoStop(HWND hWnd)									{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_GRAB_FRAME_NOSTOP, 0, 0); }
2161 
2162 BOOL capCaptureSequence(HWND hWnd)									{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SEQUENCE, 0, 0); }
2163 BOOL capCaptureSequenceNoFile(HWND hWnd)							{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SEQUENCE_NOFILE, 0, 0); }
2164 BOOL capCaptureStop(HWND hWnd)										{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_STOP, 0, 0); }
2165 BOOL capCaptureAbort(HWND hWnd)										{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_ABORT, 0, 0); }
2166 
2167 BOOL capCaptureSingleFrameOpen(HWND hWnd)							{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SINGLE_FRAME_OPEN, 0, 0); }
2168 BOOL capCaptureSingleFrameClose(HWND hWnd)							{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SINGLE_FRAME_CLOSE, 0, 0); }
2169 BOOL capCaptureSingleFrame(HWND hWnd)								{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SINGLE_FRAME, 0, 0); }
2170 
2171 BOOL capCaptureGetSetup(HWND hWnd, LPCAPTUREPARMS s, WPARAM wSize)	{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_GET_SEQUENCE_SETUP, wSize, cast(LPARAM)s); }
2172 BOOL capCaptureSetSetup(HWND hWnd, LPCAPTUREPARMS s, WPARAM wSize)	{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_SEQUENCE_SETUP, wSize, cast(LPARAM)s); }
2173 
2174 BOOL capSetMCIDeviceName(HWND hWnd, LPTSTR szName)					{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_MCI_DEVICE, 0, cast(LPARAM)szName); }
2175 BOOL capGetMCIDeviceName(HWND hWnd, LPTSTR szName, WPARAM wSize)	{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_GET_MCI_DEVICE, wSize, cast(LPARAM)szName); }
2176 
2177 BOOL capPaletteOpen(HWND hWnd, LPTSTR szName)						{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_OPEN, 0, cast(LPARAM)szName); }
2178 BOOL capPaletteSave(HWND hWnd, LPTSTR szName)						{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_SAVE, 0, cast(LPARAM)szName); }
2179 BOOL capPalettePaste(HWND hWnd)										{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_PASTE, 0, 0); }
2180 BOOL capPaletteAuto(HWND hWnd, WPARAM iFrames, LPARAM iColors)		{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_AUTOCREATE, iFrames, iColors); }
2181 BOOL capPaletteManual(HWND hWnd, WPARAM fGrab, LPARAM iColors)		{ return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_MANUALCREATE, fGrab, iColors); }
2182 
2183 /**
2184  * structs
2185  */
2186 
2187 struct CAPDRIVERCAPS {
2188 	UINT	wDeviceIndex;
2189 	BOOL	fHasOverlay;
2190 	BOOL	fHasDlgVideoSource;
2191 	BOOL	fHasDlgVideoFormat;
2192 	BOOL	fHasDlgVideoDisplay;
2193 	BOOL	fCaptureInitialized;
2194 	BOOL	fDriverSuppliesPalettes;
2195 	HANDLE	hVideoIn;
2196 	HANDLE	hVideoOut;
2197 	HANDLE	hVideoExtIn;
2198 	HANDLE	hVideoExtOut;
2199 }
2200 alias CAPDRIVERCAPS* PCAPDRIVERCAPS, LPCAPDRIVERCAPS;
2201 
2202 struct CAPSTATUS {
2203 	UINT		uiImageWidth;
2204 	UINT		uiImageHeight;
2205 	BOOL		fLiveWindow;
2206 	BOOL		fOverlayWindow;
2207 	BOOL		fScale;
2208 	POINT		ptScroll;
2209 	BOOL		fUsingDefaultPalette;
2210 	BOOL		fAudioHardware;
2211 	BOOL		fCapFileExists;
2212 	DWORD		dwCurrentVideoFrame;
2213 	DWORD		dwCurrentVideoFramesDropped;
2214 	DWORD		dwCurrentWaveSamples;
2215 	DWORD		dwCurrentTimeElapsedMS;
2216 	HPALETTE	hPalCurrent;
2217 	BOOL		fCapturingNow;
2218 	DWORD		dwReturn;
2219 	UINT		wNumVideoAllocated;
2220 	UINT		wNumAudioAllocated;
2221 }
2222 alias CAPSTATUS* PCAPSTATUS, LPCAPSTATUS;
2223 
2224 struct CAPTUREPARMS {
2225 	DWORD	dwRequestMicroSecPerFrame;
2226 	BOOL	fMakeUserHitOKToCapture;
2227 	UINT	wPercentDropForError;
2228 	BOOL	fYield;
2229 	DWORD	dwIndexSize;
2230 	UINT	wChunkGranularity;
2231 	BOOL	fUsingDOSMemory;
2232 	UINT	wNumVideoRequested;
2233 	BOOL	fCaptureAudio;
2234 	UINT	wNumAudioRequested;
2235 	UINT	vKeyAbort;
2236 	BOOL	fAbortLeftMouse;
2237 	BOOL	fAbortRightMouse;
2238 	BOOL	fLimitEnabled;
2239 	UINT	wTimeLimit;
2240 	BOOL	fMCIControl;
2241 	BOOL	fStepMCIDevice;
2242 	DWORD	dwMCIStartTime;
2243 	DWORD	dwMCIStopTime;
2244 	BOOL	fStepCaptureAt2x;
2245 	UINT	wStepCaptureAverageFrames;
2246 	DWORD	dwAudioBufferSize;
2247 	BOOL	fDisableWriteCache;
2248 	UINT	AVStreamMaster;
2249 }
2250 alias CAPTUREPARMS* PCAPTUREPARMS, LPCAPTUREPARMS;
2251 
2252 const AVSTREAMMASTER_AUDIO = 0;
2253 const AVSTREAMMASTER_NONE  = 1;
2254 
2255 struct CAPINFOCHUNK {
2256 	FOURCC	fccInfoID;
2257 	LPVOID	lpData;
2258 	LONG	cbData;
2259 }
2260 alias CAPINFOCHUNK* PCAPINFOCHUNK, LPCAPINFOCHUNK;
2261 
2262 // Callback Definitions
2263 
2264 extern (Windows) {
2265 	alias LRESULT function(HWND hWnd) CAPYIELDCALLBACK;
2266 	alias LRESULT function(HWND hWnd, int nID, LPCWSTR lpsz) CAPSTATUSCALLBACKW;
2267 	alias LRESULT function(HWND hWnd, int nID, LPCWSTR lpsz) CAPERRORCALLBACKW;
2268 	alias LRESULT function(HWND hWnd, int nID, LPCSTR lpsz) CAPSTATUSCALLBACKA;
2269 	alias LRESULT function(HWND hWnd, int nID, LPCSTR lpsz) CAPERRORCALLBACKA;
2270 }
2271 
2272 version(Unicode) {
2273 	alias CAPSTATUSCALLBACKW	CAPSTATUSCALLBACK;
2274 	alias CAPERRORCALLBACKW		CAPERRORCALLBACK;
2275 } else { // Unicode
2276 	alias CAPSTATUSCALLBACKA	CAPSTATUSCALLBACK;
2277 	alias CAPERRORCALLBACKA		CAPERRORCALLBACK;
2278 }
2279 
2280 extern (Windows) {
2281 	alias LRESULT function(HWND hWnd, LPVIDEOHDR lpVHdr) CAPVIDEOCALLBACK;
2282 	alias LRESULT function(HWND hWnd, LPWAVEHDR lpWHdr) CAPWAVECALLBACK;
2283 	alias LRESULT function(HWND hWnd, int nState) CAPCONTROLCALLBACK;
2284 }
2285 
2286 //  CapControlCallback states
2287 const CONTROLCALLBACK_PREROLL	= 1;
2288 const CONTROLCALLBACK_CAPTURING	= 2;
2289 
2290 extern (Windows) {
2291 	HWND capCreateCaptureWindowA(LPCSTR lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hwndParent, int nID);
2292 	BOOL capGetDriverDescriptionA(UINT wDriverIndex, LPSTR lpszName, int cbName, LPSTR lpszVer, int cbVer);
2293 	HWND capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hwndParent, int nID);
2294 	BOOL capGetDriverDescriptionW(UINT wDriverIndex, LPWSTR lpszName, int cbName, LPWSTR lpszVer, int cbVer);
2295 }
2296 
2297 version(Unicode) {
2298 	alias capCreateCaptureWindowW	capCreateCaptureWindow;
2299 	alias capGetDriverDescriptionW	capGetDriverDescription;
2300 } else { // Unicode
2301 	alias capCreateCaptureWindowA	capCreateCaptureWindow;
2302 	alias capGetDriverDescriptionA	capGetDriverDescription;
2303 }
2304 
2305 // New Information chunk IDs
2306 const infotypeDIGITIZATION_TIME	= mmioFOURCC!('I', 'D', 'I', 'T');
2307 const infotypeSMPTE_TIME		= mmioFOURCC!('I', 'S', 'M', 'P');
2308 
2309 // status and error callbacks
2310 enum {
2311 	IDS_CAP_BEGIN					= 300,
2312 	IDS_CAP_END						= 301,
2313 
2314 	IDS_CAP_INFO					= 401,
2315 	IDS_CAP_OUTOFMEM				= 402,
2316 	IDS_CAP_FILEEXISTS				= 403,
2317 	IDS_CAP_ERRORPALOPEN			= 404,
2318 	IDS_CAP_ERRORPALSAVE			= 405,
2319 	IDS_CAP_ERRORDIBSAVE			= 406,
2320 	IDS_CAP_DEFAVIEXT				= 407,
2321 	IDS_CAP_DEFPALEXT				= 408,
2322 	IDS_CAP_CANTOPEN				= 409,
2323 	IDS_CAP_SEQ_MSGSTART			= 410,
2324 	IDS_CAP_SEQ_MSGSTOP				= 411,
2325 
2326 	IDS_CAP_VIDEDITERR				= 412,
2327 	IDS_CAP_READONLYFILE			= 413,
2328 	IDS_CAP_WRITEERROR				= 414,
2329 	IDS_CAP_NODISKSPACE				= 415,
2330 	IDS_CAP_SETFILESIZE				= 416,
2331 	IDS_CAP_SAVEASPERCENT			= 417,
2332 
2333 	IDS_CAP_DRIVER_ERROR			= 418,
2334 
2335 	IDS_CAP_WAVE_OPEN_ERROR			= 419,
2336 	IDS_CAP_WAVE_ALLOC_ERROR		= 420,
2337 	IDS_CAP_WAVE_PREPARE_ERROR		= 421,
2338 	IDS_CAP_WAVE_ADD_ERROR			= 422,
2339 	IDS_CAP_WAVE_SIZE_ERROR			= 423,
2340 
2341 	IDS_CAP_VIDEO_OPEN_ERROR		= 424,
2342 	IDS_CAP_VIDEO_ALLOC_ERROR		= 425,
2343 	IDS_CAP_VIDEO_PREPARE_ERROR		= 426,
2344 	IDS_CAP_VIDEO_ADD_ERROR			= 427,
2345 	IDS_CAP_VIDEO_SIZE_ERROR		= 428,
2346 
2347 	IDS_CAP_FILE_OPEN_ERROR			= 429,
2348 	IDS_CAP_FILE_WRITE_ERROR		= 430,
2349 	IDS_CAP_RECORDING_ERROR			= 431,
2350 	IDS_CAP_RECORDING_ERROR2		= 432,
2351 	IDS_CAP_AVI_INIT_ERROR			= 433,
2352 	IDS_CAP_NO_FRAME_CAP_ERROR		= 434,
2353 	IDS_CAP_NO_PALETTE_WARN			= 435,
2354 	IDS_CAP_MCI_CONTROL_ERROR		= 436,
2355 	IDS_CAP_MCI_CANT_STEP_ERROR		= 437,
2356 	IDS_CAP_NO_AUDIO_CAP_ERROR		= 438,
2357 	IDS_CAP_AVI_DRAWDIB_ERROR		= 439,
2358 	IDS_CAP_COMPRESSOR_ERROR		= 440,
2359 	IDS_CAP_AUDIO_DROP_ERROR		= 441,
2360 	IDS_CAP_AUDIO_DROP_COMPERROR	= 442,
2361 
2362 	IDS_CAP_STAT_LIVE_MODE			= 500,
2363 	IDS_CAP_STAT_OVERLAY_MODE		= 501,
2364 	IDS_CAP_STAT_CAP_INIT			= 502,
2365 	IDS_CAP_STAT_CAP_FINI			= 503,
2366 	IDS_CAP_STAT_PALETTE_BUILD		= 504,
2367 	IDS_CAP_STAT_OPTPAL_BUILD		= 505,
2368 	IDS_CAP_STAT_I_FRAMES			= 506,
2369 	IDS_CAP_STAT_L_FRAMES			= 507,
2370 	IDS_CAP_STAT_CAP_L_FRAMES		= 508,
2371 	IDS_CAP_STAT_CAP_AUDIO			= 509,
2372 	IDS_CAP_STAT_VIDEOCURRENT		= 510,
2373 	IDS_CAP_STAT_VIDEOAUDIO			= 511,
2374 	IDS_CAP_STAT_VIDEOONLY			= 512,
2375 	IDS_CAP_STAT_FRAMESDROPPED		= 513,
2376 }
2377 
2378 /**
2379  * FilePreview dialog.
2380  */
2381 
2382 extern (Windows) {
2383 	BOOL GetOpenFileNamePreviewA(LPOPENFILENAMEA lpofn);
2384 	BOOL GetSaveFileNamePreviewA(LPOPENFILENAMEA lpofn);
2385 	BOOL GetOpenFileNamePreviewW(LPOPENFILENAMEW lpofn);
2386 	BOOL GetSaveFileNamePreviewW(LPOPENFILENAMEW lpofn);
2387 }
2388 
2389 version(Unicode) {
2390 	alias GetOpenFileNamePreviewW	GetOpenFileNamePreview;
2391 	alias GetSaveFileNamePreviewW	GetSaveFileNamePreview;
2392 } else { // Unicode
2393 	alias GetOpenFileNamePreviewA	GetOpenFileNamePreview;
2394 	alias GetSaveFileNamePreviewA	GetSaveFileNamePreview;
2395 }