2002-06-13 23:38:52 +02:00
|
|
|
/*
|
2003-09-08 21:38:45 +02:00
|
|
|
* Copyright 2002 Dmitry Timoshkov for CodeWeavers
|
2005-04-27 11:46:25 +02:00
|
|
|
* Copyright 2005 Maarten Lankhorst
|
2002-06-13 23:38:52 +02: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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-06-13 23:38:52 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
2002-06-13 23:38:52 +02:00
|
|
|
#include "vfw.h"
|
2002-10-07 23:43:13 +02:00
|
|
|
#include "winternl.h"
|
2002-06-13 23:38:52 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2021-09-01 22:56:46 +02:00
|
|
|
#include "unixlib.h"
|
2005-04-27 11:46:25 +02:00
|
|
|
|
2002-06-13 23:38:52 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(avicap);
|
|
|
|
|
2021-09-01 22:56:47 +02:00
|
|
|
static HINSTANCE avicap_instance;
|
2021-09-01 22:56:46 +02:00
|
|
|
static unixlib_handle_t unix_handle;
|
2002-10-07 23:43:13 +02:00
|
|
|
|
2021-09-01 22:56:47 +02:00
|
|
|
static const WCHAR class_name[] = L"wine_avicap_class";
|
|
|
|
|
|
|
|
static LRESULT CALLBACK avicap_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
if (msg >= WM_CAP_START && msg <= WM_CAP_END)
|
|
|
|
FIXME("Unhandled message %#x.\n", msg);
|
|
|
|
return DefWindowProcW(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void register_class(void)
|
|
|
|
{
|
|
|
|
WNDCLASSEXW class =
|
|
|
|
{
|
|
|
|
.cbSize = sizeof(WNDCLASSEXW),
|
|
|
|
.lpfnWndProc = avicap_wndproc,
|
|
|
|
.hInstance = avicap_instance,
|
|
|
|
.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW),
|
|
|
|
.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1),
|
|
|
|
.lpszClassName = class_name,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!RegisterClassExW(&class) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS)
|
2022-02-07 23:11:15 +01:00
|
|
|
ERR("Failed to register class, error %lu.\n", GetLastError());
|
2021-09-01 22:56:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void unregister_class(void)
|
|
|
|
{
|
|
|
|
if (!UnregisterClassW(class_name, avicap_instance) && GetLastError() != ERROR_CLASS_DOES_NOT_EXIST)
|
2022-02-07 23:11:15 +01:00
|
|
|
ERR("Failed to unregister class, error %lu.\n", GetLastError());
|
2021-09-01 22:56:47 +02:00
|
|
|
}
|
|
|
|
|
2002-10-07 23:43:13 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* capCreateCaptureWindowW (AVICAP32.@)
|
|
|
|
*/
|
2021-09-01 22:56:47 +02:00
|
|
|
HWND VFWAPI capCreateCaptureWindowW(const WCHAR *window_name, DWORD style,
|
|
|
|
int x, int y, int width, int height, HWND parent, int id)
|
2002-10-07 23:43:13 +02:00
|
|
|
{
|
2022-02-07 23:11:15 +01:00
|
|
|
TRACE("window_name %s, style %#lx, x %d, y %d, width %d, height %d, parent %p, id %#x.\n",
|
2021-09-01 22:56:47 +02:00
|
|
|
debugstr_w(window_name), style, x, y, width, height, parent, id);
|
|
|
|
|
|
|
|
return CreateWindowW(class_name, window_name, style, x, y, width, height, parent, NULL, avicap_instance, NULL);
|
2002-10-07 23:43:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* capCreateCaptureWindowA (AVICAP32.@)
|
|
|
|
*/
|
2021-09-01 22:56:47 +02:00
|
|
|
HWND VFWAPI capCreateCaptureWindowA(const char *window_name, DWORD style,
|
|
|
|
int x, int y, int width, int height, HWND parent, int id)
|
|
|
|
{
|
|
|
|
UNICODE_STRING nameW;
|
|
|
|
HWND window;
|
2002-10-07 23:43:13 +02:00
|
|
|
|
2021-09-01 22:56:47 +02:00
|
|
|
if (window_name)
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&nameW, window_name);
|
|
|
|
else
|
|
|
|
nameW.Buffer = NULL;
|
2002-10-07 23:43:13 +02:00
|
|
|
|
2021-09-01 22:56:47 +02:00
|
|
|
window = capCreateCaptureWindowW(nameW.Buffer, style, x, y, width, height, parent, id);
|
2002-10-07 23:43:13 +02:00
|
|
|
RtlFreeUnicodeString(&nameW);
|
|
|
|
|
2021-09-01 22:56:47 +02:00
|
|
|
return window;
|
2002-10-07 23:43:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* capGetDriverDescriptionA (AVICAP32.@)
|
|
|
|
*/
|
2002-06-13 23:38:52 +02:00
|
|
|
BOOL VFWAPI capGetDriverDescriptionA(WORD wDriverIndex, LPSTR lpszName,
|
2005-04-27 11:46:25 +02:00
|
|
|
INT cbName, LPSTR lpszVer, INT cbVer)
|
2002-06-13 23:38:52 +02:00
|
|
|
{
|
2008-02-25 09:59:38 +01:00
|
|
|
BOOL retval;
|
2005-04-27 11:46:25 +02:00
|
|
|
WCHAR devname[CAP_DESC_MAX], devver[CAP_DESC_MAX];
|
|
|
|
TRACE("--> capGetDriverDescriptionW\n");
|
|
|
|
retval = capGetDriverDescriptionW(wDriverIndex, devname, CAP_DESC_MAX, devver, CAP_DESC_MAX);
|
|
|
|
if (retval) {
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, devname, -1, lpszName, cbName, NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, devver, -1, lpszVer, cbVer, NULL, NULL);
|
|
|
|
}
|
|
|
|
return retval;
|
2002-06-13 23:38:52 +02:00
|
|
|
}
|
|
|
|
|
2002-10-07 23:43:13 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* capGetDriverDescriptionW (AVICAP32.@)
|
|
|
|
*/
|
2021-09-01 22:56:46 +02:00
|
|
|
BOOL VFWAPI capGetDriverDescriptionW(WORD index, WCHAR *name, int name_len, WCHAR *version, int version_len)
|
2002-06-13 23:38:52 +02:00
|
|
|
{
|
2021-09-01 22:56:46 +02:00
|
|
|
struct get_device_desc_params params;
|
2005-04-27 11:46:25 +02:00
|
|
|
|
2021-09-01 22:56:46 +02:00
|
|
|
params.index = index;
|
|
|
|
if (__wine_unix_call(unix_handle, unix_get_device_desc, ¶ms))
|
|
|
|
return FALSE;
|
2005-04-27 11:46:25 +02:00
|
|
|
|
2021-09-01 22:56:46 +02:00
|
|
|
TRACE("Found device name %s, version %s.\n", debugstr_w(params.name), debugstr_w(params.version));
|
|
|
|
lstrcpynW(name, params.name, name_len);
|
|
|
|
lstrcpynW(version, params.version, version_len);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
|
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
NtQueryVirtualMemory(GetCurrentProcess(), instance,
|
|
|
|
MemoryWineUnixFuncs, &unix_handle, sizeof(unix_handle), NULL);
|
|
|
|
DisableThreadLibraryCalls(instance);
|
2021-09-01 22:56:47 +02:00
|
|
|
register_class();
|
|
|
|
avicap_instance = instance;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
if (!reserved)
|
|
|
|
unregister_class();
|
2021-09-01 22:56:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2002-06-13 23:38:52 +02:00
|
|
|
}
|