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
);
228 IBasicVideo_GetVideoSize(wma
->vidbasic
, &rc
.right
, &rc
.bottom
);
231 if (dwFlags
& MCI_NOTIFY
)
232 mciDriverNotify(HWND_32(LOWORD(lpOpenParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
238 IUnknown_Release(wma
->vidbasic
);
239 wma
->vidbasic
= NULL
;
241 IUnknown_Release(wma
->seek
);
244 IUnknown_Release(wma
->vidwin
);
247 IGraphBuilder_Release(wma
->pgraph
);
250 IMediaControl_Release(wma
->pmctrl
);
257 return MCIERR_INTERNAL
;
260 /***************************************************************************
261 * MCIQTZ_mciClose [internal]
263 static DWORD
MCIQTZ_mciClose(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
267 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
269 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
271 return MCIERR_INVALID_DEVICE_ID
;
273 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
276 IUnknown_Release(wma
->vidwin
);
277 IUnknown_Release(wma
->vidbasic
);
278 IUnknown_Release(wma
->seek
);
279 IGraphBuilder_Release(wma
->pgraph
);
280 IMediaControl_Release(wma
->pmctrl
);
289 /***************************************************************************
290 * MCIQTZ_mciPlay [internal]
292 static DWORD
MCIQTZ_mciPlay(UINT wDevID
, DWORD dwFlags
, LPMCI_PLAY_PARMS lpParms
)
296 REFERENCE_TIME time1
= 0, time2
= 0;
300 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
303 return MCIERR_NULL_PARAMETER_BLOCK
;
305 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
307 return MCIERR_INVALID_DEVICE_ID
;
309 IMediaSeeking_GetTimeFormat(wma
->seek
, &format
);
310 if (dwFlags
& MCI_FROM
) {
311 if (IsEqualGUID(&format
, &TIME_FORMAT_MEDIA_TIME
))
312 time1
= lpParms
->dwFrom
* 10000;
314 time1
= lpParms
->dwFrom
;
315 pos1
= AM_SEEKING_AbsolutePositioning
;
317 pos1
= AM_SEEKING_NoPositioning
;
318 if (dwFlags
& MCI_TO
) {
319 if (IsEqualGUID(&format
, &TIME_FORMAT_MEDIA_TIME
))
320 time2
= lpParms
->dwTo
* 10000;
322 time2
= lpParms
->dwTo
;
324 IMediaSeeking_GetDuration(wma
->seek
, &time2
);
325 IMediaSeeking_SetPositions(wma
->seek
, &time1
, pos1
, &time2
, AM_SEEKING_AbsolutePositioning
);
327 hr
= IMediaControl_Run(wma
->pmctrl
);
329 TRACE("Cannot run filtergraph (hr = %x)\n", hr
);
330 return MCIERR_INTERNAL
;
333 IVideoWindow_put_Visible(wma
->vidwin
, OATRUE
);
335 if (dwFlags
& MCI_NOTIFY
)
336 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
340 /***************************************************************************
341 * MCIQTZ_mciSeek [internal]
343 static DWORD
MCIQTZ_mciSeek(UINT wDevID
, DWORD dwFlags
, LPMCI_SEEK_PARMS lpParms
)
349 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
352 return MCIERR_NULL_PARAMETER_BLOCK
;
354 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
356 return MCIERR_INVALID_DEVICE_ID
;
358 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
360 if (dwFlags
& MCI_SEEK_TO_START
) {
362 } else if (dwFlags
& MCI_SEEK_TO_END
) {
363 FIXME("MCI_SEEK_TO_END not implemented yet\n");
364 return MCIERR_INTERNAL
;
365 } else if (dwFlags
& MCI_TO
) {
366 FIXME("MCI_TO not implemented yet\n");
367 return MCIERR_INTERNAL
;
369 WARN("dwFlag doesn't tell where to seek to...\n");
370 return MCIERR_MISSING_PARAMETER
;
373 hr
= IMediaSeeking_SetPositions(wma
->seek
, &newpos
, AM_SEEKING_AbsolutePositioning
, NULL
, AM_SEEKING_NoPositioning
);
375 FIXME("Cannot set position (hr = %x)\n", hr
);
376 return MCIERR_INTERNAL
;
379 if (dwFlags
& MCI_NOTIFY
)
380 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
385 /***************************************************************************
386 * MCIQTZ_mciStop [internal]
388 static DWORD
MCIQTZ_mciStop(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
393 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
395 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
397 return MCIERR_INVALID_DEVICE_ID
;
402 hr
= IMediaControl_Stop(wma
->pmctrl
);
404 TRACE("Cannot stop filtergraph (hr = %x)\n", hr
);
405 return MCIERR_INTERNAL
;
409 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
414 /***************************************************************************
415 * MCIQTZ_mciPause [internal]
417 static DWORD
MCIQTZ_mciPause(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
422 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
424 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
426 return MCIERR_INVALID_DEVICE_ID
;
428 hr
= IMediaControl_Pause(wma
->pmctrl
);
430 TRACE("Cannot pause filtergraph (hr = %x)\n", hr
);
431 return MCIERR_INTERNAL
;
437 /***************************************************************************
438 * MCIQTZ_mciGetDevCaps [internal]
440 static DWORD
MCIQTZ_mciGetDevCaps(UINT wDevID
, DWORD dwFlags
, LPMCI_GETDEVCAPS_PARMS lpParms
)
444 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
447 return MCIERR_NULL_PARAMETER_BLOCK
;
449 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
451 return MCIERR_INVALID_DEVICE_ID
;
453 if (!(dwFlags
& MCI_GETDEVCAPS_ITEM
))
454 return MCIERR_MISSING_PARAMETER
;
456 switch (lpParms
->dwItem
) {
457 case MCI_GETDEVCAPS_CAN_RECORD
:
458 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
459 TRACE("MCI_GETDEVCAPS_CAN_RECORD = %08x\n", lpParms
->dwReturn
);
461 case MCI_GETDEVCAPS_HAS_AUDIO
:
462 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
463 TRACE("MCI_GETDEVCAPS_HAS_AUDIO = %08x\n", lpParms
->dwReturn
);
465 case MCI_GETDEVCAPS_HAS_VIDEO
:
466 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
467 TRACE("MCI_GETDEVCAPS_HAS_VIDEO = %08x\n", lpParms
->dwReturn
);
469 case MCI_GETDEVCAPS_DEVICE_TYPE
:
470 lpParms
->dwReturn
= MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO
, MCI_DEVTYPE_DIGITAL_VIDEO
);
471 TRACE("MCI_GETDEVCAPS_DEVICE_TYPE = %08x\n", lpParms
->dwReturn
);
473 case MCI_GETDEVCAPS_USES_FILES
:
474 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
475 TRACE("MCI_GETDEVCAPS_USES_FILES = %08x\n", lpParms
->dwReturn
);
477 case MCI_GETDEVCAPS_COMPOUND_DEVICE
:
478 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
479 TRACE("MCI_GETDEVCAPS_COMPOUND_DEVICE = %08x\n", lpParms
->dwReturn
);
481 case MCI_GETDEVCAPS_CAN_EJECT
:
482 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
483 TRACE("MCI_GETDEVCAPS_EJECT = %08x\n", lpParms
->dwReturn
);
485 case MCI_GETDEVCAPS_CAN_PLAY
:
486 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
487 TRACE("MCI_GETDEVCAPS_CAN_PLAY = %08x\n", lpParms
->dwReturn
);
489 case MCI_GETDEVCAPS_CAN_SAVE
:
490 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
491 TRACE("MCI_GETDEVCAPS_CAN_SAVE = %08x\n", lpParms
->dwReturn
);
493 case MCI_DGV_GETDEVCAPS_CAN_REVERSE
:
494 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
495 TRACE("MCI_DGV_GETDEVCAPS_CAN_REVERSE = %08x\n", lpParms
->dwReturn
);
497 case MCI_DGV_GETDEVCAPS_CAN_STRETCH
:
498 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
); /* FIXME */
499 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH = %08x\n", lpParms
->dwReturn
);
501 case MCI_DGV_GETDEVCAPS_CAN_LOCK
:
502 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
503 TRACE("MCI_DGV_GETDEVCAPS_CAN_LOCK = %08x\n", lpParms
->dwReturn
);
505 case MCI_DGV_GETDEVCAPS_CAN_FREEZE
:
506 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
507 TRACE("MCI_DGV_GETDEVCAPS_CAN_FREEZE = %08x\n", lpParms
->dwReturn
);
509 case MCI_DGV_GETDEVCAPS_CAN_STR_IN
:
510 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
511 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH_INPUT = %08x\n", lpParms
->dwReturn
);
513 case MCI_DGV_GETDEVCAPS_HAS_STILL
:
514 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
515 TRACE("MCI_DGV_GETDEVCAPS_HAS_STILL = %08x\n", lpParms
->dwReturn
);
517 case MCI_DGV_GETDEVCAPS_CAN_TEST
:
518 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
); /* FIXME */
519 TRACE("MCI_DGV_GETDEVCAPS_CAN_TEST = %08x\n", lpParms
->dwReturn
);
521 case MCI_DGV_GETDEVCAPS_MAX_WINDOWS
:
522 lpParms
->dwReturn
= 1;
523 TRACE("MCI_DGV_GETDEVCAPS_MAX_WINDOWS = %u\n", lpParms
->dwReturn
);
526 WARN("Unknown capability %08x\n", lpParms
->dwItem
);
528 case MCI_DGV_GETDEVCAPS_MAXIMUM_RATE
: /* unknown to w2k */
529 case MCI_DGV_GETDEVCAPS_MINIMUM_RATE
: /* unknown to w2k */
530 return MCIERR_UNSUPPORTED_FUNCTION
;
533 return MCI_RESOURCE_RETURNED
;
536 /***************************************************************************
537 * MCIQTZ_mciSet [internal]
539 static DWORD
MCIQTZ_mciSet(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_SET_PARMS lpParms
)
543 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
546 return MCIERR_NULL_PARAMETER_BLOCK
;
548 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
550 return MCIERR_INVALID_DEVICE_ID
;
552 if (dwFlags
& MCI_SET_TIME_FORMAT
) {
553 switch (lpParms
->dwTimeFormat
) {
554 case MCI_FORMAT_MILLISECONDS
:
555 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_MILLISECONDS\n");
556 wma
->time_format
= MCI_FORMAT_MILLISECONDS
;
558 case MCI_FORMAT_FRAMES
:
559 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_FRAMES\n");
560 wma
->time_format
= MCI_FORMAT_FRAMES
;
563 WARN("Bad time format %u\n", lpParms
->dwTimeFormat
);
564 return MCIERR_BAD_TIME_FORMAT
;
568 if (dwFlags
& MCI_SET_DOOR_OPEN
)
569 FIXME("MCI_SET_DOOR_OPEN not implemented yet\n");
570 if (dwFlags
& MCI_SET_DOOR_CLOSED
)
571 FIXME("MCI_SET_DOOR_CLOSED not implemented yet\n");
572 if (dwFlags
& MCI_SET_AUDIO
)
573 FIXME("MCI_SET_AUDIO not implemented yet\n");
574 if (dwFlags
& MCI_SET_VIDEO
)
575 FIXME("MCI_SET_VIDEO not implemented yet\n");
576 if (dwFlags
& MCI_SET_ON
)
577 FIXME("MCI_SET_ON not implemented yet\n");
578 if (dwFlags
& MCI_SET_OFF
)
579 FIXME("MCI_SET_OFF not implemented yet\n");
580 if (dwFlags
& MCI_SET_AUDIO_LEFT
)
581 FIXME("MCI_SET_AUDIO_LEFT not implemented yet\n");
582 if (dwFlags
& MCI_SET_AUDIO_RIGHT
)
583 FIXME("MCI_SET_AUDIO_RIGHT not implemented yet\n");
585 if (dwFlags
& ~0x7f03 /* All MCI_SET flags mask */)
586 ERR("Unknown flags %08x\n", dwFlags
& ~0x7f03);
591 /***************************************************************************
592 * MCIQTZ_mciStatus [internal]
594 static DWORD
MCIQTZ_mciStatus(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_STATUS_PARMSW lpParms
)
599 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
602 return MCIERR_NULL_PARAMETER_BLOCK
;
604 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
606 return MCIERR_INVALID_DEVICE_ID
;
608 if (!(dwFlags
& MCI_STATUS_ITEM
)) {
609 WARN("No status item specified\n");
610 return MCIERR_UNRECOGNIZED_COMMAND
;
613 switch (lpParms
->dwItem
) {
614 case MCI_STATUS_LENGTH
: {
615 LONGLONG duration
= -1;
617 switch (wma
->time_format
) {
618 case MCI_FORMAT_MILLISECONDS
: format
= TIME_FORMAT_MEDIA_TIME
; break;
619 case MCI_FORMAT_FRAMES
: format
= TIME_FORMAT_FRAME
; break;
620 default: ERR("Unhandled format %x\n", wma
->time_format
); break;
622 hr
= IMediaSeeking_SetTimeFormat(wma
->seek
, &format
);
624 FIXME("Cannot set time format (hr = %x)\n", hr
);
625 lpParms
->dwReturn
= 0;
628 hr
= IMediaSeeking_GetDuration(wma
->seek
, &duration
);
629 if (FAILED(hr
) || duration
< 0) {
630 FIXME("Cannot read duration (hr = %x)\n", hr
);
631 lpParms
->dwReturn
= 0;
632 } else if (wma
->time_format
!= MCI_FORMAT_MILLISECONDS
)
633 lpParms
->dwReturn
= duration
;
635 lpParms
->dwReturn
= duration
/ 10000;
638 case MCI_STATUS_POSITION
: {
639 REFERENCE_TIME curpos
;
641 hr
= IMediaSeeking_GetCurrentPosition(wma
->seek
, &curpos
);
643 FIXME("Cannot get position (hr = %x)\n", hr
);
644 return MCIERR_INTERNAL
;
646 lpParms
->dwReturn
= curpos
/ 10000;
649 case MCI_STATUS_NUMBER_OF_TRACKS
:
650 FIXME("MCI_STATUS_NUMBER_OF_TRACKS not implemented yet\n");
651 return MCIERR_UNRECOGNIZED_COMMAND
;
652 case MCI_STATUS_MODE
: {
653 LONG state
= State_Stopped
;
654 IMediaControl_GetState(wma
->pmctrl
, -1, &state
);
655 if (state
== State_Stopped
)
656 state
= MCI_MODE_STOP
;
657 else if (state
== State_Running
)
658 state
= MCI_MODE_PLAY
;
659 else if (state
== State_Paused
)
660 state
= MCI_MODE_PAUSE
;
663 case MCI_STATUS_MEDIA_PRESENT
:
664 FIXME("MCI_STATUS_MEDIA_PRESENT not implemented yet\n");
665 return MCIERR_UNRECOGNIZED_COMMAND
;
666 case MCI_STATUS_TIME_FORMAT
:
667 lpParms
->dwReturn
= wma
->time_format
;
669 case MCI_STATUS_READY
:
670 FIXME("MCI_STATUS_READY not implemented yet\n");
671 return MCIERR_UNRECOGNIZED_COMMAND
;
672 case MCI_STATUS_CURRENT_TRACK
:
673 FIXME("MCI_STATUS_CURRENT_TRACK not implemented yet\n");
674 return MCIERR_UNRECOGNIZED_COMMAND
;
676 FIXME("Unknown command %08X\n", lpParms
->dwItem
);
677 return MCIERR_UNRECOGNIZED_COMMAND
;
680 if (dwFlags
& MCI_NOTIFY
)
681 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
686 /***************************************************************************
687 * MCIQTZ_mciWhere [internal]
689 static DWORD
MCIQTZ_mciWhere(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_RECT_PARMS lpParms
)
695 DWORD ret
= MCIERR_UNRECOGNIZED_COMMAND
;
697 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
700 return MCIERR_NULL_PARAMETER_BLOCK
;
702 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
704 return MCIERR_INVALID_DEVICE_ID
;
706 hr
= IVideoWindow_get_Owner(wma
->vidwin
, (OAHWND
*)&hWnd
);
708 TRACE("No video stream, returning no window error\n");
709 return MCIERR_NO_WINDOW
;
712 if (dwFlags
& MCI_DGV_WHERE_SOURCE
) {
713 if (dwFlags
& MCI_DGV_WHERE_MAX
)
714 FIXME("MCI_DGV_WHERE_SOURCE_MAX stub %s\n", wine_dbgstr_rect(&rc
));
715 IBasicVideo_GetSourcePosition(wma
->vidbasic
, &rc
.left
, &rc
.top
, &rc
.right
, &rc
.bottom
);
716 TRACE("MCI_DGV_WHERE_SOURCE %s\n", wine_dbgstr_rect(&rc
));
718 if (dwFlags
& MCI_DGV_WHERE_DESTINATION
) {
719 if (dwFlags
& MCI_DGV_WHERE_MAX
)
720 FIXME("MCI_DGV_WHERE_DESTINATION_MAX stub %s\n", wine_dbgstr_rect(&rc
));
721 IBasicVideo_GetDestinationPosition(wma
->vidbasic
, &rc
.left
, &rc
.top
, &rc
.right
, &rc
.bottom
);
722 TRACE("MCI_DGV_WHERE_DESTINATION %s\n", wine_dbgstr_rect(&rc
));
724 if (dwFlags
& MCI_DGV_WHERE_FRAME
) {
725 if (dwFlags
& MCI_DGV_WHERE_MAX
)
726 FIXME("MCI_DGV_WHERE_FRAME_MAX not supported yet\n");
728 FIXME("MCI_DGV_WHERE_FRAME not supported yet\n");
731 if (dwFlags
& MCI_DGV_WHERE_VIDEO
) {
732 if (dwFlags
& MCI_DGV_WHERE_MAX
)
733 FIXME("MCI_DGV_WHERE_VIDEO_MAX not supported yet\n");
735 FIXME("MCI_DGV_WHERE_VIDEO not supported yet\n");
738 if (dwFlags
& MCI_DGV_WHERE_WINDOW
) {
739 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
740 GetWindowRect(GetDesktopWindow(), &rc
);
743 TRACE("MCI_DGV_WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&rc
));
745 IVideoWindow_GetWindowPosition(wma
->vidwin
, &rc
.left
, &rc
.top
, &rc
.right
, &rc
.bottom
);
746 TRACE("MCI_DGV_WHERE_WINDOW %s\n", wine_dbgstr_rect(&rc
));
755 /***************************************************************************
756 * MCIQTZ_mciWindow [internal]
758 static DWORD
MCIQTZ_mciWindow(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_WINDOW_PARMSW lpParms
)
760 WINE_MCIQTZ
*wma
= MCIQTZ_mciGetOpenDev(wDevID
);
762 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
765 return MCIERR_NULL_PARAMETER_BLOCK
;
767 return MCIERR_INVALID_DEVICE_ID
;
768 if (dwFlags
& MCI_TEST
)
771 if (dwFlags
& MCI_DGV_WINDOW_HWND
&& (IsWindow(lpParms
->hWnd
) || !lpParms
->hWnd
)) {
772 LONG visible
= OATRUE
;
774 TRACE("Setting hWnd to %p\n", lpParms
->hWnd
);
775 IVideoWindow_get_Visible(wma
->vidwin
, &visible
);
776 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
777 IVideoWindow_get_WindowStyle(wma
->vidwin
, &style
);
780 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
|WS_CHILD
);
782 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
);
783 IVideoWindow_put_Owner(wma
->vidwin
, (OAHWND
)lpParms
->hWnd
);
784 IVideoWindow_put_MessageDrain(wma
->vidwin
, (OAHWND
)lpParms
->hWnd
);
785 IVideoWindow_put_Visible(wma
->vidwin
, visible
);
786 wma
->parent
= lpParms
->hWnd
;
788 if (dwFlags
& MCI_DGV_WINDOW_STATE
) {
789 TRACE("Setting nCmdShow to %d\n", lpParms
->nCmdShow
);
790 IVideoWindow_put_WindowState(wma
->vidwin
, lpParms
->nCmdShow
);
792 if (dwFlags
& MCI_DGV_WINDOW_TEXT
) {
793 TRACE("Setting caption to %s\n", debugstr_w(lpParms
->lpstrText
));
794 IVideoWindow_put_Caption(wma
->vidwin
, lpParms
->lpstrText
);
799 /******************************************************************************
800 * MCIAVI_mciUpdate [internal]
802 static DWORD
MCIQTZ_mciUpdate(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_UPDATE_PARMS lpParms
)
807 TRACE("%04x, %08x, %p\n", wDevID
, dwFlags
, lpParms
);
810 return MCIERR_NULL_PARAMETER_BLOCK
;
812 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
814 return MCIERR_INVALID_DEVICE_ID
;
816 if (dwFlags
& MCI_DGV_UPDATE_HDC
) {
822 LONG visible
= OATRUE
;
824 res
= MCIERR_INTERNAL
;
825 /* If in stopped state, nothing has been drawn to screen
826 * moving to pause, which is needed for the old dib renderer, will result
827 * in a single frame drawn, so hide the window here */
828 IVideoWindow_get_Visible(wma
->vidwin
, &visible
);
830 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
831 /* FIXME: Should we check the original state and restore it? */
832 IMediaControl_Pause(wma
->pmctrl
);
833 IMediaControl_GetState(wma
->pmctrl
, -1, &state
);
834 if (FAILED(hr
= IBasicVideo_GetCurrentImage(wma
->vidbasic
, &size
, NULL
))) {
835 WARN("Could not get image size (hr = %x)\n", hr
);
838 data
= HeapAlloc(GetProcessHeap(), 0, size
);
839 info
= (BITMAPINFO
*)data
;
840 IBasicVideo_GetCurrentImage(wma
->vidbasic
, &size
, (LONG
*)data
);
841 data
+= info
->bmiHeader
.biSize
;
843 IBasicVideo_GetSourcePosition(wma
->vidbasic
, &src
.left
, &src
.top
, &src
.right
, &src
.bottom
);
844 IBasicVideo_GetDestinationPosition(wma
->vidbasic
, &dest
.left
, &dest
.top
, &dest
.right
, &dest
.bottom
);
845 StretchDIBits(lpParms
->hDC
,
846 dest
.left
, dest
.top
, dest
.right
+ dest
.left
, dest
.bottom
+ dest
.top
,
847 src
.left
, src
.top
, src
.right
+ src
.left
, src
.bottom
+ src
.top
,
848 data
, info
, DIB_RGB_COLORS
, SRCCOPY
);
849 HeapFree(GetProcessHeap(), 0, data
);
853 IVideoWindow_put_Visible(wma
->vidwin
, visible
);
856 FIXME("Unhandled flags %x\n", dwFlags
);
860 /***************************************************************************
861 * MCIQTZ_mciSetAudio [internal]
863 static DWORD
MCIQTZ_mciSetAudio(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_SETAUDIO_PARMSW lpParms
)
867 FIXME("(%04x, %08x, %p) : stub\n", wDevID
, dwFlags
, lpParms
);
870 return MCIERR_NULL_PARAMETER_BLOCK
;
872 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
874 return MCIERR_INVALID_DEVICE_ID
;
876 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
881 /*======================================================================*
882 * MCI QTZ entry points *
883 *======================================================================*/
885 /**************************************************************************
886 * DriverProc (MCIQTZ.@)
888 LRESULT CALLBACK
MCIQTZ_DriverProc(DWORD_PTR dwDevID
, HDRVR hDriv
, UINT wMsg
,
889 LPARAM dwParam1
, LPARAM dwParam2
)
891 TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
892 dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
895 case DRV_LOAD
: return 1;
896 case DRV_FREE
: return 1;
897 case DRV_OPEN
: return MCIQTZ_drvOpen((LPCWSTR
)dwParam1
, (LPMCI_OPEN_DRIVER_PARMSW
)dwParam2
);
898 case DRV_CLOSE
: return MCIQTZ_drvClose(dwDevID
);
899 case DRV_ENABLE
: return 1;
900 case DRV_DISABLE
: return 1;
901 case DRV_QUERYCONFIGURE
: return 1;
902 case DRV_CONFIGURE
: return MCIQTZ_drvConfigure(dwDevID
);
903 case DRV_INSTALL
: return DRVCNF_RESTART
;
904 case DRV_REMOVE
: return DRVCNF_RESTART
;
907 /* session instance */
908 if (dwDevID
== 0xFFFFFFFF)
912 case MCI_OPEN_DRIVER
: return MCIQTZ_mciOpen (dwDevID
, dwParam1
, (LPMCI_DGV_OPEN_PARMSW
) dwParam2
);
913 case MCI_CLOSE_DRIVER
: return MCIQTZ_mciClose (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
914 case MCI_PLAY
: return MCIQTZ_mciPlay (dwDevID
, dwParam1
, (LPMCI_PLAY_PARMS
) dwParam2
);
915 case MCI_SEEK
: return MCIQTZ_mciSeek (dwDevID
, dwParam1
, (LPMCI_SEEK_PARMS
) dwParam2
);
916 case MCI_STOP
: return MCIQTZ_mciStop (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
917 case MCI_PAUSE
: return MCIQTZ_mciPause (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
918 case MCI_GETDEVCAPS
: return MCIQTZ_mciGetDevCaps(dwDevID
, dwParam1
, (LPMCI_GETDEVCAPS_PARMS
) dwParam2
);
919 case MCI_SET
: return MCIQTZ_mciSet (dwDevID
, dwParam1
, (LPMCI_DGV_SET_PARMS
) dwParam2
);
920 case MCI_STATUS
: return MCIQTZ_mciStatus (dwDevID
, dwParam1
, (LPMCI_DGV_STATUS_PARMSW
) dwParam2
);
921 case MCI_WHERE
: return MCIQTZ_mciWhere (dwDevID
, dwParam1
, (LPMCI_DGV_RECT_PARMS
) dwParam2
);
922 /* Digital Video specific */
923 case MCI_SETAUDIO
: return MCIQTZ_mciSetAudio (dwDevID
, dwParam1
, (LPMCI_DGV_SETAUDIO_PARMSW
) dwParam2
);
925 return MCIQTZ_mciUpdate(dwDevID
, dwParam1
, (LPMCI_DGV_UPDATE_PARMS
)dwParam2
);
927 return MCIQTZ_mciWindow(dwDevID
, dwParam1
, (LPMCI_DGV_WINDOW_PARMSW
)dwParam2
);
943 /* Digital Video specific */
954 FIXME("Unimplemented command [%08X]\n", wMsg
);
958 WARN("Unsupported command [%08X]\n", wMsg
);
962 FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
965 TRACE("Sending msg [%08X] to default driver proc\n", wMsg
);
966 return DefDriverProc(dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
969 return MCIERR_UNRECOGNIZED_COMMAND
;