[aravis] aravis: allows to enable/disable interfaces.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] aravis: allows to enable/disable interfaces.
- Date: Fri, 20 Jul 2012 13:03:19 +0000 (UTC)
commit eb1d34f967a0ecbef6cda264ca811751840156ac
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Fri Jul 20 15:02:34 2012 +0200
aravis: allows to enable/disable interfaces.
And disable "Fake" by default.
docs/reference/aravis/aravis-sections.txt | 2 +
src/arvsystem.c | 97 ++++++++++++++++++++++++-----
src/arvsystem.h | 2 +
viewer/arvviewer.c | 2 +
4 files changed, 87 insertions(+), 16 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index 54e67ec..0f91fb8 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -145,6 +145,8 @@ ArvBufferClass
ArvInterface
arv_get_device_id
arv_get_interface_id
+arv_disable_interface
+arv_enable_interface
arv_get_n_devices
arv_get_n_interfaces
arv_update_device_list
diff --git a/src/arvsystem.c b/src/arvsystem.c
index 20d8d9d..d660503 100644
--- a/src/arvsystem.c
+++ b/src/arvsystem.c
@@ -25,16 +25,27 @@
#include <arvfakeinterface.h>
#include <arvdevice.h>
#include <arvdebug.h>
+#include <string.h>
typedef struct {
const char *interface_id;
+ gboolean is_available;
ArvInterface * (*get_interface_instance) (void);
void (*destroy_interface_instance) (void);
} ArvInterfaceInfos;
ArvInterfaceInfos interfaces[] = {
- {"Fake", arv_fake_interface_get_instance, arv_fake_interface_destroy_instance},
- {"GigE-Vision", arv_gv_interface_get_instance, arv_gv_interface_destroy_instance}
+ {
+ .interface_id = "Fake",
+ .is_available = FALSE,
+ .get_interface_instance = arv_fake_interface_get_instance,
+ .destroy_interface_instance = arv_fake_interface_destroy_instance
+ },
+ { .interface_id = "GigEVision",
+ .is_available = TRUE,
+ .get_interface_instance = arv_gv_interface_get_instance,
+ .destroy_interface_instance = arv_gv_interface_destroy_instance
+ }
};
unsigned int
@@ -52,6 +63,52 @@ arv_get_interface_id (unsigned int index)
return interfaces[index].interface_id;
}
+/**
+ * arv_enable_interface:
+ * @interface_id: name of the interface
+ *
+ * Enable an interface by name. By default, all interfaces are enabled, except "Fake".
+ */
+
+void
+arv_enable_interface (const char *interface_id)
+{
+ guint i;
+
+ g_return_if_fail (interface_id != NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (interfaces) ; i++)
+ if (strcmp (interface_id, interfaces[i].interface_id) == 0) {
+ interfaces[i].is_available = TRUE;
+ return;
+ }
+
+ g_warning ("[Arv::enable_interface] Unknown interface '%s'", interface_id);
+}
+
+/**
+ * arv_disable_interface:
+ * @interface_id: name of the interface
+ *
+ * Disable an interface by name. By default, all interfaces are enabled, except "Fake".
+ */
+
+void
+arv_disable_interface (const char *interface_id)
+{
+ guint i;
+
+ g_return_if_fail (interface_id != NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (interfaces); i++)
+ if (strcmp (interface_id, interfaces[i].interface_id) == 0) {
+ interfaces[i].is_available = FALSE;
+ return;
+ }
+
+ g_warning ("[Arv::enable_interface] Unknown interface '%s'", interface_id);
+}
+
void
arv_update_device_list (void)
{
@@ -59,9 +116,11 @@ arv_update_device_list (void)
for (i = 0; i < G_N_ELEMENTS (interfaces); i++) {
ArvInterface *interface;
-
- interface = interfaces[i].get_interface_instance ();
- arv_interface_update_device_list (interface);
+
+ if (interfaces[i].is_available) {
+ interface = interfaces[i].get_interface_instance ();
+ arv_interface_update_device_list (interface);
+ }
}
}
@@ -74,8 +133,10 @@ arv_get_n_devices (void)
for (i = 0; i < G_N_ELEMENTS (interfaces); i++) {
ArvInterface *interface;
- interface = interfaces[i].get_interface_instance ();
- n_devices += arv_interface_get_n_devices (interface);
+ if (interfaces[i].is_available) {
+ interface = interfaces[i].get_interface_instance ();
+ n_devices += arv_interface_get_n_devices (interface);
+ }
}
return n_devices;
@@ -91,13 +152,15 @@ arv_get_device_id (unsigned int index)
ArvInterface *interface;
unsigned int n_devices;
- interface = interfaces[i].get_interface_instance ();
- n_devices = arv_interface_get_n_devices (interface);
+ if (interfaces[i].is_available) {
+ interface = interfaces[i].get_interface_instance ();
+ n_devices = arv_interface_get_n_devices (interface);
- if (index - offset < n_devices)
- return arv_interface_get_device_id (interface, index - offset);
+ if (index - offset < n_devices)
+ return arv_interface_get_device_id (interface, index - offset);
- offset += n_devices;
+ offset += n_devices;
+ }
}
return NULL;
@@ -120,10 +183,12 @@ arv_open_device (const char *device_id)
ArvInterface *interface;
ArvDevice *device;
- interface = interfaces[i].get_interface_instance ();
- device = arv_interface_open_device (interface, device_id);
- if (device != NULL)
- return device;
+ if (interfaces[i].is_available) {
+ interface = interfaces[i].get_interface_instance ();
+ device = arv_interface_open_device (interface, device_id);
+ if (device != NULL)
+ return device;
+ }
}
return NULL;
diff --git a/src/arvsystem.h b/src/arvsystem.h
index d6b4a65..dd451c7 100644
--- a/src/arvsystem.h
+++ b/src/arvsystem.h
@@ -29,6 +29,8 @@ G_BEGIN_DECLS
unsigned int arv_get_n_interfaces (void);
const char * arv_get_interface_id (unsigned int index);
+void arv_enable_interface (const char *interface_id);
+void arv_disable_interface (const char *interface_id);
void arv_update_device_list (void);
unsigned int arv_get_n_devices (void);
diff --git a/viewer/arvviewer.c b/viewer/arvviewer.c
index 76c9bf0..0e12326 100644
--- a/viewer/arvviewer.c
+++ b/viewer/arvviewer.c
@@ -796,6 +796,8 @@ main (int argc,char *argv[])
arv_debug_enable (arv_viewer_option_debug_domains);
+ arv_enable_interface ("Fake");
+
#ifdef ARAVIS_WITH_NOTIFY
notify_init ("Aravis Viewer");
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]