$NetBSD$

--- configure.ac.orig	2009-05-18 22:46:44.000000000 +0200
+++ configure.ac
@@ -105,6 +102,10 @@ fi
 
 AM_CONDITIONAL(WITH_HILDON, test "x$enable_hildon" = "xyes")
 
+AC_CHECK_HEADER([sys/videoio.h],
+  [AC_DEFINE(USE_SYS_VIDEOIO_H, 1, define to 1 if sys/videoio.h is present)],
+  [AC_DEFINE(USE_SYS_VIDEOIO_H, 0, define to 1 if sys/videoio.h is present)], [])
+
 AC_PATH_PROG(GCONFTOOL, gconftool-2)
 AM_GCONF_SOURCE_2
 
$NetBSD$

--- src/cheese-webcam.c.orig	2009-05-18 22:46:03.000000000 +0200
+++ src/cheese-webcam.c
@@ -37,7 +37,18 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
+
+#if USE_SYS_VIDEOIO_H > 0
+#include <sys/types.h>
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/types.h>
+#include <sys/videodev2.h>
+#elif defined(__linux__)
 #include <linux/videodev.h>
+#else
+#define NO_VIDEO_SUPPORT
+#endif
 
 #include "cheese-webcam.h"
 
@@ -302,8 +313,12 @@ cheese_webcam_get_video_devices_from_hal
     char                   *parent_udi = NULL;
     char                   *subsystem = NULL;
     char                   *gstreamer_src, *product_name;
+#ifndef NO_VIDEO_SUPPORT
     struct v4l2_capability  v2cap;
+#endif
+#ifdef VIDIOCGCAP
     struct video_capability v1cap;
+#endif
     gint vendor_id = 0;
     gint product_id = 0;
     gchar *property_name = NULL;
@@ -317,15 +332,17 @@ cheese_webcam_get_video_devices_from_hal
 
     if (parent_udi != NULL) {
       subsystem = libhal_device_get_property_string (hal_ctx, parent_udi, "info.subsystem", NULL);
-      if (subsystem == NULL) continue;
-      property_name = g_strjoin (".", subsystem, "vendor_id", NULL);
-      vendor_id = libhal_device_get_property_int (hal_ctx, parent_udi, property_name , &error);
-      if (dbus_error_is_set (&error)) {
-        g_warning ("error getting vendor id: %s: %s", error.name, error.message);
-        dbus_error_free (&error);
+      if (subsystem == NULL) {
+	vendor_id = g_strdup("{No vendor ID}");
+      } else {
+        property_name = g_strjoin (".", subsystem, "vendor_id", NULL);
+        vendor_id = libhal_device_get_property_int (hal_ctx, parent_udi, property_name , &error);
+        if (dbus_error_is_set (&error)) {
+          g_warning ("error getting vendor id: %s: %s", error.name, error.message);
+          dbus_error_free (&error);
+        }
+        g_free (property_name);
       }
-      g_free (property_name);
-
       property_name = g_strjoin (".", subsystem, "product_id", NULL);
       product_id = libhal_device_get_property_int (hal_ctx, parent_udi, property_name, &error);
       if (dbus_error_is_set (&error)) {
@@ -362,9 +379,14 @@ cheese_webcam_get_video_devices_from_hal
       libhal_free_string (device);
       continue;
     }
+#ifdef VIDIOC_QUERYCAP
     ok = ioctl (fd, VIDIOC_QUERYCAP, &v2cap);
+#else
+    ok = -1;
+#endif
     if (ok < 0)
     {
+#ifdef VIDIOCGCAP
       ok = ioctl (fd, VIDIOCGCAP, &v1cap);
       if (ok < 0)
       {
@@ -378,14 +400,22 @@ cheese_webcam_get_video_devices_from_hal
       g_print ("Device type: %d\n", v1cap.type);
       gstreamer_src = "v4lsrc";
       product_name  = v1cap.name;
+#else
+      g_error ("Error while probing v4l2 capabilities for %s: %s\n",
+             device, strerror (errno));
+      libhal_free_string (device);
+      close (fd);
+      continue;
+#endif
     }
     else
     {
+#ifndef NO_VIDEO_SUPPORT
       guint cap = v2cap.capabilities;
       g_print ("Detected v4l2 device: %s\n", v2cap.card);
       g_print ("Driver: %s, version: %d\n", v2cap.driver, v2cap.version);
       /* g_print ("Bus info: %s\n", v2cap.bus_info); */ /* Doesn't seem anything useful */
-     g_print ("Capabilities: 0x%08X\n", v2cap.capabilities);
+      g_print ("Capabilities: 0x%08X\n", v2cap.capabilities);
       if (!(cap & V4L2_CAP_VIDEO_CAPTURE))
       {
         g_print ("Device %s seems to not have the capture capability, (radio tuner?)\n"
@@ -396,6 +426,10 @@ cheese_webcam_get_video_devices_from_hal
       }
       gstreamer_src = "v4l2src";
       product_name  = (char *) v2cap.card;
+#else /* NO_VIDEO_SUPPORT */
+      gstreamer_src = "v4l2src";
+      product_name = "Webcam";
+#endif
     }
 
     g_print ("\n");
