summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/motionautoaway/motionawayplugin.cpp
diff options
context:
space:
mode:
authorMavridis Philippe <[email protected]>2021-06-30 11:50:40 +0300
committerMavridis Philippe <[email protected]>2021-06-30 18:41:00 +0300
commita7c8fb0d6c42c021be900c1a43df0e0aada1af50 (patch)
tree9851dc57a08131162f2d0074255f36a0b1ce4546 /kopete/plugins/motionautoaway/motionawayplugin.cpp
parent88c2dc15e7839673636c0f26b87d7318d7b931f9 (diff)
downloadtdenetwork-a7c8fb0d6c42c021be900c1a43df0e0aada1af50.tar.gz
tdenetwork-a7c8fb0d6c42c021be900c1a43df0e0aada1af50.zip
Fixed Kopete FTBFS
This commit also adds initial V4L2 support for Motion AutoAway plugin. Signed-off-by: Mavridis Philippe <[email protected]> (cherry picked from commit 7a3a7896b3c96bee076ed0da65d10eec7fc06b85)
Diffstat (limited to 'kopete/plugins/motionautoaway/motionawayplugin.cpp')
-rw-r--r--kopete/plugins/motionautoaway/motionawayplugin.cpp60
1 files changed, 53 insertions, 7 deletions
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++)