summaryrefslogtreecommitdiffstats
path: root/test/grab-async.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-09-21 12:11:55 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-09-21 12:11:55 +0200
commit9f262857d13a3e0d7ee214b33b90359c51227718 (patch)
treeb0c2bad6ba10037703785e2c695a65af621c5a32 /test/grab-async.c
parent7132f5b74e74597fea4e358381e9e102bba7c8ed (diff)
downloaduca-9f262857d13a3e0d7ee214b33b90359c51227718.tar.gz
uca-9f262857d13a3e0d7ee214b33b90359c51227718.tar.bz2
uca-9f262857d13a3e0d7ee214b33b90359c51227718.tar.xz
uca-9f262857d13a3e0d7ee214b33b90359c51227718.zip
Port grab-async to new plugin manager
Diffstat (limited to 'test/grab-async.c')
-rw-r--r--test/grab-async.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/test/grab-async.c b/test/grab-async.c
index e1ec114..6132829 100644
--- a/test/grab-async.c
+++ b/test/grab-async.c
@@ -19,6 +19,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include "uca-plugin-manager.h"
#include "uca-camera.h"
static UcaCamera *camera = NULL;
@@ -29,7 +30,8 @@ typedef struct {
guint counter;
} CallbackData;
-static void sigint_handler(int signal)
+static void
+sigint_handler(int signal)
{
printf("Closing down libuca\n");
uca_camera_stop_recording(camera, NULL);
@@ -37,7 +39,8 @@ static void sigint_handler(int signal)
exit(signal);
}
-static void grab_callback(gpointer data, gpointer user_data)
+static void
+grab_callback(gpointer data, gpointer user_data)
{
CallbackData *cbd = (CallbackData *) user_data;
gchar *filename = g_strdup_printf("frame-%04i.raw", cbd->counter++);
@@ -49,16 +52,49 @@ static void grab_callback(gpointer data, gpointer user_data)
g_free(filename);
}
-int main(int argc, char *argv[])
+static void
+print_usage (void)
+{
+ GList *types;
+ UcaPluginManager *manager;
+
+ manager = uca_plugin_manager_new ();
+ g_print ("Usage: benchmark [ ");
+ types = uca_plugin_manager_get_available_cameras (manager);
+
+ if (types == NULL) {
+ g_print ("] -- no camera plugin found\n");
+ return;
+ }
+
+ for (GList *it = g_list_first (types); it != NULL; it = g_list_next (it)) {
+ gchar *name = (gchar *) it->data;
+ if (g_list_next (it) == NULL)
+ g_print ("%s ]\n", name);
+ else
+ g_print ("%s, ", name);
+ }
+}
+
+int
+main(int argc, char *argv[])
{
CallbackData cbd;
guint sensor_width, sensor_height;
gchar *name;
+ UcaPluginManager *manager;
GError *error = NULL;
(void) signal(SIGINT, sigint_handler);
g_type_init();
- camera = uca_camera_new("pco", &error);
+
+ if (argc < 2) {
+ print_usage();
+ return 1;
+ }
+
+ manager = uca_plugin_manager_new ();
+ camera = uca_plugin_manager_new_camera (manager, argv[1], &error);
if (camera == NULL) {
g_print("Error during initialization: %s\n", error->message);