1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
4 * Digital video MCI Wine Driver
6 * Copyright 1999, 2000 Eric POUECH
7 * Copyright 2003 Dmitry Timoshkov
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "private_mciavi.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(mciavi);
30 static const WCHAR mciaviW[] = {'M','C','I','A','V','I',0};
32 static LRESULT WINAPI MCIAVI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
34 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam);
38 SetWindowLongW(hWnd, 0, (LPARAM)((CREATESTRUCTW *)lParam)->lpCreateParams);
39 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
42 MCIAVI_mciClose(GetWindowLongW(hWnd, 0), MCI_WAIT, NULL);
43 SetWindowLongW(hWnd, 0, 0);
44 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
49 GetClientRect(hWnd, &rect);
50 FillRect((HDC)wParam, &rect, GetStockObject(BLACK_BRUSH));
56 WINE_MCIAVI *wma = (WINE_MCIAVI *)mciGetDriverData(GetWindowLongW(hWnd, 0));
59 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
61 EnterCriticalSection(&wma->cs);
63 /* the animation isn't playing, don't paint */
64 if (wma->dwStatus == MCI_MODE_NOT_READY)
66 LeaveCriticalSection(&wma->cs);
67 /* default paint handling */
68 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
72 MCIAVI_PaintFrame(wma, (HDC)wParam);
76 BeginPaint(hWnd, &ps);
77 MCIAVI_PaintFrame(wma, ps.hdc);
81 LeaveCriticalSection(&wma->cs);
86 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
90 BOOL MCIAVI_UnregisterClass(void)
92 return UnregisterClassW(mciaviW, MCIAVI_hInstance);
95 BOOL MCIAVI_RegisterClass(void)
99 ZeroMemory(&wndClass, sizeof(WNDCLASSW));
100 wndClass.style = CS_DBLCLKS;
101 wndClass.lpfnWndProc = MCIAVI_WindowProc;
102 wndClass.cbWndExtra = sizeof(MCIDEVICEID);
103 wndClass.hInstance = MCIAVI_hInstance;
104 wndClass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
105 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
106 wndClass.lpszClassName = mciaviW;
108 if (RegisterClassW(&wndClass)) return TRUE;
109 if (GetLastError() == ERROR_CLASS_ALREADY_EXISTS) return TRUE;
114 BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARMSW lpOpenParms)
116 static const WCHAR captionW[] = {'W','i','n','e',' ','M','C','I','-','A','V','I',' ','p','l','a','y','e','r',0};
118 DWORD dwStyle = WS_OVERLAPPEDWINDOW;
121 /* what should be done ? */
122 if (wma->hWnd) return TRUE;
124 if (dwFlags & MCI_DGV_OPEN_PARENT) hParent = lpOpenParms->hWndParent;
125 if (dwFlags & MCI_DGV_OPEN_WS) dwStyle = lpOpenParms->dwStyle;
127 rc.left = rc.top = 0;
128 rc.right = (wma->hic ? wma->outbih : wma->inbih)->biWidth;
129 rc.bottom = (wma->hic ? wma->outbih : wma->inbih)->biHeight;
130 AdjustWindowRect(&rc, dwStyle, FALSE);
131 if (!(dwStyle & (WS_CHILD|WS_POPUP))) /* overlapped window ? */
135 rc.left = rc.top = CW_USEDEFAULT;
138 wma->hWnd = CreateWindowW(mciaviW, captionW,
139 dwStyle, rc.left, rc.top,
141 hParent, 0, MCIAVI_hInstance,
142 (LPVOID)wma->wDevID);
143 wma->hWndPaint = wma->hWnd;
144 return (BOOL)wma->hWnd;
147 /***************************************************************************
148 * MCIAVI_mciPut [internal]
150 DWORD MCIAVI_mciPut(UINT wDevID, DWORD dwFlags, LPMCI_DGV_PUT_PARMS lpParms)
152 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
155 TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpParms);
157 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
158 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
160 EnterCriticalSection(&wma->cs);
162 if (dwFlags & MCI_DGV_RECT) {
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 FIXME("PUT_WINDOW %s\n", wine_dbgstr_rect(&rc));
193 LeaveCriticalSection(&wma->cs);
194 return MCIERR_UNRECOGNIZED_COMMAND;
196 LeaveCriticalSection(&wma->cs);
200 /******************************************************************************
201 * MCIAVI_mciWhere [internal]
203 DWORD MCIAVI_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
205 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
207 TRACE("(%04x, %08lx, %p)\n", wDevID, dwFlags, lpParms);
209 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
210 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
212 EnterCriticalSection(&wma->cs);
214 if (dwFlags & MCI_DGV_WHERE_DESTINATION) {
215 if (dwFlags & MCI_DGV_WHERE_MAX) {
216 GetClientRect(wma->hWndPaint, &lpParms->rc);
217 TRACE("WHERE_DESTINATION_MAX %s\n", wine_dbgstr_rect(&lpParms->rc));
219 TRACE("WHERE_DESTINATION %s\n", wine_dbgstr_rect(&wma->dest));
220 lpParms->rc = wma->dest;
223 if (dwFlags & MCI_DGV_WHERE_FRAME) {
224 if (dwFlags & MCI_DGV_WHERE_MAX)
225 FIXME("MCI_DGV_WHERE_FRAME_MAX\n");
227 FIXME("MCI_DGV_WHERE_FRAME\n");
228 LeaveCriticalSection(&wma->cs);
229 return MCIERR_UNRECOGNIZED_COMMAND;
231 if (dwFlags & MCI_DGV_WHERE_SOURCE) {
232 if (dwFlags & MCI_DGV_WHERE_MAX) {
236 rect.right = wma->inbih->biWidth;
237 rect.bottom = wma->inbih->biHeight;
238 TRACE("WHERE_SOURCE_MAX %s\n", wine_dbgstr_rect(&rect));
241 TRACE("WHERE_SOURCE %s\n", wine_dbgstr_rect(&wma->source));
242 lpParms->rc = wma->source;
245 if (dwFlags & MCI_DGV_WHERE_VIDEO) {
246 if (dwFlags & MCI_DGV_WHERE_MAX)
247 FIXME("WHERE_VIDEO_MAX\n");
249 FIXME("WHERE_VIDEO\n");
250 LeaveCriticalSection(&wma->cs);
251 return MCIERR_UNRECOGNIZED_COMMAND;
253 if (dwFlags & MCI_DGV_WHERE_WINDOW) {
254 if (dwFlags & MCI_DGV_WHERE_MAX) {
255 GetWindowRect(GetDesktopWindow(), &lpParms->rc);
256 TRACE("WHERE_WINDOW_MAX %s\n", wine_dbgstr_rect(&lpParms->rc));
258 GetWindowRect(wma->hWndPaint, &lpParms->rc);
259 TRACE("WHERE_WINDOW %s\n", wine_dbgstr_rect(&lpParms->rc));
262 LeaveCriticalSection(&wma->cs);
266 /***************************************************************************
267 * MCIAVI_mciWindow [internal]
269 DWORD MCIAVI_mciWindow(UINT wDevID, DWORD dwFlags, LPMCI_DGV_WINDOW_PARMSW lpParms)
271 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
273 TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpParms);
275 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
276 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
278 EnterCriticalSection(&wma->cs);
280 if (dwFlags & MCI_DGV_WINDOW_HWND) {
281 if (IsWindow(lpParms->hWnd))
283 TRACE("Setting hWnd to %p\n", lpParms->hWnd);
284 if (wma->hWnd) ShowWindow(wma->hWnd, SW_HIDE);
285 wma->hWndPaint = (lpParms->hWnd == MCI_DGV_WINDOW_DEFAULT) ? wma->hWnd : lpParms->hWnd;
288 if (dwFlags & MCI_DGV_WINDOW_STATE) {
289 TRACE("Setting nCmdShow to %d\n", lpParms->nCmdShow);
290 ShowWindow(wma->hWndPaint, lpParms->nCmdShow);
292 if (dwFlags & MCI_DGV_WINDOW_TEXT) {
293 TRACE("Setting caption to %s\n", debugstr_w(lpParms->lpstrText));
294 SetWindowTextW(wma->hWndPaint, lpParms->lpstrText);
297 LeaveCriticalSection(&wma->cs);