shell32: Replaced drive.ico with a Tango compliant icon.
[wine.git] / dlls / mciqtz32 / mciqtz.c
blobc826de17633fe4772ae4910ca684b2272b435d46
1 /*
2 * DirectShow MCI Driver
4 * Copyright 2009 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "mmddk.h"
26 #include "wine/debug.h"
27 #include "mciqtz_private.h"
28 #include "digitalv.h"
29 #include "wownt32.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(mciqtz);
33 static DWORD MCIQTZ_mciClose(UINT, DWORD, LPMCI_GENERIC_PARMS);
34 static DWORD MCIQTZ_mciStop(UINT, DWORD, LPMCI_GENERIC_PARMS);
36 /*======================================================================*
37 * MCI QTZ implementation *
38 *======================================================================*/
40 HINSTANCE MCIQTZ_hInstance = 0;
42 /***********************************************************************
43 * DllMain (MCIQTZ.0)
45 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
47 switch (fdwReason) {
48 case DLL_PROCESS_ATTACH:
49 DisableThreadLibraryCalls(hInstDLL);
50 MCIQTZ_hInstance = hInstDLL;
51 break;
53 return TRUE;
56 /**************************************************************************
57 * MCIQTZ_mciGetOpenDev [internal]
59 static WINE_MCIQTZ* MCIQTZ_mciGetOpenDev(UINT wDevID)
61 WINE_MCIQTZ* wma = (WINE_MCIQTZ*)mciGetDriverData(wDevID);
63 if (!wma) {
64 WARN("Invalid wDevID=%u\n", wDevID);
65 return NULL;
67 return wma;
70 /**************************************************************************
71 * MCIQTZ_drvOpen [internal]
73 static DWORD MCIQTZ_drvOpen(LPCWSTR str, LPMCI_OPEN_DRIVER_PARMSW modp)
75 WINE_MCIQTZ* wma;
77 TRACE("(%s, %p)\n", debugstr_w(str), modp);
79 /* session instance */
80 if (!modp)
81 return 0xFFFFFFFF;
83 wma = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MCIQTZ));
84 if (!wma)
85 return 0;
87 wma->wDevID = modp->wDeviceID;
88 mciSetDriverData(wma->wDevID, (DWORD_PTR)wma);
90 return modp->wDeviceID;
93 /**************************************************************************
94 * MCIQTZ_drvClose [internal]
96 static DWORD MCIQTZ_drvClose(DWORD dwDevID)
98 WINE_MCIQTZ* wma;
100 TRACE("(%04x)\n", dwDevID);
102 wma = MCIQTZ_mciGetOpenDev(dwDevID);
104 if (wma) {
105 /* finish all outstanding things */
106 MCIQTZ_mciClose(dwDevID, MCI_WAIT, NULL);
108 mciSetDriverData(dwDevID, 0);
109 HeapFree(GetProcessHeap(), 0, wma);
110 return 1;
113 return (dwDevID == 0xFFFFFFFF) ? 1 : 0;
116 /**************************************************************************
117 * MCIQTZ_drvConfigure [internal]
119 static DWORD MCIQTZ_drvConfigure(DWORD dwDevID)
121 WINE_MCIQTZ* wma;
123 TRACE("(%04x)\n", dwDevID);
125 wma = MCIQTZ_mciGetOpenDev(dwDevID);
126 if (!wma)
127 return 0;
129 MCIQTZ_mciStop(dwDevID, MCI_WAIT, NULL);
131 MessageBoxA(0, "Sample QTZ Wine Driver !", "MM-Wine Driver", MB_OK);
133 return 1;
136 /***************************************************************************
137 * MCIQTZ_mciOpen [internal]
139 static DWORD MCIQTZ_mciOpen(UINT wDevID, DWORD dwFlags,
140 LPMCI_DGV_OPEN_PARMSW lpOpenParms)
142 WINE_MCIQTZ* wma;
143 HRESULT hr;
145 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpOpenParms);
147 if (!lpOpenParms)
148 return MCIERR_NULL_PARAMETER_BLOCK;
150 wma = MCIQTZ_mciGetOpenDev(wDevID);
151 if (!wma)
152 return MCIERR_INVALID_DEVICE_ID;
154 MCIQTZ_mciStop(wDevID, MCI_WAIT, NULL);
156 hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
157 wma->uninit = SUCCEEDED(hr);
159 hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (LPVOID*)&wma->pgraph);
160 if (FAILED(hr)) {
161 TRACE("Cannot create filtergraph (hr = %x)\n", hr);
162 goto err;
165 hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaControl, (LPVOID*)&wma->pmctrl);
166 if (FAILED(hr)) {
167 TRACE("Cannot get IMediaControl interface (hr = %x)\n", hr);
168 goto err;
171 if (!(dwFlags & MCI_OPEN_ELEMENT) || (dwFlags & MCI_OPEN_ELEMENT_ID)) {
172 TRACE("Wrong dwFlags %x\n", dwFlags);
173 goto err;
176 if (!lpOpenParms->lpstrElementName || !lpOpenParms->lpstrElementName[0]) {
177 TRACE("Invalid filename specified\n");
178 goto err;
181 TRACE("Open file %s\n", debugstr_w(lpOpenParms->lpstrElementName));
183 hr = IGraphBuilder_RenderFile(wma->pgraph, lpOpenParms->lpstrElementName, NULL);
184 if (FAILED(hr)) {
185 TRACE("Cannot render file (hr = %x)\n", hr);
186 goto err;
189 wma->opened = TRUE;
191 return 0;
193 err:
194 if (wma->pgraph)
195 IGraphBuilder_Release(wma->pgraph);
196 wma->pgraph = NULL;
197 if (wma->pmctrl)
198 IMediaControl_Release(wma->pmctrl);
199 wma->pmctrl = NULL;
201 if (wma->uninit)
202 CoUninitialize();
204 return MCIERR_INTERNAL;
207 /***************************************************************************
208 * MCIQTZ_mciClose [internal]
210 static DWORD MCIQTZ_mciClose(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
212 WINE_MCIQTZ* wma;
214 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
216 wma = MCIQTZ_mciGetOpenDev(wDevID);
217 if (!wma)
218 return MCIERR_INVALID_DEVICE_ID;
220 MCIQTZ_mciStop(wDevID, MCI_WAIT, NULL);
222 if (wma->opened) {
223 IGraphBuilder_Release(wma->pgraph);
224 IMediaControl_Release(wma->pmctrl);
225 if (wma->uninit)
226 CoUninitialize();
227 wma->opened = FALSE;
230 return 0;
233 /***************************************************************************
234 * MCIQTZ_mciPlay [internal]
236 static DWORD MCIQTZ_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
238 WINE_MCIQTZ* wma;
239 HRESULT hr;
241 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
243 if (!lpParms)
244 return MCIERR_NULL_PARAMETER_BLOCK;
246 wma = MCIQTZ_mciGetOpenDev(wDevID);
247 if (!wma)
248 return MCIERR_INVALID_DEVICE_ID;
250 hr = IMediaControl_Run(wma->pmctrl);
251 if (FAILED(hr)) {
252 TRACE("Cannot run filtergraph (hr = %x)\n", hr);
253 return MCIERR_INTERNAL;
256 wma->started = TRUE;
258 return 0;
261 /***************************************************************************
262 * MCIQTZ_mciSeek [internal]
264 static DWORD MCIQTZ_mciSeek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
266 WINE_MCIQTZ* wma;
267 HRESULT hr;
268 IMediaPosition* pmpos;
269 LONGLONG newpos;
271 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
273 if (!lpParms)
274 return MCIERR_NULL_PARAMETER_BLOCK;
276 wma = MCIQTZ_mciGetOpenDev(wDevID);
277 if (!wma)
278 return MCIERR_INVALID_DEVICE_ID;
280 MCIQTZ_mciStop(wDevID, MCI_WAIT, NULL);
282 if (dwFlags & MCI_SEEK_TO_START) {
283 newpos = 0;
284 } else if (dwFlags & MCI_SEEK_TO_END) {
285 FIXME("MCI_SEEK_TO_END not implemented yet\n");
286 return MCIERR_INTERNAL;
287 } else if (dwFlags & MCI_TO) {
288 FIXME("MCI_TO not implemented yet\n");
289 return MCIERR_INTERNAL;
290 } else {
291 WARN("dwFlag doesn't tell where to seek to...\n");
292 return MCIERR_MISSING_PARAMETER;
295 hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaPosition, (LPVOID*)&pmpos);
296 if (FAILED(hr)) {
297 FIXME("Cannot get IMediaPostion interface (hr = %x)\n", hr);
298 return MCIERR_INTERNAL;
301 hr = IMediaPosition_put_CurrentPosition(pmpos, newpos);
302 if (FAILED(hr)) {
303 FIXME("Cannot set position (hr = %x)\n", hr);
304 IMediaPosition_Release(pmpos);
305 return MCIERR_INTERNAL;
308 IMediaPosition_Release(pmpos);
310 if (dwFlags & MCI_NOTIFY)
311 mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), wDevID, MCI_NOTIFY_SUCCESSFUL);
313 return 0;
316 /***************************************************************************
317 * MCIQTZ_mciStop [internal]
319 static DWORD MCIQTZ_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
321 WINE_MCIQTZ* wma;
322 HRESULT hr;
324 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
326 wma = MCIQTZ_mciGetOpenDev(wDevID);
327 if (!wma)
328 return MCIERR_INVALID_DEVICE_ID;
330 if (!wma->started)
331 return 0;
333 hr = IMediaControl_Stop(wma->pmctrl);
334 if (FAILED(hr)) {
335 TRACE("Cannot stop filtergraph (hr = %x)\n", hr);
336 return MCIERR_INTERNAL;
339 wma->started = FALSE;
341 return 0;
344 /***************************************************************************
345 * MCIQTZ_mciGetDevCaps [internal]
347 static DWORD MCIQTZ_mciGetDevCaps(UINT wDevID, DWORD dwFlags, LPMCI_GETDEVCAPS_PARMS lpParms)
349 WINE_MCIQTZ* wma;
351 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
353 if (!lpParms)
354 return MCIERR_NULL_PARAMETER_BLOCK;
356 wma = MCIQTZ_mciGetOpenDev(wDevID);
357 if (!wma)
358 return MCIERR_INVALID_DEVICE_ID;
360 if (!(dwFlags & MCI_GETDEVCAPS_ITEM))
361 return MCIERR_MISSING_PARAMETER;
363 switch (lpParms->dwItem) {
364 case MCI_GETDEVCAPS_CAN_RECORD:
365 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
366 TRACE("MCI_GETDEVCAPS_CAN_RECORD = %08x\n", lpParms->dwReturn);
367 break;
368 case MCI_GETDEVCAPS_HAS_AUDIO:
369 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
370 TRACE("MCI_GETDEVCAPS_HAS_AUDIO = %08x\n", lpParms->dwReturn);
371 break;
372 case MCI_GETDEVCAPS_HAS_VIDEO:
373 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
374 TRACE("MCI_GETDEVCAPS_HAS_VIDEO = %08x\n", lpParms->dwReturn);
375 break;
376 case MCI_GETDEVCAPS_DEVICE_TYPE:
377 lpParms->dwReturn = MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO, MCI_DEVTYPE_DIGITAL_VIDEO);
378 TRACE("MCI_GETDEVCAPS_DEVICE_TYPE = %08x\n", lpParms->dwReturn);
379 break;
380 case MCI_GETDEVCAPS_USES_FILES:
381 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
382 TRACE("MCI_GETDEVCAPS_USES_FILES = %08x\n", lpParms->dwReturn);
383 break;
384 case MCI_GETDEVCAPS_COMPOUND_DEVICE:
385 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
386 TRACE("MCI_GETDEVCAPS_COMPOUND_DEVICE = %08x\n", lpParms->dwReturn);
387 break;
388 case MCI_GETDEVCAPS_CAN_EJECT:
389 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
390 TRACE("MCI_GETDEVCAPS_EJECT = %08x\n", lpParms->dwReturn);
391 break;
392 case MCI_GETDEVCAPS_CAN_PLAY:
393 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
394 TRACE("MCI_GETDEVCAPS_CAN_PLAY = %08x\n", lpParms->dwReturn);
395 break;
396 case MCI_GETDEVCAPS_CAN_SAVE:
397 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
398 TRACE("MCI_GETDEVCAPS_CAN_SAVE = %08x\n", lpParms->dwReturn);
399 break;
400 case MCI_DGV_GETDEVCAPS_CAN_REVERSE:
401 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
402 TRACE("MCI_DGV_GETDEVCAPS_CAN_REVERSE = %08x\n", lpParms->dwReturn);
403 break;
404 case MCI_DGV_GETDEVCAPS_CAN_STRETCH:
405 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE); /* FIXME */
406 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH = %08x\n", lpParms->dwReturn);
407 break;
408 case MCI_DGV_GETDEVCAPS_CAN_LOCK:
409 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
410 TRACE("MCI_DGV_GETDEVCAPS_CAN_LOCK = %08x\n", lpParms->dwReturn);
411 break;
412 case MCI_DGV_GETDEVCAPS_CAN_FREEZE:
413 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
414 TRACE("MCI_DGV_GETDEVCAPS_CAN_FREEZE = %08x\n", lpParms->dwReturn);
415 break;
416 case MCI_DGV_GETDEVCAPS_CAN_STR_IN:
417 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
418 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH_INPUT = %08x\n", lpParms->dwReturn);
419 break;
420 case MCI_DGV_GETDEVCAPS_HAS_STILL:
421 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
422 TRACE("MCI_DGV_GETDEVCAPS_HAS_STILL = %08x\n", lpParms->dwReturn);
423 break;
424 case MCI_DGV_GETDEVCAPS_CAN_TEST:
425 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE); /* FIXME */
426 TRACE("MCI_DGV_GETDEVCAPS_CAN_TEST = %08x\n", lpParms->dwReturn);
427 break;
428 case MCI_DGV_GETDEVCAPS_MAX_WINDOWS:
429 lpParms->dwReturn = 1;
430 TRACE("MCI_DGV_GETDEVCAPS_MAX_WINDOWS = %u\n", lpParms->dwReturn);
431 return 0;
432 default:
433 WARN("Unknown capability %08x\n", lpParms->dwItem);
434 /* Fall through */
435 case MCI_DGV_GETDEVCAPS_MAXIMUM_RATE: /* unknown to w2k */
436 case MCI_DGV_GETDEVCAPS_MINIMUM_RATE: /* unknown to w2k */
437 return MCIERR_UNSUPPORTED_FUNCTION;
440 return MCI_RESOURCE_RETURNED;
443 /***************************************************************************
444 * MCIQTZ_mciSet [internal]
446 static DWORD MCIQTZ_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_DGV_SET_PARMS lpParms)
448 WINE_MCIQTZ* wma;
450 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
452 if (!lpParms)
453 return MCIERR_NULL_PARAMETER_BLOCK;
455 wma = MCIQTZ_mciGetOpenDev(wDevID);
456 if (!wma)
457 return MCIERR_INVALID_DEVICE_ID;
459 if (dwFlags & MCI_SET_TIME_FORMAT) {
460 switch (lpParms->dwTimeFormat) {
461 case MCI_FORMAT_MILLISECONDS:
462 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_MILLISECONDS\n");
463 wma->time_format = MCI_FORMAT_MILLISECONDS;
464 break;
465 case MCI_FORMAT_FRAMES:
466 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_FRAMES\n");
467 wma->time_format = MCI_FORMAT_FRAMES;
468 break;
469 default:
470 WARN("Bad time format %u\n", lpParms->dwTimeFormat);
471 return MCIERR_BAD_TIME_FORMAT;
475 if (dwFlags & MCI_SET_DOOR_OPEN)
476 FIXME("MCI_SET_DOOR_OPEN not implemented yet\n");
477 if (dwFlags & MCI_SET_DOOR_CLOSED)
478 FIXME("MCI_SET_DOOR_CLOSED not implemented yet\n");
479 if (dwFlags & MCI_SET_AUDIO)
480 FIXME("MCI_SET_AUDIO not implemented yet\n");
481 if (dwFlags & MCI_SET_VIDEO)
482 FIXME("MCI_SET_VIDEO not implemented yet\n");
483 if (dwFlags & MCI_SET_ON)
484 FIXME("MCI_SET_ON not implemented yet\n");
485 if (dwFlags & MCI_SET_OFF)
486 FIXME("MCI_SET_OFF not implemented yet\n");
487 if (dwFlags & MCI_SET_AUDIO_LEFT)
488 FIXME("MCI_SET_AUDIO_LEFT not implemented yet\n");
489 if (dwFlags & MCI_SET_AUDIO_RIGHT)
490 FIXME("MCI_SET_AUDIO_RIGHT not implemented yet\n");
492 if (dwFlags & ~0x7f03 /* All MCI_SET flags mask */)
493 ERR("Unknown flags %08x\n", dwFlags & ~0x7f03);
495 return 0;
498 /***************************************************************************
499 * MCIQTZ_mciStatus [internal]
501 static DWORD MCIQTZ_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_DGV_STATUS_PARMSW lpParms)
503 WINE_MCIQTZ* wma;
505 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
507 if (!lpParms)
508 return MCIERR_NULL_PARAMETER_BLOCK;
510 wma = MCIQTZ_mciGetOpenDev(wDevID);
511 if (!wma)
512 return MCIERR_INVALID_DEVICE_ID;
514 if (!(dwFlags & MCI_STATUS_ITEM)) {
515 WARN("No status item specified\n");
516 return MCIERR_UNRECOGNIZED_COMMAND;
519 switch (lpParms->dwItem) {
520 case MCI_STATUS_LENGTH:
521 FIXME("MCI_STATUS_LENGTH not implemented yet\n");
522 return MCIERR_UNRECOGNIZED_COMMAND;
523 case MCI_STATUS_POSITION:
525 HRESULT hr;
526 REFTIME curpos;
527 IMediaPosition* pmpos;
529 hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaPosition, (LPVOID*)&pmpos);
530 if (FAILED(hr)) {
531 FIXME("Cannot get IMediaPostion interface (hr = %x)\n", hr);
532 return MCIERR_INTERNAL;
535 hr = IMediaPosition_get_CurrentPosition(pmpos, &curpos);
536 if (FAILED(hr)) {
537 FIXME("Cannot get position (hr = %x)\n", hr);
538 IMediaPosition_Release(pmpos);
539 return MCIERR_INTERNAL;
542 IMediaPosition_Release(pmpos);
543 lpParms->dwReturn = curpos / 10000;
545 break;
547 case MCI_STATUS_NUMBER_OF_TRACKS:
548 FIXME("MCI_STATUS_NUMBER_OF_TRACKS not implemented yet\n");
549 return MCIERR_UNRECOGNIZED_COMMAND;
550 case MCI_STATUS_MODE:
551 FIXME("MCI_STATUS_MODE not implemented yet\n");
552 return MCIERR_UNRECOGNIZED_COMMAND;
553 case MCI_STATUS_MEDIA_PRESENT:
554 FIXME("MCI_STATUS_MEDIA_PRESENT not implemented yet\n");
555 return MCIERR_UNRECOGNIZED_COMMAND;
556 case MCI_STATUS_TIME_FORMAT:
557 FIXME("MCI_STATUS_TIME_FORMAT not implemented yet\n");
558 return MCIERR_UNRECOGNIZED_COMMAND;
559 case MCI_STATUS_READY:
560 FIXME("MCI_STATUS_READY not implemented yet\n");
561 return MCIERR_UNRECOGNIZED_COMMAND;
562 case MCI_STATUS_CURRENT_TRACK:
563 FIXME("MCI_STATUS_CURRENT_TRACK not implemented yet\n");
564 return MCIERR_UNRECOGNIZED_COMMAND;
565 default:
566 FIXME("Unknown command %08X\n", lpParms->dwItem);
567 return MCIERR_UNRECOGNIZED_COMMAND;
570 if (dwFlags & MCI_NOTIFY)
571 mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)), wDevID, MCI_NOTIFY_SUCCESSFUL);
573 return 0;
576 /***************************************************************************
577 * MCIQTZ_mciWhere [internal]
579 static DWORD MCIQTZ_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
581 WINE_MCIQTZ* wma;
582 IVideoWindow* pVideoWindow;
583 HRESULT hr;
584 HWND hWnd;
585 RECT rc;
587 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
589 if (!lpParms)
590 return MCIERR_NULL_PARAMETER_BLOCK;
592 wma = MCIQTZ_mciGetOpenDev(wDevID);
593 if (!wma)
594 return MCIERR_INVALID_DEVICE_ID;
596 /* Find if there is a video stream and get the display window */
597 hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IVideoWindow, (LPVOID*)&pVideoWindow);
598 if (FAILED(hr)) {
599 ERR("Cannot get IVideoWindow interface (hr = %x)\n", hr);
600 return MCIERR_INTERNAL;
603 hr = IVideoWindow_get_Owner(pVideoWindow, (OAHWND*)&hWnd);
604 IVideoWindow_Release(pVideoWindow);
605 if (FAILED(hr)) {
606 TRACE("No video stream, returning no window error\n");
607 return MCIERR_NO_WINDOW;
610 if (dwFlags & MCI_DGV_WHERE_SOURCE) {
611 if (dwFlags & MCI_DGV_WHERE_MAX)
612 FIXME("MCI_DGV_WHERE_SOURCE_MAX not supported yet\n");
613 else
614 FIXME("MCI_DGV_WHERE_SOURCE not supported yet\n");
615 return MCIERR_UNRECOGNIZED_COMMAND;
617 if (dwFlags & MCI_DGV_WHERE_DESTINATION) {
618 if (dwFlags & MCI_DGV_WHERE_MAX) {
619 GetClientRect(hWnd, &rc);
620 TRACE("MCI_DGV_WHERE_DESTINATION_MAX %s\n", wine_dbgstr_rect(&rc));
621 } else {
622 FIXME("MCI_DGV_WHERE_DESTINATION not supported yet\n");
623 return MCIERR_UNRECOGNIZED_COMMAND;
626 if (dwFlags & MCI_DGV_WHERE_FRAME) {
627 if (dwFlags & MCI_DGV_WHERE_MAX)
628 FIXME("MCI_DGV_WHERE_FRAME_MAX not supported yet\n");
629 else
630 FIXME("MCI_DGV_WHERE_FRAME not supported yet\n");
631 return MCIERR_UNRECOGNIZED_COMMAND;
633 if (dwFlags & MCI_DGV_WHERE_VIDEO) {
634 if (dwFlags & MCI_DGV_WHERE_MAX)
635 FIXME("MCI_DGV_WHERE_VIDEO_MAX not supported yet\n");
636 else
637 FIXME("MCI_DGV_WHERE_VIDEO not supported yet\n");
638 return MCIERR_UNRECOGNIZED_COMMAND;
640 if (dwFlags & MCI_DGV_WHERE_WINDOW) {
641 if (dwFlags & MCI_DGV_WHERE_MAX) {
642 GetWindowRect(GetDesktopWindow(), &rc);
643 TRACE("MCI_DGV_WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&rc));
644 } else {
645 GetWindowRect(hWnd, &rc);
646 TRACE("MCI_DGV_WHERE_WINDOW %s\n", wine_dbgstr_rect(&rc));
650 /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height
651 * So convert the normal RECT into a MCI RECT before returning */
652 lpParms->rc.left = rc.left;
653 lpParms->rc.top = rc.right;
654 lpParms->rc.right = rc.right - rc.left;
655 lpParms->rc.bottom = rc.bottom - rc.top;
657 return 0;
660 /***************************************************************************
661 * MCIQTZ_mciSetAudio [internal]
663 static DWORD MCIQTZ_mciSetAudio(UINT wDevID, DWORD dwFlags, LPMCI_DGV_SETAUDIO_PARMSW lpParms)
665 WINE_MCIQTZ *wma;
667 FIXME("(%04x, %08x, %p) : stub\n", wDevID, dwFlags, lpParms);
669 if (!lpParms)
670 return MCIERR_NULL_PARAMETER_BLOCK;
672 wma = MCIQTZ_mciGetOpenDev(wDevID);
673 if (!wma)
674 return MCIERR_INVALID_DEVICE_ID;
676 MCIQTZ_mciStop(wDevID, MCI_WAIT, NULL);
678 return 0;
681 /*======================================================================*
682 * MCI QTZ entry points *
683 *======================================================================*/
685 /**************************************************************************
686 * DriverProc (MCIQTZ.@)
688 LRESULT CALLBACK MCIQTZ_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
689 LPARAM dwParam1, LPARAM dwParam2)
691 TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
692 dwDevID, hDriv, wMsg, dwParam1, dwParam2);
694 switch (wMsg) {
695 case DRV_LOAD: return 1;
696 case DRV_FREE: return 1;
697 case DRV_OPEN: return MCIQTZ_drvOpen((LPCWSTR)dwParam1, (LPMCI_OPEN_DRIVER_PARMSW)dwParam2);
698 case DRV_CLOSE: return MCIQTZ_drvClose(dwDevID);
699 case DRV_ENABLE: return 1;
700 case DRV_DISABLE: return 1;
701 case DRV_QUERYCONFIGURE: return 1;
702 case DRV_CONFIGURE: return MCIQTZ_drvConfigure(dwDevID);
703 case DRV_INSTALL: return DRVCNF_RESTART;
704 case DRV_REMOVE: return DRVCNF_RESTART;
707 /* session instance */
708 if (dwDevID == 0xFFFFFFFF)
709 return 1;
711 switch (wMsg) {
712 case MCI_OPEN_DRIVER: return MCIQTZ_mciOpen (dwDevID, dwParam1, (LPMCI_DGV_OPEN_PARMSW) dwParam2);
713 case MCI_CLOSE_DRIVER: return MCIQTZ_mciClose (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
714 case MCI_PLAY: return MCIQTZ_mciPlay (dwDevID, dwParam1, (LPMCI_PLAY_PARMS) dwParam2);
715 case MCI_SEEK: return MCIQTZ_mciSeek (dwDevID, dwParam1, (LPMCI_SEEK_PARMS) dwParam2);
716 case MCI_STOP: return MCIQTZ_mciStop (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
717 case MCI_GETDEVCAPS: return MCIQTZ_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS) dwParam2);
718 case MCI_SET: return MCIQTZ_mciSet (dwDevID, dwParam1, (LPMCI_DGV_SET_PARMS) dwParam2);
719 case MCI_STATUS: return MCIQTZ_mciStatus (dwDevID, dwParam1, (LPMCI_DGV_STATUS_PARMSW) dwParam2);
720 case MCI_WHERE: return MCIQTZ_mciWhere (dwDevID, dwParam1, (LPMCI_DGV_RECT_PARMS) dwParam2);
721 /* Digital Video specific */
722 case MCI_SETAUDIO: return MCIQTZ_mciSetAudio (dwDevID, dwParam1, (LPMCI_DGV_SETAUDIO_PARMSW) dwParam2);
723 case MCI_RECORD:
724 case MCI_PAUSE:
725 case MCI_RESUME:
726 case MCI_INFO:
727 case MCI_PUT:
728 case MCI_WINDOW:
729 case MCI_LOAD:
730 case MCI_SAVE:
731 case MCI_FREEZE:
732 case MCI_REALIZE:
733 case MCI_UNFREEZE:
734 case MCI_UPDATE:
735 case MCI_STEP:
736 case MCI_COPY:
737 case MCI_CUT:
738 case MCI_DELETE:
739 case MCI_PASTE:
740 case MCI_CUE:
741 /* Digital Video specific */
742 case MCI_CAPTURE:
743 case MCI_MONITOR:
744 case MCI_RESERVE:
745 case MCI_SIGNAL:
746 case MCI_SETVIDEO:
747 case MCI_QUALITY:
748 case MCI_LIST:
749 case MCI_UNDO:
750 case MCI_CONFIGURE:
751 case MCI_RESTORE:
752 FIXME("Unimplemented command [%08X]\n", wMsg);
753 break;
754 case MCI_SPIN:
755 case MCI_ESCAPE:
756 WARN("Unsupported command [%08X]\n", wMsg);
757 break;
758 case MCI_OPEN:
759 case MCI_CLOSE:
760 FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
761 break;
762 default:
763 TRACE("Sending msg [%08X] to default driver proc\n", wMsg);
764 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
767 return MCIERR_UNRECOGNIZED_COMMAND;