2 * Copyright 1998 Marcus Meissner
11 #include "wine/winestring.h"
15 DEFAULT_DEBUG_CHANNEL(msvideo)
17 /****************************************************************************
18 * VideoForWindowsVersion [MSVFW.2][MSVIDEO.2]
19 * Returns the version in major.minor form.
20 * In Windows95 this returns 0x040003b6 (4.950)
23 VideoForWindowsVersion(void) {
24 return 0x040003B6; /* 4.950 */
27 /* system.ini: [drivers] */
29 /**************************************************************************
31 * Get information about an installable compressor. Return TRUE if there
36 DWORD fccType, /* [in] type of compressor ('vidc') */
37 DWORD fccHandler, /* [in] <n>th compressor */
38 ICINFO *lpicinfo /* [out] information about compressor */
40 char type[5],buf[2000];
42 memcpy(type,&fccType,4);type[4]=0;
43 TRACE(msvideo,"(%s,%ld,%p).\n",type,fccHandler,lpicinfo);
44 /* does OpenDriver/CloseDriver */
45 lpicinfo->dwSize = sizeof(ICINFO);
46 lpicinfo->fccType = fccType;
47 lpicinfo->dwFlags = 0;
48 if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) {
51 if (!lstrncmpiA(type,s,4)) {
53 lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0);
57 s=s+lstrlenA(s)+1; /* either next char or \0 */
63 /**************************************************************************
65 * Opens an installable compressor. Return special handle.
68 ICOpen(DWORD fccType,DWORD fccHandler,UINT wMode) {
69 char type[5],handler[5],codecname[20];
74 memcpy(type,&fccType,4);type[4]=0;
75 memcpy(handler,&fccHandler,4);handler[4]=0;
76 TRACE(msvideo,"(%s,%s,0x%08lx)\n",type,handler,(DWORD)wMode);
77 sprintf(codecname,"%s.%s",type,handler);
79 /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
80 * same layout as ICOPEN
82 icopen.fccType = fccType;
83 icopen.fccHandler = fccHandler;
84 icopen.dwSize = sizeof(ICOPEN);
85 icopen.dwFlags = wMode;
86 /* FIXME: do we need to fill out the rest too? */
87 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
89 if (!strcasecmp(type,"vids")) {
90 sprintf(codecname,"vidc.%s",handler);
91 fccType = mmioFOURCC('v','i','d','c');
93 hdrv=OpenDriverA(codecname,"drivers32",(LPARAM)&icopen);
97 whic = HeapAlloc(GetProcessHeap(),0,sizeof(WINE_HIC));
99 whic->driverproc= NULL;
100 whic->private = ICSendMessage((HIC)whic,DRV_OPEN,0,(LPARAM)&icopen);
103 HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode,
104 FARPROC lpfnHandler) {
105 char type[5],handler[5];
109 memcpy(type,&fccType,4);type[4]=0;
110 memcpy(handler,&fccHandler,4);handler[4]=0;
111 FIXME(msvideo,"(%s,%s,%d,%p), stub!\n",type,handler,wMode,lpfnHandler);
112 hic = ICOpen(fccType,fccHandler,wMode);
115 whic = (WINE_HIC*)hic;
116 whic->driverproc = lpfnHandler;
122 ICGetInfo(HIC hic,ICINFO *picinfo,DWORD cb) {
125 TRACE(msvideo,"(0x%08lx,%p,%ld)\n",(DWORD)hic,picinfo,cb);
126 ret = ICSendMessage(hic,ICM_GETINFO,(DWORD)picinfo,cb);
127 TRACE(msvideo," -> 0x%08lx\n",ret);
133 DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn,
134 LPBITMAPINFOHEADER lpbiOut, WORD wMode
136 char type[5],handler[5];
141 case ICMODE_FASTCOMPRESS:
142 case ICMODE_COMPRESS:
143 querymsg = ICM_COMPRESS_QUERY;
145 case ICMODE_DECOMPRESS:
146 case ICMODE_FASTDECOMPRESS:
147 querymsg = ICM_DECOMPRESS_QUERY;
150 querymsg = ICM_DRAW_QUERY;
153 FIXME(msvideo,"Unknown mode (%d)\n",wMode);
157 /* Easy case: handler/type match, we just fire a query and return */
158 hic = ICOpen(fccType,fccHandler,wMode);
160 if (!ICSendMessage(hic,querymsg,(DWORD)lpbiIn,(DWORD)lpbiOut))
164 type[4]='\0';memcpy(type,&fccType,4);
165 handler[4]='\0';memcpy(handler,&fccHandler,4);
166 if (fccType==streamtypeVIDEO) {
167 hic = ICLocate(ICTYPE_VIDEO,fccHandler,lpbiIn,lpbiOut,wMode);
171 FIXME(msvideo,"(%s,%s,%p,%p,0x%04x),unhandled!\n",type,handler,lpbiIn,lpbiOut,wMode);
175 HIC VFWAPI ICGetDisplayFormat(
176 HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
177 INT depth,INT dx,INT dy
182 FIXME(msvideo,"(0x%08lx,%p,%p,%d,%d,%d),stub!\n",(DWORD)hic,lpbiIn,lpbiOut,depth,dx,dy);
184 tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
188 if ((dy == lpbiIn->biHeight) || (dx == lpbiIn->biWidth))
189 dy = dx = 0; /* no resize needed */
190 /* Can we decompress it ? */
191 lres = ICDecompressQuery(tmphic,lpbiIn,NULL);
193 goto errout; /* no, sorry */
194 ICDecompressGetFormat(hic,lpbiIn,lpbiOut);
196 lpbiOut->biCompression = 0;
197 lpbiOut->biSize = sizeof(*lpbiOut);
202 depth = GetDeviceCaps(hdc,12)*GetDeviceCaps(hdc,14);
204 if (depth==15) depth = 16;
205 if (depth<8) depth = 8;
206 /* more constraints and tests */
208 if (lpbiIn->biBitCount == 8)
220 HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpData,
221 LPBITMAPINFOHEADER lpbiInput,LPVOID lpBits,LPDWORD lpckid,
222 LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,
223 LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev
227 iccmp.dwFlags = dwFlags;
229 iccmp.lpbiOutput = lpbiOutput;
230 iccmp.lpOutput = lpData;
231 iccmp.lpbiInput = lpbiInput;
232 iccmp.lpInput = lpBits;
234 iccmp.lpckid = lpckid;
235 iccmp.lpdwFlags = lpdwFlags;
236 iccmp.lFrameNum = lFrameNum;
237 iccmp.dwFrameSize = dwFrameSize;
238 iccmp.dwQuality = dwQuality;
239 iccmp.lpbiPrev = lpbiPrev;
240 iccmp.lpPrev = lpPrev;
241 return ICSendMessage(hic,ICM_COMPRESS,(LPARAM)&iccmp,sizeof(iccmp));
245 ICDecompress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiFormat,LPVOID lpData,LPBITMAPINFOHEADER lpbi,LPVOID lpBits) {
248 icd.dwFlags = dwFlags;
249 icd.lpbiInput = lpbiFormat;
250 icd.lpInput = lpData;
252 icd.lpbiOutput = lpbi;
253 icd.lpOutput = lpBits;
255 return ICSendMessage(hic,ICM_DECOMPRESS,(LPARAM)&icd,sizeof(icd));
259 ICSendMessage(HIC hic,UINT msg,DWORD lParam1,DWORD lParam2) {
261 WINE_HIC *whic = (WINE_HIC*)hic;
263 #define XX(x) case x: TRACE(msvideo,"(0x%08lx,"#x",0x%08lx,0x%08lx)\n",(DWORD)hic,lParam1,lParam2);break;
268 XX(ICM_COMPRESS_FRAMES_INFO)
269 XX(ICM_COMPRESS_GET_FORMAT)
270 XX(ICM_COMPRESS_GET_SIZE)
271 XX(ICM_COMPRESS_QUERY)
272 XX(ICM_COMPRESS_BEGIN)
275 XX(ICM_DECOMPRESS_GET_FORMAT)
276 XX(ICM_DECOMPRESS_QUERY)
277 XX(ICM_DECOMPRESS_BEGIN)
279 XX(ICM_DECOMPRESS_END)
280 XX(ICM_DECOMPRESS_SET_PALETTE)
281 XX(ICM_DECOMPRESS_GET_PALETTE)
284 XX(ICM_DRAW_GET_PALETTE)
294 XX(ICM_DRAW_RENDERBUFFER)
295 XX(ICM_DRAW_START_PLAY)
296 XX(ICM_DRAW_STOP_PLAY)
297 XX(ICM_DRAW_SUGGESTFORMAT)
298 XX(ICM_DRAW_CHANGEPALETTE)
299 XX(ICM_GETBUFFERSWANTED)
300 XX(ICM_GETDEFAULTKEYFRAMERATE)
301 XX(ICM_DECOMPRESSEX_BEGIN)
302 XX(ICM_DECOMPRESSEX_QUERY)
304 XX(ICM_DECOMPRESSEX_END)
305 XX(ICM_SET_STATUS_PROC)
307 FIXME(msvideo,"(0x%08lx,0x%08lx,0x%08lx,0x%08lx)\n",(DWORD)hic,(DWORD)msg,lParam1,lParam2);
310 if (whic->driverproc) {
311 FIXME(msvideo,"(0x%08lx,0x%08lx,0x%08lx,0x%08lx), calling %p\n",(DWORD)hic,(DWORD)msg,lParam1,lParam2,whic->driverproc);
312 ret = whic->driverproc(whic->hdrv,1,msg,lParam1,lParam2);
315 ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2);
316 TRACE(msvideo," -> 0x%08lx\n",ret);
320 DWORD VFWAPIV ICDrawBegin(
322 DWORD dwFlags,/* flags */
323 HPALETTE hpal, /* palette to draw with */
324 HWND hwnd, /* window to draw to */
325 HDC hdc, /* HDC to draw to */
326 INT xDst, /* destination rectangle */
330 LPBITMAPINFOHEADER lpbi, /* format of frame to draw */
331 INT xSrc, /* source rectangle */
335 DWORD dwRate, /* frames/second = (dwRate/dwScale) */
339 icdb.dwFlags = dwFlags;
352 icdb.dwRate = dwRate;
353 icdb.dwScale = dwScale;
354 return ICSendMessage(hic,ICM_DRAW_BEGIN,(LPARAM)&icdb,sizeof(icdb));
357 DWORD VFWAPIV ICDraw(
358 HIC hic,DWORD dwFlags,LPVOID lpFormat,LPVOID lpData,DWORD cbData,
363 icd.dwFlags = dwFlags;
364 icd.lpFormat = lpFormat;
368 return ICSendMessage(hic,ICM_DRAW,(LPARAM)&icd,sizeof(icd));
371 LRESULT WINAPI ICClose(HIC hic) {
372 WINE_HIC *whic = (WINE_HIC*)hic;
373 TRACE(msvideo,"(%d).\n",hic);
374 /* FIXME: correct? */
375 CloseDriver(whic->hdrv,0,0);
376 HeapFree(GetProcessHeap(),0,whic);
380 HANDLE /* HDRAWDIB */ WINAPI
381 DrawDibOpen( void ) {
382 FIXME(msvideo,"stub!\n");
386 BOOL VFWAPI DrawDibBegin(HANDLE /*HDRAWDIB*/ hdd,
390 LPBITMAPINFOHEADER lpbi,
394 FIXME(msvideo,"(%d,0x%lx,%d,%d,%p,%d,%d,0x%08lx), stub!\n",
395 hdd,(DWORD)hdc,dxDst,dyDst,lpbi,dxSrc,dySrc,(DWORD)wFlags
402 DrawDibSetPalette(HANDLE /*HDRAWDIB*/ hdd, HPALETTE hpal) {
403 FIXME(msvideo,"(%d,%d),stub!\n",hdd,hpal);
407 UINT VFWAPI DrawDibRealize(HANDLE /*HDRAWDIB*/ hdd, HDC hdc, BOOL fBackground) {
408 FIXME(msvideo,"(0x%08lx,0x%08lx,%d),stub!\n",(DWORD)hdd,(DWORD)hdc,fBackground);
413 HWND VFWAPIV MCIWndCreate (HWND hwndParent, HINSTANCE hInstance,
414 DWORD dwStyle,LPVOID szFile)
415 { FIXME(msvideo,"%x %x %lx %p\n",hwndParent, hInstance, dwStyle, szFile);
418 HWND VFWAPIV MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance,
419 DWORD dwStyle,LPCSTR szFile)
420 { FIXME(msvideo,"%x %x %lx %s\n",hwndParent, hInstance, dwStyle, szFile);
423 HWND VFWAPIV MCIWndCreateW(HWND hwndParent, HINSTANCE hInstance,
424 DWORD dwStyle,LPCWSTR szFile)
425 { FIXME(msvideo,"%x %x %lx %s\n",hwndParent, hInstance, dwStyle, debugstr_w(szFile));