2002-06-13 21:38:52 +00:00
|
|
|
/*
|
2003-09-08 19:38:45 +00:00
|
|
|
* Copyright 2002 Dmitry Timoshkov for CodeWeavers
|
2005-04-27 09:46:25 +00:00
|
|
|
* Copyright 2005 Maarten Lankhorst
|
2002-06-13 21:38:52 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-06-13 21:38:52 +00:00
|
|
|
*/
|
|
|
|
|
2005-04-27 09:46:25 +00:00
|
|
|
#include "config.h"
|
2005-08-03 21:25:10 +00:00
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2005-04-27 09:46:25 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
# include <sys/ioctl.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_ERRNO_H
|
|
|
|
# include <sys/errno.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ASM_TYPES_H
|
|
|
|
# include <asm/types.h>
|
|
|
|
#endif
|
2011-07-14 19:38:14 +00:00
|
|
|
#ifdef HAVE_LINUX_VIDEODEV2_H
|
|
|
|
# include <linux/videodev2.h>
|
2005-04-27 09:46:25 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2003-09-05 23:08:26 +00:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
2003-09-09 19:39:31 +00:00
|
|
|
#include "winuser.h"
|
2002-06-13 21:38:52 +00:00
|
|
|
#include "vfw.h"
|
2005-04-27 09:46:25 +00:00
|
|
|
#include "winnls.h"
|
2002-10-07 21:43:13 +00:00
|
|
|
#include "winternl.h"
|
2002-06-13 21:38:52 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2005-04-27 09:46:25 +00:00
|
|
|
#define CAP_DESC_MAX 32
|
|
|
|
|
2002-06-13 21:38:52 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(avicap);
|
|
|
|
|
2002-10-07 21:43:13 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* capCreateCaptureWindowW (AVICAP32.@)
|
|
|
|
*/
|
|
|
|
HWND VFWAPI capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, INT x,
|
|
|
|
INT y, INT nWidth, INT nHeight, HWND hWnd,
|
|
|
|
INT nID)
|
|
|
|
{
|
2006-09-28 23:19:00 +00:00
|
|
|
FIXME("%s, %08x, %08x, %08x, %08x, %08x, %p, %08x\n",
|
2002-10-07 21:43:13 +00:00
|
|
|
debugstr_w(lpszWindowName), dwStyle,
|
|
|
|
x, y, nWidth, nHeight, hWnd, nID);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* capCreateCaptureWindowA (AVICAP32.@)
|
|
|
|
*/
|
|
|
|
HWND VFWAPI capCreateCaptureWindowA(LPCSTR lpszWindowName, DWORD dwStyle, INT x,
|
|
|
|
INT y, INT nWidth, INT nHeight, HWND hWnd,
|
|
|
|
INT nID)
|
|
|
|
{ UNICODE_STRING nameW;
|
|
|
|
HWND retW;
|
|
|
|
|
|
|
|
if (lpszWindowName) RtlCreateUnicodeStringFromAsciiz(&nameW, lpszWindowName);
|
|
|
|
else nameW.Buffer = NULL;
|
|
|
|
|
|
|
|
retW = capCreateCaptureWindowW(nameW.Buffer, dwStyle, x, y, nWidth, nHeight,
|
|
|
|
hWnd, nID);
|
|
|
|
RtlFreeUnicodeString(&nameW);
|
|
|
|
|
|
|
|
return retW;
|
|
|
|
}
|
|
|
|
|
2011-07-14 19:38:14 +00:00
|
|
|
#ifdef HAVE_LINUX_VIDEODEV2_H
|
2005-04-27 09:46:25 +00:00
|
|
|
|
|
|
|
static int xioctl(int fd, int request, void * arg)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
do r = ioctl (fd, request, arg);
|
|
|
|
while (-1 == r && EINTR == errno);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL query_video_device(int devnum, char *name, int namesize, char *version, int versionsize)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
char device[16];
|
|
|
|
struct stat st;
|
|
|
|
struct v4l2_capability caps;
|
|
|
|
|
|
|
|
snprintf(device, sizeof(device), "/dev/video%i", devnum);
|
|
|
|
|
|
|
|
if (stat (device, &st) == -1) {
|
|
|
|
/* This is probably because the device does not exist */
|
|
|
|
WARN("%s: %s\n", device, strerror(errno));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!S_ISCHR (st.st_mode)) {
|
|
|
|
ERR("%s: Not a device\n", device);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fd = open(device, O_RDWR | O_NONBLOCK);
|
|
|
|
if (fd == -1) {
|
|
|
|
ERR("%s: Failed to open: %s\n", device, strerror(errno));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&caps, 0, sizeof(caps));
|
|
|
|
if (xioctl(fd, VIDIOC_QUERYCAP, &caps) != -1) {
|
2005-09-12 15:32:50 +00:00
|
|
|
lstrcpynA(name, (char *)caps.card, namesize);
|
|
|
|
snprintf(version, versionsize, "%s v%u.%u.%u", (char *)caps.driver, (caps.version >> 16) & 0xFF,
|
2005-04-27 09:46:25 +00:00
|
|
|
(caps.version >> 8) & 0xFF, caps.version & 0xFF);
|
|
|
|
close(fd);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errno != EINVAL && errno != 515)
|
|
|
|
/* errno 515 is used by some webcam drivers for unknown IOICTL command */
|
2011-07-14 19:38:14 +00:00
|
|
|
ERR("%s: Querying failed: %s\n", device, strerror(errno));
|
|
|
|
else ERR("%s: Querying failed: Not a V4L compatible device\n", device);
|
2005-04-27 09:46:25 +00:00
|
|
|
|
|
|
|
close(fd);
|
2011-07-14 19:38:14 +00:00
|
|
|
return FALSE;
|
2005-04-27 09:46:25 +00:00
|
|
|
}
|
|
|
|
|
2011-07-14 19:38:14 +00:00
|
|
|
#else /* HAVE_LINUX_VIDEODEV2_H */
|
2005-04-27 09:46:25 +00:00
|
|
|
|
|
|
|
static BOOL query_video_device(int devnum, char *name, int namesize, char *version, int versionsize)
|
|
|
|
{
|
|
|
|
ERR("Video 4 Linux support not enabled\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-07-14 19:38:14 +00:00
|
|
|
#endif /* HAVE_LINUX_VIDEODEV2_H */
|
2005-04-27 09:46:25 +00:00
|
|
|
|
2002-10-07 21:43:13 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* capGetDriverDescriptionA (AVICAP32.@)
|
|
|
|
*/
|
2002-06-13 21:38:52 +00:00
|
|
|
BOOL VFWAPI capGetDriverDescriptionA(WORD wDriverIndex, LPSTR lpszName,
|
2005-04-27 09:46:25 +00:00
|
|
|
INT cbName, LPSTR lpszVer, INT cbVer)
|
2002-06-13 21:38:52 +00:00
|
|
|
{
|
2008-02-25 08:59:38 +00:00
|
|
|
BOOL retval;
|
2005-04-27 09:46:25 +00: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 21:38:52 +00:00
|
|
|
}
|
|
|
|
|
2002-10-07 21:43:13 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* capGetDriverDescriptionW (AVICAP32.@)
|
|
|
|
*/
|
2002-06-13 21:38:52 +00:00
|
|
|
BOOL VFWAPI capGetDriverDescriptionW(WORD wDriverIndex, LPWSTR lpszName,
|
2005-04-27 09:46:25 +00:00
|
|
|
INT cbName, LPWSTR lpszVer, INT cbVer)
|
2002-06-13 21:38:52 +00:00
|
|
|
{
|
2005-04-27 09:46:25 +00:00
|
|
|
char devname[CAP_DESC_MAX], devver[CAP_DESC_MAX];
|
|
|
|
|
|
|
|
if (!query_video_device(wDriverIndex, devname, CAP_DESC_MAX, devver, CAP_DESC_MAX)) return FALSE;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_UNIXCP, 0, devname, -1, lpszName, cbName);
|
|
|
|
MultiByteToWideChar(CP_UNIXCP, 0, devver, -1, lpszVer, cbVer);
|
|
|
|
TRACE("Version: %s - Name: %s\n", debugstr_w(lpszVer), debugstr_w(lpszName));
|
|
|
|
return TRUE;
|
2002-06-13 21:38:52 +00:00
|
|
|
}
|