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
)
149 RECT rc
= { 0, 0, 0, 0 };
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 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IMediaSeeking
, (void**)&wma
->seek
);
179 TRACE("Cannot get IMediaSeeking interface (hr = %x)\n", hr
);
183 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IVideoWindow
, (void**)&wma
->vidwin
);
185 TRACE("Cannot get IVideoWindow interface (hr = %x)\n", hr
);
189 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IBasicVideo
, (void**)&wma
->vidbasic
);
191 TRACE("Cannot get IBasicVideo interface (hr = %x)\n", hr
);
195 if (!(dwFlags
& MCI_OPEN_ELEMENT
) || (dwFlags
& MCI_OPEN_ELEMENT_ID
)) {
196 TRACE("Wrong dwFlags %x\n", dwFlags
);
200 if (!lpOpenParms
->lpstrElementName
|| !lpOpenParms
->lpstrElementName
[0]) {
201 TRACE("Invalid filename specified\n");
205 TRACE("Open file %s\n", debugstr_w(lpOpenParms
->lpstrElementName
));
207 hr
= IGraphBuilder_RenderFile(wma
->pgraph
, lpOpenParms
->lpstrElementName
, NULL
);
209 TRACE("Cannot render file (hr = %x)\n", hr
);
213 IVideoWindow_put_AutoShow(wma
->vidwin
, OAFALSE
);
214 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
215 if (dwFlags
& MCI_DGV_OPEN_WS
)
216 style
= lpOpenParms
->dwStyle
;
217 if (dwFlags
& MCI_DGV_OPEN_PARENT
) {
218 IVideoWindow_put_MessageDrain(wma
->vidwin
, (OAHWND
)lpOpenParms
->hWndParent
);
219 IVideoWindow_put_WindowState(wma
->vidwin
, SW_HIDE
);
220 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
|WS_CHILD
);
221 IVideoWindow_put_Owner(wma
->vidwin
, (OAHWND
)lpOpenParms
->hWndParent
);
222 GetClientRect(lpOpenParms
->hWndParent
, &rc
);
223 IVideoWindow_SetWindowPosition(wma
->vidwin
, rc
.left
, rc
.top
, rc
.right
- rc
.top
, rc
.bottom
- rc
.top
);
224 wma
->parent
= (HWND
)lpOpenParms
->hWndParent
;
227 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
);
230 if (dwFlags
& MCI_NOTIFY
)
231 mciDriverNotify(HWND_32(LOWORD(lpOpenParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
237 IUnknown_Release(wma
->vidbasic
);
238 wma
->vidbasic
= NULL
;
240 IUnknown_Release(wma
->seek
);
243 IUnknown_Release(wma
->vidwin
);
246 IGraphBuilder_Release(wma
->pgraph
);
249 IMediaControl_Release(wma
->pmctrl
);
255 return MCIERR_INTERNAL
;
258 /***************************************************************************
259 * MCIQTZ_mciClose [internal]
261 static DWORD
MCIQTZ_mciClose(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
265 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
267 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
269 return MCIERR_INVALID_DEVICE_ID
;
271 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
274 IUnknown_Release(wma
->vidwin
);
275 IUnknown_Release(wma
->vidbasic
);
276 IUnknown_Release(wma
->seek
);
277 IGraphBuilder_Release(wma
->pgraph
);
278 IMediaControl_Release(wma
->pmctrl
);
287 /***************************************************************************
288 * MCIQTZ_mciPlay [internal]
290 static DWORD
MCIQTZ_mciPlay(UINT wDevID
, DWORD dwFlags
, LPMCI_PLAY_PARMS lpParms
)
295 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
298 return MCIERR_NULL_PARAMETER_BLOCK
;
300 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
302 return MCIERR_INVALID_DEVICE_ID
;
304 hr
= IMediaControl_Run(wma
->pmctrl
);
306 TRACE("Cannot run filtergraph (hr = %x)\n", hr
);
307 return MCIERR_INTERNAL
;
311 IVideoWindow_put_Visible(wma
->vidwin
, OATRUE
);
316 /***************************************************************************
317 * MCIQTZ_mciSeek [internal]
319 static DWORD
MCIQTZ_mciSeek(UINT wDevID
, DWORD dwFlags
, LPMCI_SEEK_PARMS lpParms
)
325 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
328 return MCIERR_NULL_PARAMETER_BLOCK
;
330 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
332 return MCIERR_INVALID_DEVICE_ID
;
334 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
336 if (dwFlags
& MCI_SEEK_TO_START
) {
338 } else if (dwFlags
& MCI_SEEK_TO_END
) {
339 FIXME("MCI_SEEK_TO_END not implemented yet\n");
340 return MCIERR_INTERNAL
;
341 } else if (dwFlags
& MCI_TO
) {
342 FIXME("MCI_TO not implemented yet\n");
343 return MCIERR_INTERNAL
;
345 WARN("dwFlag doesn't tell where to seek to...\n");
346 return MCIERR_MISSING_PARAMETER
;
349 hr
= IMediaSeeking_SetPositions(wma
->seek
, &newpos
, AM_SEEKING_AbsolutePositioning
, NULL
, AM_SEEKING_NoPositioning
);
351 FIXME("Cannot set position (hr = %x)\n", hr
);
352 return MCIERR_INTERNAL
;
355 if (dwFlags
& MCI_NOTIFY
)
356 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
361 /***************************************************************************
362 * MCIQTZ_mciStop [internal]
364 static DWORD
MCIQTZ_mciStop(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
369 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
371 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
373 return MCIERR_INVALID_DEVICE_ID
;
378 hr
= IMediaControl_Stop(wma
->pmctrl
);
380 TRACE("Cannot stop filtergraph (hr = %x)\n", hr
);
381 return MCIERR_INTERNAL
;
385 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
390 /***************************************************************************
391 * MCIQTZ_mciPause [internal]
393 static DWORD
MCIQTZ_mciPause(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
398 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
400 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
402 return MCIERR_INVALID_DEVICE_ID
;
404 hr
= IMediaControl_Pause(wma
->pmctrl
);
406 TRACE("Cannot pause filtergraph (hr = %x)\n", hr
);
407 return MCIERR_INTERNAL
;
413 /***************************************************************************
414 * MCIQTZ_mciGetDevCaps [internal]
416 static DWORD
MCIQTZ_mciGetDevCaps(UINT wDevID
, DWORD dwFlags
, LPMCI_GETDEVCAPS_PARMS lpParms
)
420 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
423 return MCIERR_NULL_PARAMETER_BLOCK
;
425 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
427 return MCIERR_INVALID_DEVICE_ID
;
429 if (!(dwFlags
& MCI_GETDEVCAPS_ITEM
))
430 return MCIERR_MISSING_PARAMETER
;
432 switch (lpParms
->dwItem
) {
433 case MCI_GETDEVCAPS_CAN_RECORD
:
434 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
435 TRACE("MCI_GETDEVCAPS_CAN_RECORD = %08x\n", lpParms
->dwReturn
);
437 case MCI_GETDEVCAPS_HAS_AUDIO
:
438 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
439 TRACE("MCI_GETDEVCAPS_HAS_AUDIO = %08x\n", lpParms
->dwReturn
);
441 case MCI_GETDEVCAPS_HAS_VIDEO
:
442 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
443 TRACE("MCI_GETDEVCAPS_HAS_VIDEO = %08x\n", lpParms
->dwReturn
);
445 case MCI_GETDEVCAPS_DEVICE_TYPE
:
446 lpParms
->dwReturn
= MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO
, MCI_DEVTYPE_DIGITAL_VIDEO
);
447 TRACE("MCI_GETDEVCAPS_DEVICE_TYPE = %08x\n", lpParms
->dwReturn
);
449 case MCI_GETDEVCAPS_USES_FILES
:
450 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
451 TRACE("MCI_GETDEVCAPS_USES_FILES = %08x\n", lpParms
->dwReturn
);
453 case MCI_GETDEVCAPS_COMPOUND_DEVICE
:
454 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
455 TRACE("MCI_GETDEVCAPS_COMPOUND_DEVICE = %08x\n", lpParms
->dwReturn
);
457 case MCI_GETDEVCAPS_CAN_EJECT
:
458 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
459 TRACE("MCI_GETDEVCAPS_EJECT = %08x\n", lpParms
->dwReturn
);
461 case MCI_GETDEVCAPS_CAN_PLAY
:
462 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
463 TRACE("MCI_GETDEVCAPS_CAN_PLAY = %08x\n", lpParms
->dwReturn
);
465 case MCI_GETDEVCAPS_CAN_SAVE
:
466 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
467 TRACE("MCI_GETDEVCAPS_CAN_SAVE = %08x\n", lpParms
->dwReturn
);
469 case MCI_DGV_GETDEVCAPS_CAN_REVERSE
:
470 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
471 TRACE("MCI_DGV_GETDEVCAPS_CAN_REVERSE = %08x\n", lpParms
->dwReturn
);
473 case MCI_DGV_GETDEVCAPS_CAN_STRETCH
:
474 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
); /* FIXME */
475 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH = %08x\n", lpParms
->dwReturn
);
477 case MCI_DGV_GETDEVCAPS_CAN_LOCK
:
478 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
479 TRACE("MCI_DGV_GETDEVCAPS_CAN_LOCK = %08x\n", lpParms
->dwReturn
);
481 case MCI_DGV_GETDEVCAPS_CAN_FREEZE
:
482 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
483 TRACE("MCI_DGV_GETDEVCAPS_CAN_FREEZE = %08x\n", lpParms
->dwReturn
);
485 case MCI_DGV_GETDEVCAPS_CAN_STR_IN
:
486 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
487 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH_INPUT = %08x\n", lpParms
->dwReturn
);
489 case MCI_DGV_GETDEVCAPS_HAS_STILL
:
490 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
491 TRACE("MCI_DGV_GETDEVCAPS_HAS_STILL = %08x\n", lpParms
->dwReturn
);
493 case MCI_DGV_GETDEVCAPS_CAN_TEST
:
494 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
); /* FIXME */
495 TRACE("MCI_DGV_GETDEVCAPS_CAN_TEST = %08x\n", lpParms
->dwReturn
);
497 case MCI_DGV_GETDEVCAPS_MAX_WINDOWS
:
498 lpParms
->dwReturn
= 1;
499 TRACE("MCI_DGV_GETDEVCAPS_MAX_WINDOWS = %u\n", lpParms
->dwReturn
);
502 WARN("Unknown capability %08x\n", lpParms
->dwItem
);
504 case MCI_DGV_GETDEVCAPS_MAXIMUM_RATE
: /* unknown to w2k */
505 case MCI_DGV_GETDEVCAPS_MINIMUM_RATE
: /* unknown to w2k */
506 return MCIERR_UNSUPPORTED_FUNCTION
;
509 return MCI_RESOURCE_RETURNED
;
512 /***************************************************************************
513 * MCIQTZ_mciSet [internal]
515 static DWORD
MCIQTZ_mciSet(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_SET_PARMS lpParms
)
519 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
522 return MCIERR_NULL_PARAMETER_BLOCK
;
524 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
526 return MCIERR_INVALID_DEVICE_ID
;
528 if (dwFlags
& MCI_SET_TIME_FORMAT
) {
529 switch (lpParms
->dwTimeFormat
) {
530 case MCI_FORMAT_MILLISECONDS
:
531 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_MILLISECONDS\n");
532 wma
->time_format
= MCI_FORMAT_MILLISECONDS
;
534 case MCI_FORMAT_FRAMES
:
535 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_FRAMES\n");
536 wma
->time_format
= MCI_FORMAT_FRAMES
;
539 WARN("Bad time format %u\n", lpParms
->dwTimeFormat
);
540 return MCIERR_BAD_TIME_FORMAT
;
544 if (dwFlags
& MCI_SET_DOOR_OPEN
)
545 FIXME("MCI_SET_DOOR_OPEN not implemented yet\n");
546 if (dwFlags
& MCI_SET_DOOR_CLOSED
)
547 FIXME("MCI_SET_DOOR_CLOSED not implemented yet\n");
548 if (dwFlags
& MCI_SET_AUDIO
)
549 FIXME("MCI_SET_AUDIO not implemented yet\n");
550 if (dwFlags
& MCI_SET_VIDEO
)
551 FIXME("MCI_SET_VIDEO not implemented yet\n");
552 if (dwFlags
& MCI_SET_ON
)
553 FIXME("MCI_SET_ON not implemented yet\n");
554 if (dwFlags
& MCI_SET_OFF
)
555 FIXME("MCI_SET_OFF not implemented yet\n");
556 if (dwFlags
& MCI_SET_AUDIO_LEFT
)
557 FIXME("MCI_SET_AUDIO_LEFT not implemented yet\n");
558 if (dwFlags
& MCI_SET_AUDIO_RIGHT
)
559 FIXME("MCI_SET_AUDIO_RIGHT not implemented yet\n");
561 if (dwFlags
& ~0x7f03 /* All MCI_SET flags mask */)
562 ERR("Unknown flags %08x\n", dwFlags
& ~0x7f03);
567 /***************************************************************************
568 * MCIQTZ_mciStatus [internal]
570 static DWORD
MCIQTZ_mciStatus(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_STATUS_PARMSW lpParms
)
575 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
578 return MCIERR_NULL_PARAMETER_BLOCK
;
580 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
582 return MCIERR_INVALID_DEVICE_ID
;
584 if (!(dwFlags
& MCI_STATUS_ITEM
)) {
585 WARN("No status item specified\n");
586 return MCIERR_UNRECOGNIZED_COMMAND
;
589 switch (lpParms
->dwItem
) {
590 case MCI_STATUS_LENGTH
: {
591 LONGLONG duration
= -1;
593 switch (wma
->time_format
) {
594 case MCI_FORMAT_MILLISECONDS
: format
= TIME_FORMAT_MEDIA_TIME
; break;
595 case MCI_FORMAT_FRAMES
: format
= TIME_FORMAT_FRAME
; break;
596 default: ERR("Unhandled format %x\n", wma
->time_format
); break;
598 hr
= IMediaSeeking_SetTimeFormat(wma
->seek
, &format
);
600 FIXME("Cannot set time format (hr = %x)\n", hr
);
601 lpParms
->dwReturn
= 0;
604 hr
= IMediaSeeking_GetDuration(wma
->seek
, &duration
);
605 if (FAILED(hr
) || duration
< 0) {
606 FIXME("Cannot read duration (hr = %x)\n", hr
);
607 lpParms
->dwReturn
= 0;
608 } else if (wma
->time_format
!= MCI_FORMAT_MILLISECONDS
)
609 lpParms
->dwReturn
= duration
;
611 lpParms
->dwReturn
= duration
/ 10000;
614 case MCI_STATUS_POSITION
: {
615 REFERENCE_TIME curpos
;
617 hr
= IMediaSeeking_GetCurrentPosition(wma
->seek
, &curpos
);
619 FIXME("Cannot get position (hr = %x)\n", hr
);
620 return MCIERR_INTERNAL
;
622 lpParms
->dwReturn
= curpos
/ 10000;
625 case MCI_STATUS_NUMBER_OF_TRACKS
:
626 FIXME("MCI_STATUS_NUMBER_OF_TRACKS not implemented yet\n");
627 return MCIERR_UNRECOGNIZED_COMMAND
;
628 case MCI_STATUS_MODE
:
629 FIXME("MCI_STATUS_MODE not implemented yet\n");
630 return MCIERR_UNRECOGNIZED_COMMAND
;
631 case MCI_STATUS_MEDIA_PRESENT
:
632 FIXME("MCI_STATUS_MEDIA_PRESENT not implemented yet\n");
633 return MCIERR_UNRECOGNIZED_COMMAND
;
634 case MCI_STATUS_TIME_FORMAT
:
635 lpParms
->dwReturn
= wma
->time_format
;
637 case MCI_STATUS_READY
:
638 FIXME("MCI_STATUS_READY not implemented yet\n");
639 return MCIERR_UNRECOGNIZED_COMMAND
;
640 case MCI_STATUS_CURRENT_TRACK
:
641 FIXME("MCI_STATUS_CURRENT_TRACK not implemented yet\n");
642 return MCIERR_UNRECOGNIZED_COMMAND
;
644 FIXME("Unknown command %08X\n", lpParms
->dwItem
);
645 return MCIERR_UNRECOGNIZED_COMMAND
;
648 if (dwFlags
& MCI_NOTIFY
)
649 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
654 /***************************************************************************
655 * MCIQTZ_mciWhere [internal]
657 static DWORD
MCIQTZ_mciWhere(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_RECT_PARMS lpParms
)
663 DWORD ret
= MCIERR_UNRECOGNIZED_COMMAND
;
665 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
668 return MCIERR_NULL_PARAMETER_BLOCK
;
670 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
672 return MCIERR_INVALID_DEVICE_ID
;
674 hr
= IVideoWindow_get_Owner(wma
->vidwin
, (OAHWND
*)&hWnd
);
676 TRACE("No video stream, returning no window error\n");
677 return MCIERR_NO_WINDOW
;
680 if (dwFlags
& MCI_DGV_WHERE_SOURCE
) {
681 if (dwFlags
& MCI_DGV_WHERE_MAX
)
682 FIXME("MCI_DGV_WHERE_SOURCE_MAX stub %s\n", wine_dbgstr_rect(&rc
));
683 IBasicVideo_get_SourceLeft(wma
->vidbasic
, &rc
.left
);
684 IBasicVideo_get_SourceTop(wma
->vidbasic
, &rc
.top
);
685 IBasicVideo_get_SourceWidth(wma
->vidbasic
, &rc
.right
);
686 IBasicVideo_get_SourceHeight(wma
->vidbasic
, &rc
.bottom
);
687 /* Undo conversion done below */
690 TRACE("MCI_DGV_WHERE_SOURCE %s\n", wine_dbgstr_rect(&rc
));
692 if (dwFlags
& MCI_DGV_WHERE_DESTINATION
) {
693 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
694 GetClientRect(hWnd
, &rc
);
695 TRACE("MCI_DGV_WHERE_DESTINATION_MAX %s\n", wine_dbgstr_rect(&rc
));
697 FIXME("MCI_DGV_WHERE_DESTINATION not supported yet\n");
701 if (dwFlags
& MCI_DGV_WHERE_FRAME
) {
702 if (dwFlags
& MCI_DGV_WHERE_MAX
)
703 FIXME("MCI_DGV_WHERE_FRAME_MAX not supported yet\n");
705 FIXME("MCI_DGV_WHERE_FRAME not supported yet\n");
708 if (dwFlags
& MCI_DGV_WHERE_VIDEO
) {
709 if (dwFlags
& MCI_DGV_WHERE_MAX
)
710 FIXME("MCI_DGV_WHERE_VIDEO_MAX not supported yet\n");
712 FIXME("MCI_DGV_WHERE_VIDEO not supported yet\n");
715 if (dwFlags
& MCI_DGV_WHERE_WINDOW
) {
716 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
717 GetWindowRect(GetDesktopWindow(), &rc
);
718 TRACE("MCI_DGV_WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&rc
));
720 GetWindowRect(hWnd
, &rc
);
721 TRACE("MCI_DGV_WHERE_WINDOW %s\n", wine_dbgstr_rect(&rc
));
727 /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height
728 * So convert the normal RECT into a MCI RECT before returning */
729 lpParms
->rc
.left
= rc
.left
;
730 lpParms
->rc
.top
= rc
.top
;
731 lpParms
->rc
.right
= rc
.right
- rc
.left
;
732 lpParms
->rc
.bottom
= rc
.bottom
- rc
.top
;
737 /***************************************************************************
738 * MCIQTZ_mciWindow [internal]
740 static DWORD
MCIQTZ_mciWindow(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_WINDOW_PARMSW lpParms
)
742 WINE_MCIQTZ
*wma
= MCIQTZ_mciGetOpenDev(wDevID
);
744 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
747 return MCIERR_NULL_PARAMETER_BLOCK
;
749 return MCIERR_INVALID_DEVICE_ID
;
750 if (dwFlags
& MCI_TEST
)
753 if (dwFlags
& MCI_DGV_WINDOW_HWND
&& (IsWindow(lpParms
->hWnd
) || !lpParms
->hWnd
)) {
755 TRACE("Setting hWnd to %p\n", lpParms
->hWnd
);
756 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
757 IVideoWindow_get_WindowStyle(wma
->vidwin
, &style
);
760 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
|WS_CHILD
);
762 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
);
763 IVideoWindow_put_Owner(wma
->vidwin
, (OAHWND
)lpParms
->hWnd
);
764 IVideoWindow_put_MessageDrain(wma
->vidwin
, (OAHWND
)lpParms
->hWnd
);
765 IVideoWindow_put_Visible(wma
->vidwin
, OATRUE
);
766 wma
->parent
= lpParms
->hWnd
;
768 if (dwFlags
& MCI_DGV_WINDOW_STATE
) {
769 TRACE("Setting nCmdShow to %d\n", lpParms
->nCmdShow
);
770 IVideoWindow_put_WindowState(wma
->vidwin
, lpParms
->nCmdShow
);
772 if (dwFlags
& MCI_DGV_WINDOW_TEXT
) {
773 TRACE("Setting caption to %s\n", debugstr_w(lpParms
->lpstrText
));
774 IVideoWindow_put_Caption(wma
->vidwin
, lpParms
->lpstrText
);
779 /******************************************************************************
780 * MCIAVI_mciUpdate [internal]
782 static DWORD
MCIQTZ_mciUpdate(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_UPDATE_PARMS lpParms
)
787 TRACE("%04x, %08x, %p\n", wDevID
, dwFlags
, lpParms
);
790 return MCIERR_NULL_PARAMETER_BLOCK
;
792 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
794 return MCIERR_INVALID_DEVICE_ID
;
796 if (dwFlags
& MCI_DGV_UPDATE_HDC
) {
803 res
= MCIERR_INTERNAL
;
804 /* If in stopped state, nothing has been drawn to screen
805 * moving to pause, which is needed for the old dib renderer, will result
806 * in a single frame drawn, so hide the window here */
807 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
808 /* FIXME: Should we check the original state and restore it? */
809 IMediaControl_Pause(wma
->pmctrl
);
810 IMediaControl_GetState(wma
->pmctrl
, -1, &state
);
811 if (FAILED(hr
= IBasicVideo_GetCurrentImage(wma
->vidbasic
, &size
, NULL
))) {
812 WARN("Could not get image size (hr = %x)\n", hr
);
815 data
= HeapAlloc(GetProcessHeap(), 0, size
);
816 info
= (BITMAPINFO
*)data
;
817 IBasicVideo_GetCurrentImage(wma
->vidbasic
, &size
, (LONG
*)data
);
818 data
+= info
->bmiHeader
.biSize
;
820 IBasicVideo_GetSourcePosition(wma
->vidbasic
, &src
.left
, &src
.top
, &src
.right
, &src
.bottom
);
821 IBasicVideo_GetDestinationPosition(wma
->vidbasic
, &dest
.left
, &dest
.top
, &dest
.right
, &dest
.bottom
);
822 StretchDIBits(lpParms
->hDC
,
823 dest
.left
, dest
.top
, dest
.right
+ dest
.left
, dest
.bottom
+ dest
.top
,
824 src
.left
, src
.top
, src
.right
+ src
.left
, src
.bottom
+ src
.top
,
825 data
, info
, DIB_RGB_COLORS
, SRCCOPY
);
826 HeapFree(GetProcessHeap(), 0, data
);
830 IVideoWindow_put_Visible(wma
->vidwin
, OATRUE
);
833 FIXME("Unhandled flags %x\n", dwFlags
);
837 /***************************************************************************
838 * MCIQTZ_mciSetAudio [internal]
840 static DWORD
MCIQTZ_mciSetAudio(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_SETAUDIO_PARMSW lpParms
)
844 FIXME("(%04x, %08x, %p) : stub\n", wDevID
, dwFlags
, lpParms
);
847 return MCIERR_NULL_PARAMETER_BLOCK
;
849 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
851 return MCIERR_INVALID_DEVICE_ID
;
853 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
858 /*======================================================================*
859 * MCI QTZ entry points *
860 *======================================================================*/
862 /**************************************************************************
863 * DriverProc (MCIQTZ.@)
865 LRESULT CALLBACK
MCIQTZ_DriverProc(DWORD_PTR dwDevID
, HDRVR hDriv
, UINT wMsg
,
866 LPARAM dwParam1
, LPARAM dwParam2
)
868 TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
869 dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
872 case DRV_LOAD
: return 1;
873 case DRV_FREE
: return 1;
874 case DRV_OPEN
: return MCIQTZ_drvOpen((LPCWSTR
)dwParam1
, (LPMCI_OPEN_DRIVER_PARMSW
)dwParam2
);
875 case DRV_CLOSE
: return MCIQTZ_drvClose(dwDevID
);
876 case DRV_ENABLE
: return 1;
877 case DRV_DISABLE
: return 1;
878 case DRV_QUERYCONFIGURE
: return 1;
879 case DRV_CONFIGURE
: return MCIQTZ_drvConfigure(dwDevID
);
880 case DRV_INSTALL
: return DRVCNF_RESTART
;
881 case DRV_REMOVE
: return DRVCNF_RESTART
;
884 /* session instance */
885 if (dwDevID
== 0xFFFFFFFF)
889 case MCI_OPEN_DRIVER
: return MCIQTZ_mciOpen (dwDevID
, dwParam1
, (LPMCI_DGV_OPEN_PARMSW
) dwParam2
);
890 case MCI_CLOSE_DRIVER
: return MCIQTZ_mciClose (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
891 case MCI_PLAY
: return MCIQTZ_mciPlay (dwDevID
, dwParam1
, (LPMCI_PLAY_PARMS
) dwParam2
);
892 case MCI_SEEK
: return MCIQTZ_mciSeek (dwDevID
, dwParam1
, (LPMCI_SEEK_PARMS
) dwParam2
);
893 case MCI_STOP
: return MCIQTZ_mciStop (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
894 case MCI_PAUSE
: return MCIQTZ_mciPause (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
895 case MCI_GETDEVCAPS
: return MCIQTZ_mciGetDevCaps(dwDevID
, dwParam1
, (LPMCI_GETDEVCAPS_PARMS
) dwParam2
);
896 case MCI_SET
: return MCIQTZ_mciSet (dwDevID
, dwParam1
, (LPMCI_DGV_SET_PARMS
) dwParam2
);
897 case MCI_STATUS
: return MCIQTZ_mciStatus (dwDevID
, dwParam1
, (LPMCI_DGV_STATUS_PARMSW
) dwParam2
);
898 case MCI_WHERE
: return MCIQTZ_mciWhere (dwDevID
, dwParam1
, (LPMCI_DGV_RECT_PARMS
) dwParam2
);
899 /* Digital Video specific */
900 case MCI_SETAUDIO
: return MCIQTZ_mciSetAudio (dwDevID
, dwParam1
, (LPMCI_DGV_SETAUDIO_PARMSW
) dwParam2
);
902 return MCIQTZ_mciUpdate(dwDevID
, dwParam1
, (LPMCI_DGV_UPDATE_PARMS
)dwParam2
);
904 return MCIQTZ_mciWindow(dwDevID
, dwParam1
, (LPMCI_DGV_WINDOW_PARMSW
)dwParam2
);
920 /* Digital Video specific */
931 FIXME("Unimplemented command [%08X]\n", wMsg
);
935 WARN("Unsupported command [%08X]\n", wMsg
);
939 FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
942 TRACE("Sending msg [%08X] to default driver proc\n", wMsg
);
943 return DefDriverProc(dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
946 return MCIERR_UNRECOGNIZED_COMMAND
;