Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/dlls/avicap32/avicap32_main.c
4393 views
1
/*
2
* Copyright 2002 Dmitry Timoshkov for CodeWeavers
3
* Copyright 2005 Maarten Lankhorst
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
9
*
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18
*/
19
20
#include <stdarg.h>
21
#include "windef.h"
22
#include "winbase.h"
23
#include "wingdi.h"
24
#include "winuser.h"
25
#include "vfw.h"
26
#include "winternl.h"
27
#include "wine/debug.h"
28
29
#include "unixlib.h"
30
31
WINE_DEFAULT_DEBUG_CHANNEL(avicap);
32
33
static HINSTANCE avicap_instance;
34
35
static const WCHAR class_name[] = L"wine_avicap_class";
36
37
static LRESULT CALLBACK avicap_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
38
{
39
switch (msg)
40
{
41
default:
42
if (msg >= WM_CAP_START && msg <= WM_CAP_END)
43
FIXME("Unhandled message %#x.\n", msg);
44
return DefWindowProcW(hwnd, msg, wparam, lparam);
45
}
46
}
47
48
static void register_class(void)
49
{
50
WNDCLASSEXW class =
51
{
52
.cbSize = sizeof(WNDCLASSEXW),
53
.lpfnWndProc = avicap_wndproc,
54
.hInstance = avicap_instance,
55
.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW),
56
.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1),
57
.lpszClassName = class_name,
58
};
59
60
if (!RegisterClassExW(&class) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS)
61
ERR("Failed to register class, error %lu.\n", GetLastError());
62
}
63
64
static void unregister_class(void)
65
{
66
if (!UnregisterClassW(class_name, avicap_instance) && GetLastError() != ERROR_CLASS_DOES_NOT_EXIST)
67
ERR("Failed to unregister class, error %lu.\n", GetLastError());
68
}
69
70
/***********************************************************************
71
* capCreateCaptureWindowW (AVICAP32.@)
72
*/
73
HWND VFWAPI capCreateCaptureWindowW(const WCHAR *window_name, DWORD style,
74
int x, int y, int width, int height, HWND parent, int id)
75
{
76
TRACE("window_name %s, style %#lx, x %d, y %d, width %d, height %d, parent %p, id %#x.\n",
77
debugstr_w(window_name), style, x, y, width, height, parent, id);
78
79
return CreateWindowW(class_name, window_name, style, x, y, width, height, parent, NULL, avicap_instance, NULL);
80
}
81
82
/***********************************************************************
83
* capCreateCaptureWindowA (AVICAP32.@)
84
*/
85
HWND VFWAPI capCreateCaptureWindowA(const char *window_name, DWORD style,
86
int x, int y, int width, int height, HWND parent, int id)
87
{
88
UNICODE_STRING nameW;
89
HWND window;
90
91
if (window_name)
92
RtlCreateUnicodeStringFromAsciiz(&nameW, window_name);
93
else
94
nameW.Buffer = NULL;
95
96
window = capCreateCaptureWindowW(nameW.Buffer, style, x, y, width, height, parent, id);
97
RtlFreeUnicodeString(&nameW);
98
99
return window;
100
}
101
102
/***********************************************************************
103
* capGetDriverDescriptionA (AVICAP32.@)
104
*/
105
BOOL VFWAPI capGetDriverDescriptionA(WORD wDriverIndex, LPSTR lpszName,
106
INT cbName, LPSTR lpszVer, INT cbVer)
107
{
108
BOOL retval;
109
WCHAR devname[CAP_DESC_MAX], devver[CAP_DESC_MAX];
110
TRACE("--> capGetDriverDescriptionW\n");
111
retval = capGetDriverDescriptionW(wDriverIndex, devname, CAP_DESC_MAX, devver, CAP_DESC_MAX);
112
if (retval) {
113
WideCharToMultiByte(CP_ACP, 0, devname, -1, lpszName, cbName, NULL, NULL);
114
WideCharToMultiByte(CP_ACP, 0, devver, -1, lpszVer, cbVer, NULL, NULL);
115
}
116
return retval;
117
}
118
119
/***********************************************************************
120
* capGetDriverDescriptionW (AVICAP32.@)
121
*/
122
BOOL VFWAPI capGetDriverDescriptionW(WORD index, WCHAR *name, int name_len, WCHAR *version, int version_len)
123
{
124
struct get_device_desc_params params;
125
126
params.index = index;
127
if (WINE_UNIX_CALL(unix_get_device_desc, &params)) return FALSE;
128
129
TRACE("Found device name %s, version %s.\n", debugstr_w(params.name), debugstr_w(params.version));
130
lstrcpynW(name, params.name, name_len);
131
lstrcpynW(version, params.version, version_len);
132
return TRUE;
133
}
134
135
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
136
{
137
switch (reason)
138
{
139
case DLL_PROCESS_ATTACH:
140
DisableThreadLibraryCalls(instance);
141
__wine_init_unix_call();
142
register_class();
143
avicap_instance = instance;
144
break;
145
146
case DLL_PROCESS_DETACH:
147
if (!reserved)
148
unregister_class();
149
break;
150
}
151
152
return TRUE;
153
}
154
155