diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 2 | ||||
-rw-r--r-- | examples/sample-afl.c | 71 |
2 files changed, 15 insertions, 58 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index 409f28458..e7ff7be7c 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -32,7 +32,7 @@ noinst_PROGRAMS += \ best-iso \ sample-capture sample-trigger-capture sample-justfocus -sample_afl_SOURCES = sample-afl.c samples.h context.c +sample_afl_SOURCES = sample-afl.c samples.h context.c autodetect.c sample_autodetect_SOURCES = sample-autodetect.c samples.h context.c config.c sample_owner_SOURCES = sample-owner.c samples.h context.c config.c sample_multi_detect_SOURCES = sample-multi-detect.c samples.h autodetect.c context.c config.c diff --git a/examples/sample-afl.c b/examples/sample-afl.c index c56176544..04701ff29 100644 --- a/examples/sample-afl.c +++ b/examples/sample-afl.c @@ -10,76 +10,35 @@ * */ +static void errordumper(GPLogLevel level, const char *domain, const char *str, + void *data) { + /* Do not log ... but let it appear here so we discover debug paths */ + fprintf(stderr, "%s\n", str); +} + + int main(int argc, char **argv) { Camera *camera = NULL; int ret; GPContext *context; CameraWidget *rootwidget; - GPPortInfo pi; char buf[200]; - GPPortInfoList *portinfolist = NULL; - CameraAbilitiesList *abilities = NULL; - CameraAbilities a; CameraText summary; + gp_log_add_func(GP_LOG_DEBUG, errordumper, NULL); + context = sample_create_context (); /* see context.c */ - ret = gp_port_info_list_new (&portinfolist); - if (ret < GP_OK) { - fprintf(stderr,"no portlist allocated.\n"); - goto out; - } - ret = gp_port_info_list_load (portinfolist); - if (ret < GP_OK) { - fprintf(stderr,"no portlist loaded.\n"); - goto out; - } - gp_camera_new (&camera); strcpy(buf,"usb:"); if (argc > 1) strcat (buf, argv[1]); - ret = gp_port_info_list_lookup_path (portinfolist, buf); - if (ret < GP_OK) { - fprintf(stderr,"path %s not found.\n", buf); - goto out; - } - ret = gp_port_info_list_get_info (portinfolist, ret, &pi); - if (ret < GP_OK) { - fprintf(stderr,"port info not gotten.\n"); - goto out; - } - ret = gp_camera_set_port_info (camera, pi); - if (ret < GP_OK) { - fprintf(stderr,"port info not set in camera.\n"); - goto out; - } - - /* First lookup the model / driver */ - - /* Load all the camera drivers we have... */ - ret = gp_abilities_list_new (&abilities); - if (ret < GP_OK) { - fprintf(stderr,"Abilitylist not allocated.\n"); - goto out; - } - ret = gp_abilities_list_load (abilities, context); - if (ret < GP_OK) { - fprintf(stderr,"Abilitylist not loaded.\n"); - goto out; - } + fprintf(stderr,"setting path %s.\n", buf); - ret = gp_abilities_list_lookup_model (abilities, "USB PTP Class Camera"); - if (ret < GP_OK) { - fprintf(stderr,"Camera not found.\n"); - } - ret = gp_abilities_list_get_abilities (abilities, ret, &a); - if (ret < GP_OK) { - fprintf(stderr,"Abilities not gotten.\n"); - } - ret = gp_camera_set_abilities (camera, a); + ret = sample_open_camera (&camera, "USB PTP Class Camera", buf, context); if (ret < GP_OK) { - fprintf(stderr,"Abilities not set in camera.\n"); + fprintf(stderr,"camera %s not found.\n", buf); + goto out; } ret = gp_camera_init (camera, context); @@ -95,7 +54,7 @@ int main(int argc, char **argv) { goto out; } -#if 0 +#if 1 ret = gp_camera_get_config (camera, &rootwidget, context); if (ret < GP_OK) { fprintf (stderr,"Could not get config.\n"); @@ -106,8 +65,6 @@ int main(int argc, char **argv) { /* AFL PART ENDS HERE */ out: - gp_abilities_list_free (abilities); - gp_port_info_list_free (portinfolist); gp_camera_exit (camera, context); gp_camera_free (camera); return 0; |