Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 315587 Details for
Bug 460956
Patch(es): fix cheese on systems with more then1 v4l device
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
cheese-2.23.90-dont-use-non-capture-devices.patch
cheese-2.23.90-dont-use-non-capture-devices.patch (text/plain), 8.14 KB, created by
Hans de Goede
on 2008-09-02 20:14:03 UTC
(
hide
)
Description:
cheese-2.23.90-dont-use-non-capture-devices.patch
Filename:
MIME Type:
Creator:
Hans de Goede
Created:
2008-09-02 20:14:03 UTC
Size:
8.14 KB
patch
obsolete
>diff -up cheese-2.23.90/src/cheese-webcam.c.ioctl cheese-2.23.90/src/cheese-webcam.c >--- cheese-2.23.90/src/cheese-webcam.c.ioctl 2008-08-18 20:32:53.000000000 +0200 >+++ cheese-2.23.90/src/cheese-webcam.c 2008-09-02 08:09:11.000000000 +0200 >@@ -33,6 +33,11 @@ > #include <gdk-pixbuf/gdk-pixbuf.h> > #include <X11/Xlib.h> > #include <libhal.h> >+/* for ioctl query */ >+#include <fcntl.h> >+#include <unistd.h> >+#include <sys/ioctl.h> >+#include <linux/videodev.h> > > #include "cheese-webcam.h" > #include "cheese-flash.h" >@@ -234,16 +239,13 @@ static void > cheese_webcam_get_video_devices_from_hal (CheeseWebcam *webcam) > { > CheeseWebcamPrivate* priv = CHEESE_WEBCAM_GET_PRIVATE (webcam); >- int i; >- int num_udis; >- int num_devices; /* Devices we actually create formats for; can either be the >- * number of webcams detected, or 1 if none were. The one >- * refers to a fake device so that resolution changing still >- * works even if the computer doesn't have a webcam. */ >+ int i, fd, ok; >+ int num_udis = 0; > char **udis; > DBusError error; > LibHalContext *hal_ctx; > >+ priv->num_webcam_devices = 0; > > dbus_error_init (&error); > hal_ctx = libhal_ctx_new (); >@@ -251,14 +253,14 @@ cheese_webcam_get_video_devices_from_hal > { > g_error ("error: libhal_ctx_new"); > dbus_error_free (&error); >- return; >+ goto fallback; > } > > if (!libhal_ctx_set_dbus_connection (hal_ctx, dbus_bus_get (DBUS_BUS_SYSTEM, &error))) > { > g_error ("error: libhal_ctx_set_dbus_connection: %s: %s", error.name, error.message); > dbus_error_free (&error); >- return; >+ goto fallback; > } > > if (!libhal_ctx_init (hal_ctx, &error)) >@@ -270,53 +272,106 @@ cheese_webcam_get_video_devices_from_hal > } > g_error ("Could not initialise connection to hald.\n" > "Normally this means the HAL daemon (hald) is not running or not ready"); >- return; >+ goto fallback; > } > > udis = libhal_find_device_by_capability (hal_ctx, "video4linux", &num_udis, &error); > > if (dbus_error_is_set (&error)) > { >- g_error ("error: %s: %s\n", error.name, error.message); >+ g_error ("error: libhal_find_device_by_capability: %s: %s\n", error.name, error.message); > dbus_error_free (&error); >- return; >+ goto fallback; > } > > /* Initialize webcam structures */ >- >- if (num_udis > 0) >- priv->num_webcam_devices = num_devices = num_udis; >- else >- { >- num_devices = 1; >- priv->num_webcam_devices = num_udis; /* We don't have any real cameras-- >- * this is important when we create >- * the pipeline. */ >- } >- >- priv->webcam_devices = g_new0 (CheeseWebcamDevice, num_devices); >- for (i = 0; i < num_devices; i++) >- { >- priv->webcam_devices[i].num_video_formats = 0; >- priv->webcam_devices[i].video_formats = g_array_new (FALSE, FALSE, sizeof (CheeseVideoFormat)); >- priv->webcam_devices[i].hal_udi = g_strdup (udis[i]); >- } >+ priv->webcam_devices = g_new0 (CheeseWebcamDevice, num_udis); > >- for (i = 0; i < priv->num_webcam_devices; i++) >+ for (i = 0; i < num_udis; i++) > { > char *device; >- >+ char *gstreamer_src, *product_name; >+ struct v4l2_capability v2cap; >+ struct video_capability v1cap; >+ > device = libhal_device_get_property_string (hal_ctx, udis[i], "video4linux.device", &error); > if (dbus_error_is_set (&error)) > { >- g_error ("error: %s: %s\n", error.name, error.message); >+ g_error ("error geting device for %s: %s: %s\n", udis[i], error.name, error.message); > dbus_error_free (&error); >- return; >+ continue; >+ } >+ >+ /* vbi devices support capture capability too, but cannot be used, >+ so detect them by device name */ >+ if (strstr(device, "vbi")) { >+ g_print ("Skipping vbi device: %s\n", device); >+ libhal_free_string (device); >+ continue; > } >- priv->webcam_devices[i].video_device = g_strdup (device); >+ >+ if ((fd = open(device, O_RDONLY | O_NONBLOCK)) < 0) { >+ g_error ("Failed to open %s: %s\n", device, strerror(errno)); >+ libhal_free_string (device); >+ continue; >+ } >+ ok = ioctl (fd, VIDIOC_QUERYCAP, &v2cap); >+ if (ok < 0) { >+ ok = ioctl (fd, VIDIOCGCAP, &v1cap); >+ if (ok < 0) { >+ g_error ("Error while probing v4l capabilities for %s: %s\n", >+ device, strerror (errno)); >+ libhal_free_string (device); >+ close(fd); >+ continue; >+ } >+ g_print ("Detected v4l device: %s\n", v1cap.name); >+ g_print ("Device type: %d\n", v1cap.type); >+ gstreamer_src = "v4lsrc"; >+ product_name = v1cap.name; >+ } >+ else { >+ 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); >+ 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); >+ libhal_free_string (device); >+ close(fd); >+ continue; >+ } >+ gstreamer_src = "v4l2src"; >+ product_name = (char *)v2cap.card; >+ } >+ >+ priv->webcam_devices[priv->num_webcam_devices].hal_udi = g_strdup (udis[i]); >+ priv->webcam_devices[priv->num_webcam_devices].video_device = g_strdup (device); >+ priv->webcam_devices[priv->num_webcam_devices].gstreamer_src = g_strdup (gstreamer_src); >+ priv->webcam_devices[priv->num_webcam_devices].product_name = g_strdup (product_name); >+ priv->webcam_devices[priv->num_webcam_devices].num_video_formats = 0; >+ priv->webcam_devices[priv->num_webcam_devices].video_formats = >+ g_array_new (FALSE, FALSE, sizeof (CheeseVideoFormat)); >+ priv->num_webcam_devices++; >+ >+ close(fd); > libhal_free_string (device); > } > libhal_free_string_array (udis); >+ >+ if (priv->num_webcam_devices == 0) >+ { >+ /* Create a fake device so that resolution changing stil works even if the >+ computer doesn't have a webcam. */ >+fallback: >+ if (num_udis == 0) >+ priv->webcam_devices = g_new0 (CheeseWebcamDevice, 1); >+ priv->webcam_devices[0].num_video_formats = 0; >+ priv->webcam_devices[0].video_formats = g_array_new (FALSE, FALSE, sizeof (CheeseVideoFormat)); >+ priv->webcam_devices[0].hal_udi = g_strdup ("cheese_fake_videodevice"); >+ } > } > > static void >@@ -477,20 +532,11 @@ cheese_webcam_get_webcam_device_data (Ch > GstStateChangeReturn ret; > GstMessage *msg; > GstBus *bus; >- gboolean pipeline_works = FALSE; > int i, j; > >- static const char* GSTREAMER_VIDEO_SOURCES[] = >- { >- "v4l2src", >- "v4lsrc" >- }; >- >- i = 0; >- while (!pipeline_works && (i < G_N_ELEMENTS (GSTREAMER_VIDEO_SOURCES))) > { > pipeline_desc = g_strdup_printf ("%s name=source device=%s ! fakesink", >- GSTREAMER_VIDEO_SOURCES[i], >+ webcam_device->gstreamer_src, > webcam_device->video_device); > err = NULL; > pipeline = gst_parse_launch (pipeline_desc, &err); >@@ -512,10 +558,8 @@ cheese_webcam_get_webcam_device_data (Ch > char *name; > GstCaps *caps; > >- pipeline_works = TRUE; > gst_element_set_state (pipeline, GST_STATE_PAUSED); > >- webcam_device->gstreamer_src = g_strdup (GSTREAMER_VIDEO_SOURCES[i]); > src = gst_bin_get_by_name (GST_BIN (pipeline), "source"); > > g_object_get (G_OBJECT (src), "device-name", &name, NULL); >@@ -523,7 +567,6 @@ cheese_webcam_get_webcam_device_data (Ch > name = "Unknown"; > > g_print ("Detected webcam: %s\n", name); >- webcam_device->product_name = g_strdup (name); > pad = gst_element_get_pad (src, "src"); > caps = gst_pad_get_caps (pad); > gst_object_unref (pad); >@@ -537,8 +580,8 @@ cheese_webcam_get_webcam_device_data (Ch > g_error_free (err); > > g_free (pipeline_desc); >- i++; > } >+ > g_print ("device: %s\n", webcam_device->video_device); > for (i = 0; i < webcam_device->num_video_formats; i++) > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 460956
: 315587 |
315588
|
315589
|
315590
|
315591
|
315592