summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2018-04-16 19:25:28 +0200
committerMarcus Meissner <marcus@jet.franken.de>2018-04-16 19:25:28 +0200
commit76bfee1646bc024ba249eaae3419588a3a5187ec (patch)
treed52749f61bbd7f81755fa62c11609428c40327b0 /examples
parent194e75ed07cbb17eec642e13775118d72df07a4f (diff)
downloadlibgphoto2-76bfee1646bc024ba249eaae3419588a3a5187ec.tar.gz
free various event data
added GP_EVENT_FILE_CHANGED
Diffstat (limited to 'examples')
-rw-r--r--examples/best-iso.c7
-rw-r--r--examples/foo.c63
-rw-r--r--examples/sample-photobooth.c5
-rw-r--r--examples/sample-tether.c7
-rw-r--r--examples/sample-trigger-capture.c6
5 files changed, 88 insertions, 0 deletions
diff --git a/examples/best-iso.c b/examples/best-iso.c
index 84204b3f9..84f96367a 100644
--- a/examples/best-iso.c
+++ b/examples/best-iso.c
@@ -243,10 +243,17 @@ camera_tether(Camera *camera, GPContext *context) {
printf(" Deleting %s on camera...\n", path->name);
retval = gp_camera_file_delete(camera, path->folder, path->name, context);
gp_file_free(file);
+ free(path);
break;
case GP_EVENT_FOLDER_ADDED:
path = (CameraFilePath*)evtdata;
printf("Folder added on camera: %s / %s\n", path->folder, path->name);
+ free(path);
+ break;
+ case GP_EVENT_FILE_CHANGED:
+ path = (CameraFilePath*)evtdata;
+ printf("File changed on camera: %s / %s\n", path->folder, path->name);
+ free(path);
break;
case GP_EVENT_CAPTURE_COMPLETE:
printf("Capture Complete.\n");
diff --git a/examples/foo.c b/examples/foo.c
new file mode 100644
index 000000000..c9b22b523
--- /dev/null
+++ b/examples/foo.c
@@ -0,0 +1,63 @@
+/*
+
+ My Preview Trying to capture preview images with libgphoto2
+
+*/
+
+// block of includes from preview.c
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <gphoto2/gphoto2.h>
+#include "samples.h"
+#include <sys/time.h> // there's a gettimeofday somewhere
+
+
+Camera *canon;
+GPContext *canoncontext;
+
+void get_one(void) { // capture 1 preview image
+ CameraFile *file;
+ char jpgname[] = "test2.jpg";
+ int rslt;
+ rslt = gp_file_new(&file);
+ if (rslt) {
+ printf("Error creating new CameraFile %i\n",rslt);
+ exit(1);
+ }
+ // skipping focus for now but do it here
+ // skipping zoom also
+ rslt = gp_camera_capture_preview(canon, file, canoncontext);
+ if (rslt) {
+ printf("error capturing preview %i\n",rslt);
+ exit(1);
+ }
+ rslt = gp_file_save(file, jpgname);
+ if (rslt) {
+ printf("Error saving file (in gp_file_save) %i\n",rslt);
+ exit(1);
+ }
+}
+
+int main(void) {
+ int rslt;
+ // skip this for now
+// gp_log_add_func(GP_LOG_ERROR, errordumper, NULL);
+ gp_camera_new(&canon);
+ canoncontext = sample_create_context();
+ printf("Camera init. Takes about 10 seconds.\n");
+ rslt = gp_camera_init(canon, canoncontext);
+ if (rslt) {
+ printf("Error initializing camera %i\n",rslt);
+ exit(1);
+ }
+ //canon_enable_capture(canon, TRUE, canoncontext); // in config.c
+ get_one();
+ gp_camera_exit(canon, canoncontext);
+ return 0;
+}
diff --git a/examples/sample-photobooth.c b/examples/sample-photobooth.c
index 67588accd..53271fc79 100644
--- a/examples/sample-photobooth.c
+++ b/examples/sample-photobooth.c
@@ -221,6 +221,11 @@ main(int argc, char **argv) {
fprintf (stderr, "saved to %s\n", output_file);
break;
}
+ case GP_EVENT_FILE_CHANGED:
+ path = (CameraFilePath*)evtdata;
+ printf("File changed on camera: %s / %s\n", path->folder, path->name);
+ free (evtdata);
+ break;
case GP_EVENT_FOLDER_ADDED:
path = (CameraFilePath*)evtdata;
printf("Folder added on camera: %s / %s\n", path->folder, path->name);
diff --git a/examples/sample-tether.c b/examples/sample-tether.c
index 3b6f863b8..92232066e 100644
--- a/examples/sample-tether.c
+++ b/examples/sample-tether.c
@@ -50,10 +50,17 @@ camera_tether(Camera *camera, GPContext *context) {
printf(" Deleting %s on camera...\n", path->name);
retval = gp_camera_file_delete(camera, path->folder, path->name, context);
gp_file_free(file);
+ free(evtdata);
break;
case GP_EVENT_FOLDER_ADDED:
path = (CameraFilePath*)evtdata;
printf("Folder added on camera: %s / %s\n", path->folder, path->name);
+ free(evtdata);
+ break;
+ case GP_EVENT_FILE_CHANGED:
+ path = (CameraFilePath*)evtdata;
+ printf("File changed on camera: %s / %s\n", path->folder, path->name);
+ free(evtdata);
break;
case GP_EVENT_CAPTURE_COMPLETE:
printf("Capture Complete.\n");
diff --git a/examples/sample-trigger-capture.c b/examples/sample-trigger-capture.c
index 7b61b9df7..688521756 100644
--- a/examples/sample-trigger-capture.c
+++ b/examples/sample-trigger-capture.c
@@ -64,6 +64,11 @@ wait_event_and_download (Camera *camera, int waittime, GPContext *context) {
break;
case GP_EVENT_FOLDER_ADDED:
fprintf (stderr, "wait for event FOLDER_ADDED\n");
+ free(data);
+ break;
+ case GP_EVENT_FILE_CHANGED:
+ fprintf (stderr, "wait for event FILE_CHANGED\n");
+ free(data);
break;
case GP_EVENT_FILE_ADDED:
fprintf (stderr, "File %s / %s added to queue.\n", path->folder, path->name);
@@ -79,6 +84,7 @@ wait_event_and_download (Camera *camera, int waittime, GPContext *context) {
memcpy (&queue[nrofqueue].path, path, sizeof(CameraFilePath));
queue[nrofqueue].offset = 0;
nrofqueue++;
+ free(data);
break;
}
}