[aravis] Handle pixel formats as strings
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] Handle pixel formats as strings
- Date: Mon, 9 Jul 2012 08:55:00 +0000 (UTC)
commit b3442d48a159899bde664844bf3baaabbc9c2cb2
Author: Jure Varlec <jure varlec ad-vega si>
Date: Fri Jul 6 14:11:24 2012 +0200
Handle pixel formats as strings
After some further testing, I found that the GSList used in
arv_camera_get_available_pixel_formats_as_display_names shouldn't be freed.
While fixing that, I also saw that I made an error when reorganizing commits
into patches. So here's a remake of the last patch.
-- Jure
--------->8-----------------
>From 174152dc0f38f78c2ea10e480f0763b4d613c8b7 Mon Sep 17 00:00:00 2001
From: Jure Varlec <jure varlec ad-vega si>
Date: Mon, 2 Jul 2012 10:14:03 +0200
Subject: [PATCH 7/7] Add
arv_camera_get_available_pixel_formats_as_display_names.
src/arvcamera.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/arvcamera.h | 1 +
2 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/src/arvcamera.c b/src/arvcamera.c
index aae85b9..88b4260 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -409,6 +409,60 @@ arv_camera_get_available_pixel_formats_as_strings (ArvCamera *camera, guint *n_p
return arv_device_get_enumeration_feature_available_strings (camera->priv->device, "PixelFormat", n_pixel_formats);
}
+/**
+ * arv_camera_get_available_pixel_formats_as_display_names:
+ * @camera: a #ArvCamera
+ * @n_pixel_formats: (out): number of different pixel formats
+ *
+ * Retrieves the list of all available pixel formats as display names.
+ * In general, these are human-readable strings cannot be used as settings.
+ *
+ * Returns: (array length=n_pixel_formats) (transfer full): a newly allocated array of strings.
+ */
+
+const char **
+arv_camera_get_available_pixel_formats_as_display_names (ArvCamera *camera, guint *n_pixel_formats)
+{
+ ArvGcNode *node;
+ GSList *entries, *iter;
+ GError *error = NULL;
+ const char **strings;
+ const char *string = NULL;
+ int i;
+
+ *n_pixel_formats = 0;
+ g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
+ node = arv_device_get_feature (camera->priv->device, "PixelFormat");
+
+ if (ARV_IS_GC_ENUMERATION (node))
+ entries = (GSList*) arv_gc_enumeration_get_entries (ARV_GC_ENUMERATION (node));
+ else
+ return NULL;
+
+ strings = g_new (const char *, g_slist_length (entries));
+ i = 0;
+ for (iter = entries; iter != NULL; iter = iter->next) {
+ string = arv_gc_feature_node_get_display_name (iter->data, &error);
+ if (error != NULL) {
+ string = NULL;
+ g_error_free (error);
+ error = NULL;
+ }
+ if (string == NULL)
+ string = arv_gc_feature_node_get_name (iter->data);
+ if (string == NULL) break;
+ strings[i++] = string;
+ }
+
+ if (string == NULL) {
+ g_free (strings);
+ return NULL;
+ }
+
+ *n_pixel_formats = i;
+ return strings;
+}
+
/* Acquisition control */
/**
diff --git a/src/arvcamera.h b/src/arvcamera.h
index 20afebb..9cf0d76 100644
--- a/src/arvcamera.h
+++ b/src/arvcamera.h
@@ -77,6 +77,7 @@ ArvPixelFormat arv_camera_get_pixel_format (ArvCamera *camera);
const char * arv_camera_get_pixel_format_as_string (ArvCamera *camera);
gint64 * arv_camera_get_available_pixel_formats (ArvCamera *camera, guint *n_pixel_formats);
const char ** arv_camera_get_available_pixel_formats_as_strings (ArvCamera *camera, guint *n_pixel_formats);
+const char ** arv_camera_get_available_pixel_formats_as_display_names (ArvCamera *camera, guint *n_pixel_formats);
/* Acquisition control */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]