dt_camctl_t *dt_camctl_new() { dt_camctl_t *camctl=g_malloc(sizeof(dt_camctl_t)); memset(camctl,0,sizeof(dt_camctl_t)); dt_print(DT_DEBUG_CAMCTL,"[camera_control] creating new context %lx\n",(unsigned long int)camctl); // Initialize gphoto2 context and setup dispatch callbacks camctl->gpcontext = gp_context_new(); gp_context_set_idle_func( camctl->gpcontext , (GPContextIdleFunc)_idle_func_dispatch, camctl ); gp_context_set_status_func( camctl->gpcontext , (GPContextStatusFunc)_status_func_dispatch, camctl ); gp_context_set_error_func( camctl->gpcontext , (GPContextErrorFunc)_error_func_dispatch, camctl ); gp_context_set_message_func( camctl->gpcontext , (GPContextMessageFunc)_message_func_dispatch, camctl ); // Load all camera drivers we know... gp_abilities_list_new( &camctl->gpcams ); gp_abilities_list_load( camctl->gpcams, camctl->gpcontext ); dt_print(DT_DEBUG_CAMCTL,"[camera_control] loaded %d camera drivers.\n", gp_abilities_list_count( camctl->gpcams ) ); dt_pthread_mutex_init(&camctl->lock, NULL); // Let's detect cameras connexted dt_camctl_detect_cameras(camctl); return camctl; }
void gp_glue_context_set_error_func (GPGlueContext *gluecontext, GPGlueContextErrorFunc error_func, void *data) { gluecontext->error_func = error_func; gluecontext->error_data = data; gp_context_set_error_func (gluecontext->context, gp_glue_error_func_wrapper, gluecontext); }
GPContext* photo_camera::photo_camera_create_context( void ) { context_ = gp_context_new(); // Optional debugging and status output gp_context_set_error_func( context_, photo_reporter::contextError, NULL ); gp_context_set_status_func( context_, photo_reporter::contextStatus, NULL ); return context_; }
// Create a constext. used in init. GPContext* create_context() { GPContext *context; context = gp_context_new(); // make sure we log errors. helps work out wtf is going on. gp_context_set_error_func (context, (GPContextErrorFunc) ctx_error_func, NULL); gp_context_set_status_func (context, (GPContextStatusFunc) ctx_status_func, NULL); return context; }
GPStatus() { #ifdef HAVE_GPHOTO2 context = gp_context_new(); cancel = false; gp_context_set_cancel_func(context, cancel_func, 0); #ifdef GPHOTO2_DEBUG gp_context_set_progress_funcs(context, start_func, update_func, stop_func, 0); gp_context_set_error_func(context, error_func, 0); gp_context_set_status_func(context, status_func, 0); #endif /* GPHOTO2_DEBUG */ #endif /* HAVE_GPHOTO2 */ }
void Context::init_messages() { gp_context_set_error_func(context, error_func, NULL); gp_context_set_message_func(context, msg_func, NULL); gp_context_set_status_func(context, status_func, NULL); // debug logging is massive const char *debug_enable = getenv("GPWRAP_LOG_DEBUG"); static bool debug_created; if (debug_enable && debug_enable[0] == '1' && !debug_created) { debug_created = true; // maybe should have a top-level class for this as it's not context specific // typecast because just enum vs int in header, should be safe gp_log_add_func(GP_LOG_DEBUG, reinterpret_cast<GPLogFunc>(log_func), NULL); } }
void gp_params_init (GPParams *p, char **envp) { if (!p) return; memset (p, 0, sizeof (GPParams)); p->folder = strdup ("/"); if (!p->folder) { fprintf (stderr, _("Not enough memory.")); fputc ('\n', stderr); exit (1); } gp_camera_new (&p->camera); p->cols = 79; p->flags = FLAGS_RECURSE; /* Create a context. Report progress only if users will see it. */ p->context = gp_context_new (); gp_context_set_cancel_func (p->context, ctx_cancel_func, p); gp_context_set_error_func (p->context, ctx_error_func, p); gp_context_set_status_func (p->context, ctx_status_func, p); gp_context_set_message_func (p->context, ctx_message_func, p); if (isatty (STDOUT_FILENO)) gp_context_set_progress_funcs (p->context, ctx_progress_start_func, ctx_progress_update_func, ctx_progress_stop_func, p); p->_abilities_list = NULL; p->debug_func_id = -1; p->envp = envp; }
int init(t_cam *c) { c->liveview = 0; c->liveview_fps = 30; c->liveview_fps_time = 1000000 / 30; pthread_mutex_init(&c->liveview_mutex, NULL); pthread_cond_init(&c->liveview_condvar, NULL); c->folder_path = strdup("/tmp/"); c->camera_value_list = NULL; gp_context_set_error_func(c->context, (GPContextErrorFunc)error_func, NULL); gp_context_set_message_func(c->context, (GPContextMessageFunc)message_func, NULL); gp_camera_new(&c->camera); c->context = gp_context_new(); printf("Camera Init\n"); c->ret = gp_camera_init(c->camera, c->context); if (c->ret != GP_OK) { printf("gp_camera_init: %d\n", c->ret); return (GP_ERROR); } /* get_initial_camera_values(t_cam *c); */ return (GP_OK); }
int main () { CameraFilesystem *fs; CameraFileInfo info; CameraList *list; int x, count; const char *name; char *foldername; GPContext *context; #ifdef HAVE_MCHECK_H mtrace(); #endif CHECK (gp_list_new(&list)); gp_log_add_func (GP_LOG_DEBUG, log_func, NULL); context = gp_context_new (); gp_context_set_error_func (context, error_func, NULL); printf ("*** Creating file system...\n"); CHECK (gp_filesystem_new (&fs)); printf ("*** Setting the callbacks...\n"); CHECK (gp_filesystem_set_funcs (fs, &fsfuncs, NULL)); printf ("*** Adding a file...\n"); CHECK (gp_filesystem_append (fs, "/", "my.file", context)); gp_filesystem_dump (fs); printf ("*** Removing this file...\n"); CHECK (gp_filesystem_delete_file (fs, "/", "my.file", context)); gp_filesystem_dump (fs); printf ("*** Resetting...\n"); CHECK (gp_filesystem_reset (fs)); gp_filesystem_dump (fs); printf ("*** Adding /...\n"); CHECK (gp_filesystem_append (fs, "/", NULL, context)); printf ("*** Adding /whatever ...\n"); CHECK (gp_filesystem_append (fs, "/whatever", NULL, context)); printf ("*** Adding /whatever/dir...\n"); CHECK (gp_filesystem_append (fs, "/whatever/dir", NULL, context)); printf ("*** Adding /whatever/dir/file1...\n"); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file1", context)); gp_filesystem_dump (fs); printf ("*** Adding /whatever/dir/file2...\n"); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file2", context)); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file3", context)); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file4", context)); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file5", context)); gp_filesystem_dump (fs); printf ("*** Deleting everything below root...\n"); CHECK (gp_filesystem_delete_all (fs, "/", context)); gp_filesystem_dump (fs); printf ("*** Appending root directory...\n"); CHECK (gp_filesystem_append (fs, "/", NULL, context)); printf ("*** Appending some directories...\n"); CHECK (gp_filesystem_append (fs, "/whatever", NULL, context)); CHECK (gp_filesystem_append (fs, "/whatever/directory", NULL, context)); printf ("*** Adding some files...\n"); CHECK (gp_filesystem_append (fs, "/whatever/directory", "some.file", context)); CHECK (gp_filesystem_append (fs, "/whatever/directory", "some.file2", context)); CHECK (gp_filesystem_append (fs, "/another/directory", "another.file", context)); gp_filesystem_dump (fs); printf ("*** Getting info about a file...\n"); CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file", &info, context)); printf ("*** Getting info again (cache!)...\n"); CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file", &info, context)); printf ("*** Set info about another file...\n"); CHECK (gp_filesystem_set_info (fs, "/whatever/directory", "some.file2", info, context)); printf ("*** Getting info about this file (cache!)...\n"); CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file2", &info, context)); printf ("*** Deleting a file...\n"); CHECK (gp_filesystem_delete_file (fs, "/whatever/directory", "some.file2", context)); gp_filesystem_dump (fs); printf ("*** Resetting the filesystem...\n"); CHECK (gp_filesystem_reset (fs)); gp_filesystem_dump (fs); printf ("*** Getting file list for folder '/whatever/directory'...\n"); CHECK (gp_filesystem_list_folders (fs, "/whatever/directory", list, context)); printf ("*** Getting file list for folder '/whatever/directory' " "again (cached!)...\n"); CHECK (gp_filesystem_list_folders (fs, "/whatever/directory", list, context)); printf ("*** Counting the contents...\n"); CHECK (count = gp_list_count (list)); printf ("*** Listing the contents...\n"); for (x = 0; x < count; x++) { CHECK (gp_list_get_name (list, x, &name)); printf (" %i: '%s'\n", x, name); } printf ("*** Getting folder of 'file1'...\n"); CHECK (gp_filesystem_get_folder (fs, "file1", &foldername, context)); printf ("... found in '%s'.\n", foldername); free(foldername); printf ("*** Deleting a couple of files...\n"); CHECK (gp_filesystem_delete_file (fs, "/whatever", "file5", context)); CHECK (gp_filesystem_delete_file (fs, "/whatever", "file4", context)); CHECK (gp_filesystem_delete_file (fs, "/whatever", "file3", context)); gp_filesystem_dump (fs); printf ("*** Freeing file system...\n"); CHECK (gp_filesystem_free (fs)); gp_context_unref (context); CHECK (gp_list_free(list)); #ifdef HAVE_MCHECK_H muntrace(); #endif return (0); }
photoController::photoController() { context = gp_context_new(); gp_context_set_error_func(context, ContextErrorPrint, NULL); initCamera(); }