openbsd-ports/x11/gnome/cheese/patches/patch-src_cheese-webcam_c
ajacoutot 1dbeef6b9f - update to cheese-2.24.1
note that until gstreamer v4l2 support is fixed, this port stays not
functionnal (robert? ;-))
2008-11-14 16:18:00 +00:00

107 lines
2.8 KiB
Plaintext

$OpenBSD: patch-src_cheese-webcam_c,v 1.2 2008/11/14 16:18:00 ajacoutot Exp $
--- src/cheese-webcam.c.orig Mon Oct 20 18:01:47 2008
+++ src/cheese-webcam.c Fri Nov 14 17:08:41 2008
@@ -32,13 +32,25 @@
#include <gst/gst.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <X11/Xlib.h>
+#ifndef __OpenBSD__ // no HAL under OpenBSD
#include <libhal.h>
+#else
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+#include <sys/types.h>
+#include <sys/videoio.h>
+#endif
+#endif
/* for ioctl query */
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
+#ifdef __linux__
#include <linux/videodev.h>
+#endif
#include "cheese-webcam.h"
#include "cheese-flash.h"
@@ -244,6 +256,7 @@ cheese_webcam_bus_message_cb (GstBus *bus, GstMessage
}
}
+#ifndef __OpenBSD__ // no HAL under OpenBSD
static void
cheese_webcam_get_video_devices_from_hal (CheeseWebcam *webcam)
{
@@ -394,7 +407,55 @@ fallback:
priv->webcam_devices[0].hal_udi = g_strdup ("cheese_fake_videodevice");
}
}
+#else // __OpenBSD__
+static void
+cheese_webcam_get_video_devices_from_probe (CheeseWebcam *webcam)
+{
+ CheeseWebcamPrivate* priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
+ struct v4l2_capability caps;
+ gchar videodev[] = "/dev/video?";
+ guint16 cammask = 0;
+ int i, ncams = 0, fd, ret, cur = 0;
+
+ for (i = 0; i < 9; i++)
+ {
+ videodev[strlen(videodev) - 1] = '0' + i;
+ fd = open(videodev, O_RDONLY);
+ if (fd == -1)
+ continue;
+ ret = ioctl(fd, VIDIOC_QUERYCAP, &caps);
+ close(fd);
+ if (ret)
+ {
+ continue;
+ }
+ g_message("Found video device: %s\n", caps.card);
+ cammask |= (1 << i);
+ ++ncams;
+ }
+ priv->num_webcam_devices = ncams;
+ if (ncams == 0)
+ return;
+ priv->webcam_devices = g_new0 (CheeseWebcamDevice, ncams);
+ for (i = 0; i < ncams; i++)
+ {
+ priv->webcam_devices[i].num_video_formats = 0;
+ priv->webcam_devices[i].video_formats = g_array_new (FALSE, FALSE, sizeof (CheeseVideoFormat));
+ }
+
+ for (i = 0; i < 9; i++)
+ {
+ if (cammask & (1 << i))
+ {
+ videodev[strlen(videodev) - 1] = '0' + i;
+ priv->webcam_devices[i].video_device = g_strdup (videodev);
+ ++cur;
+ }
+ }
+}
+#endif /* __OpenBSD__ */
+
static void
cheese_webcam_get_supported_framerates (CheeseVideoFormat *video_format, GstStructure *structure)
{
@@ -698,7 +759,11 @@ cheese_webcam_detect_webcam_devices (CheeseWebcam *web
int i;
- cheese_webcam_get_video_devices_from_hal (webcam);
+#ifndef __OpenBSD__ // no HAL under OpenBSD
+ cheese_webcam_get_video_devices_from_hal (webcam);
+#else
+ cheese_webcam_get_video_devices_from_probe (webcam);
+#endif
for (i = 0; i < priv->num_webcam_devices; i++)
{
cheese_webcam_get_webcam_device_data (webcam, &(priv->webcam_devices[i]));