diff options
author | kwm <kwm@df743ca5-7f9a-e211-a948-0013205c9059> | 2011-04-13 17:44:34 +0800 |
---|---|---|
committer | kwm <kwm@df743ca5-7f9a-e211-a948-0013205c9059> | 2011-04-13 17:44:34 +0800 |
commit | 232aaa7a3f495116b568c008500b65a3608c16c7 (patch) | |
tree | 499405c2f27daafd62ad0e95f1ae566020e68008 /multimedia/cheese3 | |
parent | 5329429a4c6851c4191b208238d22aba441ab4fe (diff) | |
download | marcuscom-ports-232aaa7a3f495116b568c008500b65a3608c16c7.tar marcuscom-ports-232aaa7a3f495116b568c008500b65a3608c16c7.tar.gz marcuscom-ports-232aaa7a3f495116b568c008500b65a3608c16c7.tar.bz2 marcuscom-ports-232aaa7a3f495116b568c008500b65a3608c16c7.tar.lz marcuscom-ports-232aaa7a3f495116b568c008500b65a3608c16c7.tar.xz marcuscom-ports-232aaa7a3f495116b568c008500b65a3608c16c7.tar.zst marcuscom-ports-232aaa7a3f495116b568c008500b65a3608c16c7.zip |
Port hal patches from cheese 2.30. This enables cheese to find video devices again.
Add depend on gstreamer jpeg plugin, camerabin wants it.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@15806 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'multimedia/cheese3')
-rw-r--r-- | multimedia/cheese3/Makefile | 5 | ||||
-rw-r--r-- | multimedia/cheese3/files/patch-configure | 292 | ||||
-rw-r--r-- | multimedia/cheese3/files/patch-libcheese_cheese-camera-device-monitor.c | 395 |
3 files changed, 690 insertions, 2 deletions
diff --git a/multimedia/cheese3/Makefile b/multimedia/cheese3/Makefile index 8d4fdffee..7d09e52cf 100644 --- a/multimedia/cheese3/Makefile +++ b/multimedia/cheese3/Makefile @@ -3,11 +3,12 @@ # Whom: FreeBSD GNOME Team <gnome@FreeBSD.org> # # $FreeBSD$ -# $MCom: ports/multimedia/cheese3/Makefile,v 1.3 2011/03/30 07:50:26 kwm Exp $ +# $MCom: ports/multimedia/cheese3/Makefile,v 1.4 2011/04/05 19:55:37 kwm Exp $ # PORTNAME= cheese PORTVERSION= 3.0.0 +PORTREVISION= 1 CATEGORIES= multimedia gnome MASTER_SITES= GNOME DIST_SUBDIR= gnome3 @@ -30,7 +31,7 @@ USE_GMAKE= yes USE_GNOME= gnomehack gnomeprefix intlhack evolutiondataserver3 librsvg2 \ gnomedocutils gnomedesktop3 USE_GETTEXT= yes -USE_GSTREAMER= good v4l2 bad +USE_GSTREAMER= good v4l2 bad jpeg INSTALLS_OMF= yes INSTALLS_ICONS= yes USE_LDCONFIG= yes diff --git a/multimedia/cheese3/files/patch-configure b/multimedia/cheese3/files/patch-configure new file mode 100644 index 000000000..767841350 --- /dev/null +++ b/multimedia/cheese3/files/patch-configure @@ -0,0 +1,292 @@ +--- configure.orig 2011-04-13 11:06:34.000000000 +0200 ++++ configure 2011-04-13 11:07:44.000000000 +0200 +@@ -854,7 +723,10 @@ CHEESE_CFLAGS + HAVE_XTEST_FALSE + HAVE_XTEST_TRUE + XTEST_LIBS ++OS_FREEBSD + OS_LINUX ++HAL_LIBS ++HAL_CFLAGS + UDEV_LIBS + UDEV_CFLAGS + PKG_CONFIG_LIBDIR +@@ -1059,6 +934,8 @@ PKG_CONFIG_PATH + PKG_CONFIG_LIBDIR + UDEV_CFLAGS + UDEV_LIBS ++HAL_CFLAGS ++HAL_LIBS + CHEESE_CFLAGS + CHEESE_LIBS + CHEESE_GTK_CFLAGS +@@ -1739,6 +1618,8 @@ Some influential environment variables: + path overriding pkg-config's built-in search path + UDEV_CFLAGS C compiler flags for UDEV, overriding pkg-config + UDEV_LIBS linker flags for UDEV, overriding pkg-config ++ HAL_CFLAGS C compiler flags for HAL, overriding pkg-config ++ HAL_LIBS linker flags for HAL, overriding pkg-config + CHEESE_CFLAGS + C compiler flags for CHEESE, overriding pkg-config + CHEESE_LIBS linker flags for CHEESE, overriding pkg-config +@@ -14255,6 +15037,80 @@ $as_echo "#define HAVE_UDEV 1" >>confdef + UDEV_PKG=gudev-1.0 + fi + ++HAL_PKG= ++ ++pkg_failed=no ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for HAL" >&5 ++$as_echo_n "checking for HAL... " >&6; } ++ ++if test -n "$HAL_CFLAGS"; then ++ pkg_cv_HAL_CFLAGS="$HAL_CFLAGS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1 hal\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "dbus-1 hal") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_HAL_CFLAGS=`$PKG_CONFIG --cflags "dbus-1 hal" 2>/dev/null` ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++if test -n "$HAL_LIBS"; then ++ pkg_cv_HAL_LIBS="$HAL_LIBS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1 hal\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "dbus-1 hal") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_HAL_LIBS=`$PKG_CONFIG --libs "dbus-1 hal" 2>/dev/null` ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++ ++ ++ ++if test $pkg_failed = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then ++ _pkg_short_errors_supported=yes ++else ++ _pkg_short_errors_supported=no ++fi ++ if test $_pkg_short_errors_supported = yes; then ++ HAL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "dbus-1 hal" 2>&1` ++ else ++ HAL_PKG_ERRORS=`$PKG_CONFIG --print-errors "dbus-1 hal" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$HAL_PKG_ERRORS" >&5 ++ ++ HAL_PKG= ++elif test $pkg_failed = untried; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ HAL_PKG= ++else ++ HAL_CFLAGS=$pkg_cv_HAL_CFLAGS ++ HAL_LIBS=$pkg_cv_HAL_LIBS ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++$as_echo "#define HAVE_HAL 1" >>confdefs.h ++ ++ HAL_PKG=hal ++fi ++ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking operating system" >&5 + $as_echo_n "checking operating system... " >&6; } + case $host in +@@ -14269,6 +15125,17 @@ $as_echo "Linux" >&6; } + as_fn_error $? "libgudev is required under Linux and not installed" "$LINENO" 5 + fi + ;; ++ *-freebsd*) ++ ++$as_echo "#define OS_FREEBSD /**/" >>confdefs.h ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: FreeBSD" >&5 ++$as_echo "FreeBSD" >&6; } ++ if test x$HAL_PKG = "x" ; then ++ as_fn_error $? "hal is required under FreeBSD and not installed" "$LINENO" 5 ++ fi ++ ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported operating system" >&5 + $as_echo "unsupported operating system" >&6; } +@@ -14370,7 +15237,8 @@ if test -n "$CHEESE_CFLAGS"; then + clutter-1.0 >= \$CLUTTER_REQUIRED \\ + clutter-gst-1.0 >= \$CLUTTERGST_REQUIRED \\ + mx-1.0 \\ +- \$UDEV_PKG ++ \$UDEV_PKG \\ ++ \$HAL_PKG + \""; } >&5 + ($PKG_CONFIG --exists --print-errors "\ + glib-2.0 >= $GLIB_REQUIRED \ +@@ -14383,7 +15251,8 @@ if test -n "$CHEESE_CFLAGS"; then + clutter-1.0 >= $CLUTTER_REQUIRED \ + clutter-gst-1.0 >= $CLUTTERGST_REQUIRED \ + mx-1.0 \ +- $UDEV_PKG ++ $UDEV_PKG \ ++ $HAL_PKG + ") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 +@@ -14399,7 +15268,8 @@ if test -n "$CHEESE_CFLAGS"; then + clutter-1.0 >= $CLUTTER_REQUIRED \ + clutter-gst-1.0 >= $CLUTTERGST_REQUIRED \ + mx-1.0 \ +- $UDEV_PKG ++ $UDEV_PKG \ ++ $HAL_PKG + " 2>/dev/null` + else + pkg_failed=yes +@@ -14422,7 +15292,8 @@ if test -n "$CHEESE_LIBS"; then + clutter-1.0 >= \$CLUTTER_REQUIRED \\ + clutter-gst-1.0 >= \$CLUTTERGST_REQUIRED \\ + mx-1.0 \\ +- \$UDEV_PKG ++ \$UDEV_PKG \\ ++ \$HAL_PKG + \""; } >&5 + ($PKG_CONFIG --exists --print-errors "\ + glib-2.0 >= $GLIB_REQUIRED \ +@@ -14435,7 +15306,8 @@ if test -n "$CHEESE_LIBS"; then + clutter-1.0 >= $CLUTTER_REQUIRED \ + clutter-gst-1.0 >= $CLUTTERGST_REQUIRED \ + mx-1.0 \ +- $UDEV_PKG ++ $UDEV_PKG \ ++ $HAL_PKG + ") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 +@@ -14451,7 +15323,8 @@ if test -n "$CHEESE_LIBS"; then + clutter-1.0 >= $CLUTTER_REQUIRED \ + clutter-gst-1.0 >= $CLUTTERGST_REQUIRED \ + mx-1.0 \ +- $UDEV_PKG ++ $UDEV_PKG \ ++ $HAL_PKG + " 2>/dev/null` + else + pkg_failed=yes +@@ -14483,7 +15356,8 @@ fi + clutter-1.0 >= $CLUTTER_REQUIRED \ + clutter-gst-1.0 >= $CLUTTERGST_REQUIRED \ + mx-1.0 \ +- $UDEV_PKG ++ $UDEV_PKG \ ++ $HAL_PKG + " 2>&1` + else + CHEESE_PKG_ERRORS=`$PKG_CONFIG --print-errors "\ +@@ -14497,7 +15371,8 @@ fi + clutter-1.0 >= $CLUTTER_REQUIRED \ + clutter-gst-1.0 >= $CLUTTERGST_REQUIRED \ + mx-1.0 \ +- $UDEV_PKG ++ $UDEV_PKG \ ++ $HAL_PKG + " 2>&1` + fi + # Put the nasty error message in config.log where it belongs +@@ -14514,7 +15389,8 @@ fi + clutter-1.0 >= $CLUTTER_REQUIRED \ + clutter-gst-1.0 >= $CLUTTERGST_REQUIRED \ + mx-1.0 \ +- $UDEV_PKG ++ $UDEV_PKG \ ++ $HAL_PKG + ) were not met: + + $CHEESE_PKG_ERRORS +@@ -14570,6 +15446,7 @@ if test -n "$CHEESE_GTK_CFLAGS"; then + gee-1.0 >= \$GEE_REQUIRED \\ + libcanberra-gtk3 >= \$LIBCANBERRA_REQUIRED \\ + \$UDEV_PKG \\ ++ \$HAL_PKG \\ + gnome-video-effects + \""; } >&5 + ($PKG_CONFIG --exists --print-errors "\ +@@ -14582,6 +15459,7 @@ if test -n "$CHEESE_GTK_CFLAGS"; then + gee-1.0 >= $GEE_REQUIRED \ + libcanberra-gtk3 >= $LIBCANBERRA_REQUIRED \ + $UDEV_PKG \ ++ $HAL_PKG \ + gnome-video-effects + ") 2>&5 + ac_status=$? +@@ -14597,6 +15475,7 @@ if test -n "$CHEESE_GTK_CFLAGS"; then + gee-1.0 >= $GEE_REQUIRED \ + libcanberra-gtk3 >= $LIBCANBERRA_REQUIRED \ + $UDEV_PKG \ ++ $HAL_PKG \ + gnome-video-effects + " 2>/dev/null` + else +@@ -14619,6 +15498,7 @@ if test -n "$CHEESE_GTK_LIBS"; then + gee-1.0 >= \$GEE_REQUIRED \\ + libcanberra-gtk3 >= \$LIBCANBERRA_REQUIRED \\ + \$UDEV_PKG \\ ++ \$HAL_PKG \\ + gnome-video-effects + \""; } >&5 + ($PKG_CONFIG --exists --print-errors "\ +@@ -14631,6 +15511,7 @@ if test -n "$CHEESE_GTK_LIBS"; then + gee-1.0 >= $GEE_REQUIRED \ + libcanberra-gtk3 >= $LIBCANBERRA_REQUIRED \ + $UDEV_PKG \ ++ $HAL_PKG \ + gnome-video-effects + ") 2>&5 + ac_status=$? +@@ -14646,6 +15527,7 @@ if test -n "$CHEESE_GTK_LIBS"; then + gee-1.0 >= $GEE_REQUIRED \ + libcanberra-gtk3 >= $LIBCANBERRA_REQUIRED \ + $UDEV_PKG \ ++ $HAL_PKG \ + gnome-video-effects + " 2>/dev/null` + else +@@ -14677,6 +15559,7 @@ fi + gee-1.0 >= $GEE_REQUIRED \ + libcanberra-gtk3 >= $LIBCANBERRA_REQUIRED \ + $UDEV_PKG \ ++ $HAL_PKG \ + gnome-video-effects + " 2>&1` + else +@@ -14690,6 +15573,7 @@ fi + gee-1.0 >= $GEE_REQUIRED \ + libcanberra-gtk3 >= $LIBCANBERRA_REQUIRED \ + $UDEV_PKG \ ++ $HAL_PKG \ + gnome-video-effects + " 2>&1` + fi +@@ -14706,6 +15590,7 @@ fi + gee-1.0 >= $GEE_REQUIRED \ + libcanberra-gtk3 >= $LIBCANBERRA_REQUIRED \ + $UDEV_PKG \ ++ $HAL_PKG \ + gnome-video-effects + ) were not met: + diff --git a/multimedia/cheese3/files/patch-libcheese_cheese-camera-device-monitor.c b/multimedia/cheese3/files/patch-libcheese_cheese-camera-device-monitor.c new file mode 100644 index 000000000..f208eae88 --- /dev/null +++ b/multimedia/cheese3/files/patch-libcheese_cheese-camera-device-monitor.c @@ -0,0 +1,395 @@ +--- libcheese/cheese-camera-device-monitor.c.orig 2011-03-07 21:08:19.000000000 +0100 ++++ libcheese/cheese-camera-device-monitor.c 2011-04-13 11:07:36.000000000 +0200 +@@ -30,16 +30,11 @@ + #define G_UDEV_API_IS_SUBJECT_TO_CHANGE 1 + #include <gudev/gudev.h> + #else +- #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> +- #endif /* USE_SYS_VIDEOIO_H */ ++ #include <glib/gstdio.h> ++ #include <libhal.h> ++ #include <dbus/dbus.h> ++ #include <dbus/dbus-glib-lowlevel.h> ++ #include <unistd.h> + #endif + + #include "cheese-camera-device-monitor.h" +@@ -82,6 +77,8 @@ typedef struct + #ifdef HAVE_UDEV + GUdevClient *client; + #else ++ DBusConnection *connection; ++ LibHalContext *hal_ctx; + guint filler; + #endif /* HAVE_UDEV */ + } CheeseCameraDeviceMonitorPrivate; +@@ -243,93 +240,240 @@ cheese_camera_device_monitor_coldplug (C + if (i == 0) GST_WARNING ("No device found"); + } + +-#else /* HAVE_UDEV */ +-void +-cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor) ++static void ++cheese_camera_device_monitor_finalize (GObject *object) + { +- #if 0 ++ CheeseCameraDeviceMonitor *monitor; ++ ++ monitor = CHEESE_CAMERA_DEVICE_MONITOR (object); + CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); +- struct v4l2_capability v2cap; +- struct video_capability v1cap; +- int fd, ok; + +- if ((fd = open (device_path, O_RDONLY | O_NONBLOCK)) < 0) ++ if (priv->client != NULL) + { +- g_warning ("Failed to open %s: %s", device_path, strerror (errno)); ++ g_object_unref (priv->client); ++ priv->client = NULL; ++ } ++ G_OBJECT_CLASS (cheese_camera_device_monitor_parent_class)->finalize (object); ++} ++ ++static void ++cheese_camera_device_monitor_class_init (CheeseCameraDeviceMonitorClass *klass) ++{ ++ GObjectClass *object_class = G_OBJECT_CLASS (klass); ++ ++ if (cheese_device_monitor_cat == NULL) ++ GST_DEBUG_CATEGORY_INIT (cheese_device_monitor_cat, ++ "cheese-device-monitor", ++ 0, "Cheese Camera Device Monitor"); ++ ++ object_class->finalize = cheese_camera_device_monitor_finalize; ++ ++ /** ++ * CheeseCameraDeviceMonitor::added: ++ * @device: A private object representing the newly added camera. ++ * @id: Device unique identifier. ++ * @device: Device file name (e.g. /dev/video2). ++ * @product_name: Device product name (human readable, intended to be displayed in a UI). ++ * @api_version: Supported video4linux API: 1 for v4l, 2 for v4l2. ++ * ++ * The ::added signal is emitted when a camera is added, or on start-up ++ * after #cheese_camera_device_monitor_colplug is called. ++ **/ ++ monitor_signals[ADDED] = g_signal_new ("added", G_OBJECT_CLASS_TYPE (klass), ++ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, ++ G_STRUCT_OFFSET (CheeseCameraDeviceMonitorClass, added), ++ NULL, NULL, ++ _cheese_marshal_VOID__STRING_STRING_STRING_INT, ++ G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT); ++ ++ /** ++ * CheeseCameraDeviceMonitor::removed: ++ * @device: A private object representing the newly added camera ++ * @id: Device unique identifier. ++ * ++ * The ::removed signal is emitted when a camera is un-plugged, or ++ * disabled on the system. ++ **/ ++ monitor_signals[REMOVED] = g_signal_new ("removed", G_OBJECT_CLASS_TYPE (klass), ++ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, ++ G_STRUCT_OFFSET (CheeseCameraDeviceMonitorClass, removed), ++ NULL, NULL, ++ g_cclosure_marshal_VOID__STRING, ++ G_TYPE_NONE, 1, G_TYPE_STRING); ++ ++ g_type_class_add_private (klass, sizeof (CheeseCameraDeviceMonitorPrivate)); ++} ++ ++static void ++cheese_camera_device_monitor_init (CheeseCameraDeviceMonitor *monitor) ++{ ++ CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); ++ const gchar *const subsystems[] = {"video4linux", NULL}; ++ ++ priv->client = g_udev_client_new (subsystems); ++ g_signal_connect (G_OBJECT (priv->client), "uevent", ++ G_CALLBACK (cheese_camera_device_monitor_uevent_cb), monitor); ++} ++ ++#else /* HAVE_UDEV */ ++ ++static void ++cheese_camera_device_monitor_handle_udi (CheeseCameraDeviceMonitor *monitor, ++ const char *udi) ++ { ++ CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); ++ char *device_file; ++ char *product_name; ++ char *capstr; ++ gint v4l_version = 0; ++ DBusError error; ++ ++ GST_INFO ("Checking hal device '%s'", udi); ++ ++ dbus_error_init (&error); ++ ++ product_name = libhal_device_get_property_string (priv->hal_ctx, udi, "info.product", &error); ++ if (dbus_error_is_set (&error)) ++ { ++ GST_WARNING ("error getting product name: %s: %s", error.name, error.message); ++ dbus_error_free (&error); + return; + } +- ok = ioctl (fd, VIDIOC_QUERYCAP, &v2cap); +- if (ok < 0) ++ ++ device_file = libhal_device_get_property_string (priv->hal_ctx, udi, "video4linux.device", &error); ++ if (dbus_error_is_set (&error)) + { +- ok = ioctl (fd, VIDIOCGCAP, &v1cap); +- if (ok < 0) +- { +- g_warning ("Error while probing v4l capabilities for %s: %s", +- device_path, strerror (errno)); +- close (fd); +- return; +- } +- g_print ("Detected v4l device: %s\n", v1cap.name); +- g_print ("Device type: %d\n", v1cap.type); +- gstreamer_src = "v4lsrc"; +- product_name = v1cap.name; ++ GST_WARNING ("error getting V4L device for %s: %s: %s", udi, error.name, error.message); ++ dbus_error_free (&error); ++ libhal_free_string (product_name); + } +- else ++ ++ if (g_access (device_file, (R_OK | W_OK)) == -1) + { +- 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); +- if (!(cap & V4L2_CAP_VIDEO_CAPTURE)) +- { +- g_print ("Device %s seems to not have the capture capability, (radio tuner?)\n" +- "Removing it from device list.\n", device_path); +- close (fd); +- return; +- } +- gstreamer_src = "v4l2src"; +- product_name = (char *) v2cap.card; ++ GST_WARNING ("Device %s does not have proper permissions. Permissions must be 0666", device_file); ++ libhal_free_string (product_name); ++ libhal_free_string (device_file); ++ return; + } +- close (fd); + +- GList *devices, *l; ++ capstr = libhal_device_get_property_string (priv->hal_ctx, udi, "video4linux.version", &error); ++ if (dbus_error_is_set (&error)) ++ { ++ GST_WARNING ("error getting V4L version for %s: %s: %s", udi, error.name, error.message); ++ dbus_error_free (&error); ++ libhal_free_string (product_name); ++ libhal_free_string (device_file); ++ return; ++ } + +- g_print ("Probing devices with udev...\n"); ++ v4l_version = atoi (capstr); ++ libhal_free_string (capstr); + +- if (priv->client == NULL) +- return; ++ g_signal_emit (monitor, monitor_signals[ADDED], 0, ++ udi, ++ device_file, ++ product_name, ++ v4l_version); ++} + +- devices = g_udev_client_query_by_subsystem (priv->client, "video4linux"); ++static void ++cheese_camera_device_monitor_removed (LibHalContext *ctx, ++ const char *udi) ++ { ++ CheeseCameraDeviceMonitor *monitor; ++ void *data; + +- /* Initialize camera structures */ +- for (l = devices; l != NULL; l = l->next) ++ data = libhal_ctx_get_user_data (ctx); ++ g_assert (data); ++ ++ monitor = CHEESE_CAMERA_DEVICE_MONITOR (data); ++ ++ g_signal_emit (monitor, monitor_signals[REMOVED], 0, udi); ++} ++ ++void ++cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor) ++{ ++ CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); ++ gint i, num_udis = 0; ++ gchar **udis; ++ DBusError error; ++ ++ if (priv->hal_ctx == NULL) ++ return; ++ ++ GST_INFO ("Probing devices with HAL..."); ++ ++ dbus_error_init (&error); ++ ++ udis = libhal_find_device_by_capability (priv->hal_ctx, "video4linux", &num_udis, &error); ++ ++ if (dbus_error_is_set (&error)) + { +- cheese_camera_device_monitor_added (monitor, l->data); +- g_object_unref (l->data); ++ GST_WARNING ("libhal_find_device_by_capability: %s: %s", error.name, error.message); ++ dbus_error_free (&error); ++ return; + } +- g_list_free (devices); +- #endif ++ ++ /* Initialize camera structures */ ++ for (i = 0; i < num_udis; i++) ++ cheese_camera_device_monitor_handle_udi (monitor, udis[i]); ++ libhal_free_string_array (udis); ++ ++ if (i == 0) ++ GST_WARNING ("No device found"); + } + +-#endif /* HAVE_UDEV */ ++static void ++cheese_camera_device_monitor_added (LibHalContext *ctx, const char *udi) ++{ ++ CheeseCameraDeviceMonitor *monitor; ++ gchar **caps; ++ guint i; ++ void *data; ++ ++ data = libhal_ctx_get_user_data (ctx); ++ g_assert (data); ++ ++ monitor = CHEESE_CAMERA_DEVICE_MONITOR (data); ++ ++ caps = libhal_device_get_property_strlist (ctx, udi, "info.capabilities", NULL); ++ if (caps == NULL) ++ return; ++ ++ for (i = 0; caps[i] != NULL; i++) ++ { ++ if (g_strcmp0 (caps[i], "video4linux") == 0) ++ { ++ cheese_camera_device_monitor_handle_udi (monitor, udi); ++ break; ++ } ++ } ++ libhal_free_string_array (caps); ++} + + static void + cheese_camera_device_monitor_finalize (GObject *object) + { +-#ifdef HAVE_UDEV + CheeseCameraDeviceMonitor *monitor; + + monitor = CHEESE_CAMERA_DEVICE_MONITOR (object); + CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); + +- if (priv->client != NULL) ++ if (priv->connection != NULL) + { +- g_object_unref (priv->client); +- priv->client = NULL; ++ dbus_connection_unref (priv->connection); ++ priv->connection = NULL; + } +-#endif /* HAVE_UDEV */ ++ ++ if (priv->hal_ctx != NULL) ++ { ++ libhal_ctx_set_device_added (priv->hal_ctx, NULL); ++ libhal_ctx_set_device_removed (priv->hal_ctx, NULL); ++ libhal_ctx_free (priv->hal_ctx); ++ priv->hal_ctx = NULL; ++ } ++ + G_OBJECT_CLASS (cheese_camera_device_monitor_parent_class)->finalize (object); + } + +@@ -384,16 +528,56 @@ cheese_camera_device_monitor_class_init + static void + cheese_camera_device_monitor_init (CheeseCameraDeviceMonitor *monitor) + { +-#ifdef HAVE_UDEV +- CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); +- const gchar *const subsystems[] = {"video4linux", NULL}; ++ CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); ++ LibHalContext *hal_ctx; ++ DBusError error; + +- priv->client = g_udev_client_new (subsystems); +- g_signal_connect (G_OBJECT (priv->client), "uevent", +- G_CALLBACK (cheese_camera_device_monitor_uevent_cb), monitor); +-#endif /* HAVE_UDEV */ ++ dbus_error_init (&error); ++ ++ priv->connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error); ++ ++ dbus_connection_set_exit_on_disconnect (priv->connection, FALSE); ++ ++ hal_ctx = libhal_ctx_new (); ++ if (hal_ctx == NULL) ++ { ++ GST_WARNING ("Could not create libhal context"); ++ dbus_error_free (&error); ++ return; ++ } ++ ++ if (!libhal_ctx_set_dbus_connection (hal_ctx, priv->connection)) ++ { ++ GST_WARNING ("libhal_ctx_set_dbus_connection: %s: %s", error.name, error.message); ++ dbus_error_free (&error); ++ return; ++ } ++ if (!libhal_ctx_init (hal_ctx, &error)) ++ { ++ if (dbus_error_is_set (&error)) ++ { ++ GST_WARNING ("libhal_ctx_init: %s: %s", error.name, error.message); ++ dbus_error_free (&error); ++ } ++ GST_WARNING ("Could not initialise connection to hald.\n" ++ "Normally this means the HAL daemon (hald) is not running or not ready"); ++ return; ++ } ++ ++ dbus_connection_setup_with_g_main (priv->connection, NULL); ++ ++ if (!libhal_ctx_set_user_data (hal_ctx, monitor)) ++ GST_WARNING ("Failed to set user data on HAL context"); ++ if (!libhal_ctx_set_device_added (hal_ctx, cheese_camera_device_monitor_added)) ++ GST_WARNING ("Failed to connect to device added signal from HAL"); ++ if (!libhal_ctx_set_device_removed (hal_ctx, cheese_camera_device_monitor_removed)) ++ GST_WARNING ("Failed to connect to device removed signal from HAL"); ++ ++ priv->hal_ctx = hal_ctx; + } + ++#endif /* !HAVE_UDEV */ ++ + /** + * cheese_camera_device_monitor_new: + * |