2001-02-14 22:49:22 +01:00
|
|
|
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Digital video MCI Wine Driver
|
|
|
|
*
|
|
|
|
* Copyright 1999, 2000 Eric POUECH
|
2004-01-01 01:48:01 +01:00
|
|
|
* Copyright 2003 Dmitry Timoshkov
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-02-14 22:49:22 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "private_mciavi.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-02-14 22:49:22 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mciavi);
|
2001-02-14 22:49:22 +01:00
|
|
|
|
2004-02-27 01:42:44 +01:00
|
|
|
static const WCHAR mciaviW[] = {'M','C','I','A','V','I',0};
|
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
static LRESULT WINAPI MCIAVI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
switch (uMsg) {
|
|
|
|
case WM_CREATE:
|
2004-02-27 01:42:44 +01:00
|
|
|
SetWindowLongW(hWnd, 0, (LPARAM)((CREATESTRUCTW *)lParam)->lpCreateParams);
|
|
|
|
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
case WM_DESTROY:
|
2004-02-27 01:42:44 +01:00
|
|
|
MCIAVI_mciClose(GetWindowLongW(hWnd, 0), MCI_WAIT, NULL);
|
|
|
|
SetWindowLongW(hWnd, 0, 0);
|
|
|
|
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
case WM_ERASEBKGND:
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
GetClientRect(hWnd, &rect);
|
|
|
|
FillRect((HDC)wParam, &rect, GetStockObject(BLACK_BRUSH));
|
|
|
|
}
|
2004-01-01 01:48:01 +01:00
|
|
|
return 1;
|
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
case WM_PAINT:
|
|
|
|
{
|
2004-02-27 01:42:44 +01:00
|
|
|
WINE_MCIAVI *wma = (WINE_MCIAVI *)mciGetDriverData(GetWindowLongW(hWnd, 0));
|
2004-01-01 01:48:01 +01:00
|
|
|
|
|
|
|
if (!wma)
|
2004-02-27 01:42:44 +01:00
|
|
|
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
2004-01-01 01:48:01 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&wma->cs);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
/* the animation isn't playing, don't paint */
|
|
|
|
if (wma->dwStatus == MCI_MODE_NOT_READY)
|
2004-01-01 01:48:01 +01:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&wma->cs);
|
2001-02-14 22:49:22 +01:00
|
|
|
/* default paint handling */
|
2004-02-27 01:42:44 +01:00
|
|
|
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
2004-01-01 01:48:01 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-01 01:48:01 +01:00
|
|
|
if (wParam)
|
2001-02-14 22:49:22 +01:00
|
|
|
MCIAVI_PaintFrame(wma, (HDC)wParam);
|
2004-01-01 01:48:01 +01:00
|
|
|
else
|
|
|
|
{
|
2001-02-14 22:49:22 +01:00
|
|
|
PAINTSTRUCT ps;
|
2004-03-02 00:38:25 +01:00
|
|
|
BeginPaint(hWnd, &ps);
|
|
|
|
MCIAVI_PaintFrame(wma, ps.hdc);
|
2001-02-14 22:49:22 +01:00
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
}
|
2004-01-01 01:48:01 +01:00
|
|
|
|
|
|
|
LeaveCriticalSection(&wma->cs);
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
2004-01-01 01:48:01 +01:00
|
|
|
return 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
default:
|
2004-02-27 01:42:44 +01:00
|
|
|
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-01-06 21:39:48 +01:00
|
|
|
BOOL MCIAVI_UnregisterClass(void)
|
2001-02-14 22:49:22 +01:00
|
|
|
{
|
2004-02-27 01:42:44 +01:00
|
|
|
return UnregisterClassW(mciaviW, MCIAVI_hInstance);
|
2004-01-06 21:39:48 +01:00
|
|
|
}
|
2001-02-14 22:49:22 +01:00
|
|
|
|
2004-01-06 21:39:48 +01:00
|
|
|
BOOL MCIAVI_RegisterClass(void)
|
|
|
|
{
|
2004-02-27 01:42:44 +01:00
|
|
|
WNDCLASSW wndClass;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-02-27 01:42:44 +01:00
|
|
|
ZeroMemory(&wndClass, sizeof(WNDCLASSW));
|
2004-01-01 01:48:01 +01:00
|
|
|
wndClass.style = CS_DBLCLKS;
|
2004-02-27 01:42:44 +01:00
|
|
|
wndClass.lpfnWndProc = MCIAVI_WindowProc;
|
2004-01-01 01:48:01 +01:00
|
|
|
wndClass.cbWndExtra = sizeof(MCIDEVICEID);
|
|
|
|
wndClass.hInstance = MCIAVI_hInstance;
|
2004-02-27 01:42:44 +01:00
|
|
|
wndClass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
|
|
|
|
wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
|
|
|
wndClass.lpszClassName = mciaviW;
|
|
|
|
|
|
|
|
if (RegisterClassW(&wndClass)) return TRUE;
|
|
|
|
if (GetLastError() == ERROR_CLASS_ALREADY_EXISTS) return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-02-27 01:42:44 +01:00
|
|
|
return FALSE;
|
2004-01-06 21:39:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARMSA lpOpenParms)
|
|
|
|
{
|
2004-02-27 01:42:44 +01:00
|
|
|
static const WCHAR captionW[] = {'W','i','n','e',' ','M','C','I','-','A','V','I',' ','p','l','a','y','e','r',0};
|
2004-01-06 21:39:48 +01:00
|
|
|
HWND hParent = 0;
|
|
|
|
DWORD dwStyle = WS_OVERLAPPEDWINDOW;
|
|
|
|
int p = CW_USEDEFAULT;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
/* what should be done ? */
|
|
|
|
if (wma->hWnd) return TRUE;
|
2001-02-14 22:49:22 +01:00
|
|
|
|
|
|
|
if (dwFlags & MCI_DGV_OPEN_PARENT) hParent = lpOpenParms->hWndParent;
|
|
|
|
if (dwFlags & MCI_DGV_OPEN_WS) dwStyle = lpOpenParms->dwStyle;
|
|
|
|
if (dwStyle & WS_CHILD) p = 0;
|
|
|
|
|
2003-12-31 20:00:03 +01:00
|
|
|
rc.left = p;
|
|
|
|
rc.top = p;
|
|
|
|
rc.right = (wma->hic ? wma->outbih : wma->inbih)->biWidth;
|
|
|
|
rc.bottom = (wma->hic ? wma->outbih : wma->inbih)->biHeight;
|
|
|
|
AdjustWindowRect(&rc, dwStyle, FALSE);
|
|
|
|
|
2004-02-27 01:42:44 +01:00
|
|
|
wma->hWnd = CreateWindowW(mciaviW, captionW,
|
2003-12-31 20:00:03 +01:00
|
|
|
dwStyle, rc.left, rc.top,
|
|
|
|
rc.right, rc.bottom,
|
2004-01-01 01:48:01 +01:00
|
|
|
hParent, 0, MCIAVI_hInstance,
|
|
|
|
(LPVOID)wma->wDevID);
|
2003-12-31 20:00:03 +01:00
|
|
|
wma->hWndPaint = wma->hWnd;
|
2001-02-14 22:49:22 +01:00
|
|
|
return (BOOL)wma->hWnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* MCIAVI_mciPut [internal]
|
|
|
|
*/
|
|
|
|
DWORD MCIAVI_mciPut(UINT wDevID, DWORD dwFlags, LPMCI_DGV_PUT_PARMS lpParms)
|
|
|
|
{
|
|
|
|
WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
|
|
|
|
RECT rc;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-01 01:48:01 +01:00
|
|
|
TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-01 01:48:01 +01:00
|
|
|
EnterCriticalSection(&wma->cs);
|
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
if (dwFlags & MCI_DGV_RECT) {
|
|
|
|
rc = lpParms->rc;
|
|
|
|
} else {
|
2004-01-01 01:48:01 +01:00
|
|
|
GetClientRect(wma->hWndPaint, &rc);
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
if (dwFlags & MCI_DGV_PUT_CLIENT) {
|
2004-01-01 01:48:01 +01:00
|
|
|
FIXME("PUT_CLIENT %s\n", wine_dbgstr_rect(&rc));
|
|
|
|
LeaveCriticalSection(&wma->cs);
|
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_PUT_DESTINATION) {
|
2004-01-01 01:48:01 +01:00
|
|
|
TRACE("PUT_DESTINATION %s\n", wine_dbgstr_rect(&rc));
|
|
|
|
wma->dest = rc;
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_PUT_FRAME) {
|
2004-01-01 01:48:01 +01:00
|
|
|
FIXME("PUT_FRAME %s\n", wine_dbgstr_rect(&rc));
|
|
|
|
LeaveCriticalSection(&wma->cs);
|
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_PUT_SOURCE) {
|
2004-01-01 01:48:01 +01:00
|
|
|
TRACE("PUT_SOURCE %s\n", wine_dbgstr_rect(&rc));
|
|
|
|
wma->source = rc;
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_PUT_VIDEO) {
|
2004-01-01 01:48:01 +01:00
|
|
|
FIXME("PUT_VIDEO %s\n", wine_dbgstr_rect(&rc));
|
|
|
|
LeaveCriticalSection(&wma->cs);
|
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_PUT_WINDOW) {
|
2004-01-01 01:48:01 +01:00
|
|
|
FIXME("PUT_WINDOW %s\n", wine_dbgstr_rect(&rc));
|
|
|
|
LeaveCriticalSection(&wma->cs);
|
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
2004-01-01 01:48:01 +01:00
|
|
|
LeaveCriticalSection(&wma->cs);
|
2001-02-14 22:49:22 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* MCIAVI_mciWhere [internal]
|
|
|
|
*/
|
|
|
|
DWORD MCIAVI_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
|
|
|
|
{
|
|
|
|
WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
|
|
|
|
|
|
|
|
TRACE("(%04x, %08lx, %p)\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-01 01:48:01 +01:00
|
|
|
if (dwFlags & MCI_DGV_WHERE_MAX)
|
|
|
|
{
|
|
|
|
FIXME("WHERE_MAX\n");
|
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&wma->cs);
|
2001-02-14 22:49:22 +01:00
|
|
|
|
|
|
|
if (dwFlags & MCI_DGV_WHERE_DESTINATION) {
|
2004-01-01 01:48:01 +01:00
|
|
|
TRACE("WHERE_DESTINATION %s\n", wine_dbgstr_rect(&wma->dest));
|
|
|
|
lpParms->rc = wma->dest;
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_WHERE_FRAME) {
|
2004-01-01 01:48:01 +01:00
|
|
|
FIXME("MCI_DGV_WHERE_FRAME\n");
|
|
|
|
LeaveCriticalSection(&wma->cs);
|
2001-02-14 22:49:22 +01:00
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_WHERE_SOURCE) {
|
2004-01-01 01:48:01 +01:00
|
|
|
TRACE("WHERE_SOURCE %s\n", wine_dbgstr_rect(&wma->source));
|
|
|
|
lpParms->rc = wma->source;
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_WHERE_VIDEO) {
|
2004-01-01 01:48:01 +01:00
|
|
|
FIXME("WHERE_VIDEO\n");
|
|
|
|
LeaveCriticalSection(&wma->cs);
|
2001-02-14 22:49:22 +01:00
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_WHERE_WINDOW) {
|
2004-01-01 01:48:01 +01:00
|
|
|
GetClientRect(wma->hWndPaint, &lpParms->rc);
|
|
|
|
TRACE("WHERE_WINDOW %s\n", wine_dbgstr_rect(&lpParms->rc));
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
2004-01-01 01:48:01 +01:00
|
|
|
LeaveCriticalSection(&wma->cs);
|
2001-02-14 22:49:22 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* MCIAVI_mciWindow [internal]
|
|
|
|
*/
|
|
|
|
DWORD MCIAVI_mciWindow(UINT wDevID, DWORD dwFlags, LPMCI_DGV_WINDOW_PARMSA lpParms)
|
|
|
|
{
|
|
|
|
WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
TRACE("(%04x, %08lX, %p)\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-01 01:48:01 +01:00
|
|
|
EnterCriticalSection(&wma->cs);
|
|
|
|
|
2001-02-14 22:49:22 +01:00
|
|
|
if (dwFlags & MCI_DGV_WINDOW_HWND) {
|
2004-01-01 01:48:01 +01:00
|
|
|
if (IsWindow(lpParms->hWnd))
|
|
|
|
{
|
|
|
|
TRACE("Setting hWnd to %p\n", lpParms->hWnd);
|
|
|
|
if (wma->hWnd) ShowWindow(wma->hWnd, SW_HIDE);
|
|
|
|
wma->hWndPaint = (lpParms->hWnd == MCI_DGV_WINDOW_DEFAULT) ? wma->hWnd : lpParms->hWnd;
|
|
|
|
}
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_WINDOW_STATE) {
|
|
|
|
TRACE("Setting nCmdShow to %d\n", lpParms->nCmdShow);
|
2004-03-02 00:38:25 +01:00
|
|
|
ShowWindow(wma->hWndPaint, lpParms->nCmdShow);
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_DGV_WINDOW_TEXT) {
|
|
|
|
TRACE("Setting caption to '%s'\n", lpParms->lpstrText);
|
2003-12-31 20:00:03 +01:00
|
|
|
SetWindowTextA(wma->hWndPaint, lpParms->lpstrText);
|
2001-02-14 22:49:22 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-01 01:48:01 +01:00
|
|
|
LeaveCriticalSection(&wma->cs);
|
2001-02-14 22:49:22 +01:00
|
|
|
return 0;
|
|
|
|
}
|