summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2016-10-11 08:36:18 +0200
committerMarcus Meissner <marcus@jet.franken.de>2016-10-11 08:36:18 +0200
commitd3881999469bf427d4543e2b7ca79289937df56a (patch)
treef7415e88b52086effc92e927ec219c68201fd4da /examples
parent45fe36273089b17e3582f9bafd51fe0799d38210 (diff)
downloadlibgphoto2-d3881999469bf427d4543e2b7ca79289937df56a.tar.gz
added configuration reading to photobooth sample
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am2
-rw-r--r--examples/sample-photobooth.c27
2 files changed, 27 insertions, 2 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index be12feab2..86d7626f3 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -40,7 +40,7 @@ sample_multi_detect_SOURCES = sample-multi-detect.c samples.h autodetect.c conte
lunkwill_canon_capture_SOURCES = lunkwill-canon-capture.c context.c samples.h config.c
sample_capture_SOURCES = sample-capture.c context.c samples.h config.c focus.c
sample_trigger_capture_SOURCES = sample-trigger-capture.c context.c samples.h config.c
-sample_photobooth_SOURCES = sample-photobooth.c samples.h context.c
+sample_photobooth_SOURCES = sample-photobooth.c samples.h context.c config.c
sample_preview_SOURCES = preview.c samples.h context.c config.c focus.c
sample_tether_SOURCES = samples.h sample-tether.c context.c config.c
best_iso_SOURCES = best-iso.c
diff --git a/examples/sample-photobooth.c b/examples/sample-photobooth.c
index 76a7cb72b..2e3c00ae1 100644
--- a/examples/sample-photobooth.c
+++ b/examples/sample-photobooth.c
@@ -14,6 +14,9 @@
#include "samples.h"
+#define CONFIG_FILE "config.txt"
+#define PREVIEW "preview.jpg"
+
static void errordumper(GPLogLevel level, const char *domain, const char *str,
void *data) {
/* printf("%s (data %p)\n", str,data);*/
@@ -106,6 +109,28 @@ main(int argc, char **argv) {
}
/*
+ * Read configuration changes from "config.txt".
+ */
+ if (read_config) {
+ FILE *config;
+ char buf[512];
+
+ config = fopen (CONFIG_FILE, "r");
+ while (fgets (buf, sizeof(buf), config)) {
+ char *s;
+
+ s = strchr(buf,'=');
+ if (!s) continue;
+
+ *s=0;
+ retval = set_config_value_string (camera, buf, s+1, context);
+ if (retval < GP_OK)
+ fprintf (stderr, "setting configuration '%s' to '%s' failed with %d.\n", buf, s+1, retval);
+ }
+ fclose (config);
+ }
+
+ /*
* Capture a preview on every loop. Save as preview.jpg.
*/
retval = gp_file_new(&file);
@@ -119,7 +144,7 @@ main(int argc, char **argv) {
fprintf(stderr,"gp_camera_capture_preview failed: %d\n", retval);
exit(1);
}
- retval = gp_file_save(file, "preview.jpg");
+ retval = gp_file_save(file, PREVIEW);
if (retval != GP_OK) {
fprintf(stderr,"saving preview failed: %d\n", retval);
exit(1);