summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/avdevice
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2015-06-26 13:08:12 +0200
committerSlávek Banko <[email protected]>2015-06-26 13:27:08 +0200
commit74f46ee8bdc32c7cd65c17addea3117c3047e7c0 (patch)
treefdb03ae6d11fb5ed7803492da0e7ba1a2e4bf415 /kopete/libkopete/avdevice
parentec6378cdd8ea847ecdd81f8976b5adf2551cef56 (diff)
downloadtdenetwork-74f46ee8bdc32c7cd65c17addea3117c3047e7c0.tar.gz
tdenetwork-74f46ee8bdc32c7cd65c17addea3117c3047e7c0.zip
Add webcam support in kopete on freebsd
[taken from FreeBSD kopete patches] Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'kopete/libkopete/avdevice')
-rw-r--r--kopete/libkopete/avdevice/videocontrol.h8
-rw-r--r--kopete/libkopete/avdevice/videodevice.cpp63
-rw-r--r--kopete/libkopete/avdevice/videodevice.h13
-rw-r--r--kopete/libkopete/avdevice/videodevicepool.cpp2
4 files changed, 57 insertions, 29 deletions
diff --git a/kopete/libkopete/avdevice/videocontrol.h b/kopete/libkopete/avdevice/videocontrol.h
index dbef6b5e..e2d89756 100644
--- a/kopete/libkopete/avdevice/videocontrol.h
+++ b/kopete/libkopete/avdevice/videocontrol.h
@@ -18,7 +18,15 @@
#ifndef 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>
+#endif
#undef __STRICT_ANSI__
#ifndef __u64 //required by videodev.h
#define __u64 unsigned long long
diff --git a/kopete/libkopete/avdevice/videodevice.cpp b/kopete/libkopete/avdevice/videodevice.cpp
index 1df1220f..f79479e7 100644
--- a/kopete/libkopete/avdevice/videodevice.cpp
+++ b/kopete/libkopete/avdevice/videodevice.cpp
@@ -56,6 +56,7 @@ VideoDevice::~VideoDevice()
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
void VideoDevice::enumerateMenu (void)
@@ -79,7 +80,7 @@ void VideoDevice::enumerateMenu (void)
}
}
-
+#endif
#endif
@@ -179,7 +180,7 @@ int VideoDevice::checkDevice()
m_videostream=false;
m_driver=VIDEODEV_DRIVER_NONE;
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
//if(!getWorkaroundBrokenDriver())
@@ -510,7 +511,7 @@ int VideoDevice::initDevice()
m_io_method = IO_METHOD_NONE;
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
if(V4L2_capabilities.capabilities & V4L2_CAP_READWRITE)
@@ -556,7 +557,7 @@ int VideoDevice::initDevice()
}
// 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
cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl (VIDIOC_CROPCAP, &cropcap))
@@ -674,7 +675,7 @@ kdDebug(14010) << k_funcinfo << "setSize(" << newwidth << ", " << newheight <<
// Change resolution for the video device
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
// CLEAR (fmt);
@@ -776,7 +777,7 @@ pixel_format VideoDevice::setPixelFormat(pixel_format newformat)
// Change the pixel format for the video device
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
// CLEAR (fmt);
@@ -865,7 +866,7 @@ int VideoDevice::selectInput(int newinput)
{
switch (m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
if (-1 == ioctl (descriptor, VIDIOC_S_INPUT, &newinput))
@@ -933,7 +934,7 @@ int VideoDevice::startCapturing()
case IO_METHOD_READ: // Nothing to do
break;
case IO_METHOD_MMAP:
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
{
unsigned int loop;
@@ -955,7 +956,7 @@ int VideoDevice::startCapturing()
#endif
break;
case IO_METHOD_USERPTR:
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
{
unsigned int loop;
@@ -993,7 +994,7 @@ int VideoDevice::getFrame()
/// @todo implement me
ssize_t bytesread;
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
struct v4l2_buffer v4l2buffer;
#endif
@@ -1027,7 +1028,7 @@ int VideoDevice::getFrame()
}
break;
case IO_METHOD_MMAP:
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
CLEAR (v4l2buffer);
v4l2buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -1087,7 +1088,7 @@ memcpy(&m_currentbuffer.data[0], m_rawbuffers[v4l2buffer.index].start, m_current
#endif
break;
case IO_METHOD_USERPTR:
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
{
unsigned int i;
@@ -1473,7 +1474,7 @@ float VideoDevice::setBrightness(float brightness)
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
{
@@ -1543,7 +1544,7 @@ float VideoDevice::setContrast(float contrast)
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
{
@@ -1613,7 +1614,7 @@ float VideoDevice::setSaturation(float saturation)
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
{
@@ -1683,7 +1684,7 @@ float VideoDevice::setWhiteness(float whiteness)
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
{
@@ -1753,7 +1754,7 @@ float VideoDevice::setHue(float hue)
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
{
@@ -1874,7 +1875,7 @@ pixel_format VideoDevice::pixelFormatForPalette( int palette )
{
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
switch(palette)
@@ -1937,7 +1938,9 @@ pixel_format VideoDevice::pixelFormatForPalette( int palette )
case VIDEO_PALETTE_RGB32 : return PIXELFORMAT_RGB32; break;
case VIDEO_PALETTE_YUYV : return PIXELFORMAT_YUYV; break;
case VIDEO_PALETTE_UYVY : return PIXELFORMAT_UYVY; break;
+#if !defined(__FreeBSD__)
case VIDEO_PALETTE_YUV420 :
+#endif
case VIDEO_PALETTE_YUV420P : return PIXELFORMAT_YUV420P; break;
case VIDEO_PALETTE_YUV422P : return PIXELFORMAT_YUV422P; break;
}
@@ -1954,7 +1957,7 @@ int VideoDevice::pixelFormatCode(pixel_format pixelformat)
{
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
switch(pixelformat)
@@ -2029,7 +2032,11 @@ int VideoDevice::pixelFormatCode(pixel_format pixelformat)
case PIXELFORMAT_GREY : return VIDEO_PALETTE_GREY; break;
case PIXELFORMAT_YUYV : return VIDEO_PALETTE_YUYV; 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;
+#endif
case PIXELFORMAT_YUV422P: return VIDEO_PALETTE_YUV422P; break;
// Compressed formats
@@ -2082,7 +2089,11 @@ int VideoDevice::pixelFormatDepth(pixel_format pixelformat)
case PIXELFORMAT_GREY : return 8; break;
case PIXELFORMAT_YUYV : 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;
+#endif
case PIXELFORMAT_YUV422P: return 16; break;
// Compressed formats
@@ -2160,7 +2171,7 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
returnvalue = "None";
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
switch(pixelformat)
@@ -2222,7 +2233,9 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
case VIDEO_PALETTE_RGB32 : returnvalue = pixelFormatName(PIXELFORMAT_RGB32); break;
case VIDEO_PALETTE_YUYV : returnvalue = pixelFormatName(PIXELFORMAT_YUYV); break;
case VIDEO_PALETTE_UYVY : returnvalue = pixelFormatName(PIXELFORMAT_UYVY); break;
+#if !defined(__FreeBSD__)
case VIDEO_PALETTE_YUV420 :
+#endif
case VIDEO_PALETTE_YUV420P : returnvalue = pixelFormatName(PIXELFORMAT_YUV420P); break;
case VIDEO_PALETTE_YUV422P : returnvalue = pixelFormatName(PIXELFORMAT_YUV422P); break;
}
@@ -2237,14 +2250,14 @@ TQString VideoDevice::pixelFormatName(int pixelformat)
int VideoDevice::detectPixelFormats()
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
int err = 0;
#endif
#endif
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
fmtdesc.index = 0;
@@ -2321,7 +2334,7 @@ __u64 VideoDevice::signalStandardCode(signal_standard standard)
{
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
switch(standard)
@@ -2463,7 +2476,7 @@ TQString VideoDevice::signalStandardName(int standard)
returnvalue = "None";
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
switch(standard)
@@ -2533,7 +2546,7 @@ int VideoDevice::detectSignalStandards()
{
switch(m_driver)
{
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
case VIDEODEV_DRIVER_V4L2:
break;
diff --git a/kopete/libkopete/avdevice/videodevice.h b/kopete/libkopete/avdevice/videodevice.h
index 61bd8844..dd9047c9 100644
--- a/kopete/libkopete/avdevice/videodevice.h
+++ b/kopete/libkopete/avdevice/videodevice.h
@@ -33,9 +33,14 @@
#include <unistd.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>
+#endif
#undef __STRICT_ANSI__
#ifndef __u64 //required by videodev.h
#define __u64 unsigned long long
@@ -50,8 +55,10 @@
#define pgoff_t unsigned long
#endif
+#if defined(__linux__)
#include <linux/fs.h>
#include <linux/kernel.h>
+#endif
#if defined(HAVE_LIBV4L1_VIDEODEV_H)
#include <libv4l1-videodev.h>
#elif defined(HAVE_LINUX_VIDEODEV_H)
@@ -86,7 +93,7 @@ namespace AV {
typedef enum
{
VIDEODEV_DRIVER_NONE
-#if defined( __linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
,
VIDEODEV_DRIVER_V4L
#ifdef V4L2_CAP_VIDEO_CAPTURE
@@ -282,7 +289,7 @@ public:
int descriptor;
//protected:
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
#ifdef V4L2_CAP_VIDEO_CAPTURE
struct v4l2_capability V4L2_capabilities;
struct v4l2_cropcap cropcap;
diff --git a/kopete/libkopete/avdevice/videodevicepool.cpp b/kopete/libkopete/avdevice/videodevicepool.cpp
index 4c96a452..7396d5a0 100644
--- a/kopete/libkopete/avdevice/videodevicepool.cpp
+++ b/kopete/libkopete/avdevice/videodevicepool.cpp
@@ -606,7 +606,7 @@ int VideoDevicePool::scanDevices()
/// @todo implement me
kdDebug(14010) << k_funcinfo << "called" << endl;
-#if defined(__linux__) && defined(ENABLE_AV)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
TQDir videodevice_dir;
const TQString videodevice_dir_path=TQString::fromLocal8Bit("/dev/v4l/");
const TQString videodevice_dir_filter=TQString::fromLocal8Bit("video*");