| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | $NetBSD: patch-ab,v 1.3 2008/11/28 14:29:31 jmcneill Exp $ | | 1 | $NetBSD: patch-ab,v 1.4 2008/12/02 11:47:09 wiz Exp $ |
2 | | | 2 | |
3 | --- src/cheese-webcam.c.orig 2008-10-20 12:01:47.000000000 -0400 | | 3 | --- src/cheese-webcam.c.orig 2008-11-24 23:03:19.000000000 +0000 |
4 | +++ src/cheese-webcam.c | | 4 | +++ src/cheese-webcam.c |
5 | @@ -32,13 +32,24 @@ | | 5 | @@ -32,13 +32,24 @@ |
6 | #include <gst/gst.h> | | 6 | #include <gst/gst.h> |
7 | #include <gdk-pixbuf/gdk-pixbuf.h> | | 7 | #include <gdk-pixbuf/gdk-pixbuf.h> |
8 | #include <X11/Xlib.h> | | 8 | #include <X11/Xlib.h> |
9 | + | | 9 | + |
10 | +#if HAVE_HAL | | 10 | +#if HAVE_HAL |
11 | #include <libhal.h> | | 11 | #include <libhal.h> |
12 | +#endif | | 12 | +#endif |
13 | | | 13 | |
14 | -/* for ioctl query */ | | 14 | -/* for ioctl query */ |
15 | +#include <sys/ioctl.h> | | 15 | +#include <sys/ioctl.h> |
16 | #include <fcntl.h> | | 16 | #include <fcntl.h> |
| @@ -19,75 +19,67 @@ $NetBSD: patch-ab,v 1.3 2008/11/28 14:29 | | | @@ -19,75 +19,67 @@ $NetBSD: patch-ab,v 1.3 2008/11/28 14:29 |
19 | + | | 19 | + |
20 | +#if defined(__NetBSD__) || defined(__OpenBSD__) | | 20 | +#if defined(__NetBSD__) || defined(__OpenBSD__) |
21 | +#include <sys/types.h> | | 21 | +#include <sys/types.h> |
22 | +#include <sys/videoio.h> | | 22 | +#include <sys/videoio.h> |
23 | +#elif defined(__sun) | | 23 | +#elif defined(__sun) |
24 | +#include <sys/types.h> | | 24 | +#include <sys/types.h> |
25 | +#include <sys/videodev2.h> | | 25 | +#include <sys/videodev2.h> |
26 | +#elif defined(__linux__) | | 26 | +#elif defined(__linux__) |
27 | #include <linux/videodev.h> | | 27 | #include <linux/videodev.h> |
28 | +#endif | | 28 | +#endif |
29 | | | 29 | |
30 | #include "cheese-webcam.h" | | 30 | #include "cheese-webcam.h" |
31 | #include "cheese-flash.h" | | 31 | #include "cheese-flash.h" |
32 | @@ -234,7 +245,6 @@ cheese_webcam_bus_message_cb (GstBus *bu | | 32 | @@ -244,6 +255,7 @@ cheese_webcam_bus_message_cb (GstBus *bu |
33 | g_print ("Received EOS message\n"); | | | |
34 | | | | |
35 | g_source_remove (priv->eos_timeout_id); | | | |
36 | - | | | |
37 | g_signal_emit (webcam, webcam_signals[VIDEO_SAVED], 0); | | | |
38 | | | | |
39 | cheese_webcam_change_sink (webcam, priv->video_display_bin, | | | |
40 | @@ -244,6 +254,7 @@ cheese_webcam_bus_message_cb (GstBus *bu | | | |
41 | } | | 33 | } |
42 | } | | 34 | } |
43 | | | 35 | |
44 | +#if HAVE_HAL | | 36 | +#if HAVE_HAL |
45 | static void | | 37 | static void |
46 | cheese_webcam_get_video_devices_from_hal (CheeseWebcam *webcam) | | 38 | cheese_webcam_get_video_devices_from_hal (CheeseWebcam *webcam) |
47 | { | | 39 | { |
48 | @@ -302,7 +313,9 @@ cheese_webcam_get_video_devices_from_hal | | 40 | @@ -306,7 +318,9 @@ cheese_webcam_get_video_devices_from_hal |
49 | char *device; | | 41 | char *subsystem = NULL; |
50 | char *gstreamer_src, *product_name; | | 42 | char *gstreamer_src, *product_name; |
51 | struct v4l2_capability v2cap; | | 43 | struct v4l2_capability v2cap; |
52 | +#ifdef VIDIOCGCAP | | 44 | +#ifdef VIDIOCGCAP |
53 | struct video_capability v1cap; | | 45 | struct video_capability v1cap; |
54 | +#endif | | 46 | +#endif |
55 | | | 47 | gint vendor_id = 0; |
56 | device = libhal_device_get_property_string (hal_ctx, udis[i], "video4linux.device", &error); | | 48 | gint product_id = 0; |
57 | if (dbus_error_is_set (&error)) | | 49 | gchar *property_name = NULL; |
58 | @@ -330,6 +343,7 @@ cheese_webcam_get_video_devices_from_hal | | 50 | @@ -368,6 +382,7 @@ cheese_webcam_get_video_devices_from_hal |
59 | ok = ioctl (fd, VIDIOC_QUERYCAP, &v2cap); | | 51 | ok = ioctl (fd, VIDIOC_QUERYCAP, &v2cap); |
60 | if (ok < 0) | | 52 | if (ok < 0) |
61 | { | | 53 | { |
62 | +#ifdef VIDIOCGCAP | | 54 | +#ifdef VIDIOCGCAP |
63 | ok = ioctl (fd, VIDIOCGCAP, &v1cap); | | 55 | ok = ioctl (fd, VIDIOCGCAP, &v1cap); |
64 | if (ok < 0) | | 56 | if (ok < 0) |
65 | { | | 57 | { |
66 | @@ -343,6 +357,13 @@ cheese_webcam_get_video_devices_from_hal | | 58 | @@ -381,6 +396,13 @@ cheese_webcam_get_video_devices_from_hal |
67 | g_print ("Device type: %d\n", v1cap.type); | | 59 | g_print ("Device type: %d\n", v1cap.type); |
68 | gstreamer_src = "v4lsrc"; | | 60 | gstreamer_src = "v4lsrc"; |
69 | product_name = v1cap.name; | | 61 | product_name = v1cap.name; |
70 | +#else | | 62 | +#else |
71 | + g_error ("Error while probing v4l2 capabilities for %s: %s\n", | | 63 | + g_error ("Error while probing v4l2 capabilities for %s: %s\n", |
72 | + device, strerror (errno)); | | 64 | + device, strerror (errno)); |
73 | + libhal_free_string (device); | | 65 | + libhal_free_string (device); |
74 | + close (fd); | | 66 | + close (fd); |
75 | + continue; | | 67 | + continue; |
76 | +#endif | | 68 | +#endif |
77 | } | | 69 | } |
78 | else | | 70 | else |
79 | { | | 71 | { |
80 | @@ -394,6 +415,55 @@ fallback: | | 72 | @@ -434,6 +456,55 @@ fallback: |
81 | priv->webcam_devices[0].hal_udi = g_strdup ("cheese_fake_videodevice"); | | 73 | priv->webcam_devices[0].hal_udi = g_strdup ("cheese_fake_videodevice"); |
82 | } | | 74 | } |
83 | } | | 75 | } |
84 | +#else | | 76 | +#else |
85 | +static void | | 77 | +static void |
86 | +cheese_webcam_get_video_devices_from_probe (CheeseWebcam *webcam) | | 78 | +cheese_webcam_get_video_devices_from_probe (CheeseWebcam *webcam) |
87 | +{ | | 79 | +{ |
88 | + CheeseWebcamPrivate* priv = CHEESE_WEBCAM_GET_PRIVATE (webcam); | | 80 | + CheeseWebcamPrivate* priv = CHEESE_WEBCAM_GET_PRIVATE (webcam); |
89 | + struct v4l2_capability caps; | | 81 | + struct v4l2_capability caps; |
90 | + gchar videodev[] = "/dev/video?"; | | 82 | + gchar videodev[] = "/dev/video?"; |
91 | + guint16 cammask = 0; | | 83 | + guint16 cammask = 0; |
92 | + int i, ncams = 0, fd, ret, cur = 0; | | 84 | + int i, ncams = 0, fd, ret, cur = 0; |
93 | + | | 85 | + |
| @@ -123,25 +115,25 @@ $NetBSD: patch-ab,v 1.3 2008/11/28 14:29 | | | @@ -123,25 +115,25 @@ $NetBSD: patch-ab,v 1.3 2008/11/28 14:29 |
123 | + if (cammask & (1 << i)) | | 115 | + if (cammask & (1 << i)) |
124 | + { | | 116 | + { |
125 | + videodev[strlen(videodev) - 1] = '0' + i; | | 117 | + videodev[strlen(videodev) - 1] = '0' + i; |
126 | + priv->webcam_devices[i].video_device = g_strdup (videodev); | | 118 | + priv->webcam_devices[i].video_device = g_strdup (videodev); |
127 | + ++cur; | | 119 | + ++cur; |
128 | + } | | 120 | + } |
129 | + } | | 121 | + } |
130 | +} | | 122 | +} |
131 | +#endif /* !HAVE_HAL */ | | 123 | +#endif /* !HAVE_HAL */ |
132 | + | | 124 | + |
133 | | | 125 | |
134 | static void | | 126 | static void |
135 | cheese_webcam_get_supported_framerates (CheeseVideoFormat *video_format, GstStructure *structure) | | 127 | cheese_webcam_get_supported_framerates (CheeseVideoFormat *video_format, GstStructure *structure) |
136 | @@ -698,7 +768,11 @@ cheese_webcam_detect_webcam_devices (Che | | 128 | @@ -739,7 +810,11 @@ cheese_webcam_detect_webcam_devices (Che |
137 | | | 129 | |
138 | int i; | | 130 | int i; |
139 | | | 131 | |
140 | +#if HAVE_HAL | | 132 | +#if HAVE_HAL |
141 | cheese_webcam_get_video_devices_from_hal (webcam); | | 133 | cheese_webcam_get_video_devices_from_hal (webcam); |
142 | +#else | | 134 | +#else |
143 | + cheese_webcam_get_video_devices_from_probe (webcam); | | 135 | + cheese_webcam_get_video_devices_from_probe (webcam); |
144 | +#endif | | 136 | +#endif |
| | | 137 | |
| | | 138 | g_print ("Probing supported video formats...\n"); |
145 | for (i = 0; i < priv->num_webcam_devices; i++) | | 139 | for (i = 0; i < priv->num_webcam_devices; i++) |
146 | { | | | |
147 | cheese_webcam_get_webcam_device_data (webcam, &(priv->webcam_devices[i])); | | | |