146ecef5ec34bc46f3b7dccfd87dbb7b00584b1c
[easyphoto] / camera.h
1 /**
2  * @file camera.h
3  * @author Rouslan Solomakhin
4  * @license GPL
5  */
6
7 #ifndef _CAMERA_H_
8 #define _CAMERA_H_
9
10 #include <pthread.h>
11 #include <unistd.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <gst/gst.h>
15
16 /**
17  * Maximum length of the file name for the photo.
18  */
19 #define PHOTO_FILE_NAME_LENGTH 256
20
21 /**
22  * Context for the process of taking photos.
23  */
24 typedef struct
25 {
26   pthread_mutex_t lock;
27         GstElement *pipeline;
28         guint buffer_cb_id;
29   char file_name[PHOTO_FILE_NAME_LENGTH];
30   gboolean success;
31 } photo_t;
32
33 /**
34  * Initialize the camera context.
35  * @param context Allocated context.
36  * @param argc Number of arguments to main.
37  * @param argv Argument vector to main.
38  * @return TRUE for success. FALSE for failure.
39  */
40 gboolean photo_initialize( photo_t *context, int *argc, char **argv[] );
41
42 /**
43  * Take a photo.
44  * @param context Context for the process of taking photos.
45  * @param file_name Name of the file where photo is saved.
46  * @return TRUE for success. FALSE for failure.
47  */
48 gboolean photo_take( photo_t *context, const char *file_name );
49
50 /**
51  * Destroy the camera context.
52  * @param context The context to destroy.
53  * @return TRUE for success. FALSE for failure.
54  */
55 gboolean photo_destroy( photo_t *context );
56
57 #endif // _CAMERA_H_