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
26 #include "wine/debug.h"
27 #include "mciqtz_private.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 /***********************************************************************
45 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID fImpLoad
)
48 case DLL_PROCESS_ATTACH
:
49 DisableThreadLibraryCalls(hInstDLL
);
50 MCIQTZ_hInstance
= hInstDLL
;
56 /**************************************************************************
57 * MCIQTZ_mciGetOpenDev [internal]
59 static WINE_MCIQTZ
* MCIQTZ_mciGetOpenDev(UINT wDevID
)
61 WINE_MCIQTZ
* wma
= (WINE_MCIQTZ
*)mciGetDriverData(wDevID
);
64 WARN("Invalid wDevID=%u\n", wDevID
);
70 /**************************************************************************
71 * MCIQTZ_drvOpen [internal]
73 static DWORD
MCIQTZ_drvOpen(LPCWSTR str
, LPMCI_OPEN_DRIVER_PARMSW modp
)
76 static const WCHAR mciAviWStr
[] = {'M','C','I','A','V','I',0};
78 TRACE("(%s, %p)\n", debugstr_w(str
), modp
);
80 /* session instance */
84 wma
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINE_MCIQTZ
));
88 modp
->wType
= MCI_DEVTYPE_DIGITAL_VIDEO
;
89 wma
->wDevID
= modp
->wDeviceID
;
90 modp
->wCustomCommandTable
= wma
->command_table
= mciLoadCommandResource(MCIQTZ_hInstance
, mciAviWStr
, 0);
91 mciSetDriverData(wma
->wDevID
, (DWORD_PTR
)wma
);
93 return modp
->wDeviceID
;
96 /**************************************************************************
97 * MCIQTZ_drvClose [internal]
99 static DWORD
MCIQTZ_drvClose(DWORD dwDevID
)
103 TRACE("(%04x)\n", dwDevID
);
105 wma
= MCIQTZ_mciGetOpenDev(dwDevID
);
108 /* finish all outstanding things */
109 MCIQTZ_mciClose(dwDevID
, MCI_WAIT
, NULL
);
111 mciFreeCommandResource(wma
->command_table
);
112 mciSetDriverData(dwDevID
, 0);
113 HeapFree(GetProcessHeap(), 0, wma
);
117 return (dwDevID
== 0xFFFFFFFF) ? 1 : 0;
120 /**************************************************************************
121 * MCIQTZ_drvConfigure [internal]
123 static DWORD
MCIQTZ_drvConfigure(DWORD dwDevID
)
127 TRACE("(%04x)\n", dwDevID
);
129 wma
= MCIQTZ_mciGetOpenDev(dwDevID
);
133 MCIQTZ_mciStop(dwDevID
, MCI_WAIT
, NULL
);
135 MessageBoxA(0, "Sample QTZ Wine Driver !", "MM-Wine Driver", MB_OK
);
140 /***************************************************************************
141 * MCIQTZ_mciOpen [internal]
143 static DWORD
MCIQTZ_mciOpen(UINT wDevID
, DWORD dwFlags
,
144 LPMCI_DGV_OPEN_PARMSW lpOpenParms
)
148 IBasicVideo
*vidbasic
;
149 IVideoWindow
*vidwin
;
151 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpOpenParms
);
154 return MCIERR_NULL_PARAMETER_BLOCK
;
156 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
158 return MCIERR_INVALID_DEVICE_ID
;
160 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
162 hr
= CoInitializeEx(NULL
, COINIT_MULTITHREADED
);
163 wma
->uninit
= SUCCEEDED(hr
);
165 hr
= CoCreateInstance(&CLSID_FilterGraph
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IGraphBuilder
, (LPVOID
*)&wma
->pgraph
);
167 TRACE("Cannot create filtergraph (hr = %x)\n", hr
);
171 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IMediaControl
, (LPVOID
*)&wma
->pmctrl
);
173 TRACE("Cannot get IMediaControl interface (hr = %x)\n", hr
);
177 if (!(dwFlags
& MCI_OPEN_ELEMENT
) || (dwFlags
& MCI_OPEN_ELEMENT_ID
)) {
178 TRACE("Wrong dwFlags %x\n", dwFlags
);
182 if (!lpOpenParms
->lpstrElementName
|| !lpOpenParms
->lpstrElementName
[0]) {
183 TRACE("Invalid filename specified\n");
187 TRACE("Open file %s\n", debugstr_w(lpOpenParms
->lpstrElementName
));
189 hr
= IGraphBuilder_RenderFile(wma
->pgraph
, lpOpenParms
->lpstrElementName
, NULL
);
191 TRACE("Cannot render file (hr = %x)\n", hr
);
195 hr
= IFilterGraph2_QueryInterface(wma
->pgraph
, &IID_IVideoWindow
, (void**)&vidwin
);
197 hr
= IFilterGraph2_QueryInterface(wma
->pgraph
, &IID_IBasicVideo
, (void**)&vidbasic
);
200 RECT rc
= { 0, 0, 0, 0 };
201 IVideoWindow_put_AutoShow(vidwin
, OAFALSE
);
202 IVideoWindow_put_Visible(vidwin
, OAFALSE
);
204 if (dwFlags
& MCI_DGV_OPEN_WS
)
205 style
|= lpOpenParms
->dwStyle
;
206 if (dwFlags
& MCI_DGV_OPEN_PARENT
) {
207 IVideoWindow_put_MessageDrain(vidwin
, (OAHWND
)lpOpenParms
->hWndParent
);
208 IVideoWindow_put_WindowState(vidwin
, SW_HIDE
);
209 IVideoWindow_put_WindowStyle(vidwin
, WS_CHILD
);
210 IVideoWindow_put_Owner(vidwin
, (OAHWND
)lpOpenParms
->hWndParent
);
211 wma
->parent
= (HWND
)lpOpenParms
->hWndParent
;
214 IVideoWindow_put_WindowStyle(vidwin
, style
);
215 IBasicVideo_GetVideoSize(vidbasic
, &rc
.right
, &rc
.bottom
);
216 IVideoWindow_SetWindowPosition(vidwin
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
217 IBasicVideo_Release(vidbasic
);
220 IVideoWindow_Release(vidwin
);
228 IGraphBuilder_Release(wma
->pgraph
);
231 IMediaControl_Release(wma
->pmctrl
);
237 return MCIERR_INTERNAL
;
240 /***************************************************************************
241 * MCIQTZ_mciClose [internal]
243 static DWORD
MCIQTZ_mciClose(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
247 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
249 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
251 return MCIERR_INVALID_DEVICE_ID
;
253 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
256 IGraphBuilder_Release(wma
->pgraph
);
257 IMediaControl_Release(wma
->pmctrl
);
266 /***************************************************************************
267 * MCIQTZ_mciPlay [internal]
269 static DWORD
MCIQTZ_mciPlay(UINT wDevID
, DWORD dwFlags
, LPMCI_PLAY_PARMS lpParms
)
274 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
277 return MCIERR_NULL_PARAMETER_BLOCK
;
279 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
281 return MCIERR_INVALID_DEVICE_ID
;
283 hr
= IMediaControl_Run(wma
->pmctrl
);
285 TRACE("Cannot run filtergraph (hr = %x)\n", hr
);
286 return MCIERR_INTERNAL
;
290 IVideoWindow
*vidwin
;
291 IFilterGraph2_QueryInterface(wma
->pgraph
, &IID_IVideoWindow
, (void**)&vidwin
);
293 IVideoWindow_put_Visible(vidwin
, OATRUE
);
294 IVideoWindow_Release(vidwin
);
301 /***************************************************************************
302 * MCIQTZ_mciSeek [internal]
304 static DWORD
MCIQTZ_mciSeek(UINT wDevID
, DWORD dwFlags
, LPMCI_SEEK_PARMS lpParms
)
308 IMediaPosition
* pmpos
;
311 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
314 return MCIERR_NULL_PARAMETER_BLOCK
;
316 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
318 return MCIERR_INVALID_DEVICE_ID
;
320 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
322 if (dwFlags
& MCI_SEEK_TO_START
) {
324 } else if (dwFlags
& MCI_SEEK_TO_END
) {
325 FIXME("MCI_SEEK_TO_END not implemented yet\n");
326 return MCIERR_INTERNAL
;
327 } else if (dwFlags
& MCI_TO
) {
328 FIXME("MCI_TO not implemented yet\n");
329 return MCIERR_INTERNAL
;
331 WARN("dwFlag doesn't tell where to seek to...\n");
332 return MCIERR_MISSING_PARAMETER
;
335 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IMediaPosition
, (LPVOID
*)&pmpos
);
337 FIXME("Cannot get IMediaPostion interface (hr = %x)\n", hr
);
338 return MCIERR_INTERNAL
;
341 hr
= IMediaPosition_put_CurrentPosition(pmpos
, newpos
);
343 FIXME("Cannot set position (hr = %x)\n", hr
);
344 IMediaPosition_Release(pmpos
);
345 return MCIERR_INTERNAL
;
348 IMediaPosition_Release(pmpos
);
350 if (dwFlags
& MCI_NOTIFY
)
351 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
356 /***************************************************************************
357 * MCIQTZ_mciStop [internal]
359 static DWORD
MCIQTZ_mciStop(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
364 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
366 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
368 return MCIERR_INVALID_DEVICE_ID
;
373 hr
= IMediaControl_Stop(wma
->pmctrl
);
375 TRACE("Cannot stop filtergraph (hr = %x)\n", hr
);
376 return MCIERR_INTERNAL
;
380 IVideoWindow
*vidwin
;
381 IFilterGraph2_QueryInterface(wma
->pgraph
, &IID_IVideoWindow
, (void**)&vidwin
);
383 IVideoWindow_put_Visible(vidwin
, OAFALSE
);
384 IVideoWindow_Release(vidwin
);
391 /***************************************************************************
392 * MCIQTZ_mciPause [internal]
394 static DWORD
MCIQTZ_mciPause(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
399 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
401 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
403 return MCIERR_INVALID_DEVICE_ID
;
405 hr
= IMediaControl_Pause(wma
->pmctrl
);
407 TRACE("Cannot pause filtergraph (hr = %x)\n", hr
);
408 return MCIERR_INTERNAL
;
414 /***************************************************************************
415 * MCIQTZ_mciGetDevCaps [internal]
417 static DWORD
MCIQTZ_mciGetDevCaps(UINT wDevID
, DWORD dwFlags
, LPMCI_GETDEVCAPS_PARMS lpParms
)
421 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
424 return MCIERR_NULL_PARAMETER_BLOCK
;
426 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
428 return MCIERR_INVALID_DEVICE_ID
;
430 if (!(dwFlags
& MCI_GETDEVCAPS_ITEM
))
431 return MCIERR_MISSING_PARAMETER
;
433 switch (lpParms
->dwItem
) {
434 case MCI_GETDEVCAPS_CAN_RECORD
:
435 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
436 TRACE("MCI_GETDEVCAPS_CAN_RECORD = %08x\n", lpParms
->dwReturn
);
438 case MCI_GETDEVCAPS_HAS_AUDIO
:
439 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
440 TRACE("MCI_GETDEVCAPS_HAS_AUDIO = %08x\n", lpParms
->dwReturn
);
442 case MCI_GETDEVCAPS_HAS_VIDEO
:
443 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
444 TRACE("MCI_GETDEVCAPS_HAS_VIDEO = %08x\n", lpParms
->dwReturn
);
446 case MCI_GETDEVCAPS_DEVICE_TYPE
:
447 lpParms
->dwReturn
= MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO
, MCI_DEVTYPE_DIGITAL_VIDEO
);
448 TRACE("MCI_GETDEVCAPS_DEVICE_TYPE = %08x\n", lpParms
->dwReturn
);
450 case MCI_GETDEVCAPS_USES_FILES
:
451 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
452 TRACE("MCI_GETDEVCAPS_USES_FILES = %08x\n", lpParms
->dwReturn
);
454 case MCI_GETDEVCAPS_COMPOUND_DEVICE
:
455 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
456 TRACE("MCI_GETDEVCAPS_COMPOUND_DEVICE = %08x\n", lpParms
->dwReturn
);
458 case MCI_GETDEVCAPS_CAN_EJECT
:
459 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
460 TRACE("MCI_GETDEVCAPS_EJECT = %08x\n", lpParms
->dwReturn
);
462 case MCI_GETDEVCAPS_CAN_PLAY
:
463 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
464 TRACE("MCI_GETDEVCAPS_CAN_PLAY = %08x\n", lpParms
->dwReturn
);
466 case MCI_GETDEVCAPS_CAN_SAVE
:
467 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
468 TRACE("MCI_GETDEVCAPS_CAN_SAVE = %08x\n", lpParms
->dwReturn
);
470 case MCI_DGV_GETDEVCAPS_CAN_REVERSE
:
471 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
472 TRACE("MCI_DGV_GETDEVCAPS_CAN_REVERSE = %08x\n", lpParms
->dwReturn
);
474 case MCI_DGV_GETDEVCAPS_CAN_STRETCH
:
475 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
); /* FIXME */
476 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH = %08x\n", lpParms
->dwReturn
);
478 case MCI_DGV_GETDEVCAPS_CAN_LOCK
:
479 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
480 TRACE("MCI_DGV_GETDEVCAPS_CAN_LOCK = %08x\n", lpParms
->dwReturn
);
482 case MCI_DGV_GETDEVCAPS_CAN_FREEZE
:
483 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
484 TRACE("MCI_DGV_GETDEVCAPS_CAN_FREEZE = %08x\n", lpParms
->dwReturn
);
486 case MCI_DGV_GETDEVCAPS_CAN_STR_IN
:
487 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
488 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH_INPUT = %08x\n", lpParms
->dwReturn
);
490 case MCI_DGV_GETDEVCAPS_HAS_STILL
:
491 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
492 TRACE("MCI_DGV_GETDEVCAPS_HAS_STILL = %08x\n", lpParms
->dwReturn
);
494 case MCI_DGV_GETDEVCAPS_CAN_TEST
:
495 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
); /* FIXME */
496 TRACE("MCI_DGV_GETDEVCAPS_CAN_TEST = %08x\n", lpParms
->dwReturn
);
498 case MCI_DGV_GETDEVCAPS_MAX_WINDOWS
:
499 lpParms
->dwReturn
= 1;
500 TRACE("MCI_DGV_GETDEVCAPS_MAX_WINDOWS = %u\n", lpParms
->dwReturn
);
503 WARN("Unknown capability %08x\n", lpParms
->dwItem
);
505 case MCI_DGV_GETDEVCAPS_MAXIMUM_RATE
: /* unknown to w2k */
506 case MCI_DGV_GETDEVCAPS_MINIMUM_RATE
: /* unknown to w2k */
507 return MCIERR_UNSUPPORTED_FUNCTION
;
510 return MCI_RESOURCE_RETURNED
;
513 /***************************************************************************
514 * MCIQTZ_mciSet [internal]
516 static DWORD
MCIQTZ_mciSet(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_SET_PARMS lpParms
)
520 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
523 return MCIERR_NULL_PARAMETER_BLOCK
;
525 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
527 return MCIERR_INVALID_DEVICE_ID
;
529 if (dwFlags
& MCI_SET_TIME_FORMAT
) {
530 switch (lpParms
->dwTimeFormat
) {
531 case MCI_FORMAT_MILLISECONDS
:
532 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_MILLISECONDS\n");
533 wma
->time_format
= MCI_FORMAT_MILLISECONDS
;
535 case MCI_FORMAT_FRAMES
:
536 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_FRAMES\n");
537 wma
->time_format
= MCI_FORMAT_FRAMES
;
540 WARN("Bad time format %u\n", lpParms
->dwTimeFormat
);
541 return MCIERR_BAD_TIME_FORMAT
;
545 if (dwFlags
& MCI_SET_DOOR_OPEN
)
546 FIXME("MCI_SET_DOOR_OPEN not implemented yet\n");
547 if (dwFlags
& MCI_SET_DOOR_CLOSED
)
548 FIXME("MCI_SET_DOOR_CLOSED not implemented yet\n");
549 if (dwFlags
& MCI_SET_AUDIO
)
550 FIXME("MCI_SET_AUDIO not implemented yet\n");
551 if (dwFlags
& MCI_SET_VIDEO
)
552 FIXME("MCI_SET_VIDEO not implemented yet\n");
553 if (dwFlags
& MCI_SET_ON
)
554 FIXME("MCI_SET_ON not implemented yet\n");
555 if (dwFlags
& MCI_SET_OFF
)
556 FIXME("MCI_SET_OFF not implemented yet\n");
557 if (dwFlags
& MCI_SET_AUDIO_LEFT
)
558 FIXME("MCI_SET_AUDIO_LEFT not implemented yet\n");
559 if (dwFlags
& MCI_SET_AUDIO_RIGHT
)
560 FIXME("MCI_SET_AUDIO_RIGHT not implemented yet\n");
562 if (dwFlags
& ~0x7f03 /* All MCI_SET flags mask */)
563 ERR("Unknown flags %08x\n", dwFlags
& ~0x7f03);
568 /***************************************************************************
569 * MCIQTZ_mciStatus [internal]
571 static DWORD
MCIQTZ_mciStatus(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_STATUS_PARMSW lpParms
)
576 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
579 return MCIERR_NULL_PARAMETER_BLOCK
;
581 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
583 return MCIERR_INVALID_DEVICE_ID
;
585 if (!(dwFlags
& MCI_STATUS_ITEM
)) {
586 WARN("No status item specified\n");
587 return MCIERR_UNRECOGNIZED_COMMAND
;
590 switch (lpParms
->dwItem
) {
591 case MCI_STATUS_LENGTH
: {
593 LONGLONG duration
= -1;
595 switch (wma
->time_format
) {
596 case MCI_FORMAT_MILLISECONDS
: format
= TIME_FORMAT_MEDIA_TIME
; break;
597 case MCI_FORMAT_FRAMES
: format
= TIME_FORMAT_FRAME
; break;
598 default: ERR("Unhandled format %x\n", wma
->time_format
); break;
600 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IMediaSeeking
, (void**)&seek
);
602 FIXME("Cannot get IMediaPostion interface (hr = %x)\n", hr
);
603 return MCIERR_INTERNAL
;
605 hr
= IMediaSeeking_SetTimeFormat(seek
, &format
);
607 IMediaSeeking_Release(seek
);
608 FIXME("Cannot set time format (hr = %x)\n", hr
);
609 lpParms
->dwReturn
= 0;
612 hr
= IMediaSeeking_GetDuration(seek
, &duration
);
613 IMediaSeeking_Release(seek
);
614 if (FAILED(hr
) || duration
< 0) {
615 FIXME("Cannot read duration (hr = %x)\n", hr
);
616 lpParms
->dwReturn
= 0;
617 } else if (wma
->time_format
!= MCI_FORMAT_MILLISECONDS
)
618 lpParms
->dwReturn
= duration
;
620 lpParms
->dwReturn
= duration
/ 10000;
623 case MCI_STATUS_POSITION
: {
624 IMediaPosition
* pmpos
;
627 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IMediaPosition
, (LPVOID
*)&pmpos
);
629 FIXME("Cannot get IMediaPostion interface (hr = %x)\n", hr
);
630 return MCIERR_INTERNAL
;
633 hr
= IMediaPosition_get_CurrentPosition(pmpos
, &curpos
);
635 FIXME("Cannot get position (hr = %x)\n", hr
);
636 IMediaPosition_Release(pmpos
);
637 return MCIERR_INTERNAL
;
640 IMediaPosition_Release(pmpos
);
641 lpParms
->dwReturn
= curpos
/ 10000;
645 case MCI_STATUS_NUMBER_OF_TRACKS
:
646 FIXME("MCI_STATUS_NUMBER_OF_TRACKS not implemented yet\n");
647 return MCIERR_UNRECOGNIZED_COMMAND
;
648 case MCI_STATUS_MODE
:
649 FIXME("MCI_STATUS_MODE not implemented yet\n");
650 return MCIERR_UNRECOGNIZED_COMMAND
;
651 case MCI_STATUS_MEDIA_PRESENT
:
652 FIXME("MCI_STATUS_MEDIA_PRESENT not implemented yet\n");
653 return MCIERR_UNRECOGNIZED_COMMAND
;
654 case MCI_STATUS_TIME_FORMAT
:
655 lpParms
->dwReturn
= wma
->time_format
;
657 case MCI_STATUS_READY
:
658 FIXME("MCI_STATUS_READY not implemented yet\n");
659 return MCIERR_UNRECOGNIZED_COMMAND
;
660 case MCI_STATUS_CURRENT_TRACK
:
661 FIXME("MCI_STATUS_CURRENT_TRACK not implemented yet\n");
662 return MCIERR_UNRECOGNIZED_COMMAND
;
664 FIXME("Unknown command %08X\n", lpParms
->dwItem
);
665 return MCIERR_UNRECOGNIZED_COMMAND
;
668 if (dwFlags
& MCI_NOTIFY
)
669 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
674 /***************************************************************************
675 * MCIQTZ_mciWhere [internal]
677 static DWORD
MCIQTZ_mciWhere(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_RECT_PARMS lpParms
)
680 IVideoWindow
* pVideoWindow
;
681 IBasicVideo
*pBasicVideo
;
685 DWORD ret
= MCIERR_UNRECOGNIZED_COMMAND
;
687 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
690 return MCIERR_NULL_PARAMETER_BLOCK
;
692 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
694 return MCIERR_INVALID_DEVICE_ID
;
696 /* Find if there is a video stream and get the display window */
697 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
699 ERR("Cannot get IVideoWindow interface (hr = %x)\n", hr
);
700 return MCIERR_INTERNAL
;
703 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
705 ERR("Cannot get IBasicVideo interface (hr = %x)\n", hr
);
706 IUnknown_Release(pVideoWindow
);
707 return MCIERR_INTERNAL
;
710 hr
= IVideoWindow_get_Owner(pVideoWindow
, (OAHWND
*)&hWnd
);
712 TRACE("No video stream, returning no window error\n");
713 IUnknown_Release(pVideoWindow
);
714 return MCIERR_NO_WINDOW
;
717 if (dwFlags
& MCI_DGV_WHERE_SOURCE
) {
718 if (dwFlags
& MCI_DGV_WHERE_MAX
)
719 FIXME("MCI_DGV_WHERE_SOURCE_MAX stub %s\n", wine_dbgstr_rect(&rc
));
720 IBasicVideo_get_SourceLeft(pBasicVideo
, &rc
.left
);
721 IBasicVideo_get_SourceTop(pBasicVideo
, &rc
.top
);
722 IBasicVideo_get_SourceWidth(pBasicVideo
, &rc
.right
);
723 IBasicVideo_get_SourceHeight(pBasicVideo
, &rc
.bottom
);
724 /* Undo conversion done below */
727 TRACE("MCI_DGV_WHERE_SOURCE %s\n", wine_dbgstr_rect(&rc
));
729 if (dwFlags
& MCI_DGV_WHERE_DESTINATION
) {
730 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
731 GetClientRect(hWnd
, &rc
);
732 TRACE("MCI_DGV_WHERE_DESTINATION_MAX %s\n", wine_dbgstr_rect(&rc
));
734 FIXME("MCI_DGV_WHERE_DESTINATION not supported yet\n");
738 if (dwFlags
& MCI_DGV_WHERE_FRAME
) {
739 if (dwFlags
& MCI_DGV_WHERE_MAX
)
740 FIXME("MCI_DGV_WHERE_FRAME_MAX not supported yet\n");
742 FIXME("MCI_DGV_WHERE_FRAME not supported yet\n");
745 if (dwFlags
& MCI_DGV_WHERE_VIDEO
) {
746 if (dwFlags
& MCI_DGV_WHERE_MAX
)
747 FIXME("MCI_DGV_WHERE_VIDEO_MAX not supported yet\n");
749 FIXME("MCI_DGV_WHERE_VIDEO not supported yet\n");
752 if (dwFlags
& MCI_DGV_WHERE_WINDOW
) {
753 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
754 GetWindowRect(GetDesktopWindow(), &rc
);
755 TRACE("MCI_DGV_WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&rc
));
757 GetWindowRect(hWnd
, &rc
);
758 TRACE("MCI_DGV_WHERE_WINDOW %s\n", wine_dbgstr_rect(&rc
));
764 /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height
765 * So convert the normal RECT into a MCI RECT before returning */
766 IVideoWindow_Release(pVideoWindow
);
767 IBasicVideo_Release(pBasicVideo
);
768 lpParms
->rc
.left
= rc
.left
;
769 lpParms
->rc
.top
= rc
.top
;
770 lpParms
->rc
.right
= rc
.right
- rc
.left
;
771 lpParms
->rc
.bottom
= rc
.bottom
- rc
.top
;
776 /******************************************************************************
777 * MCIAVI_mciUpdate [internal]
779 static DWORD
MCIQTZ_mciUpdate(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_UPDATE_PARMS lpParms
)
784 TRACE("%04x, %08x, %p\n", wDevID
, dwFlags
, lpParms
);
787 return MCIERR_NULL_PARAMETER_BLOCK
;
789 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
791 return MCIERR_INVALID_DEVICE_ID
;
793 if (dwFlags
& MCI_DGV_UPDATE_HDC
) {
794 IBasicVideo
*vidbasic
;
795 IVideoWindow
*vidwin
;
796 res
= MCIERR_INTERNAL
;
797 IFilterGraph2_QueryInterface(wma
->pgraph
, &IID_IVideoWindow
, (void**)&vidwin
);
798 IFilterGraph2_QueryInterface(wma
->pgraph
, &IID_IBasicVideo
, (void**)&vidbasic
);
799 if (vidbasic
&& vidwin
) {
806 /* If in stopped state, nothing has been drawn to screen
807 * moving to pause, which is needed for the old dib renderer, will result
808 * in a single frame drawn, so hide the window here */
809 IVideoWindow_put_Visible(vidwin
, OAFALSE
);
810 /* FIXME: Should we check the original state and restore it? */
811 IMediaControl_Pause(wma
->pmctrl
);
812 IMediaControl_GetState(wma
->pmctrl
, -1, &state
);
813 if (FAILED(hr
= IBasicVideo_GetCurrentImage(vidbasic
, &size
, NULL
))) {
814 WARN("Could not get image size (hr = %x)\n", hr
);
817 data
= HeapAlloc(GetProcessHeap(), 0, size
);
818 info
= (BITMAPINFO
*)data
;
819 IBasicVideo_GetCurrentImage(vidbasic
, &size
, (LONG
*)data
);
820 data
+= info
->bmiHeader
.biSize
;
822 IBasicVideo_GetSourcePosition(vidbasic
, &src
.left
, &src
.top
, &src
.right
, &src
.bottom
);
823 IBasicVideo_GetDestinationPosition(vidbasic
, &dest
.left
, &dest
.top
, &dest
.right
, &dest
.bottom
);
824 StretchDIBits(lpParms
->hDC
,
825 dest
.left
, dest
.top
, dest
.right
+ dest
.left
, dest
.bottom
+ dest
.top
,
826 src
.left
, src
.top
, src
.right
+ src
.left
, src
.bottom
+ src
.top
,
827 data
, info
, DIB_RGB_COLORS
, SRCCOPY
);
828 HeapFree(GetProcessHeap(), 0, data
);
833 IBasicVideo_Release(vidbasic
);
836 IVideoWindow_put_Visible(vidwin
, OATRUE
);
837 IVideoWindow_Release(vidwin
);
841 FIXME("Unhandled flags %x\n", dwFlags
);
845 /***************************************************************************
846 * MCIQTZ_mciSetAudio [internal]
848 static DWORD
MCIQTZ_mciSetAudio(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_SETAUDIO_PARMSW lpParms
)
852 FIXME("(%04x, %08x, %p) : stub\n", wDevID
, dwFlags
, lpParms
);
855 return MCIERR_NULL_PARAMETER_BLOCK
;
857 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
859 return MCIERR_INVALID_DEVICE_ID
;
861 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
866 /*======================================================================*
867 * MCI QTZ entry points *
868 *======================================================================*/
870 /**************************************************************************
871 * DriverProc (MCIQTZ.@)
873 LRESULT CALLBACK
MCIQTZ_DriverProc(DWORD_PTR dwDevID
, HDRVR hDriv
, UINT wMsg
,
874 LPARAM dwParam1
, LPARAM dwParam2
)
876 TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
877 dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
880 case DRV_LOAD
: return 1;
881 case DRV_FREE
: return 1;
882 case DRV_OPEN
: return MCIQTZ_drvOpen((LPCWSTR
)dwParam1
, (LPMCI_OPEN_DRIVER_PARMSW
)dwParam2
);
883 case DRV_CLOSE
: return MCIQTZ_drvClose(dwDevID
);
884 case DRV_ENABLE
: return 1;
885 case DRV_DISABLE
: return 1;
886 case DRV_QUERYCONFIGURE
: return 1;
887 case DRV_CONFIGURE
: return MCIQTZ_drvConfigure(dwDevID
);
888 case DRV_INSTALL
: return DRVCNF_RESTART
;
889 case DRV_REMOVE
: return DRVCNF_RESTART
;
892 /* session instance */
893 if (dwDevID
== 0xFFFFFFFF)
897 case MCI_OPEN_DRIVER
: return MCIQTZ_mciOpen (dwDevID
, dwParam1
, (LPMCI_DGV_OPEN_PARMSW
) dwParam2
);
898 case MCI_CLOSE_DRIVER
: return MCIQTZ_mciClose (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
899 case MCI_PLAY
: return MCIQTZ_mciPlay (dwDevID
, dwParam1
, (LPMCI_PLAY_PARMS
) dwParam2
);
900 case MCI_SEEK
: return MCIQTZ_mciSeek (dwDevID
, dwParam1
, (LPMCI_SEEK_PARMS
) dwParam2
);
901 case MCI_STOP
: return MCIQTZ_mciStop (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
902 case MCI_PAUSE
: return MCIQTZ_mciPause (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
903 case MCI_GETDEVCAPS
: return MCIQTZ_mciGetDevCaps(dwDevID
, dwParam1
, (LPMCI_GETDEVCAPS_PARMS
) dwParam2
);
904 case MCI_SET
: return MCIQTZ_mciSet (dwDevID
, dwParam1
, (LPMCI_DGV_SET_PARMS
) dwParam2
);
905 case MCI_STATUS
: return MCIQTZ_mciStatus (dwDevID
, dwParam1
, (LPMCI_DGV_STATUS_PARMSW
) dwParam2
);
906 case MCI_WHERE
: return MCIQTZ_mciWhere (dwDevID
, dwParam1
, (LPMCI_DGV_RECT_PARMS
) dwParam2
);
907 /* Digital Video specific */
908 case MCI_SETAUDIO
: return MCIQTZ_mciSetAudio (dwDevID
, dwParam1
, (LPMCI_DGV_SETAUDIO_PARMSW
) dwParam2
);
910 return MCIQTZ_mciUpdate(dwDevID
, dwParam1
, (LPMCI_DGV_UPDATE_PARMS
)dwParam2
);
927 /* Digital Video specific */
938 FIXME("Unimplemented command [%08X]\n", wMsg
);
942 WARN("Unsupported command [%08X]\n", wMsg
);
946 FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
949 TRACE("Sending msg [%08X] to default driver proc\n", wMsg
);
950 return DefDriverProc(dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
953 return MCIERR_UNRECOGNIZED_COMMAND
;