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