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
|
|
|
*/
|
|
|
|
|
2005-04-27 11:46:25 +02:00
|
|
|
#include "config.h"
|
2005-08-03 23:25:10 +02:00
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2005-04-27 11:46:25 +02: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
|
2011-12-15 11:16:27 +01:00
|
|
|
#include <errno.h>
|
2005-04-27 11:46:25 +02:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ASM_TYPES_H
|
|
|
|
# include <asm/types.h>
|
|
|
|
#endif
|
2011-07-14 21:38:14 +02:00
|
|
|
#ifdef HAVE_LINUX_VIDEODEV2_H
|
|
|
|
# include <linux/videodev2.h>
|
2005-04-27 11:46:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2003-09-06 01:08:26 +02:00
|
|
|
|
|
|
|
#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"
|
2005-04-27 11:46:25 +02:00
|
|
|
#include "winnls.h"
|
2002-10-07 23:43:13 +02:00
|
|
|
#include "winternl.h"
|
2002-06-13 23:38:52 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2005-04-27 11:46:25 +02:00
|
|
|
#define CAP_DESC_MAX 32
|
|
|
|
|
2002-06-13 23:38:52 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(avicap);
|
|
|
|
|
2002-10-07 23:43:13 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* capCreateCaptureWindowW (AVICAP32.@)
|
|
|
|
*/
|
|
|
|
HWND VFWAPI capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, INT x,
|
|
|
|
INT y, INT nWidth, INT nHeight, HWND hWnd,
|
|
|
|
INT nID)
|
|
|
|
{
|
2012-02-23 15:14:06 +01:00
|
|
|
FIXME("(%s, %08x, %08x, %08x, %08x, %08x, %p, %08x): stub\n",
|
|
|
|
debugstr_w(lpszWindowName), dwStyle, x, y, nWidth, nHeight, hWnd, nID);
|
2002-10-07 23:43:13 +02:00
|
|
|
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 21:38:14 +02:00
|
|
|
#ifdef HAVE_LINUX_VIDEODEV2_H
|
2005-04-27 11:46:25 +02: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) {
|
2019-04-23 03:15:16 +02:00
|
|
|
BOOL isCaptureDevice;
|
2019-04-27 21:06:59 +02:00
|
|
|
#ifdef V4L2_CAP_DEVICE_CAPS
|
2019-04-23 03:15:16 +02:00
|
|
|
if (caps.capabilities & V4L2_CAP_DEVICE_CAPS)
|
|
|
|
isCaptureDevice = caps.device_caps & V4L2_CAP_VIDEO_CAPTURE;
|
|
|
|
else
|
2019-04-27 21:06:59 +02:00
|
|
|
#endif
|
2019-04-23 03:15:16 +02:00
|
|
|
isCaptureDevice = caps.capabilities & V4L2_CAP_VIDEO_CAPTURE;
|
|
|
|
if (isCaptureDevice) {
|
|
|
|
lstrcpynA(name, (char *)caps.card, namesize);
|
|
|
|
snprintf(version, versionsize, "%s v%u.%u.%u", (char *)caps.driver, (caps.version >> 16) & 0xFF,
|
2005-04-27 11:46:25 +02:00
|
|
|
(caps.version >> 8) & 0xFF, caps.version & 0xFF);
|
2019-04-23 03:15:16 +02:00
|
|
|
}
|
2005-04-27 11:46:25 +02:00
|
|
|
close(fd);
|
2019-04-23 03:15:16 +02:00
|
|
|
return isCaptureDevice;
|
2005-04-27 11:46:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (errno != EINVAL && errno != 515)
|
|
|
|
/* errno 515 is used by some webcam drivers for unknown IOICTL command */
|
2011-07-14 21:38:14 +02: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 11:46:25 +02:00
|
|
|
|
|
|
|
close(fd);
|
2011-07-14 21:38:14 +02:00
|
|
|
return FALSE;
|
2005-04-27 11:46:25 +02:00
|
|
|
}
|
|
|
|
|
2011-07-14 21:38:14 +02:00
|
|
|
#else /* HAVE_LINUX_VIDEODEV2_H */
|
2005-04-27 11:46:25 +02: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 21:38:14 +02:00
|
|
|
#endif /* HAVE_LINUX_VIDEODEV2_H */
|
2005-04-27 11:46:25 +02:00
|
|
|
|
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.@)
|
|
|
|
*/
|
2002-06-13 23:38:52 +02:00
|
|
|
BOOL VFWAPI capGetDriverDescriptionW(WORD wDriverIndex, LPWSTR lpszName,
|
2005-04-27 11:46:25 +02:00
|
|
|
INT cbName, LPWSTR lpszVer, INT cbVer)
|
2002-06-13 23:38:52 +02:00
|
|
|
{
|
2005-04-27 11:46:25 +02: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 23:38:52 +02:00
|
|
|
}
|