summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2021-06-30 11:50:40 +0300
committerMavridis Philippe <mavridisf@gmail.com>2021-06-30 18:41:00 +0300
commita7c8fb0d6c42c021be900c1a43df0e0aada1af50 (patch)
tree9851dc57a08131162f2d0074255f36a0b1ce4546
parent88c2dc15e7839673636c0f26b87d7318d7b931f9 (diff)
downloadtdenetwork-a7c8fb0d.tar.gz
tdenetwork-a7c8fb0d.zip
Fixed Kopete FTBFS
This commit also adds initial V4L2 support for Motion AutoAway plugin. Signed-off-by: Mavridis Philippe <mavridisf@gmail.com> (cherry picked from commit 7a3a7896b3c96bee076ed0da65d10eec7fc06b85)
-rw-r--r--kopete/libkopete/avdevice/videodevice.h4
-rw-r--r--kopete/plugins/motionautoaway/motionawayplugin.cpp60
2 files changed, 55 insertions, 9 deletions
diff --git a/kopete/libkopete/avdevice/videodevice.h b/kopete/libkopete/avdevice/videodevice.h
index a1ace57e..0c3cb473 100644
--- a/kopete/libkopete/avdevice/videodevice.h
+++ b/kopete/libkopete/avdevice/videodevice.h
@@ -92,7 +92,7 @@ typedef enum
{
VIDEODEV_DRIVER_NONE
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
-#if defined(__LINUX_VIDEODEV2_H) /* V4L2 */
+#if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
,
VIDEODEV_DRIVER_V4L2
#elif defined(__LINUX_VIDEODEV_H) /* V4L */
@@ -289,7 +289,7 @@ public:
//protected:
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(ENABLE_AV)
-#if defined(__LINUX_VIDEODEV2_H) /* V4L2 */
+#if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
struct v4l2_capability V4L2_capabilities;
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
diff --git a/kopete/plugins/motionautoaway/motionawayplugin.cpp b/kopete/plugins/motionautoaway/motionawayplugin.cpp
index cf3a62f4..fa6136ef 100644
--- a/kopete/plugins/motionautoaway/motionawayplugin.cpp
+++ b/kopete/plugins/motionautoaway/motionawayplugin.cpp
@@ -110,9 +110,13 @@ MotionAwayPlugin::MotionAwayPlugin( TQObject *parent, const char *name, const TQ
kdDebug(14305) << k_funcinfo << "Worked! Setting Capture timers!" << endl;
/* Capture first image, or we will get a alarm on start */
getImage (m_deviceHandler, m_imageRef, DEF_WIDTH, DEF_HEIGHT, IN_DEFAULT, NORM_DEFAULT,
- VIDEO_PALETTE_RGB24);
+#ifdef V4L2_CAP_VIDEO_CAPTURE /* V4L2 */
+ V4L2_PIX_FMT_RGB24);
+#else /* V4L or BSD compat layer */
+ VIDEO_PALETTE_RGB24);
+#endif
- /* We have the first image now */
+ /* We have the first image now */
m_tookFirst = true;
m_wentAway = false;
@@ -142,14 +146,49 @@ void MotionAwayPlugin::loadSettings(){
int MotionAwayPlugin::getImage(int _dev, TQByteArray &_image, int _width, int _height, int _input, int _norm, int _fmt)
{
- struct video_capability vid_caps;
- struct video_channel vid_chnl;
- struct video_window vid_win;
struct pollfd video_fd;
// Just to avoid a warning
_fmt = 0;
+#if defined(V4L2_CAP_VIDEO_CAPTURE) /* V4L2 */
+ struct v4l2_queryctrl queryctrl;
+ struct v4l2_format fmt;
+ int newinput = _input;
+
+ if (ioctl(_dev, VIDIOC_QUERYCTRL, &queryctrl) == -1)
+ {
+ perror("ioctl (VIDIOC_QUERYCTRL)");
+ return(-1);
+ }
+
+ if (_input != IN_DEFAULT)
+ {
+ newinput = -1;
+ if (ioctl(_dev, VIDIOC_S_INPUT, &newinput) == -1)
+ {
+ perror ("ioctl (VIDIOC_S_INPUT)");
+ return EXIT_FAILURE;
+ }
+ }
+
+ // Set image size
+ if (ioctl(_dev, VIDIOC_G_FMT, &fmt) == -1)
+ perror("ioctl (VIDIOC_G_FMT)");
+
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmt.fmt.pix.width = _width;
+ fmt.fmt.pix.height = _height;
+ fmt.fmt.pix.field = V4L2_FIELD_ANY;
+
+ if (ioctl(_dev, VIDIOC_S_FMT, &fmt) == -1)
+ perror("ioctl (VIDIOC_S_FMT)");
+
+#elif defined(__LINUX_VIDEODEV_H) /* V4L */
+ struct video_capability vid_caps;
+ struct video_channel vid_chnl;
+ struct video_window vid_win;
+
if (ioctl (_dev, VIDIOCGCAP, &vid_caps) == -1)
{
perror ("ioctl (VIDIOCGCAP)");
@@ -186,6 +225,8 @@ int MotionAwayPlugin::getImage(int _dev, TQByteArray &_image, int _width, int _h
if (ioctl (_dev, VIDIOCSWIN, &vid_win) == -1)
return (-1);
+#endif
+
/* Check if data available on the video device */
video_fd.fd = _dev;
video_fd.events = 0;
@@ -206,10 +247,15 @@ void MotionAwayPlugin::slotCapture()
{
/* Should go on forever... emphasis on 'should' */
if ( getImage ( m_deviceHandler, m_imageNew, m_width, m_height, IN_DEFAULT, NORM_DEFAULT,
- VIDEO_PALETTE_RGB24) == m_width * m_height *3 )
+#ifdef V4L2_CAP_VIDEO_CAPTURE /* V4L2 */
+ V4L2_PIX_FMT_RGB24
+#else /* V4L or BSD compat layer */
+ VIDEO_PALETTE_RGB24
+#endif
+ ) == m_width * m_height *3 )
{
int diffs = 0;
- if ( m_tookFirst )
+ if ( m_tookFirst )
{
/* Make a differences picture in image_out */
for (int i=0; i< m_width * m_height * 3 ; i++)