diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2011-04-26 17:20:03 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2011-04-26 17:20:03 +0200 |
commit | bf265341fea65c31992497338eccfab5bfdf217f (patch) | |
tree | 6937b7e1383a44014256833545e7b79a22a878a2 /test | |
parent | 56d716f47fac506ccaca0cdd934dc2bc1ee6644a (diff) | |
download | uca-bf265341fea65c31992497338eccfab5bfdf217f.tar.gz uca-bf265341fea65c31992497338eccfab5bfdf217f.tar.bz2 uca-bf265341fea65c31992497338eccfab5bfdf217f.tar.xz uca-bf265341fea65c31992497338eccfab5bfdf217f.zip |
Make uca_camera really private and thus breaks API
Diffstat (limited to 'test')
-rw-r--r-- | test/benchmark.c | 20 | ||||
-rw-r--r-- | test/control.c | 28 | ||||
-rw-r--r-- | test/enum.c | 6 | ||||
-rw-r--r-- | test/grab-async.c | 16 | ||||
-rw-r--r-- | test/grab.c | 18 |
5 files changed, 46 insertions, 42 deletions
diff --git a/test/benchmark.c b/test/benchmark.c index 900b66a..ae7593a 100644 --- a/test/benchmark.c +++ b/test/benchmark.c @@ -23,35 +23,35 @@ void grab_callback_raw(uint32_t image_number, void *buffer, void *meta_data, voi void benchmark_cam(struct uca_camera *cam) { char name[256]; - cam->get_property(cam, UCA_PROP_NAME, name, 256); + uca_cam_get_property(cam, UCA_PROP_NAME, name, 256); uint32_t val = 5000; - cam->set_property(cam, UCA_PROP_EXPOSURE, &val); + uca_cam_set_property(cam, UCA_PROP_EXPOSURE, &val); val = 0; - cam->set_property(cam, UCA_PROP_DELAY, &val); + uca_cam_set_property(cam, UCA_PROP_DELAY, &val); uint32_t width, height, bits; - cam->get_property(cam, UCA_PROP_WIDTH, &width, 0); - cam->get_property(cam, UCA_PROP_HEIGHT, &height, 0); - cam->get_property(cam, UCA_PROP_BITDEPTH, &bits, 0); + uca_cam_get_property(cam, UCA_PROP_WIDTH, &width, 0); + uca_cam_get_property(cam, UCA_PROP_HEIGHT, &height, 0); + uca_cam_get_property(cam, UCA_PROP_BITDEPTH, &bits, 0); int pixel_size = bits == 8 ? 1 : 2; struct timeval start, stop; for (int i = 0; i < 2; i++) { char *buffer = (char *) malloc(width*height*pixel_size); - cam->set_property(cam, UCA_PROP_HEIGHT, &height); + uca_cam_set_property(cam, UCA_PROP_HEIGHT, &height); uca_cam_alloc(cam, 20); /* * Experiment 1: Grab n frames manually */ gettimeofday(&start, NULL); - cam->start_recording(cam); + uca_cam_start_recording(cam); for (int i = 0; i < 1000; i++) - cam->grab(cam, (char *) buffer, NULL); + uca_cam_grab(cam, (char *) buffer, NULL); - cam->stop_recording(cam); + uca_cam_stop_recording(cam); gettimeofday(&stop, NULL); float seconds = time_diff(&start, &stop) / 1000000.0; diff --git a/test/control.c b/test/control.c index 47c2fab..ee6d6e7 100644 --- a/test/control.c +++ b/test/control.c @@ -99,7 +99,7 @@ void *grab_thread(void *args) struct uca_camera *cam = data->cam; while (data->running) { - cam->grab(cam, (char *) data->buffer, NULL); + uca_cam_grab(cam, (char *) data->buffer, NULL); if (data->pixel_size == 1) convert_8bit_to_rgb(data->pixels, data->buffer, data->width, data->height); else if (data->pixel_size == 2) @@ -120,7 +120,7 @@ static void on_toolbutton_run_clicked(GtkWidget *widget, gpointer args) ThreadData *data = (ThreadData *) args; GError *error = NULL; data->running = TRUE; - data->cam->start_recording(data->cam); + uca_cam_start_recording(data->cam); if (!g_thread_create(grab_thread, data, FALSE, &error)) { g_printerr("Failed to create thread: %s\n", error->message); uca_destroy(data->u); @@ -131,7 +131,7 @@ static void on_toolbutton_stop_clicked(GtkWidget *widget, gpointer args) { ThreadData *data = (ThreadData *) args; data->running = FALSE; - data->cam->stop_recording(data->cam); + uca_cam_stop_recording(data->cam); } static void on_valuecell_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer data) @@ -152,9 +152,13 @@ static void on_valuecell_edited(GtkCellRendererText *renderer, gchar *path, gcha /* TODO: extensive value checking */ uint32_t val = (uint32_t) g_ascii_strtoull(new_text, NULL, 10); - cam->set_property(cam, prop_id, &val); - if ((prop_id == UCA_PROP_WIDTH) || (prop_id == UCA_PROP_HEIGHT)) - reallocate_buffers(value_data->thread_data, cam->frame_width, cam->frame_height); + uca_cam_set_property(cam, prop_id, &val); + if ((prop_id == UCA_PROP_WIDTH) || (prop_id == UCA_PROP_HEIGHT)) { + uint32_t width, height; + uca_cam_get_property(cam, UCA_PROP_WIDTH, &width, 0); + uca_cam_get_property(cam, UCA_PROP_HEIGHT, &height, 0); + reallocate_buffers(value_data->thread_data, width, height); + } gtk_tree_store_set(value_data->tree_store, &iter, COLUMN_VALUE, new_text, -1); } @@ -243,16 +247,16 @@ void fill_tree_store(GtkTreeStore *tree_store, struct uca_camera *cam) uint32_t result = UCA_NO_ERROR; switch (property->type) { case uca_string: - result = cam->get_property(cam, prop_id, value_string, num_bytes); + result = uca_cam_get_property(cam, prop_id, value_string, num_bytes); break; case uca_uint8t: - result = cam->get_property(cam, prop_id, &value_8, 0); + result = uca_cam_get_property(cam, prop_id, &value_8, 0); g_sprintf(value_string, "%d", value_8); break; case uca_uint32t: - result = cam->get_property(cam, prop_id, &value_32, 0); + result = uca_cam_get_property(cam, prop_id, &value_32, 0); g_sprintf(value_string, "%d", value_32); break; } @@ -309,9 +313,9 @@ int main(int argc, char *argv[]) int width, height, bits_per_sample; struct uca_camera *cam = u->cameras; - cam->get_property(cam, UCA_PROP_WIDTH, &width, 0); - cam->get_property(cam, UCA_PROP_HEIGHT, &height, 0); - cam->get_property(cam, UCA_PROP_BITDEPTH, &bits_per_sample, 0); + uca_cam_get_property(cam, UCA_PROP_WIDTH, &width, 0); + uca_cam_get_property(cam, UCA_PROP_HEIGHT, &height, 0); + uca_cam_get_property(cam, UCA_PROP_BITDEPTH, &bits_per_sample, 0); g_thread_init(NULL); gdk_threads_init(); diff --git a/test/enum.c b/test/enum.c index f28bf9b..e9395a5 100644 --- a/test/enum.c +++ b/test/enum.c @@ -42,21 +42,21 @@ int main(int argc, char *argv[]) printf("%s = ", prop->name); switch (prop->type) { case uca_string: - if (cam->get_property(cam, i, string_value, num_bytes) == UCA_NO_ERROR) { + if (uca_cam_get_property(cam, i, string_value, num_bytes) == UCA_NO_ERROR) { printf("%s ", string_value); } else printf("n/a"); break; case uca_uint32t: - if (cam->get_property(cam, i, &uint32_value, 0) == UCA_NO_ERROR) { + if (uca_cam_get_property(cam, i, &uint32_value, 0) == UCA_NO_ERROR) { printf("%i %s", uint32_value, uca_unit_map[prop->unit]); } else printf("n/a"); break; case uca_uint8t: - if (cam->get_property(cam, i, &uint8_value, 0) == UCA_NO_ERROR) { + if (uca_cam_get_property(cam, i, &uint8_value, 0) == UCA_NO_ERROR) { printf("%i %s", uint8_value, uca_unit_map[prop->unit]); } else diff --git a/test/grab-async.c b/test/grab-async.c index 058ec3f..a6e6e65 100644 --- a/test/grab-async.c +++ b/test/grab-async.c @@ -37,22 +37,22 @@ int main(int argc, char *argv[]) struct uca_camera *cam = u->cameras; uint32_t val = 5000; - cam->set_property(cam, UCA_PROP_EXPOSURE, &val); + uca_cam_set_property(cam, UCA_PROP_EXPOSURE, &val); val = 0; - cam->set_property(cam, UCA_PROP_DELAY, &val); + uca_cam_set_property(cam, UCA_PROP_DELAY, &val); struct image_props props; - cam->get_property(cam, UCA_PROP_WIDTH, &props.width, 0); - cam->get_property(cam, UCA_PROP_HEIGHT, &props.height, 0); - cam->get_property(cam, UCA_PROP_BITDEPTH, &props.bits, 0); + uca_cam_get_property(cam, UCA_PROP_WIDTH, &props.width, 0); + uca_cam_get_property(cam, UCA_PROP_HEIGHT, &props.height, 0); + uca_cam_get_property(cam, UCA_PROP_BITDEPTH, &props.bits, 0); uca_cam_alloc(cam, 10); - cam->register_callback(cam, &grab_callback, &props); - cam->start_recording(cam); + uca_cam_register_callback(cam, &grab_callback, &props); + uca_cam_start_recording(cam); printf("grabbing for 2 seconds\n"); sleep(2); - cam->stop_recording(cam); + uca_cam_stop_recording(cam); printf("done\n"); fflush(stdout); diff --git a/test/grab.c b/test/grab.c index c8a6153..b0bd0ee 100644 --- a/test/grab.c +++ b/test/grab.c @@ -20,26 +20,26 @@ int main(int argc, char *argv[]) struct uca_camera *cam = u->cameras; uint32_t val = 5000; - handle_error(cam->set_property(cam, UCA_PROP_EXPOSURE, &val)); + handle_error(uca_cam_set_property(cam, UCA_PROP_EXPOSURE, &val)); val = 0; - handle_error(cam->set_property(cam, UCA_PROP_DELAY, &val)); + handle_error(uca_cam_set_property(cam, UCA_PROP_DELAY, &val)); val = 1; - handle_error(cam->set_property(cam, UCA_PROP_GRAB_SYNCHRONOUS, &val)); + handle_error(uca_cam_set_property(cam, UCA_PROP_GRAB_SYNCHRONOUS, &val)); uint32_t width, height, bits; - handle_error(cam->get_property(cam, UCA_PROP_WIDTH, &width, 0)); - handle_error(cam->get_property(cam, UCA_PROP_HEIGHT, &height, 0)); - handle_error(cam->get_property(cam, UCA_PROP_BITDEPTH, &bits, 0)); + handle_error(uca_cam_get_property(cam, UCA_PROP_WIDTH, &width, 0)); + handle_error(uca_cam_get_property(cam, UCA_PROP_HEIGHT, &height, 0)); + handle_error(uca_cam_get_property(cam, UCA_PROP_BITDEPTH, &bits, 0)); handle_error(uca_cam_alloc(cam, 10)); const int pixel_size = bits == 8 ? 1 : 2; uint16_t *buffer = (uint16_t *) malloc(width * height * pixel_size); - handle_error(cam->start_recording(cam)); - handle_error(cam->grab(cam, (char *) buffer, NULL)); - handle_error(cam->stop_recording(cam)); + handle_error(uca_cam_start_recording(cam)); + handle_error(uca_cam_grab(cam, (char *) buffer, NULL)); + handle_error(uca_cam_stop_recording(cam)); uca_destroy(u); FILE *fp = fopen("out.raw", "wb"); |