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
23 #include "private_mciavi.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(mciavi
);
28 static const WCHAR mciaviW
[] = {'M','C','I','A','V','I',0};
30 static LRESULT WINAPI
MCIAVI_WindowProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
32 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hWnd
, uMsg
, wParam
, lParam
);
36 SetWindowLongW(hWnd
, 0, (LPARAM
)((CREATESTRUCTW
*)lParam
)->lpCreateParams
);
37 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
40 MCIAVI_mciClose(GetWindowLongW(hWnd
, 0), MCI_WAIT
, NULL
);
41 SetWindowLongW(hWnd
, 0, 0);
42 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
47 GetClientRect(hWnd
, &rect
);
48 FillRect((HDC
)wParam
, &rect
, GetStockObject(BLACK_BRUSH
));
54 WINE_MCIAVI
*wma
= (WINE_MCIAVI
*)mciGetDriverData(GetWindowLongW(hWnd
, 0));
57 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
59 EnterCriticalSection(&wma
->cs
);
61 /* the animation isn't playing, don't paint */
62 if (wma
->dwStatus
== MCI_MODE_NOT_READY
)
64 LeaveCriticalSection(&wma
->cs
);
65 /* default paint handling */
66 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
70 MCIAVI_PaintFrame(wma
, (HDC
)wParam
);
74 BeginPaint(hWnd
, &ps
);
75 MCIAVI_PaintFrame(wma
, ps
.hdc
);
79 LeaveCriticalSection(&wma
->cs
);
84 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
88 BOOL
MCIAVI_UnregisterClass(void)
90 return UnregisterClassW(mciaviW
, MCIAVI_hInstance
);
93 BOOL
MCIAVI_RegisterClass(void)
97 ZeroMemory(&wndClass
, sizeof(WNDCLASSW
));
98 wndClass
.style
= CS_DBLCLKS
;
99 wndClass
.lpfnWndProc
= MCIAVI_WindowProc
;
100 wndClass
.cbWndExtra
= sizeof(MCIDEVICEID
);
101 wndClass
.hInstance
= MCIAVI_hInstance
;
102 wndClass
.hCursor
= LoadCursorW(0, (LPCWSTR
)IDC_ARROW
);
103 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_3DFACE
+ 1);
104 wndClass
.lpszClassName
= mciaviW
;
106 if (RegisterClassW(&wndClass
)) return TRUE
;
107 if (GetLastError() == ERROR_CLASS_ALREADY_EXISTS
) return TRUE
;
112 BOOL
MCIAVI_CreateWindow(WINE_MCIAVI
* wma
, DWORD dwFlags
, LPMCI_DGV_OPEN_PARMSW lpOpenParms
)
114 static const WCHAR captionW
[] = {'W','i','n','e',' ','M','C','I','-','A','V','I',' ','p','l','a','y','e','r',0};
116 DWORD dwStyle
= WS_OVERLAPPEDWINDOW
;
119 /* what should be done ? */
120 if (wma
->hWnd
) return TRUE
;
122 if (dwFlags
& MCI_DGV_OPEN_PARENT
) hParent
= lpOpenParms
->hWndParent
;
123 if (dwFlags
& MCI_DGV_OPEN_WS
) dwStyle
= lpOpenParms
->dwStyle
;
125 rc
.left
= rc
.top
= 0;
126 rc
.right
= (wma
->hic
? wma
->outbih
: wma
->inbih
)->biWidth
;
127 rc
.bottom
= (wma
->hic
? wma
->outbih
: wma
->inbih
)->biHeight
;
128 AdjustWindowRect(&rc
, dwStyle
, FALSE
);
129 if (!(dwStyle
& (WS_CHILD
|WS_POPUP
))) /* overlapped window ? */
133 rc
.left
= rc
.top
= CW_USEDEFAULT
;
136 wma
->hWnd
= CreateWindowW(mciaviW
, captionW
,
137 dwStyle
, rc
.left
, rc
.top
,
139 hParent
, 0, MCIAVI_hInstance
,
140 ULongToPtr(wma
->wDevID
));
141 wma
->hWndPaint
= wma
->hWnd
;
142 return wma
->hWnd
!= 0;
145 /***************************************************************************
146 * MCIAVI_mciPut [internal]
148 DWORD
MCIAVI_mciPut(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_PUT_PARMS lpParms
)
150 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
153 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
155 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
156 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
158 EnterCriticalSection(&wma
->cs
);
160 if (dwFlags
& MCI_DGV_RECT
) {
163 GetClientRect(wma
->hWndPaint
, &rc
);
166 if (dwFlags
& MCI_DGV_PUT_CLIENT
) {
167 FIXME("PUT_CLIENT %s\n", wine_dbgstr_rect(&rc
));
168 LeaveCriticalSection(&wma
->cs
);
169 return MCIERR_UNRECOGNIZED_COMMAND
;
171 if (dwFlags
& MCI_DGV_PUT_DESTINATION
) {
172 TRACE("PUT_DESTINATION %s\n", wine_dbgstr_rect(&rc
));
175 if (dwFlags
& MCI_DGV_PUT_FRAME
) {
176 FIXME("PUT_FRAME %s\n", wine_dbgstr_rect(&rc
));
177 LeaveCriticalSection(&wma
->cs
);
178 return MCIERR_UNRECOGNIZED_COMMAND
;
180 if (dwFlags
& MCI_DGV_PUT_SOURCE
) {
181 TRACE("PUT_SOURCE %s\n", wine_dbgstr_rect(&rc
));
184 if (dwFlags
& MCI_DGV_PUT_VIDEO
) {
185 FIXME("PUT_VIDEO %s\n", wine_dbgstr_rect(&rc
));
186 LeaveCriticalSection(&wma
->cs
);
187 return MCIERR_UNRECOGNIZED_COMMAND
;
189 if (dwFlags
& MCI_DGV_PUT_WINDOW
) {
190 FIXME("PUT_WINDOW %s\n", wine_dbgstr_rect(&rc
));
191 LeaveCriticalSection(&wma
->cs
);
192 return MCIERR_UNRECOGNIZED_COMMAND
;
194 LeaveCriticalSection(&wma
->cs
);
198 /******************************************************************************
199 * MCIAVI_mciWhere [internal]
201 DWORD
MCIAVI_mciWhere(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_RECT_PARMS lpParms
)
203 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
205 TRACE("(%04x, %08x, %p)\n", wDevID
, dwFlags
, lpParms
);
207 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
208 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
210 EnterCriticalSection(&wma
->cs
);
212 if (dwFlags
& MCI_DGV_WHERE_DESTINATION
) {
213 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
214 GetClientRect(wma
->hWndPaint
, &lpParms
->rc
);
215 TRACE("WHERE_DESTINATION_MAX %s\n", wine_dbgstr_rect(&lpParms
->rc
));
217 TRACE("WHERE_DESTINATION %s\n", wine_dbgstr_rect(&wma
->dest
));
218 lpParms
->rc
= wma
->dest
;
221 if (dwFlags
& MCI_DGV_WHERE_FRAME
) {
222 if (dwFlags
& MCI_DGV_WHERE_MAX
)
223 FIXME("MCI_DGV_WHERE_FRAME_MAX\n");
225 FIXME("MCI_DGV_WHERE_FRAME\n");
226 LeaveCriticalSection(&wma
->cs
);
227 return MCIERR_UNRECOGNIZED_COMMAND
;
229 if (dwFlags
& MCI_DGV_WHERE_SOURCE
) {
230 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
234 rect
.right
= wma
->inbih
->biWidth
;
235 rect
.bottom
= wma
->inbih
->biHeight
;
236 TRACE("WHERE_SOURCE_MAX %s\n", wine_dbgstr_rect(&rect
));
239 TRACE("WHERE_SOURCE %s\n", wine_dbgstr_rect(&wma
->source
));
240 lpParms
->rc
= wma
->source
;
243 if (dwFlags
& MCI_DGV_WHERE_VIDEO
) {
244 if (dwFlags
& MCI_DGV_WHERE_MAX
)
245 FIXME("WHERE_VIDEO_MAX\n");
247 FIXME("WHERE_VIDEO\n");
248 LeaveCriticalSection(&wma
->cs
);
249 return MCIERR_UNRECOGNIZED_COMMAND
;
251 if (dwFlags
& MCI_DGV_WHERE_WINDOW
) {
252 if (dwFlags
& MCI_DGV_WHERE_MAX
) {
253 GetWindowRect(GetDesktopWindow(), &lpParms
->rc
);
254 TRACE("WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&lpParms
->rc
));
256 GetWindowRect(wma
->hWndPaint
, &lpParms
->rc
);
257 TRACE("WHERE_WINDOW %s\n", wine_dbgstr_rect(&lpParms
->rc
));
260 LeaveCriticalSection(&wma
->cs
);
264 /***************************************************************************
265 * MCIAVI_mciWindow [internal]
267 DWORD
MCIAVI_mciWindow(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_WINDOW_PARMSW lpParms
)
269 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
271 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
273 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
274 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
276 EnterCriticalSection(&wma
->cs
);
278 if (dwFlags
& MCI_DGV_WINDOW_HWND
) {
279 if (IsWindow(lpParms
->hWnd
))
281 TRACE("Setting hWnd to %p\n", lpParms
->hWnd
);
282 if (wma
->hWnd
) ShowWindow(wma
->hWnd
, SW_HIDE
);
283 wma
->hWndPaint
= (lpParms
->hWnd
== MCI_DGV_WINDOW_DEFAULT
) ? wma
->hWnd
: lpParms
->hWnd
;
286 if (dwFlags
& MCI_DGV_WINDOW_STATE
) {
287 TRACE("Setting nCmdShow to %d\n", lpParms
->nCmdShow
);
288 ShowWindow(wma
->hWndPaint
, lpParms
->nCmdShow
);
290 if (dwFlags
& MCI_DGV_WINDOW_TEXT
) {
291 TRACE("Setting caption to %s\n", debugstr_w(lpParms
->lpstrText
));
292 SetWindowTextW(wma
->hWndPaint
, lpParms
->lpstrText
);
295 LeaveCriticalSection(&wma
->cs
);