Release 990226.
[wine/gsoc-2012-control.git] / multimedia / msvideo.c
blobf95ef2660224ef8f1e63358ed30067c0d15d8b7f
1 /*
2 * Copyright 1998 Marcus Meissner
3 */
4 #include <stdio.h>
5 #include <strings.h>
7 #include "windows.h"
8 #include "driver.h"
9 #include "mmsystem.h"
10 #include "ole2.h"
11 #include "vfw.h"
12 #include "debug.h"
14 /****************************************************************************
15 * VideoForWindowsVersion [MSVFW32.2][MSVIDEO.2]
16 * Returns the version in major.minor form.
17 * In Windows95 this returns 0x040003b6 (4.950)
19 DWORD WINAPI
20 VideoForWindowsVersion(void) {
21 return 0x040003B6; /* 4.950 */
24 /* system.ini: [drivers32] */
26 /**************************************************************************
27 * ICInfo [MSVFW32.33]
28 * Get information about an installable compressor. Return TRUE if there
29 * is one.
31 BOOL WINAPI
32 ICInfo(
33 DWORD fccType, /* [in] type of compressor ('vidc') */
34 DWORD fccHandler, /* [in] <n>th compressor */
35 ICINFO *lpicinfo /* [out] information about compressor */
36 ) {
37 char type[5],buf[2000];
39 memcpy(type,&fccType,4);type[4]=0;
40 TRACE(msvideo,"(%s,%ld,%p).\n",type,fccHandler,lpicinfo);
41 /* does OpenDriver/CloseDriver */
42 lpicinfo->dwSize = sizeof(ICINFO);
43 lpicinfo->fccType = fccType;
44 lpicinfo->dwFlags = 0;
45 if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) {
46 char *s = buf;
47 while (*s) {
48 if (!lstrncmpiA(type,s,4)) {
49 if(!fccHandler--) {
50 lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0);
51 return TRUE;
54 s=s+lstrlenA(s)+1; /* either next char or \0 */
57 return FALSE;
60 /**************************************************************************
61 * ICOpen [MSVFW32.37]
62 * Opens an installable compressor. Return special handle.
64 HIC WINAPI
65 ICOpen(DWORD fccType,DWORD fccHandler,UINT wMode) {
66 char type[5],handler[5],codecname[20];
67 ICOPEN icopen;
68 HDRVR hdrv;
69 WINE_HIC *whic;
71 memcpy(type,&fccType,4);type[4]=0;
72 memcpy(handler,&fccHandler,4);handler[4]=0;
73 TRACE(msvideo,"(%s,%s,0x%08lx)\n",type,handler,(DWORD)wMode);
74 sprintf(codecname,"%s.%s",type,handler);
76 /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
77 * same layout as ICOPEN
79 icopen.fccType = fccType;
80 icopen.fccHandler = fccHandler;
81 icopen.dwSize = sizeof(ICOPEN);
82 icopen.dwFlags = wMode;
83 /* FIXME: do we need to fill out the rest too? */
84 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
85 if (!hdrv) {
86 if (!strcasecmp(type,"vids")) {
87 sprintf(codecname,"vidc.%s",handler);
88 fccType = mmioFOURCC('v','i','d','c');
90 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
91 return 0;
93 whic = HeapAlloc(GetProcessHeap(),0,sizeof(WINE_HIC));
94 whic->hdrv = hdrv;
95 #if 0
96 whic->driverproc= GetProcAddress(GetDriverModuleHandle(hdrv),"DriverProc");
97 whic->private = whic->driverproc(0,hdrv,DRV_OPEN,0,&icopen);
98 #endif
99 return (HIC)whic;
102 LRESULT WINAPI
103 ICGetInfo(HIC hic,ICINFO *picinfo,DWORD cb) {
104 LRESULT ret;
106 TRACE(msvideo,"(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
107 ret = ICSendMessage(hic,ICM_GETINFO,(DWORD)picinfo,cb);
108 TRACE(msvideo," -> 0x%08lx\n",ret);
109 return ret;
112 HIC VFWAPI
113 ICLocate(
114 DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
115 LPBITMAPINFOHEADER lpbiOut, WORD wMode
117 char type[5],handler[5];
118 HIC hic;
119 DWORD querymsg;
121 switch (wMode) {
122 case ICMODE_FASTCOMPRESS:
123 case ICMODE_COMPRESS:
124 querymsg = ICM_COMPRESS_QUERY;
125 break;
126 case ICMODE_DECOMPRESS:
127 case ICMODE_FASTDECOMPRESS:
128 querymsg = ICM_DECOMPRESS_QUERY;
129 break;
130 case ICMODE_DRAW:
131 querymsg = ICM_DRAW_QUERY;
132 break;
133 default:
134 FIXME(msvideo,"Unknown mode (%d)\n",wMode);
135 return 0;
138 /* Easy case: handler/type match, we just fire a query and return */
139 hic = ICOpen(fccType,fccHandler,wMode);
140 if (hic) {
141 if (!ICSendMessage(hic,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
142 return hic;
143 ICClose(hic);
145 type[4]='\0';memcpy(type,&fccType,4);
146 handler[4]='\0';memcpy(handler,&fccHandler,4);
147 FIXME(msvideo,"(%s,%s,%p,%p,0x%04x),unhandled!\n",type,handler,lpbiIn,lpbiOut,wMode);
148 return 0;
151 DWORD VFWAPIV
152 ICCompress(
153 HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
154 LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
155 LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
156 LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev
158 ICCOMPRESS iccmp;
160 iccmp.dwFlags = dwFlags;
162 iccmp.lpbiOutput = lpbiOutput;
163 iccmp.lpOutput = lpData;
164 iccmp.lpbiInput = lpbiInput;
165 iccmp.lpInput = lpBits;
167 iccmp.lpckid = lpckid;
168 iccmp.lpdwFlags = lpdwFlags;
169 iccmp.lFrameNum = lFrameNum;
170 iccmp.dwFrameSize = dwFrameSize;
171 iccmp.dwQuality = dwQuality;
172 iccmp.lpbiPrev = lpbiPrev;
173 iccmp.lpPrev = lpPrev;
174 return ICSendMessage(hic,ICM_COMPRESS,(LPARAM)&iccmp,sizeof(iccmp));
177 DWORD VFWAPIV
178 ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits) {
179 ICDECOMPRESS icd;
181 icd.dwFlags = dwFlags;
182 icd.lpbiInput = lpbiFormat;
183 icd.lpInput = lpData;
185 icd.lpbiOutput = lpbi;
186 icd.lpOutput = lpBits;
188 icd.ckid = ??? ckid from AVI file? how do we get it? ;
190 return ICSendMessage(hic,ICM_DECOMPRESS,(LPARAM)&icd,sizeof(icd));
193 LRESULT VFWAPI
194 ICSendMessage(HIC hic,UINT msg,DWORD lParam1,DWORD lParam2) {
195 LRESULT ret;
196 WINE_HIC *whic = (WINE_HIC*)hic;
198 #define XX(x) case x: TRACE(msvideo,"(0x%08lx,"#x",0x%08lx,0x%08lx)\n",(DWORD)hic,lParam1,lParam2);break;
200 switch (msg) {
201 XX(ICM_ABOUT)
202 XX(ICM_GETINFO)
203 XX(ICM_COMPRESS_FRAMES_INFO)
204 XX(ICM_COMPRESS_GET_FORMAT)
205 XX(ICM_COMPRESS_GET_SIZE)
206 XX(ICM_COMPRESS_QUERY)
207 XX(ICM_COMPRESS_BEGIN)
208 XX(ICM_COMPRESS)
209 XX(ICM_COMPRESS_END)
210 XX(ICM_DECOMPRESS_GET_FORMAT)
211 XX(ICM_DECOMPRESS_QUERY)
212 XX(ICM_DECOMPRESS_BEGIN)
213 XX(ICM_DECOMPRESS)
214 XX(ICM_DECOMPRESS_END)
215 XX(ICM_DECOMPRESS_SET_PALETTE)
216 XX(ICM_DECOMPRESS_GET_PALETTE)
217 XX(ICM_DRAW_QUERY)
218 XX(ICM_DRAW_BEGIN)
219 XX(ICM_DRAW_GET_PALETTE)
220 XX(ICM_DRAW_START)
221 XX(ICM_DRAW_STOP)
222 XX(ICM_DRAW_END)
223 XX(ICM_DRAW_GETTIME)
224 XX(ICM_DRAW)
225 XX(ICM_DRAW_WINDOW)
226 XX(ICM_DRAW_SETTIME)
227 XX(ICM_DRAW_REALIZE)
228 XX(ICM_DRAW_FLUSH)
229 XX(ICM_DRAW_RENDERBUFFER)
230 XX(ICM_DRAW_START_PLAY)
231 XX(ICM_DRAW_STOP_PLAY)
232 XX(ICM_DRAW_SUGGESTFORMAT)
233 XX(ICM_DRAW_CHANGEPALETTE)
234 XX(ICM_GETBUFFERSWANTED)
235 XX(ICM_GETDEFAULTKEYFRAMERATE)
236 XX(ICM_DECOMPRESSEX_BEGIN)
237 XX(ICM_DECOMPRESSEX_QUERY)
238 XX(ICM_DECOMPRESSEX)
239 XX(ICM_DECOMPRESSEX_END)
240 XX(ICM_SET_STATUS_PROC)
241 default:
242 FIXME(msvideo,"(0x%08lx,0x%08lx,0x%08lx,0x%08lx)\n",(DWORD)hic,(DWORD)msg,lParam1,lParam2);
244 ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2);
245 /* ret = whic->driverproc(whic->private,whic->hdrv,msg,lParam1,lParam2);*/
246 TRACE(msvideo," -> 0x%08lx\n",ret);
247 return ret;
250 DWORD VFWAPIV ICDrawBegin(
251 HIC hic,
252 DWORD dwFlags,/* flags */
253 HPALETTE hpal, /* palette to draw with */
254 HWND hwnd, /* window to draw to */
255 HDC hdc, /* HDC to draw to */
256 INT xDst, /* destination rectangle */
257 INT yDst,
258 INT dxDst,
259 INT dyDst,
260 LPBITMAPINFOHEADER lpbi, /* format of frame to draw */
261 INT xSrc, /* source rectangle */
262 INT ySrc,
263 INT dxSrc,
264 INT dySrc,
265 DWORD dwRate, /* frames/second = (dwRate/dwScale) */
266 DWORD dwScale) {
267 return 0;
270 LRESULT WINAPI ICClose(HIC hic) {
271 WINE_HIC *whic = (WINE_HIC*)hic;
272 TRACE(msvideo,"(%d).\n",hic);
273 /* FIXME: correct? */
274 CloseDriver(whic->hdrv,0,0);
275 HeapFree(GetProcessHeap(),0,whic);
276 return 0;
279 HANDLE /* HDRAWDIB */ WINAPI
280 DrawDibOpen( void ) {
281 FIXME(msvideo,"stub!\n");
282 return 0;
284 HWND VFWAPIV MCIWndCreate (HWND hwndParent, HINSTANCE hInstance,
285 DWORD dwStyle,LPVOID szFile)
286 { FIXME(msvideo,"%x %x %lx %p\n",hwndParent, hInstance, dwStyle, szFile);
287 return 0;
289 HWND VFWAPIV MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance,
290 DWORD dwStyle,LPCSTR szFile)
291 { FIXME(msvideo,"%x %x %lx %s\n",hwndParent, hInstance, dwStyle, szFile);
292 return 0;
294 HWND VFWAPIV MCIWndCreateW(HWND hwndParent, HINSTANCE hInstance,
295 DWORD dwStyle,LPCWSTR szFile)
296 { FIXME(msvideo,"%x %x %lx %s\n",hwndParent, hInstance, dwStyle, debugstr_w(szFile));
297 return 0;