From 0d5c4a4df0836bdbab85b3ccbca1dffeb54affe1 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 10 Jun 2013 14:27:04 +0200
Subject: [PATCH 11/35] cheese-camera-device: Add
cheese_camera_device_find_full_format() helper
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
libcheese/cheese-camera-device.c | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c
index c684367..25d4a51 100644
--- a/libcheese/cheese-camera-device.c
+++ b/libcheese/cheese-camera-device.c
@@ -319,6 +319,30 @@ cheese_camera_device_format_update_framerate(CheeseVideoFormatFull *format,
}
/*
+ * cheese_camera_device_find_full_format
+ * @device: a #CheeseCameraDevice
+ * @format: #CheeseVideoFormat to find the matching #CheeseVideoFormatFull for
+ *
+ * Find a #CheeseVideoFormatFull matching the passed in #CheeseVideoFormat
+ */
+static CheeseVideoFormatFull *
+cheese_camera_device_find_full_format(CheeseCameraDevice *device,
+ CheeseVideoFormat* format)
+{
+ GList *l;
+
+ for (l = device->priv->formats; l != NULL; l = l->next)
+ {
+ CheeseVideoFormatFull *item = l->data;
+ if ((item != NULL) &&
+ (item->width == format->width) &&
+ (item->height == format->height))
+ return item;
+ }
+ return NULL;
+}
+
+/*
* cheese_camera_device_add_format:
* @device: a #CheeseCameraDevice
* @format: the #CheeseVideoFormatFull to add
@@ -330,18 +354,14 @@ cheese_camera_device_add_format (CheeseCameraDevice *device,
CheeseVideoFormatFull *format, const GValue *framerate)
{
CheeseCameraDevicePrivate *priv = device->priv;
- GList *l;
+ CheeseVideoFormatFull *existing;
- for (l = priv->formats; l != NULL; l = l->next)
+ existing = cheese_camera_device_find_full_format(device,
+ (CheeseVideoFormat *)format);
+ if (existing)
{
- CheeseVideoFormatFull *item = l->data;
- if ((item != NULL) &&
- (item->width == format->width) &&
- (item->height == format->height))
- {
- cheese_camera_device_format_update_framerate (item, framerate);
- return;
- }
+ cheese_camera_device_format_update_framerate (existing, framerate);
+ return;
}
cheese_camera_device_get_highest_framerate (framerate,
--
1.8.2.1