[cheese] Support a default CheeseCamera device
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Support a default CheeseCamera device
- Date: Fri, 4 Sep 2015 08:26:48 +0000 (UTC)
commit 4b28da6cc6809986e44ab9487ba494326e43a779
Author: David King <amigadave amigadave com>
Date: Thu Sep 3 23:20:17 2015 +0100
Support a default CheeseCamera device
Accept a name, stash it inside the camera and then search through all
the devices present on the system when setting up the camera. If a match
is found, use it, otherwise continue to setup the first device.
libcheese/cheese-camera.c | 47 +++++++++++++++++++++++++++-----------------
1 files changed, 29 insertions(+), 18 deletions(-)
---
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index 5873567..135844b 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -95,6 +95,8 @@ struct _CheeseCameraPrivate
guint eos_timeout_id;
+ gchar *initial_name;
+
CheeseCameraDeviceMonitor *monitor;
};
@@ -1275,6 +1277,7 @@ cheese_camera_finalize (GObject *object)
/* Free CheeseCameraDevice array */
g_ptr_array_free (priv->camera_devices, TRUE);
+ g_free (priv->initial_name);
g_clear_object (&priv->monitor);
G_OBJECT_CLASS (cheese_camera_parent_class)->finalize (object);
@@ -1486,28 +1489,20 @@ CheeseCamera *
cheese_camera_new (ClutterActor *video_texture, const gchar *name,
gint x_resolution, gint y_resolution)
{
- CheeseCamera *camera;
- CheeseVideoFormat format = { x_resolution, y_resolution };
+ CheeseCamera *camera;
+ CheeseVideoFormat format = { x_resolution, y_resolution };
- if (name)
- {
- /* FIXME: Implement device creation from a name. */
- g_critical ("%s",
- "Creating a camera from a device name is not implemented!");
- }
-#if 0
- camera = g_object_new (CHEESE_TYPE_CAMERA, "video-texture", video_texture,
- "device", device,
- "format", &format, NULL);
- }
- else
-#endif
- {
camera = g_object_new (CHEESE_TYPE_CAMERA, "video-texture", video_texture,
"format", &format, NULL);
- }
- return camera;
+ if (name)
+ {
+ CheeseCameraPrivate *priv = cheese_camera_get_instance_private (camera);
+
+ priv->initial_name = g_strdup (name);
+ }
+
+ return camera;
}
/**
@@ -1565,6 +1560,22 @@ cheese_camera_setup (CheeseCamera *camera, CheeseCameraDevice *device, GError **
{
cheese_camera_set_device (camera, device);
}
+ else
+ {
+ guint i;
+
+ for (i = 0; i < priv->num_camera_devices; i++)
+ {
+ device = g_ptr_array_index (priv->camera_devices, i);
+
+ if (g_strcmp0 (cheese_camera_device_get_name (device),
+ priv->initial_name) == 0)
+ {
+ cheese_camera_set_device (camera, device);
+ break;
+ }
+ }
+ }
if ((priv->camerabin = gst_element_factory_make ("camerabin", "camerabin")) == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]