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 static 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_IMediaEvent
, (void**)&wma
->mevent
);
185 TRACE("Cannot get IMediaEvent interface (hr = %x)\n", hr
);
189 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IVideoWindow
, (void**)&wma
->vidwin
);
191 TRACE("Cannot get IVideoWindow interface (hr = %x)\n", hr
);
195 hr
= IGraphBuilder_QueryInterface(wma
->pgraph
, &IID_IBasicVideo
, (void**)&wma
->vidbasic
);
197 TRACE("Cannot get IBasicVideo interface (hr = %x)\n", hr
);
201 if (!(dwFlags
& MCI_OPEN_ELEMENT
) || (dwFlags
& MCI_OPEN_ELEMENT_ID
)) {
202 TRACE("Wrong dwFlags %x\n", dwFlags
);
206 if (!lpOpenParms
->lpstrElementName
|| !lpOpenParms
->lpstrElementName
[0]) {
207 TRACE("Invalid filename specified\n");
211 TRACE("Open file %s\n", debugstr_w(lpOpenParms
->lpstrElementName
));
213 hr
= IGraphBuilder_RenderFile(wma
->pgraph
, lpOpenParms
->lpstrElementName
, NULL
);
215 TRACE("Cannot render file (hr = %x)\n", hr
);
219 IVideoWindow_put_AutoShow(wma
->vidwin
, OAFALSE
);
220 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
221 if (dwFlags
& MCI_DGV_OPEN_WS
)
222 style
= lpOpenParms
->dwStyle
;
223 if (dwFlags
& MCI_DGV_OPEN_PARENT
) {
224 IVideoWindow_put_MessageDrain(wma
->vidwin
, (OAHWND
)lpOpenParms
->hWndParent
);
225 IVideoWindow_put_WindowState(wma
->vidwin
, SW_HIDE
);
226 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
|WS_CHILD
);
227 IVideoWindow_put_Owner(wma
->vidwin
, (OAHWND
)lpOpenParms
->hWndParent
);
228 GetClientRect(lpOpenParms
->hWndParent
, &rc
);
229 IVideoWindow_SetWindowPosition(wma
->vidwin
, rc
.left
, rc
.top
, rc
.right
- rc
.top
, rc
.bottom
- rc
.top
);
230 wma
->parent
= (HWND
)lpOpenParms
->hWndParent
;
233 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
);
234 IBasicVideo_GetVideoSize(wma
->vidbasic
, &rc
.right
, &rc
.bottom
);
237 if (dwFlags
& MCI_NOTIFY
)
238 mciDriverNotify(HWND_32(LOWORD(lpOpenParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
244 IBasicVideo_Release(wma
->vidbasic
);
245 wma
->vidbasic
= NULL
;
247 IMediaSeeking_Release(wma
->seek
);
250 IVideoWindow_Release(wma
->vidwin
);
253 IGraphBuilder_Release(wma
->pgraph
);
256 IMediaEvent_Release(wma
->mevent
);
259 IMediaControl_Release(wma
->pmctrl
);
266 return MCIERR_INTERNAL
;
269 /***************************************************************************
270 * MCIQTZ_mciClose [internal]
272 static DWORD
MCIQTZ_mciClose(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
276 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
278 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
280 return MCIERR_INVALID_DEVICE_ID
;
282 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
285 IVideoWindow_Release(wma
->vidwin
);
286 IBasicVideo_Release(wma
->vidbasic
);
287 IMediaSeeking_Release(wma
->seek
);
288 IMediaEvent_Release(wma
->mevent
);
289 IGraphBuilder_Release(wma
->pgraph
);
290 IMediaControl_Release(wma
->pmctrl
);
299 /***************************************************************************
300 * MCIQTZ_mciPlay [internal]
302 static DWORD
MCIQTZ_mciPlay(UINT wDevID
, DWORD dwFlags
, LPMCI_PLAY_PARMS lpParms
)
306 REFERENCE_TIME time1
= 0, time2
= 0;
310 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
313 return MCIERR_NULL_PARAMETER_BLOCK
;
315 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
317 return MCIERR_INVALID_DEVICE_ID
;
319 IMediaSeeking_GetTimeFormat(wma
->seek
, &format
);
320 if (dwFlags
& MCI_FROM
) {
321 if (IsEqualGUID(&format
, &TIME_FORMAT_MEDIA_TIME
))
322 time1
= lpParms
->dwFrom
* 10000;
324 time1
= lpParms
->dwFrom
;
325 pos1
= AM_SEEKING_AbsolutePositioning
;
327 pos1
= AM_SEEKING_NoPositioning
;
328 if (dwFlags
& MCI_TO
) {
329 if (IsEqualGUID(&format
, &TIME_FORMAT_MEDIA_TIME
))
330 time2
= lpParms
->dwTo
* 10000;
332 time2
= lpParms
->dwTo
;
334 IMediaSeeking_GetDuration(wma
->seek
, &time2
);
335 IMediaSeeking_SetPositions(wma
->seek
, &time1
, pos1
, &time2
, AM_SEEKING_AbsolutePositioning
);
337 hr
= IMediaControl_Run(wma
->pmctrl
);
339 TRACE("Cannot run filtergraph (hr = %x)\n", hr
);
340 return MCIERR_INTERNAL
;
343 IVideoWindow_put_Visible(wma
->vidwin
, OATRUE
);
345 if (dwFlags
& MCI_NOTIFY
)
346 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
350 /***************************************************************************
351 * MCIQTZ_mciSeek [internal]
353 static DWORD
MCIQTZ_mciSeek(UINT wDevID
, DWORD dwFlags
, LPMCI_SEEK_PARMS lpParms
)
359 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
362 return MCIERR_NULL_PARAMETER_BLOCK
;
364 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
366 return MCIERR_INVALID_DEVICE_ID
;
368 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
370 if (dwFlags
& MCI_SEEK_TO_START
) {
372 } else if (dwFlags
& MCI_SEEK_TO_END
) {
373 FIXME("MCI_SEEK_TO_END not implemented yet\n");
374 return MCIERR_INTERNAL
;
375 } else if (dwFlags
& MCI_TO
) {
376 FIXME("MCI_TO not implemented yet\n");
377 return MCIERR_INTERNAL
;
379 WARN("dwFlag doesn't tell where to seek to...\n");
380 return MCIERR_MISSING_PARAMETER
;
383 hr
= IMediaSeeking_SetPositions(wma
->seek
, &newpos
, AM_SEEKING_AbsolutePositioning
, NULL
, AM_SEEKING_NoPositioning
);
385 FIXME("Cannot set position (hr = %x)\n", hr
);
386 return MCIERR_INTERNAL
;
389 if (dwFlags
& MCI_NOTIFY
)
390 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
395 /***************************************************************************
396 * MCIQTZ_mciStop [internal]
398 static DWORD
MCIQTZ_mciStop(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
403 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
405 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
407 return MCIERR_INVALID_DEVICE_ID
;
412 hr
= IMediaControl_Stop(wma
->pmctrl
);
414 TRACE("Cannot stop filtergraph (hr = %x)\n", hr
);
415 return MCIERR_INTERNAL
;
419 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
424 /***************************************************************************
425 * MCIQTZ_mciPause [internal]
427 static DWORD
MCIQTZ_mciPause(UINT wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
432 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
434 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
436 return MCIERR_INVALID_DEVICE_ID
;
438 hr
= IMediaControl_Pause(wma
->pmctrl
);
440 TRACE("Cannot pause filtergraph (hr = %x)\n", hr
);
441 return MCIERR_INTERNAL
;
447 /***************************************************************************
448 * MCIQTZ_mciGetDevCaps [internal]
450 static DWORD
MCIQTZ_mciGetDevCaps(UINT wDevID
, DWORD dwFlags
, LPMCI_GETDEVCAPS_PARMS lpParms
)
454 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
457 return MCIERR_NULL_PARAMETER_BLOCK
;
459 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
461 return MCIERR_INVALID_DEVICE_ID
;
463 if (!(dwFlags
& MCI_GETDEVCAPS_ITEM
))
464 return MCIERR_MISSING_PARAMETER
;
466 switch (lpParms
->dwItem
) {
467 case MCI_GETDEVCAPS_CAN_RECORD
:
468 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
469 TRACE("MCI_GETDEVCAPS_CAN_RECORD = %08x\n", lpParms
->dwReturn
);
471 case MCI_GETDEVCAPS_HAS_AUDIO
:
472 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
473 TRACE("MCI_GETDEVCAPS_HAS_AUDIO = %08x\n", lpParms
->dwReturn
);
475 case MCI_GETDEVCAPS_HAS_VIDEO
:
476 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
477 TRACE("MCI_GETDEVCAPS_HAS_VIDEO = %08x\n", lpParms
->dwReturn
);
479 case MCI_GETDEVCAPS_DEVICE_TYPE
:
480 lpParms
->dwReturn
= MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO
, MCI_DEVTYPE_DIGITAL_VIDEO
);
481 TRACE("MCI_GETDEVCAPS_DEVICE_TYPE = %08x\n", lpParms
->dwReturn
);
483 case MCI_GETDEVCAPS_USES_FILES
:
484 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
485 TRACE("MCI_GETDEVCAPS_USES_FILES = %08x\n", lpParms
->dwReturn
);
487 case MCI_GETDEVCAPS_COMPOUND_DEVICE
:
488 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
489 TRACE("MCI_GETDEVCAPS_COMPOUND_DEVICE = %08x\n", lpParms
->dwReturn
);
491 case MCI_GETDEVCAPS_CAN_EJECT
:
492 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
493 TRACE("MCI_GETDEVCAPS_EJECT = %08x\n", lpParms
->dwReturn
);
495 case MCI_GETDEVCAPS_CAN_PLAY
:
496 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
497 TRACE("MCI_GETDEVCAPS_CAN_PLAY = %08x\n", lpParms
->dwReturn
);
499 case MCI_GETDEVCAPS_CAN_SAVE
:
500 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
501 TRACE("MCI_GETDEVCAPS_CAN_SAVE = %08x\n", lpParms
->dwReturn
);
503 case MCI_DGV_GETDEVCAPS_CAN_REVERSE
:
504 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
505 TRACE("MCI_DGV_GETDEVCAPS_CAN_REVERSE = %08x\n", lpParms
->dwReturn
);
507 case MCI_DGV_GETDEVCAPS_CAN_STRETCH
:
508 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
); /* FIXME */
509 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH = %08x\n", lpParms
->dwReturn
);
511 case MCI_DGV_GETDEVCAPS_CAN_LOCK
:
512 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
513 TRACE("MCI_DGV_GETDEVCAPS_CAN_LOCK = %08x\n", lpParms
->dwReturn
);
515 case MCI_DGV_GETDEVCAPS_CAN_FREEZE
:
516 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
517 TRACE("MCI_DGV_GETDEVCAPS_CAN_FREEZE = %08x\n", lpParms
->dwReturn
);
519 case MCI_DGV_GETDEVCAPS_CAN_STR_IN
:
520 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
521 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH_INPUT = %08x\n", lpParms
->dwReturn
);
523 case MCI_DGV_GETDEVCAPS_HAS_STILL
:
524 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
525 TRACE("MCI_DGV_GETDEVCAPS_HAS_STILL = %08x\n", lpParms
->dwReturn
);
527 case MCI_DGV_GETDEVCAPS_CAN_TEST
:
528 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
); /* FIXME */
529 TRACE("MCI_DGV_GETDEVCAPS_CAN_TEST = %08x\n", lpParms
->dwReturn
);
531 case MCI_DGV_GETDEVCAPS_MAX_WINDOWS
:
532 lpParms
->dwReturn
= 1;
533 TRACE("MCI_DGV_GETDEVCAPS_MAX_WINDOWS = %u\n", lpParms
->dwReturn
);
536 WARN("Unknown capability %08x\n", lpParms
->dwItem
);
538 case MCI_DGV_GETDEVCAPS_MAXIMUM_RATE
: /* unknown to w2k */
539 case MCI_DGV_GETDEVCAPS_MINIMUM_RATE
: /* unknown to w2k */
540 return MCIERR_UNSUPPORTED_FUNCTION
;
543 return MCI_RESOURCE_RETURNED
;
546 /***************************************************************************
547 * MCIQTZ_mciSet [internal]
549 static DWORD
MCIQTZ_mciSet(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_SET_PARMS lpParms
)
553 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
556 return MCIERR_NULL_PARAMETER_BLOCK
;
558 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
560 return MCIERR_INVALID_DEVICE_ID
;
562 if (dwFlags
& MCI_SET_TIME_FORMAT
) {
563 switch (lpParms
->dwTimeFormat
) {
564 case MCI_FORMAT_MILLISECONDS
:
565 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_MILLISECONDS\n");
566 wma
->time_format
= MCI_FORMAT_MILLISECONDS
;
568 case MCI_FORMAT_FRAMES
:
569 TRACE("MCI_SET_TIME_FORMAT = MCI_FORMAT_FRAMES\n");
570 wma
->time_format
= MCI_FORMAT_FRAMES
;
573 WARN("Bad time format %u\n", lpParms
->dwTimeFormat
);
574 return MCIERR_BAD_TIME_FORMAT
;
578 if (dwFlags
& MCI_SET_DOOR_OPEN
)
579 FIXME("MCI_SET_DOOR_OPEN not implemented yet\n");
580 if (dwFlags
& MCI_SET_DOOR_CLOSED
)
581 FIXME("MCI_SET_DOOR_CLOSED not implemented yet\n");
582 if (dwFlags
& MCI_SET_AUDIO
)
583 FIXME("MCI_SET_AUDIO not implemented yet\n");
584 if (dwFlags
& MCI_SET_VIDEO
)
585 FIXME("MCI_SET_VIDEO not implemented yet\n");
586 if (dwFlags
& MCI_SET_ON
)
587 FIXME("MCI_SET_ON not implemented yet\n");
588 if (dwFlags
& MCI_SET_OFF
)
589 FIXME("MCI_SET_OFF not implemented yet\n");
590 if (dwFlags
& MCI_SET_AUDIO_LEFT
)
591 FIXME("MCI_SET_AUDIO_LEFT not implemented yet\n");
592 if (dwFlags
& MCI_SET_AUDIO_RIGHT
)
593 FIXME("MCI_SET_AUDIO_RIGHT not implemented yet\n");
595 if (dwFlags
& ~0x7f03 /* All MCI_SET flags mask */)
596 ERR("Unknown flags %08x\n", dwFlags
& ~0x7f03);
601 /***************************************************************************
602 * MCIQTZ_mciStatus [internal]
604 static DWORD
MCIQTZ_mciStatus(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_STATUS_PARMSW lpParms
)
609 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
612 return MCIERR_NULL_PARAMETER_BLOCK
;
614 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
616 return MCIERR_INVALID_DEVICE_ID
;
618 if (!(dwFlags
& MCI_STATUS_ITEM
)) {
619 WARN("No status item specified\n");
620 return MCIERR_UNRECOGNIZED_COMMAND
;
623 switch (lpParms
->dwItem
) {
624 case MCI_STATUS_LENGTH
: {
625 LONGLONG duration
= -1;
627 switch (wma
->time_format
) {
628 case MCI_FORMAT_MILLISECONDS
: format
= TIME_FORMAT_MEDIA_TIME
; break;
629 case MCI_FORMAT_FRAMES
: format
= TIME_FORMAT_FRAME
; break;
630 default: ERR("Unhandled format %x\n", wma
->time_format
); break;
632 hr
= IMediaSeeking_SetTimeFormat(wma
->seek
, &format
);
634 FIXME("Cannot set time format (hr = %x)\n", hr
);
635 lpParms
->dwReturn
= 0;
638 hr
= IMediaSeeking_GetDuration(wma
->seek
, &duration
);
639 if (FAILED(hr
) || duration
< 0) {
640 FIXME("Cannot read duration (hr = %x)\n", hr
);
641 lpParms
->dwReturn
= 0;
642 } else if (wma
->time_format
!= MCI_FORMAT_MILLISECONDS
)
643 lpParms
->dwReturn
= duration
;
645 lpParms
->dwReturn
= duration
/ 10000;
648 case MCI_STATUS_POSITION
: {
649 REFERENCE_TIME curpos
;
651 hr
= IMediaSeeking_GetCurrentPosition(wma
->seek
, &curpos
);
653 FIXME("Cannot get position (hr = %x)\n", hr
);
654 return MCIERR_INTERNAL
;
656 lpParms
->dwReturn
= curpos
/ 10000;
659 case MCI_STATUS_NUMBER_OF_TRACKS
:
660 FIXME("MCI_STATUS_NUMBER_OF_TRACKS not implemented yet\n");
661 return MCIERR_UNRECOGNIZED_COMMAND
;
662 case MCI_STATUS_MODE
: {
663 LONG state
= State_Stopped
;
664 IMediaControl_GetState(wma
->pmctrl
, -1, &state
);
665 if (state
== State_Stopped
)
666 lpParms
->dwReturn
= MCI_MODE_STOP
;
667 else if (state
== State_Running
) {
671 lpParms
->dwReturn
= MCI_MODE_PLAY
;
674 hr
= IMediaEvent_GetEvent(wma
->mevent
, &code
, &p1
, &p2
, 0);
675 if (hr
== S_OK
&& code
== EC_COMPLETE
){
676 lpParms
->dwReturn
= MCI_MODE_STOP
;
677 IMediaControl_Stop(wma
->pmctrl
);
679 } while (hr
== S_OK
);
681 } else if (state
== State_Paused
)
682 lpParms
->dwReturn
= MCI_MODE_PAUSE
;
685 case MCI_STATUS_MEDIA_PRESENT
:
686 FIXME("MCI_STATUS_MEDIA_PRESENT not implemented yet\n");
687 return MCIERR_UNRECOGNIZED_COMMAND
;
688 case MCI_STATUS_TIME_FORMAT
:
689 lpParms
->dwReturn
= wma
->time_format
;
691 case MCI_STATUS_READY
:
692 FIXME("MCI_STATUS_READY not implemented yet\n");
693 return MCIERR_UNRECOGNIZED_COMMAND
;
694 case MCI_STATUS_CURRENT_TRACK
:
695 FIXME("MCI_STATUS_CURRENT_TRACK not implemented yet\n");
696 return MCIERR_UNRECOGNIZED_COMMAND
;
698 FIXME("Unknown command %08X\n", lpParms
->dwItem
);
699 return MCIERR_UNRECOGNIZED_COMMAND
;
702 if (dwFlags
& MCI_NOTIFY
)
703 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)), wDevID
, MCI_NOTIFY_SUCCESSFUL
);
708 /***************************************************************************
709 * MCIQTZ_mciWhere [internal]
711 static DWORD
MCIQTZ_mciWhere(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_RECT_PARMS lpParms
)
717 DWORD ret
= MCIERR_UNRECOGNIZED_COMMAND
;
719 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
722 return MCIERR_NULL_PARAMETER_BLOCK
;
724 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
726 return MCIERR_INVALID_DEVICE_ID
;
728 hr
= IVideoWindow_get_Owner(wma
->vidwin
, (OAHWND
*)&hWnd
);
730 TRACE("No video stream, returning no window error\n");
731 return MCIERR_NO_WINDOW
;
734 if (dwFlags
& MCI_DGV_WHERE_SOURCE
) {
735 if (dwFlags
& MCI_DGV_WHERE_MAX
)
736 FIXME("MCI_DGV_WHERE_SOURCE_MAX stub %s\n", wine_dbgstr_rect(&rc
));
737 IBasicVideo_GetSourcePosition(wma
->vidbasic
, &rc
.left
, &rc
.top
, &rc
.right
, &rc
.bottom
);
738 TRACE("MCI_DGV_WHERE_SOURCE %s\n", wine_dbgstr_rect(&rc
));
740 if (dwFlags
& MCI_DGV_WHERE_DESTINATION
) {
741 if (dwFlags
& MCI_DGV_WHERE_MAX
)
742 FIXME("MCI_DGV_WHERE_DESTINATION_MAX stub %s\n", wine_dbgstr_rect(&rc
));
743 IBasicVideo_GetDestinationPosition(wma
->vidbasic
, &rc
.left
, &rc
.top
, &rc
.right
, &rc
.bottom
);
744 TRACE("MCI_DGV_WHERE_DESTINATION %s\n", wine_dbgstr_rect(&rc
));
746 if (dwFlags
& MCI_DGV_WHERE_FRAME
) {
747 if (dwFlags
& MCI_DGV_WHERE_MAX
)
748 FIXME("MCI_DGV_WHERE_FRAME_MAX not supported yet\n");
750 FIXME("MCI_DGV_WHERE_FRAME not supported yet\n");
753 if (dwFlags
& MCI_DGV_WHERE_VIDEO
) {
754 if (dwFlags
& MCI_DGV_WHERE_MAX
)
755 FIXME("MCI_DGV_WHERE_VIDEO_MAX not supported yet\n");
757 FIXME("MCI_DGV_WHERE_VIDEO not supported yet\n");
760 if (dwFlags
& MCI_DGV_WHERE_WINDOW
) {
761 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
762 GetWindowRect(GetDesktopWindow(), &rc
);
765 TRACE("MCI_DGV_WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&rc
));
767 IVideoWindow_GetWindowPosition(wma
->vidwin
, &rc
.left
, &rc
.top
, &rc
.right
, &rc
.bottom
);
768 TRACE("MCI_DGV_WHERE_WINDOW %s\n", wine_dbgstr_rect(&rc
));
777 /***************************************************************************
778 * MCIQTZ_mciWindow [internal]
780 static DWORD
MCIQTZ_mciWindow(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_WINDOW_PARMSW lpParms
)
782 WINE_MCIQTZ
*wma
= MCIQTZ_mciGetOpenDev(wDevID
);
784 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
787 return MCIERR_NULL_PARAMETER_BLOCK
;
789 return MCIERR_INVALID_DEVICE_ID
;
790 if (dwFlags
& MCI_TEST
)
793 if (dwFlags
& MCI_DGV_WINDOW_HWND
&& (IsWindow(lpParms
->hWnd
) || !lpParms
->hWnd
)) {
794 LONG visible
= OATRUE
;
796 TRACE("Setting hWnd to %p\n", lpParms
->hWnd
);
797 IVideoWindow_get_Visible(wma
->vidwin
, &visible
);
798 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
799 IVideoWindow_get_WindowStyle(wma
->vidwin
, &style
);
802 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
|WS_CHILD
);
804 IVideoWindow_put_WindowStyle(wma
->vidwin
, style
);
805 IVideoWindow_put_Owner(wma
->vidwin
, (OAHWND
)lpParms
->hWnd
);
806 IVideoWindow_put_MessageDrain(wma
->vidwin
, (OAHWND
)lpParms
->hWnd
);
807 IVideoWindow_put_Visible(wma
->vidwin
, visible
);
808 wma
->parent
= lpParms
->hWnd
;
810 if (dwFlags
& MCI_DGV_WINDOW_STATE
) {
811 TRACE("Setting nCmdShow to %d\n", lpParms
->nCmdShow
);
812 IVideoWindow_put_WindowState(wma
->vidwin
, lpParms
->nCmdShow
);
814 if (dwFlags
& MCI_DGV_WINDOW_TEXT
) {
815 TRACE("Setting caption to %s\n", debugstr_w(lpParms
->lpstrText
));
816 IVideoWindow_put_Caption(wma
->vidwin
, lpParms
->lpstrText
);
821 /******************************************************************************
822 * MCIAVI_mciUpdate [internal]
824 static DWORD
MCIQTZ_mciUpdate(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_UPDATE_PARMS lpParms
)
829 TRACE("%04x, %08x, %p\n", wDevID
, dwFlags
, lpParms
);
832 return MCIERR_NULL_PARAMETER_BLOCK
;
834 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
836 return MCIERR_INVALID_DEVICE_ID
;
838 if (dwFlags
& MCI_DGV_UPDATE_HDC
) {
844 LONG visible
= OATRUE
;
846 res
= MCIERR_INTERNAL
;
847 IMediaControl_GetState(wma
->pmctrl
, -1, &state
);
848 if (state
== State_Running
)
849 return MCIERR_UNSUPPORTED_FUNCTION
;
850 /* If in stopped state, nothing has been drawn to screen
851 * moving to pause, which is needed for the old dib renderer, will result
852 * in a single frame drawn, so hide the window here */
853 IVideoWindow_get_Visible(wma
->vidwin
, &visible
);
855 IVideoWindow_put_Visible(wma
->vidwin
, OAFALSE
);
856 /* FIXME: Should we check the original state and restore it? */
857 IMediaControl_Pause(wma
->pmctrl
);
858 IMediaControl_GetState(wma
->pmctrl
, -1, &state
);
859 if (FAILED(hr
= IBasicVideo_GetCurrentImage(wma
->vidbasic
, &size
, NULL
))) {
860 WARN("Could not get image size (hr = %x)\n", hr
);
863 data
= HeapAlloc(GetProcessHeap(), 0, size
);
864 info
= (BITMAPINFO
*)data
;
865 IBasicVideo_GetCurrentImage(wma
->vidbasic
, &size
, (LONG
*)data
);
866 data
+= info
->bmiHeader
.biSize
;
868 IBasicVideo_GetSourcePosition(wma
->vidbasic
, &src
.left
, &src
.top
, &src
.right
, &src
.bottom
);
869 IBasicVideo_GetDestinationPosition(wma
->vidbasic
, &dest
.left
, &dest
.top
, &dest
.right
, &dest
.bottom
);
870 StretchDIBits(lpParms
->hDC
,
871 dest
.left
, dest
.top
, dest
.right
+ dest
.left
, dest
.bottom
+ dest
.top
,
872 src
.left
, src
.top
, src
.right
+ src
.left
, src
.bottom
+ src
.top
,
873 data
, info
, DIB_RGB_COLORS
, SRCCOPY
);
874 HeapFree(GetProcessHeap(), 0, data
);
878 IVideoWindow_put_Visible(wma
->vidwin
, visible
);
881 FIXME("Unhandled flags %x\n", dwFlags
);
885 /***************************************************************************
886 * MCIQTZ_mciSetAudio [internal]
888 static DWORD
MCIQTZ_mciSetAudio(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_SETAUDIO_PARMSW lpParms
)
892 FIXME("(%04x, %08x, %p) : stub\n", wDevID
, dwFlags
, lpParms
);
895 return MCIERR_NULL_PARAMETER_BLOCK
;
897 wma
= MCIQTZ_mciGetOpenDev(wDevID
);
899 return MCIERR_INVALID_DEVICE_ID
;
901 MCIQTZ_mciStop(wDevID
, MCI_WAIT
, NULL
);
906 /*======================================================================*
907 * MCI QTZ entry points *
908 *======================================================================*/
910 /**************************************************************************
911 * DriverProc (MCIQTZ.@)
913 LRESULT CALLBACK
MCIQTZ_DriverProc(DWORD_PTR dwDevID
, HDRVR hDriv
, UINT wMsg
,
914 LPARAM dwParam1
, LPARAM dwParam2
)
916 TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
917 dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
920 case DRV_LOAD
: return 1;
921 case DRV_FREE
: return 1;
922 case DRV_OPEN
: return MCIQTZ_drvOpen((LPCWSTR
)dwParam1
, (LPMCI_OPEN_DRIVER_PARMSW
)dwParam2
);
923 case DRV_CLOSE
: return MCIQTZ_drvClose(dwDevID
);
924 case DRV_ENABLE
: return 1;
925 case DRV_DISABLE
: return 1;
926 case DRV_QUERYCONFIGURE
: return 1;
927 case DRV_CONFIGURE
: return MCIQTZ_drvConfigure(dwDevID
);
928 case DRV_INSTALL
: return DRVCNF_RESTART
;
929 case DRV_REMOVE
: return DRVCNF_RESTART
;
932 /* session instance */
933 if (dwDevID
== 0xFFFFFFFF)
937 case MCI_OPEN_DRIVER
: return MCIQTZ_mciOpen (dwDevID
, dwParam1
, (LPMCI_DGV_OPEN_PARMSW
) dwParam2
);
938 case MCI_CLOSE_DRIVER
: return MCIQTZ_mciClose (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
939 case MCI_PLAY
: return MCIQTZ_mciPlay (dwDevID
, dwParam1
, (LPMCI_PLAY_PARMS
) dwParam2
);
940 case MCI_SEEK
: return MCIQTZ_mciSeek (dwDevID
, dwParam1
, (LPMCI_SEEK_PARMS
) dwParam2
);
941 case MCI_STOP
: return MCIQTZ_mciStop (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
942 case MCI_PAUSE
: return MCIQTZ_mciPause (dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
) dwParam2
);
943 case MCI_GETDEVCAPS
: return MCIQTZ_mciGetDevCaps(dwDevID
, dwParam1
, (LPMCI_GETDEVCAPS_PARMS
) dwParam2
);
944 case MCI_SET
: return MCIQTZ_mciSet (dwDevID
, dwParam1
, (LPMCI_DGV_SET_PARMS
) dwParam2
);
945 case MCI_STATUS
: return MCIQTZ_mciStatus (dwDevID
, dwParam1
, (LPMCI_DGV_STATUS_PARMSW
) dwParam2
);
946 case MCI_WHERE
: return MCIQTZ_mciWhere (dwDevID
, dwParam1
, (LPMCI_DGV_RECT_PARMS
) dwParam2
);
947 /* Digital Video specific */
948 case MCI_SETAUDIO
: return MCIQTZ_mciSetAudio (dwDevID
, dwParam1
, (LPMCI_DGV_SETAUDIO_PARMSW
) dwParam2
);
950 return MCIQTZ_mciUpdate(dwDevID
, dwParam1
, (LPMCI_DGV_UPDATE_PARMS
)dwParam2
);
952 return MCIQTZ_mciWindow(dwDevID
, dwParam1
, (LPMCI_DGV_WINDOW_PARMSW
)dwParam2
);
968 /* Digital Video specific */
979 FIXME("Unimplemented command [%08X]\n", wMsg
);
983 WARN("Unsupported command [%08X]\n", wMsg
);
987 FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
990 TRACE("Sending msg [%08X] to default driver proc\n", wMsg
);
991 return DefDriverProc(dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
994 return MCIERR_UNRECOGNIZED_COMMAND
;