Fixed returned type upon open.
[wine.git] / multimedia / mciavi.c
bloba108d7c30b8b26807f36cccb58719d867d9e32d2
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 /*
4 * Digital video MCI Wine Driver
6 * Copyright 1999 Eric POUECH
7 */
9 #include <string.h>
10 #include "winuser.h"
11 #include "mmddk.h"
12 #include "user.h"
13 #include "driver.h"
14 #include "digitalv.h"
15 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(mciavi)
19 typedef struct {
20 UINT wDevID;
21 int nUseCount; /* Incremented for each shared open */
22 BOOL16 fShareable; /* TRUE if first open was shareable */
23 WORD wNotifyDeviceID; /* MCI device ID with a pending notification */
24 HANDLE16 hCallback; /* Callback handle for pending notification */
25 HMMIO hFile; /* mmio file handle open as Element */
26 WORD wStatus; /* One of MCI_MODE_XXX */
27 MCI_OPEN_PARMSA openParms;
28 DWORD dwTimeFormat;
29 } WINE_MCIAVI;
31 /*======================================================================*
32 * MCI AVI implemantation *
33 *======================================================================*/
35 /**************************************************************************
36 * AVI_drvOpen [internal]
38 static DWORD AVI_drvOpen(LPSTR str, LPMCI_OPEN_DRIVER_PARMSA modp)
40 WINE_MCIAVI* wma = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MCIAVI));
42 if (!wma)
43 return 0;
45 wma->wDevID = modp->wDeviceID;
46 mciSetDriverData(wma->wDevID, (DWORD)wma);
47 modp->wCustomCommandTable = MCI_NO_COMMAND_TABLE;
48 modp->wType = MCI_DEVTYPE_DIGITAL_VIDEO;
49 return modp->wDeviceID;
52 /**************************************************************************
53 * MCIAVI_drvClose [internal]
55 static DWORD AVI_drvClose(DWORD dwDevID)
57 WINE_MCIAVI* wma = (WINE_MCIAVI*)mciGetDriverData(dwDevID);
59 if (wma) {
60 HeapFree(GetProcessHeap(), 0, wma);
61 mciSetDriverData(dwDevID, 0);
62 return 1;
64 return 0;
67 /**************************************************************************
68 * AVI_mciGetOpenDev [internal]
70 static WINE_MCIAVI* AVI_mciGetOpenDev(UINT16 wDevID)
72 WINE_MCIAVI* wma = (WINE_MCIAVI*)mciGetDriverData(wDevID);
74 if (wma == NULL || wma->nUseCount == 0) {
75 WARN("Invalid wDevID=%u\n", wDevID);
76 return 0;
78 return wma;
81 static DWORD AVI_mciStop(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms);
83 /***************************************************************************
84 * AVI_mciOpen [internal]
86 static DWORD AVI_mciOpen(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_OPEN_PARMSA lpParms)
88 WINE_MCIAVI* wma = (WINE_MCIAVI*)mciGetDriverData(wDevID);
90 TRACE("(%04x, %08lX, %p) : semi-stub\n", wDevID, dwFlags, lpParms);
92 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
93 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
95 if (wma->nUseCount > 0) {
96 /* The driver is already open on this channel */
97 /* If the driver was opened shareable before and this open specifies */
98 /* shareable then increment the use count */
99 if (wma->fShareable && (dwFlags & MCI_OPEN_SHAREABLE))
100 ++wma->nUseCount;
101 else
102 return MCIERR_MUST_USE_SHAREABLE;
103 } else {
104 wma->nUseCount = 1;
105 wma->fShareable = dwFlags & MCI_OPEN_SHAREABLE;
107 if (dwFlags & MCI_OPEN_ELEMENT) {
108 TRACE("MCI_OPEN_ELEMENT !\n");
109 /* return MCIERR_NO_ELEMENT_ALLOWED; */
112 wma->openParms.dwCallback = lpParms->dwCallback;
113 wma->openParms.wDeviceID = (WORD)lpParms->wDeviceID;
114 wma->openParms.lpstrDeviceType = lpParms->lpstrDeviceType;
115 wma->openParms.lpstrElementName = lpParms->lpstrElementName;
116 wma->openParms.lpstrAlias = lpParms->lpstrAlias;
118 wma->wNotifyDeviceID = lpParms->wDeviceID;
119 /* FIXME: do real open */
120 wma->wStatus = MCI_MODE_STOP;
121 wma->dwTimeFormat = MCI_FORMAT_TMSF;
123 return 0;
127 /***************************************************************************
128 * AVI_mciClose [internal]
130 static DWORD AVI_mciClose(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
132 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
134 TRACE("(%04x, %08lX, %p) : semi-stub\n", wDevID, dwFlags, lpParms);
136 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
138 if (wma->nUseCount == 1) {
139 AVI_mciStop(wDevID, 0, NULL);
140 /* FIXME: do real closing */
142 wma->nUseCount--;
143 return 0;
146 /***************************************************************************
147 * AVI_mciPlay [internal]
149 static DWORD AVI_mciPlay(UINT16 wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
151 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
153 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
155 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
156 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
158 wma->wStatus = MCI_MODE_PLAY;
159 if (lpParms && (dwFlags & MCI_NOTIFY)) {
160 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
161 mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
162 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
164 return 0;
167 /***************************************************************************
168 * AVI_mciRecord [internal]
170 static DWORD AVI_mciRecord(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_RECORD_PARMS lpParms)
172 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
174 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
176 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
177 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
179 wma->wStatus = MCI_MODE_RECORD;
180 return 0;
183 /***************************************************************************
184 * AVI_mciStop [internal]
186 static DWORD AVI_mciStop(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
188 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
190 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
192 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
193 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
195 wma->wStatus = MCI_MODE_STOP;
196 return 0;
199 /***************************************************************************
200 * AVI_mciPause [internal]
202 static DWORD AVI_mciPause(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
204 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
206 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
208 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
209 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
211 wma->wStatus = MCI_MODE_PAUSE;
212 return 0;
215 /***************************************************************************
216 * AVI_mciResume [internal]
218 static DWORD AVI_mciResume(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
220 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
222 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
224 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
225 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
227 wma->wStatus = MCI_MODE_PLAY;
228 return 0;
231 /***************************************************************************
232 * AVI_mciSeek [internal]
234 static DWORD AVI_mciSeek(UINT16 wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
236 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
238 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
240 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
241 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
243 return 0;
246 /***************************************************************************
247 * AVI_mciSet [internal]
249 static DWORD AVI_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_SET_PARMS lpParms)
251 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
253 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
255 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
256 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
258 if (dwFlags & MCI_SET_TIME_FORMAT) {
259 switch (lpParms->dwTimeFormat) {
260 case MCI_FORMAT_MILLISECONDS:
261 TRACE("MCI_FORMAT_MILLISECONDS !\n");
262 wma->dwTimeFormat = MCI_FORMAT_MILLISECONDS;
263 break;
264 case MCI_FORMAT_FRAMES:
265 TRACE("MCI_FORMAT_FRAMES !\n");
266 wma->dwTimeFormat = MCI_FORMAT_FRAMES;
267 break;
268 default:
269 WARN("Bad time format %lu!\n", lpParms->dwTimeFormat);
270 return MCIERR_BAD_TIME_FORMAT;
274 if (dwFlags & MCI_SET_DOOR_OPEN) {
275 TRACE("No support for door open !\n");
276 return MCIERR_UNSUPPORTED_FUNCTION;
278 if (dwFlags & MCI_SET_DOOR_CLOSED) {
279 TRACE("No support for door close !\n");
280 return MCIERR_UNSUPPORTED_FUNCTION;
282 if (dwFlags & MCI_SET_ON) {
283 char buffer[256];
285 strcpy(buffer, "MCI_SET_ON:");
287 if (dwFlags & MCI_SET_VIDEO) {
288 strncat(buffer, " video", sizeof(buffer));
290 if (dwFlags & MCI_SET_AUDIO) {
291 strncat(buffer, " audio", sizeof(buffer));
292 if (lpParms->dwAudio & MCI_SET_AUDIO_ALL)
293 strncat(buffer, " all", sizeof(buffer));
294 if (lpParms->dwAudio & MCI_SET_AUDIO_LEFT)
295 strncat(buffer, " left", sizeof(buffer));
296 if (lpParms->dwAudio & MCI_SET_AUDIO_RIGHT)
297 strncat(buffer, " right", sizeof(buffer));
299 if (dwFlags & MCI_DGV_SET_SEEK_EXACTLY) {
300 strncat(buffer, " seek_exactly", sizeof(buffer));
302 TRACE("%s\n", buffer);
305 if (dwFlags & MCI_SET_OFF) {
306 char buffer[256];
308 strcpy(buffer, "MCI_SET_OFF:");
309 if (dwFlags & MCI_SET_VIDEO) {
310 strncat(buffer, " video", sizeof(buffer));
312 if (dwFlags & MCI_SET_AUDIO) {
313 strncat(buffer, " audio", sizeof(buffer));
314 if (lpParms->dwAudio & MCI_SET_AUDIO_ALL)
315 strncat(buffer, " all", sizeof(buffer));
316 if (lpParms->dwAudio & MCI_SET_AUDIO_LEFT)
317 strncat(buffer, " left", sizeof(buffer));
318 if (lpParms->dwAudio & MCI_SET_AUDIO_RIGHT)
319 strncat(buffer, " right", sizeof(buffer));
321 if (dwFlags & MCI_DGV_SET_SEEK_EXACTLY) {
322 strncat(buffer, " seek_exactly", sizeof(buffer));
324 TRACE("%s\n", buffer);
326 if (dwFlags & MCI_DGV_SET_FILEFORMAT) {
327 LPSTR str = "save";
328 if (dwFlags & MCI_DGV_SET_STILL)
329 str = "capture";
331 switch (lpParms->dwFileFormat) {
332 case MCI_DGV_FF_AVI: TRACE("Setting file format (%s) to 'AVI'\n", str); break;
333 case MCI_DGV_FF_AVSS: TRACE("Setting file format (%s) to 'AVSS'\n", str); break;
334 case MCI_DGV_FF_DIB: TRACE("Setting file format (%s) to 'DIB'\n", str); break;
335 case MCI_DGV_FF_JFIF: TRACE("Setting file format (%s) to 'JFIF'\n", str); break;
336 case MCI_DGV_FF_JPEG: TRACE("Setting file format (%s) to 'JPEG'\n", str); break;
337 case MCI_DGV_FF_MPEG: TRACE("Setting file format (%s) to 'MPEG'\n", str); break;
338 case MCI_DGV_FF_RDIB: TRACE("Setting file format (%s) to 'RLE DIB'\n", str); break;
339 case MCI_DGV_FF_RJPEG: TRACE("Setting file format (%s) to 'RJPEG'\n", str); break;
340 default: TRACE("Setting unknown file format (%s): %ld\n", str, lpParms->dwFileFormat);
344 if (dwFlags & MCI_DGV_SET_SPEED) {
345 TRACE("Setting speed to %ld\n", lpParms->dwSpeed);
348 return 0;
351 /***************************************************************************
352 * AVI_mciStatus [internal]
354 static DWORD AVI_mciStatus(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_STATUS_PARMSA lpParms)
356 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
357 DWORD ret = 0;
359 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
361 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
362 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
364 if (dwFlags & MCI_STATUS_ITEM) {
365 switch (lpParms->dwItem) {
366 case MCI_STATUS_CURRENT_TRACK:
367 lpParms->dwReturn = 1;
368 TRACE("MCI_STATUS_CURRENT_TRACK => %lu\n", lpParms->dwReturn);
369 break;
370 case MCI_STATUS_LENGTH:
371 if (dwFlags & MCI_TRACK) {
372 /* lpParms->dwTrack contains track # */
373 lpParms->dwReturn = 0x1234;
374 } else {
375 lpParms->dwReturn = 0x4321;
377 TRACE("MCI_STATUS_LENGTH => %lu\n", lpParms->dwReturn);
378 break;
379 case MCI_STATUS_MODE:
380 lpParms->dwReturn = MAKEMCIRESOURCE(wma->wStatus, wma->wStatus);
381 ret = MCI_RESOURCE_RETURNED;
382 TRACE("MCI_STATUS_MODE => %u\n", LOWORD(lpParms->dwReturn));
383 break;
384 case MCI_STATUS_MEDIA_PRESENT:
385 TRACE("MCI_STATUS_MEDIA_PRESENT => TRUE\n");
386 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
387 ret = MCI_RESOURCE_RETURNED;
388 break;
389 case MCI_STATUS_NUMBER_OF_TRACKS:
390 lpParms->dwReturn = 3;
391 TRACE("MCI_STATUS_NUMBER_OF_TRACKS => %lu\n", lpParms->dwReturn);
392 break;
393 case MCI_STATUS_POSITION:
394 /* FIXME: do I need to use MCI_TRACK ? */
395 lpParms->dwReturn = 0x0123;
396 TRACE("MCI_STATUS_POSITION %s => %lu\n",
397 (dwFlags & MCI_STATUS_START) ? "start" : "current", lpParms->dwReturn);
398 break;
399 case MCI_STATUS_READY:
400 lpParms->dwReturn = (wma->wStatus == MCI_MODE_NOT_READY) ?
401 MAKEMCIRESOURCE(FALSE, MCI_FALSE) : MAKEMCIRESOURCE(TRUE, MCI_TRUE);
402 ret = MCI_RESOURCE_RETURNED;
403 TRACE("MCI_STATUS_READY = %u\n", LOWORD(lpParms->dwReturn));
404 break;
405 case MCI_STATUS_TIME_FORMAT:
406 lpParms->dwReturn = MAKEMCIRESOURCE(wma->dwTimeFormat, wma->dwTimeFormat);
407 TRACE("MCI_STATUS_TIME_FORMAT => %u\n", LOWORD(lpParms->dwReturn));
408 ret = MCI_RESOURCE_RETURNED;
409 break;
410 default:
411 FIXME("Unknowm command %08lX !\n", lpParms->dwItem);
412 return MCIERR_UNRECOGNIZED_COMMAND;
414 } else {
415 WARN("No Status-Item!\n");
416 return MCIERR_UNRECOGNIZED_COMMAND;
418 if (dwFlags & MCI_NOTIFY) {
419 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
420 mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
421 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
424 return ret;
427 /***************************************************************************
428 * AVI_mciGetDevCaps [internal]
430 static DWORD AVI_mciGetDevCaps(UINT16 wDevID, DWORD dwFlags, LPMCI_GETDEVCAPS_PARMS lpParms)
432 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
433 DWORD ret;
435 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
437 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
438 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
440 if (dwFlags & MCI_GETDEVCAPS_ITEM) {
441 switch (lpParms->dwItem) {
442 case MCI_GETDEVCAPS_DEVICE_TYPE:
443 TRACE("MCI_GETDEVCAPS_DEVICE_TYPE !\n");
444 lpParms->dwReturn = MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO, MCI_DEVTYPE_DIGITAL_VIDEO);
445 ret = MCI_RESOURCE_RETURNED;
446 break;
447 case MCI_GETDEVCAPS_HAS_AUDIO:
448 TRACE("MCI_GETDEVCAPS_HAS_AUDIO !\n");
449 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
450 ret = MCI_RESOURCE_RETURNED;
451 break;
452 case MCI_GETDEVCAPS_HAS_VIDEO:
453 TRACE("MCI_GETDEVCAPS_HAS_VIDEO !\n");
454 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
455 ret = MCI_RESOURCE_RETURNED;
456 break;
457 case MCI_GETDEVCAPS_USES_FILES:
458 TRACE("MCI_GETDEVCAPS_USES_FILES !\n");
459 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
460 ret = MCI_RESOURCE_RETURNED;
461 break;
462 case MCI_GETDEVCAPS_COMPOUND_DEVICE:
463 TRACE("MCI_GETDEVCAPS_COMPOUND_DEVICE !\n");
464 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
465 ret = MCI_RESOURCE_RETURNED;
466 break;
467 case MCI_GETDEVCAPS_CAN_EJECT:
468 TRACE("MCI_GETDEVCAPS_CAN_EJECT !\n");
469 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
470 ret = MCI_RESOURCE_RETURNED;
471 break;
472 case MCI_GETDEVCAPS_CAN_PLAY:
473 TRACE("MCI_GETDEVCAPS_CAN_PLAY !\n");
474 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
475 ret = MCI_RESOURCE_RETURNED;
476 break;
477 case MCI_GETDEVCAPS_CAN_RECORD:
478 TRACE("MCI_GETDEVCAPS_CAN_RECORD !\n");
479 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
480 ret = MCI_RESOURCE_RETURNED;
481 break;
482 case MCI_GETDEVCAPS_CAN_SAVE:
483 TRACE("MCI_GETDEVCAPS_CAN_SAVE !\n");
484 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
485 ret = MCI_RESOURCE_RETURNED;
486 break;
487 default:
488 FIXME("Unknown capability (%08lx) !\n", lpParms->dwItem);
489 return MCIERR_UNRECOGNIZED_COMMAND;
491 } else {
492 WARN("No GetDevCaps-Item !\n");
493 return MCIERR_UNRECOGNIZED_COMMAND;
495 return ret;
498 /***************************************************************************
499 * AVI_mciInfo [internal]
501 static DWORD AVI_mciInfo(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_INFO_PARMSA lpParms)
503 LPSTR str = 0;
504 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
506 TRACE("(%04X, %08lX, %p) : stub;\n", wDevID, dwFlags, lpParms);
508 if (lpParms == NULL || lpParms->lpstrReturn == NULL)
509 return MCIERR_NULL_PARAMETER_BLOCK;
510 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
512 TRACE("buf=%p, len=%lu\n", lpParms->lpstrReturn, lpParms->dwRetSize);
514 switch (dwFlags) {
515 case MCI_INFO_PRODUCT:
516 str = "Wine's AVI player";
517 break;
518 case MCI_INFO_FILE:
519 str = "";
520 break;
521 #if 0
522 /* FIXME: the following manifest constants are not defined in <WINE>/include/mmsystem.h */
523 case MCI_INFO_COPYRIGHT:
524 break;
525 case MCI_INFO_NAME:
526 break;
527 #endif
528 default:
529 WARN("Don't know this info command (%lu)\n", dwFlags);
530 return MCIERR_UNRECOGNIZED_COMMAND;
532 return MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, str);
535 /***************************************************************************
536 * AVI_mciPut [internal]
538 static DWORD AVI_mciPut(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_PUT_PARMS lpParms)
540 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
541 RECT rc;
542 char buffer[256];
544 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
546 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
547 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
549 if (dwFlags & MCI_DGV_RECT) {
550 rc = lpParms->rc;
551 } else {
552 SetRectEmpty(&rc);
555 *buffer = 0;
556 if (dwFlags & MCI_DGV_PUT_CLIENT) {
557 strncat(buffer, "PUT_CLIENT", sizeof(buffer));
559 if (dwFlags & MCI_DGV_PUT_DESTINATION) {
560 strncat(buffer, "PUT_DESTINATION", sizeof(buffer));
562 if (dwFlags & MCI_DGV_PUT_FRAME) {
563 strncat(buffer, "PUT_FRAME", sizeof(buffer));
565 if (dwFlags & MCI_DGV_PUT_SOURCE) {
566 strncat(buffer, "PUT_SOURCE", sizeof(buffer));
568 if (dwFlags & MCI_DGV_PUT_VIDEO) {
569 strncat(buffer, "PUT_VIDEO", sizeof(buffer));
571 if (dwFlags & MCI_DGV_PUT_WINDOW) {
572 strncat(buffer, "PUT_WINDOW", sizeof(buffer));
574 TRACE("%s (%d,%d,%d,%d)\n", buffer, rc.left, rc.top, rc.right, rc.bottom);
576 return 0;
579 /***************************************************************************
580 * AVI_mciWindow [internal]
582 static DWORD AVI_mciWindow(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_WINDOW_PARMSA lpParms)
584 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
586 TRACE("(%04x, %08lX, %p) : stub\n", wDevID, dwFlags, lpParms);
588 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
589 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
591 if (dwFlags & MCI_DGV_WINDOW_HWND) {
592 TRACE("Setting hWnd to %08lx\n", (DWORD)lpParms->hWnd);
594 if (dwFlags & MCI_DGV_WINDOW_STATE) {
595 TRACE("Setting nCmdShow to %d\n", lpParms->nCmdShow);
597 if (dwFlags & MCI_DGV_WINDOW_TEXT) {
598 TRACE("Setting caption to '%s'\n", lpParms->lpstrText);
601 return 0;
604 /*****************************************************************************
605 * AVI_mciLoad [internal]
607 static DWORD AVI_mciLoad(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_LOAD_PARMSA lpParms)
609 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
611 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
613 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
614 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
616 return 0;
619 /******************************************************************************
620 * AVI_mciSave [internal]
622 static DWORD AVI_mciSave(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_SAVE_PARMSA lpParms)
624 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
626 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
628 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
629 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
631 return 0;
634 /******************************************************************************
635 * AVI_mciFreeze [internal]
637 static DWORD AVI_mciFreeze(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
639 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
641 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
643 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
644 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
646 return 0;
649 /******************************************************************************
650 * AVI_mciRealize [internal]
652 static DWORD AVI_mciRealize(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
654 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
656 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
658 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
659 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
661 return 0;
664 /******************************************************************************
665 * AVI_mciUnFreeze [internal]
667 static DWORD AVI_mciUnFreeze(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
669 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
671 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
673 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
674 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
676 return 0;
679 /******************************************************************************
680 * AVI_mciUpdate [internal]
682 static DWORD AVI_mciUpdate(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_UPDATE_PARMS lpParms)
684 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
686 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
688 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
689 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
691 return 0;
694 /******************************************************************************
695 * AVI_mciWhere [internal]
697 static DWORD AVI_mciWhere(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
699 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
701 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
703 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
704 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
706 return 0;
709 /******************************************************************************
710 * AVI_mciStep [internal]
712 static DWORD AVI_mciStep(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_STEP_PARMS lpParms)
714 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
716 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
718 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
719 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
721 return 0;
724 /******************************************************************************
725 * AVI_mciCopy [internal]
727 static DWORD AVI_mciCopy(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_COPY_PARMS lpParms)
729 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
731 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
733 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
734 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
736 return 0;
739 /******************************************************************************
740 * AVI_mciCut [internal]
742 static DWORD AVI_mciCut(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_CUT_PARMS lpParms)
744 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
746 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
748 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
749 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
751 return 0;
754 /******************************************************************************
755 * AVI_mciDelete [internal]
757 static DWORD AVI_mciDelete(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_DELETE_PARMS lpParms)
759 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
761 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
763 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
764 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
766 return 0;
769 /******************************************************************************
770 * AVI_mciPaste [internal]
772 static DWORD AVI_mciPaste(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_PASTE_PARMS lpParms)
774 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
776 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
778 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
779 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
781 return 0;
784 /******************************************************************************
785 * AVI_mciCue [internal]
787 static DWORD AVI_mciCue(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_CUE_PARMS lpParms)
789 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
791 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
793 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
794 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
796 return 0;
799 /******************************************************************************
800 * AVI_mciCapture [internal]
802 static DWORD AVI_mciCapture(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_CAPTURE_PARMSA lpParms)
804 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
806 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
808 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
809 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
811 return 0;
814 /******************************************************************************
815 * AVI_mciMonitor [internal]
817 static DWORD AVI_mciMonitor(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_MONITOR_PARMS lpParms)
819 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
821 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
823 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
824 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
826 return 0;
829 /******************************************************************************
830 * AVI_mciReserve [internal]
832 static DWORD AVI_mciReserve(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_RESERVE_PARMSA lpParms)
834 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
836 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
838 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
839 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
841 return 0;
844 /******************************************************************************
845 * AVI_mciSetAudio [internal]
847 static DWORD AVI_mciSetAudio(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_SETAUDIO_PARMSA lpParms)
849 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
851 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
853 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
854 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
856 return 0;
859 /******************************************************************************
860 * AVI_mciSignal [internal]
862 static DWORD AVI_mciSignal(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_SIGNAL_PARMS lpParms)
864 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
866 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
868 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
869 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
871 return 0;
874 /******************************************************************************
875 * AVI_mciSetVideo [internal]
877 static DWORD AVI_mciSetVideo(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_SETVIDEO_PARMSA lpParms)
879 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
881 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
883 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
884 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
886 return 0;
889 /******************************************************************************
890 * AVI_mciQuality [internal]
892 static DWORD AVI_mciQuality(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_QUALITY_PARMSA lpParms)
894 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
896 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
898 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
899 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
901 return 0;
904 /******************************************************************************
905 * AVI_mciList [internal]
907 static DWORD AVI_mciList(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_LIST_PARMSA lpParms)
909 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
911 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
913 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
914 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
916 return 0;
919 /******************************************************************************
920 * AVI_mciUndo [internal]
922 static DWORD AVI_mciUndo(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
924 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
926 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
928 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
929 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
931 return 0;
934 /******************************************************************************
935 * AVI_mciConfigure [internal]
937 static DWORD AVI_mciConfigure(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
939 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
941 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
943 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
944 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
946 return 0;
949 /******************************************************************************
950 * AVI_mciRestore [internal]
952 static DWORD AVI_mciRestore(UINT16 wDevID, DWORD dwFlags, LPMCI_DGV_RESTORE_PARMSA lpParms)
954 WINE_MCIAVI* wma = AVI_mciGetOpenDev(wDevID);
956 TRACE("(%04x, %08lx, %p) : stub\n", wDevID, dwFlags, lpParms);
958 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
959 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
961 return 0;
964 /*======================================================================*
965 * MCI AVI entry points *
966 *======================================================================*/
968 /**************************************************************************
969 * MCIAVI_DriverProc [sample driver]
971 LONG CALLBACK MCIAVI_DriverProc(DWORD dwDevID, HDRVR hDriv, DWORD wMsg,
972 DWORD dwParam1, DWORD dwParam2)
974 switch (wMsg) {
975 case DRV_LOAD: return 1;
976 case DRV_FREE: return 1;
977 case DRV_OPEN: return AVI_drvOpen((LPSTR)dwParam1, (LPMCI_OPEN_DRIVER_PARMSA)dwParam2);
978 case DRV_CLOSE: return AVI_drvClose(dwDevID);
979 case DRV_ENABLE: return 1;
980 case DRV_DISABLE: return 1;
981 case DRV_QUERYCONFIGURE: return 1;
982 case DRV_CONFIGURE: MessageBoxA(0, "Sample AVI Wine Driver !", "MM-Wine Driver", MB_OK); return 1;
983 case DRV_INSTALL: return DRVCNF_RESTART;
984 case DRV_REMOVE: return DRVCNF_RESTART;
986 case MCI_OPEN_DRIVER: return AVI_mciOpen (dwDevID, dwParam1, (LPMCI_DGV_OPEN_PARMSA) dwParam2);
987 case MCI_CLOSE_DRIVER: return AVI_mciClose (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
988 case MCI_PLAY: return AVI_mciPlay (dwDevID, dwParam1, (LPMCI_PLAY_PARMS) dwParam2);
989 case MCI_RECORD: return AVI_mciRecord (dwDevID, dwParam1, (LPMCI_DGV_RECORD_PARMS) dwParam2);
990 case MCI_STOP: return AVI_mciStop (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
991 case MCI_SET: return AVI_mciSet (dwDevID, dwParam1, (LPMCI_DGV_SET_PARMS) dwParam2);
992 case MCI_PAUSE: return AVI_mciPause (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
993 case MCI_RESUME: return AVI_mciResume (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
994 case MCI_STATUS: return AVI_mciStatus (dwDevID, dwParam1, (LPMCI_DGV_STATUS_PARMSA) dwParam2);
995 case MCI_GETDEVCAPS: return AVI_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS) dwParam2);
996 case MCI_INFO: return AVI_mciInfo (dwDevID, dwParam1, (LPMCI_DGV_INFO_PARMSA) dwParam2);
997 case MCI_SEEK: return AVI_mciSeek (dwDevID, dwParam1, (LPMCI_SEEK_PARMS) dwParam2);
998 case MCI_PUT: return AVI_mciPut (dwDevID, dwParam1, (LPMCI_DGV_PUT_PARMS) dwParam2);
999 case MCI_WINDOW: return AVI_mciWindow (dwDevID, dwParam1, (LPMCI_DGV_WINDOW_PARMSA) dwParam2);
1000 case MCI_LOAD: return AVI_mciLoad (dwDevID, dwParam1, (LPMCI_DGV_LOAD_PARMSA) dwParam2);
1001 case MCI_SAVE: return AVI_mciSave (dwDevID, dwParam1, (LPMCI_DGV_SAVE_PARMSA) dwParam2);
1002 case MCI_FREEZE: return AVI_mciFreeze (dwDevID, dwParam1, (LPMCI_DGV_RECT_PARMS) dwParam2);
1003 case MCI_REALIZE: return AVI_mciRealize (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
1004 case MCI_UNFREEZE: return AVI_mciUnFreeze (dwDevID, dwParam1, (LPMCI_DGV_RECT_PARMS) dwParam2);
1005 case MCI_UPDATE: return AVI_mciUpdate (dwDevID, dwParam1, (LPMCI_DGV_UPDATE_PARMS) dwParam2);
1006 case MCI_WHERE: return AVI_mciWhere (dwDevID, dwParam1, (LPMCI_DGV_RECT_PARMS) dwParam2);
1007 case MCI_STEP: return AVI_mciStep (dwDevID, dwParam1, (LPMCI_DGV_STEP_PARMS) dwParam2);
1008 case MCI_COPY: return AVI_mciCopy (dwDevID, dwParam1, (LPMCI_DGV_COPY_PARMS) dwParam2);
1009 case MCI_CUT: return AVI_mciCut (dwDevID, dwParam1, (LPMCI_DGV_CUT_PARMS) dwParam2);
1010 case MCI_DELETE: return AVI_mciDelete (dwDevID, dwParam1, (LPMCI_DGV_DELETE_PARMS) dwParam2);
1011 case MCI_PASTE: return AVI_mciPaste (dwDevID, dwParam1, (LPMCI_DGV_PASTE_PARMS) dwParam2);
1012 case MCI_CUE: return AVI_mciCue (dwDevID, dwParam1, (LPMCI_DGV_CUE_PARMS) dwParam2);
1013 /* Digital Video specific */
1014 case MCI_CAPTURE: return AVI_mciCapture (dwDevID, dwParam1, (LPMCI_DGV_CAPTURE_PARMSA) dwParam2);
1015 case MCI_MONITOR: return AVI_mciMonitor (dwDevID, dwParam1, (LPMCI_DGV_MONITOR_PARMS) dwParam2);
1016 case MCI_RESERVE: return AVI_mciReserve (dwDevID, dwParam1, (LPMCI_DGV_RESERVE_PARMSA) dwParam2);
1017 case MCI_SETAUDIO: return AVI_mciSetAudio (dwDevID, dwParam1, (LPMCI_DGV_SETAUDIO_PARMSA) dwParam2);
1018 case MCI_SIGNAL: return AVI_mciSignal (dwDevID, dwParam1, (LPMCI_DGV_SIGNAL_PARMS) dwParam2);
1019 case MCI_SETVIDEO: return AVI_mciSetVideo (dwDevID, dwParam1, (LPMCI_DGV_SETVIDEO_PARMSA) dwParam2);
1020 case MCI_QUALITY: return AVI_mciQuality (dwDevID, dwParam1, (LPMCI_DGV_QUALITY_PARMSA) dwParam2);
1021 case MCI_LIST: return AVI_mciList (dwDevID, dwParam1, (LPMCI_DGV_LIST_PARMSA) dwParam2);
1022 case MCI_UNDO: return AVI_mciUndo (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
1023 case MCI_CONFIGURE: return AVI_mciConfigure (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
1024 case MCI_RESTORE: return AVI_mciRestore (dwDevID, dwParam1, (LPMCI_DGV_RESTORE_PARMSA) dwParam2);
1026 case MCI_SPIN:
1027 case MCI_ESCAPE:
1028 WARN("Unsupported command=%s\n", MCI_MessageToString(wMsg));
1029 break;
1030 case MCI_OPEN:
1031 case MCI_CLOSE:
1032 FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
1033 break;
1034 default:
1035 TRACE("Sending msg=%s to default driver proc\n", MCI_MessageToString(wMsg));
1036 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
1038 return MCIERR_UNRECOGNIZED_COMMAND;