[aravis] camera: add arv_camera_get_available_pixel_formats.



commit fe5fd7a769511ede8ca31c562c273b1f7e089a13
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Wed Feb 16 10:22:14 2011 +0100

    camera: add arv_camera_get_available_pixel_formats.

 src/arvcamera.c        |   28 ++++++++++++++++++++++++++++
 src/arvgcenumeration.c |    2 +-
 src/arvgcnode.c        |   12 ++++++++++++
 src/arvgcnode.h        |    1 +
 4 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/src/arvcamera.c b/src/arvcamera.c
index f39688c..fd87b0a 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -37,6 +37,7 @@
 #include <arvgcinteger.h>
 #include <arvgcfloat.h>
 #include <arvgcenumeration.h>
+#include <arvgcenumentry.h>
 #include <arvgcstring.h>
 #include <arvgc.h>
 #include <arvdevice.h>
@@ -311,6 +312,33 @@ arv_camera_get_pixel_format (ArvCamera *camera)
 	return arv_device_get_integer_feature_value (camera->priv->device, "PixelFormat");
 }
 
+ArvPixelFormat *
+arv_camera_get_available_pixel_formats (ArvCamera *camera, guint *n_pixel_formats)
+{
+	ArvGcNode *enumeration;
+	ArvPixelFormat *pixel_formats;
+	const GSList *entries, *iter;
+	unsigned int i;
+
+	g_return_val_if_fail (ARV_IS_CAMERA (camera), NULL);
+	g_return_val_if_fail (n_pixel_formats != NULL, NULL);
+
+	enumeration = arv_gc_get_node (camera->priv->genicam, "PixelFormat");
+	if (!ARV_IS_GC_ENUMERATION (enumeration))
+		return NULL;
+
+	*n_pixel_formats = arv_gc_node_get_n_childs (enumeration);
+	if (*n_pixel_formats == 0)
+		return NULL;
+
+	pixel_formats = g_new (ArvPixelFormat, *n_pixel_formats);
+	entries = arv_gc_enumeration_get_entries (ARV_GC_ENUMERATION (enumeration));
+	for (iter = entries, i = 0; iter != NULL; iter = iter->next, i++)
+		pixel_formats[i] = arv_gc_enum_entry_get_value (iter->data);
+
+	return pixel_formats;
+}
+
 /* Acquisition control */
 
 /**
diff --git a/src/arvgcenumeration.c b/src/arvgcenumeration.c
index 2f66cc8..e8d0627 100644
--- a/src/arvgcenumeration.c
+++ b/src/arvgcenumeration.c
@@ -104,7 +104,7 @@ arv_gc_enumeration_set_string_value (ArvGcEnumeration *enumeration, const char *
 						   arv_gc_enum_entry_get_value (iter->data));
 			return;
 		}
-	
+
 	arv_debug ("genicam", "[GcEnumeration::set_string_value] entry %s not found", value);
 }
 
diff --git a/src/arvgcnode.c b/src/arvgcnode.c
index 94d387a..2f73d57 100644
--- a/src/arvgcnode.c
+++ b/src/arvgcnode.c
@@ -43,6 +43,7 @@ struct _ArvGcNodePrivate {
 	char *description;
 	char *display_name;
 
+	unsigned int n_childs;
 	GSList *childs;
 
 	gint modification_count;
@@ -152,6 +153,7 @@ arv_gc_node_add_child (ArvGcNode *node, ArvGcNode *child)
 	g_return_if_fail (ARV_IS_GC_NODE (child));
 
 	node->priv->childs = g_slist_append (node->priv->childs, child);
+	node->priv->n_childs++;
 }
 
 const GSList *
@@ -162,6 +164,14 @@ arv_gc_node_get_childs (ArvGcNode *node)
 	return node->priv->childs;
 }
 
+unsigned int
+arv_gc_node_get_n_childs (ArvGcNode *node)
+{
+	g_return_val_if_fail (ARV_IS_GC_NODE (node), 0);
+
+	return node->priv->n_childs;
+}
+
 ArvGcNode *
 arv_gc_node_new (void)
 {
@@ -229,6 +239,7 @@ arv_gc_node_init (ArvGcNode *gc_node)
 	gc_node->priv->description = NULL;
 	gc_node->priv->display_name = NULL;
 	gc_node->priv->childs = NULL;
+	gc_node->priv->n_childs = 0;
 
 	gc_node->priv->modification_count = 0;
 }
@@ -242,6 +253,7 @@ arv_gc_node_finalize (GObject *object)
 	for (iter = node->priv->childs; iter != NULL; iter = iter->next)
 		g_object_unref (iter->data);
 	g_slist_free (node->priv->childs);
+	node->priv->n_childs = 0;
 
 	g_free (node->priv->name);
 	g_free (node->priv->tooltip);
diff --git a/src/arvgcnode.h b/src/arvgcnode.h
index 8929da9..7881fbc 100644
--- a/src/arvgcnode.h
+++ b/src/arvgcnode.h
@@ -68,6 +68,7 @@ void 		arv_gc_node_add_element 		(ArvGcNode *gc_node, const char *name, const ch
 gboolean 	arv_gc_node_can_add_child 		(ArvGcNode *gc_node, ArvGcNode *child);
 void 		arv_gc_node_add_child 			(ArvGcNode *gc_node, ArvGcNode *child);
 const GSList *	arv_gc_node_get_childs 			(ArvGcNode *gc_node);
+unsigned int 	arv_gc_node_get_n_childs 		(ArvGcNode *gc_node);
 void 		arv_gc_node_inc_modification_count 	(ArvGcNode *gc_node);
 gint 		arv_gc_node_get_modification_count 	(ArvGcNode *gc_node);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]