diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-09-21 14:29:50 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-09-21 14:29:50 +0200 |
commit | 6eaadaa0e4ad8ce906aa8ccee63d91f0d9cb28ea (patch) | |
tree | 1b37a1eb40ad1fdec0a2bebc167f7f8128497748 /test/grab-async.c | |
parent | e6a6eb9aede59a1f7441b926b36afefd9c42b91d (diff) | |
parent | 9f262857d13a3e0d7ee214b33b90359c51227718 (diff) | |
download | uca-6eaadaa0e4ad8ce906aa8ccee63d91f0d9cb28ea.tar.gz uca-6eaadaa0e4ad8ce906aa8ccee63d91f0d9cb28ea.tar.bz2 uca-6eaadaa0e4ad8ce906aa8ccee63d91f0d9cb28ea.tar.xz uca-6eaadaa0e4ad8ce906aa8ccee63d91f0d9cb28ea.zip |
Merge branch 'plugins'
Diffstat (limited to 'test/grab-async.c')
-rw-r--r-- | test/grab-async.c | 44 |
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); |