2 * Digital video MCI Wine Driver
4 * Copyright 1999, 2000 Eric POUECH
5 * Copyright 2003 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "private_mciavi.h"
24 static const WCHAR mciaviW
[] = {'M','C','I','A','V','I',0};
26 static LRESULT WINAPI
MCIAVI_WindowProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
28 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hWnd
, uMsg
, wParam
, lParam
);
32 SetWindowLongW(hWnd
, 0, (LPARAM
)((CREATESTRUCTW
*)lParam
)->lpCreateParams
);
33 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
36 MCIAVI_mciClose(GetWindowLongW(hWnd
, 0), MCI_WAIT
, NULL
);
37 SetWindowLongW(hWnd
, 0, 0);
38 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
43 GetClientRect(hWnd
, &rect
);
44 FillRect((HDC
)wParam
, &rect
, GetStockObject(BLACK_BRUSH
));
50 WINE_MCIAVI
*wma
= (WINE_MCIAVI
*)mciGetDriverData(GetWindowLongW(hWnd
, 0));
53 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
55 EnterCriticalSection(&wma
->cs
);
57 /* the animation isn't playing, don't paint */
58 if (wma
->dwStatus
== MCI_MODE_NOT_READY
)
60 LeaveCriticalSection(&wma
->cs
);
61 /* default paint handling */
62 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
66 MCIAVI_PaintFrame(wma
, (HDC
)wParam
);
70 BeginPaint(hWnd
, &ps
);
71 MCIAVI_PaintFrame(wma
, ps
.hdc
);
75 LeaveCriticalSection(&wma
->cs
);
80 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
84 BOOL
MCIAVI_UnregisterClass(void)
86 return UnregisterClassW(mciaviW
, MCIAVI_hInstance
);
89 BOOL
MCIAVI_RegisterClass(void)
93 ZeroMemory(&wndClass
, sizeof(WNDCLASSW
));
94 wndClass
.style
= CS_DBLCLKS
;
95 wndClass
.lpfnWndProc
= MCIAVI_WindowProc
;
96 wndClass
.cbWndExtra
= sizeof(MCIDEVICEID
);
97 wndClass
.hInstance
= MCIAVI_hInstance
;
98 wndClass
.hCursor
= LoadCursorW(0, (LPCWSTR
)IDC_ARROW
);
99 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_3DFACE
+ 1);
100 wndClass
.lpszClassName
= mciaviW
;
102 if (RegisterClassW(&wndClass
)) return TRUE
;
103 if (GetLastError() == ERROR_CLASS_ALREADY_EXISTS
) return TRUE
;
108 BOOL
MCIAVI_CreateWindow(WINE_MCIAVI
* wma
, DWORD dwFlags
, LPMCI_DGV_OPEN_PARMSW lpOpenParms
)
110 static const WCHAR captionW
[] = {'W','i','n','e',' ','M','C','I','-','A','V','I',' ','p','l','a','y','e','r',0};
112 DWORD dwStyle
= WS_OVERLAPPEDWINDOW
;
115 /* what should be done ? */
116 if (wma
->hWnd
) return TRUE
;
118 if (dwFlags
& MCI_DGV_OPEN_PARENT
) hParent
= lpOpenParms
->hWndParent
;
119 if (dwFlags
& MCI_DGV_OPEN_WS
) dwStyle
= lpOpenParms
->dwStyle
;
121 rc
.left
= rc
.top
= 0;
122 rc
.right
= (wma
->hic
? wma
->outbih
: wma
->inbih
)->biWidth
;
123 rc
.bottom
= (wma
->hic
? wma
->outbih
: wma
->inbih
)->biHeight
;
124 AdjustWindowRect(&rc
, dwStyle
, FALSE
);
125 if (!(dwStyle
& (WS_CHILD
|WS_POPUP
))) /* overlapped window ? */
129 rc
.left
= rc
.top
= CW_USEDEFAULT
;
132 wma
->hWnd
= CreateWindowW(mciaviW
, captionW
,
133 dwStyle
, rc
.left
, rc
.top
,
135 hParent
, 0, MCIAVI_hInstance
,
136 ULongToPtr(wma
->wDevID
));
137 wma
->hWndPaint
= wma
->hWnd
;
138 return wma
->hWnd
!= 0;
141 /***************************************************************************
142 * MCIAVI_mciPut [internal]
144 DWORD
MCIAVI_mciPut(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_PUT_PARMS lpParms
)
146 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
149 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
151 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
152 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
153 if (dwFlags
& MCI_TEST
) return 0;
155 EnterCriticalSection(&wma
->cs
);
157 if (dwFlags
& MCI_DGV_RECT
) {
158 /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height
159 * So convert input MCI RECT into a normal RECT */
160 rc
.left
= lpParms
->rc
.left
;
161 rc
.top
= lpParms
->rc
.top
;
162 rc
.right
= lpParms
->rc
.left
+ lpParms
->rc
.right
;
163 rc
.bottom
= lpParms
->rc
.top
+ lpParms
->rc
.bottom
;
165 GetClientRect(wma
->hWndPaint
, &rc
);
168 if (dwFlags
& MCI_DGV_PUT_CLIENT
) {
169 FIXME("PUT_CLIENT %s\n", wine_dbgstr_rect(&rc
));
170 LeaveCriticalSection(&wma
->cs
);
171 return MCIERR_UNRECOGNIZED_COMMAND
;
173 if (dwFlags
& MCI_DGV_PUT_DESTINATION
) {
174 TRACE("PUT_DESTINATION %s\n", wine_dbgstr_rect(&rc
));
177 if (dwFlags
& MCI_DGV_PUT_FRAME
) {
178 FIXME("PUT_FRAME %s\n", wine_dbgstr_rect(&rc
));
179 LeaveCriticalSection(&wma
->cs
);
180 return MCIERR_UNRECOGNIZED_COMMAND
;
182 if (dwFlags
& MCI_DGV_PUT_SOURCE
) {
183 TRACE("PUT_SOURCE %s\n", wine_dbgstr_rect(&rc
));
186 if (dwFlags
& MCI_DGV_PUT_VIDEO
) {
187 FIXME("PUT_VIDEO %s\n", wine_dbgstr_rect(&rc
));
188 LeaveCriticalSection(&wma
->cs
);
189 return MCIERR_UNRECOGNIZED_COMMAND
;
191 if (dwFlags
& MCI_DGV_PUT_WINDOW
) {
192 TRACE("PUT_WINDOW %s\n", wine_dbgstr_rect(&rc
));
193 SetWindowPos(wma
->hWndPaint
, NULL
, rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, SWP_NOZORDER
);
195 LeaveCriticalSection(&wma
->cs
);
199 /******************************************************************************
200 * MCIAVI_mciWhere [internal]
202 DWORD
MCIAVI_mciWhere(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_RECT_PARMS lpParms
)
204 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
207 TRACE("(%04x, %08x, %p)\n", wDevID
, dwFlags
, lpParms
);
209 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
210 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
211 /* Ignore MCI_TEST flag. */
213 EnterCriticalSection(&wma
->cs
);
215 if (dwFlags
& MCI_DGV_WHERE_DESTINATION
) {
216 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
217 GetClientRect(wma
->hWndPaint
, &rc
);
218 TRACE("WHERE_DESTINATION_MAX %s\n", wine_dbgstr_rect(&rc
));
220 TRACE("WHERE_DESTINATION %s\n", wine_dbgstr_rect(&wma
->dest
));
224 if (dwFlags
& MCI_DGV_WHERE_FRAME
) {
225 if (dwFlags
& MCI_DGV_WHERE_MAX
)
226 FIXME("MCI_DGV_WHERE_FRAME_MAX\n");
228 FIXME("MCI_DGV_WHERE_FRAME\n");
229 LeaveCriticalSection(&wma
->cs
);
230 return MCIERR_UNRECOGNIZED_COMMAND
;
232 if (dwFlags
& MCI_DGV_WHERE_SOURCE
) {
233 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
236 rc
.right
= wma
->inbih
->biWidth
;
237 rc
.bottom
= wma
->inbih
->biHeight
;
238 TRACE("WHERE_SOURCE_MAX %s\n", wine_dbgstr_rect(&rc
));
240 TRACE("WHERE_SOURCE %s\n", wine_dbgstr_rect(&wma
->source
));
244 if (dwFlags
& MCI_DGV_WHERE_VIDEO
) {
245 if (dwFlags
& MCI_DGV_WHERE_MAX
)
246 FIXME("WHERE_VIDEO_MAX\n");
248 FIXME("WHERE_VIDEO\n");
249 LeaveCriticalSection(&wma
->cs
);
250 return MCIERR_UNRECOGNIZED_COMMAND
;
252 if (dwFlags
& MCI_DGV_WHERE_WINDOW
) {
253 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
254 GetWindowRect(GetDesktopWindow(), &rc
);
255 TRACE("WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&rc
));
257 GetWindowRect(wma
->hWndPaint
, &rc
);
258 TRACE("WHERE_WINDOW %s\n", wine_dbgstr_rect(&rc
));
262 /* In MCI, RECT structure is used differently: rc.right = width & rc.bottom = height
263 * So convert the normal RECT into a MCI RECT before returning */
264 lpParms
->rc
.left
= rc
.left
;
265 lpParms
->rc
.top
= rc
.top
;
266 lpParms
->rc
.right
= rc
.right
- rc
.left
;
267 lpParms
->rc
.bottom
= rc
.bottom
- rc
.top
;
269 LeaveCriticalSection(&wma
->cs
);
273 /***************************************************************************
274 * MCIAVI_mciWindow [internal]
276 DWORD
MCIAVI_mciWindow(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_WINDOW_PARMSW lpParms
)
278 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
280 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
282 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
283 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
284 if (dwFlags
& MCI_TEST
) return 0;
286 EnterCriticalSection(&wma
->cs
);
288 if (dwFlags
& MCI_DGV_WINDOW_HWND
) {
289 if (IsWindow(lpParms
->hWnd
))
291 TRACE("Setting hWnd to %p\n", lpParms
->hWnd
);
292 if (wma
->hWnd
) ShowWindow(wma
->hWnd
, SW_HIDE
);
293 wma
->hWndPaint
= (lpParms
->hWnd
== MCI_DGV_WINDOW_DEFAULT
) ? wma
->hWnd
: lpParms
->hWnd
;
296 if (dwFlags
& MCI_DGV_WINDOW_STATE
) {
297 TRACE("Setting nCmdShow to %d\n", lpParms
->nCmdShow
);
298 ShowWindow(wma
->hWndPaint
, lpParms
->nCmdShow
);
300 if (dwFlags
& MCI_DGV_WINDOW_TEXT
) {
301 TRACE("Setting caption to %s\n", debugstr_w(lpParms
->lpstrText
));
302 SetWindowTextW(wma
->hWndPaint
, lpParms
->lpstrText
);
305 LeaveCriticalSection(&wma
->cs
);