diff options
author | Hans de Goede <hdegoede@redhat.com> | 2013-06-10 14:27:04 +0200 |
---|---|---|
committer | David King <amigadave@amigadave.com> | 2013-09-02 22:14:41 +0100 |
commit | 4cb89c66167a1945e936707b5d2d3e5b4c9f2871 (patch) | |
tree | 618a5d54b46a331c27f2d422dbe9be61e6c6738a | |
parent | 0734924a17405d9affb501ddbfa785162fdc407e (diff) |
Add cheese_camera_device_find_full_format() helper
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | libcheese/cheese-camera-device.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c index 83c9ecc..9997f55 100644 --- a/libcheese/cheese-camera-device.c +++ b/libcheese/cheese-camera-device.c @@ -321,6 +321,33 @@ 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 = g_list_next (l)) + { + 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 @@ -333,19 +360,16 @@ cheese_camera_device_add_format (CheeseCameraDevice *device, const GValue *framerate) { CheeseCameraDevicePrivate *priv = device->priv; - GList *l; + CheeseVideoFormatFull *existing; - for (l = priv->formats; l != NULL; l = g_list_next (l)) - { - CheeseVideoFormatFull *item = l->data; + existing = cheese_camera_device_find_full_format (device, + (CheeseVideoFormat *)format); - if ((item != NULL) && - (item->width == format->width) && - (item->height == format->height)) - { - cheese_camera_device_format_update_framerate (item, framerate); - return; - } + if (existing) + { + g_slice_free (CheeseVideoFormatFull, format); + cheese_camera_device_format_update_framerate (existing, framerate); + return; } cheese_camera_device_get_highest_framerate (framerate, &format->fr_numerator, |