Add webcam support in kopete on freebsd

[taken from FreeBSD kopete patches]

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 74f46ee8bd)
pull/38/head
Slávek Banko 10 years ago
parent be43d04f2c
commit bbf336489c

@ -18,7 +18,15 @@
#ifndef KOPETE_AVVIDEOCONTROL_H #ifndef KOPETE_AVVIDEOCONTROL_H
#define KOPETE_AVVIDEOCONTROL_H #define KOPETE_AVVIDEOCONTROL_H
#if defined HAVE_CONFIG_H
#include <config.h>
#endif
#if defined HAVE_LINUX_VIDEODEV_H
#include <linux/videodev.h>
#endif
#if defined(__linux__)
#include <asm/types.h> #include <asm/types.h>
#endif
#undef __STRICT_ANSI__ #undef __STRICT_ANSI__
#ifndef __u64 //required by videodev.h #ifndef __u64 //required by videodev.h
#define __u64 unsigned long long #define __u64 unsigned long long

@ -56,6 +56,7 @@ VideoDevice::~VideoDevice()
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
void VideoDevice::enumerateMenu (void) void VideoDevice::enumerateMenu (void)
@ -79,7 +80,7 @@ void VideoDevice::enumerateMenu (void)
} }
} }
#endif
#endif #endif
@ -179,7 +180,7 @@ int VideoDevice::checkDevice()
m_videostream=false; m_videostream=false;
m_driver=VIDEODEV_DRIVER_NONE; m_driver=VIDEODEV_DRIVER_NONE;
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
//if(!getWorkaroundBrokenDriver()) //if(!getWorkaroundBrokenDriver())
@ -510,7 +511,7 @@ int VideoDevice::initDevice()
m_io_method = IO_METHOD_NONE; m_io_method = IO_METHOD_NONE;
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
if(V4L2_capabilities.capabilities & V4L2_CAP_READWRITE) if(V4L2_capabilities.capabilities & V4L2_CAP_READWRITE)
@ -556,7 +557,7 @@ int VideoDevice::initDevice()
} }
// Select video input, video standard and tune here. // Select video input, video standard and tune here.
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl (VIDIOC_CROPCAP, &cropcap)) if (-1 == xioctl (VIDIOC_CROPCAP, &cropcap))
@ -674,7 +675,7 @@ kdDebug(14010) << k_funcinfo << "setSize(" << newwidth << ", " << newheight <<
// Change resolution for the video device // Change resolution for the video device
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
// CLEAR (fmt); // CLEAR (fmt);
@ -776,7 +777,7 @@ pixel_format VideoDevice::setPixelFormat(pixel_format newformat)
// Change the pixel format for the video device // Change the pixel format for the video device
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
// CLEAR (fmt); // CLEAR (fmt);
@ -865,7 +866,7 @@ int VideoDevice::selectInput(int newinput)
{ {
switch (m_driver) switch (m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
if (-1 == ioctl (descriptor, VIDIOC_S_INPUT, &newinput)) if (-1 == ioctl (descriptor, VIDIOC_S_INPUT, &newinput))
@ -933,7 +934,7 @@ int VideoDevice::startCapturing()
case IO_METHOD_READ: // Nothing to do case IO_METHOD_READ: // Nothing to do
break; break;
case IO_METHOD_MMAP: case IO_METHOD_MMAP:
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
{ {
unsigned int loop; unsigned int loop;
@ -955,7 +956,7 @@ int VideoDevice::startCapturing()
#endif #endif
break; break;
case IO_METHOD_USERPTR: case IO_METHOD_USERPTR:
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
{ {
unsigned int loop; unsigned int loop;
@ -993,7 +994,7 @@ int VideoDevice::getFrame()
/// @todo implement me /// @todo implement me
ssize_t bytesread; ssize_t bytesread;
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
struct v4l2_buffer v4l2buffer; struct v4l2_buffer v4l2buffer;
#endif #endif
@ -1027,7 +1028,7 @@ int VideoDevice::getFrame()
} }
break; break;
case IO_METHOD_MMAP: case IO_METHOD_MMAP:
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
CLEAR (v4l2buffer); CLEAR (v4l2buffer);
v4l2buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; v4l2buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@ -1087,7 +1088,7 @@ memcpy(&m_currentbuffer.data[0], m_rawbuffers[v4l2buffer.index].start, m_current
#endif #endif
break; break;
case IO_METHOD_USERPTR: case IO_METHOD_USERPTR:
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
{ {
unsigned int i; unsigned int i;
@ -1473,7 +1474,7 @@ float VideoDevice::setBrightness(float brightness)
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
@ -1543,7 +1544,7 @@ float VideoDevice::setContrast(float contrast)
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
@ -1613,7 +1614,7 @@ float VideoDevice::setSaturation(float saturation)
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
@ -1683,7 +1684,7 @@ float VideoDevice::setWhiteness(float whiteness)
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
@ -1753,7 +1754,7 @@ float VideoDevice::setHue(float hue)
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
{ {
@ -1874,7 +1875,7 @@ pixel_format VideoDevice::pixelFormatForPalette( int palette )
{ {
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(palette) switch(palette)
@ -1937,7 +1938,9 @@ pixel_format VideoDevice::pixelFormatForPalette( int palette )
case VIDEO_PALETTE_RGB32 : return PIXELFORMAT_RGB32; break; case VIDEO_PALETTE_RGB32 : return PIXELFORMAT_RGB32; break;
case VIDEO_PALETTE_YUYV : return PIXELFORMAT_YUYV; break; case VIDEO_PALETTE_YUYV : return PIXELFORMAT_YUYV; break;
case VIDEO_PALETTE_UYVY : return PIXELFORMAT_UYVY; break; case VIDEO_PALETTE_UYVY : return PIXELFORMAT_UYVY; break;
#if !defined(__FreeBSD__)
case VIDEO_PALETTE_YUV420 : case VIDEO_PALETTE_YUV420 :
#endif
case VIDEO_PALETTE_YUV420P : return PIXELFORMAT_YUV420P; break; case VIDEO_PALETTE_YUV420P : return PIXELFORMAT_YUV420P; break;
case VIDEO_PALETTE_YUV422P : return PIXELFORMAT_YUV422P; break; case VIDEO_PALETTE_YUV422P : return PIXELFORMAT_YUV422P; break;
} }
@ -1954,7 +1957,7 @@ int VideoDevice::pixelFormatCode(pixel_format pixelformat)
{ {
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(pixelformat) switch(pixelformat)
@ -2029,7 +2032,11 @@ int VideoDevice::pixelFormatCode(pixel_format pixelformat)
case PIXELFORMAT_GREY : return VIDEO_PALETTE_GREY; break; case PIXELFORMAT_GREY : return VIDEO_PALETTE_GREY; break;
case PIXELFORMAT_YUYV : return VIDEO_PALETTE_YUYV; break; case PIXELFORMAT_YUYV : return VIDEO_PALETTE_YUYV; break;
case PIXELFORMAT_UYVY : return VIDEO_PALETTE_UYVY; break; case PIXELFORMAT_UYVY : return VIDEO_PALETTE_UYVY; break;
#if defined(__FreeBSD__)
case PIXELFORMAT_YUV420P: return VIDEO_PALETTE_YUV420P; break;
#else
case PIXELFORMAT_YUV420P: return VIDEO_PALETTE_YUV420; break; case PIXELFORMAT_YUV420P: return VIDEO_PALETTE_YUV420; break;
#endif
case PIXELFORMAT_YUV422P: return VIDEO_PALETTE_YUV422P; break; case PIXELFORMAT_YUV422P: return VIDEO_PALETTE_YUV422P; break;
// Compressed formats // Compressed formats
@ -2082,7 +2089,11 @@ int VideoDevice::pixelFormatDepth(pixel_format pixelformat)
case PIXELFORMAT_GREY : return 8; break; case PIXELFORMAT_GREY : return 8; break;
case PIXELFORMAT_YUYV : return 16; break; case PIXELFORMAT_YUYV : return 16; break;
case PIXELFORMAT_UYVY : return 16; break; case PIXELFORMAT_UYVY : return 16; break;
#if defined(__FreeBSD__)
case PIXELFORMAT_YUV420P: return 24; break;
#else
case PIXELFORMAT_YUV420P: return 16; break; case PIXELFORMAT_YUV420P: return 16; break;
#endif
case PIXELFORMAT_YUV422P: return 16; break; case PIXELFORMAT_YUV422P: return 16; break;
// Compressed formats // Compressed formats
@ -2160,7 +2171,7 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
returnvalue = "None"; returnvalue = "None";
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(pixelformat) switch(pixelformat)
@ -2222,7 +2233,9 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
case VIDEO_PALETTE_RGB32 : returnvalue = pixelFormatName(PIXELFORMAT_RGB32); break; case VIDEO_PALETTE_RGB32 : returnvalue = pixelFormatName(PIXELFORMAT_RGB32); break;
case VIDEO_PALETTE_YUYV : returnvalue = pixelFormatName(PIXELFORMAT_YUYV); break; case VIDEO_PALETTE_YUYV : returnvalue = pixelFormatName(PIXELFORMAT_YUYV); break;
case VIDEO_PALETTE_UYVY : returnvalue = pixelFormatName(PIXELFORMAT_UYVY); break; case VIDEO_PALETTE_UYVY : returnvalue = pixelFormatName(PIXELFORMAT_UYVY); break;
#if !defined(__FreeBSD__)
case VIDEO_PALETTE_YUV420 : case VIDEO_PALETTE_YUV420 :
#endif
case VIDEO_PALETTE_YUV420P : returnvalue = pixelFormatName(PIXELFORMAT_YUV420P); break; case VIDEO_PALETTE_YUV420P : returnvalue = pixelFormatName(PIXELFORMAT_YUV420P); break;
case VIDEO_PALETTE_YUV422P : returnvalue = pixelFormatName(PIXELFORMAT_YUV422P); break; case VIDEO_PALETTE_YUV422P : returnvalue = pixelFormatName(PIXELFORMAT_YUV422P); break;
} }
@ -2237,14 +2250,14 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
int VideoDevice::detectPixelFormats() int VideoDevice::detectPixelFormats()
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
int err = 0; int err = 0;
#endif #endif
#endif #endif
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
fmtdesc.index = 0; fmtdesc.index = 0;
@ -2321,7 +2334,7 @@ __u64 VideoDevice::signalStandardCode(signal_standard standard)
{ {
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(standard) switch(standard)
@ -2463,7 +2476,7 @@ TQString VideoDevice::signalStandardName(int standard)
returnvalue = "None"; returnvalue = "None";
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
switch(standard) switch(standard)
@ -2533,7 +2546,7 @@ int VideoDevice::detectSignalStandards()
{ {
switch(m_driver) switch(m_driver)
{ {
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2: case VIDEODEV_DRIVER_V4L2:
break; break;

@ -33,9 +33,14 @@
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#if defined HAVE_LINUX_VIDEODEV_H
#include <linux/videodev.h>
#endif
#if defined(__linux__)
#include <asm/types.h> #include <asm/types.h>
#endif
#undef __STRICT_ANSI__ #undef __STRICT_ANSI__
#ifndef __u64 //required by videodev.h #ifndef __u64 //required by videodev.h
#define __u64 unsigned long long #define __u64 unsigned long long
@ -50,8 +55,10 @@
#define pgoff_t unsigned long #define pgoff_t unsigned long
#endif #endif
#if defined(__linux__)
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#endif
#if defined(HAVE_LIBV4L1_VIDEODEV_H) #if defined(HAVE_LIBV4L1_VIDEODEV_H)
#include <libv4l1-videodev.h> #include <libv4l1-videodev.h>
#elif defined(HAVE_LINUX_VIDEODEV_H) #elif defined(HAVE_LINUX_VIDEODEV_H)
@ -86,7 +93,7 @@ namespace AV {
typedef enum typedef enum
{ {
VIDEODEV_DRIVER_NONE VIDEODEV_DRIVER_NONE
#if defined( __linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
, ,
VIDEODEV_DRIVER_V4L VIDEODEV_DRIVER_V4L
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
@ -282,7 +289,7 @@ public:
int descriptor; int descriptor;
//protected: //protected:
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE #ifdef V4L2_CAP_VIDEO_CAPTURE
struct v4l2_capability V4L2_capabilities; struct v4l2_capability V4L2_capabilities;
struct v4l2_cropcap cropcap; struct v4l2_cropcap cropcap;

@ -606,7 +606,7 @@ int VideoDevicePool::scanDevices()
/// @todo implement me /// @todo implement me
kdDebug(14010) << k_funcinfo << "called" << endl; kdDebug(14010) << k_funcinfo << "called" << endl;
#if defined(__linux__) && defined(ENABLE_AV) #if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
TQDir videodevice_dir; TQDir videodevice_dir;
const TQString videodevice_dir_path=TQString::fromLocal8Bit("/dev/v4l/"); const TQString videodevice_dir_path=TQString::fromLocal8Bit("/dev/v4l/");
const TQString videodevice_dir_filter=TQString::fromLocal8Bit("video*"); const TQString videodevice_dir_filter=TQString::fromLocal8Bit("video*");

Loading…
Cancel
Save