f5ec544e31381d9e91b031e943b6b07fcfde41fe
[framework/multimedia/gst-plugins-base0.10.git] / gst-libs / gst / interfaces / cameracontrol.h
1 /*
2  * GStreamer Camera Control Interface
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@samsung.com>
7  *
8  * This library is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License as published by the
10  * Free Software Foundation; either version 2.1 of the License, or (at your option)
11  * any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
14  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc., 51
20  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23
24 /* ===========================================================================================
25 EDIT HISTORY FOR MODULE
26
27         This section contains comments describing changes made to the module.
28         Notice that changes are listed in reverse chronological order.
29
30 when            who                                                     what, where, why
31 ---------       ------------------------        ------------------------------------------------------
32 12/09/08        jm80.yang@samsung.com           Created
33
34 =========================================================================================== */
35
36 #ifndef __GST_CAMERA_CONTROL_H__
37 #define __GST_CAMERA_CONTROL_H__
38
39 #include <gst/gst.h>
40 #include <gst/interfaces/cameracontrolchannel.h>
41 #include <gst/interfaces/interfaces-enumtypes.h>
42
43 G_BEGIN_DECLS
44
45 #define GST_TYPE_CAMERA_CONTROL \
46         (gst_camera_control_get_type())
47 #define GST_CAMERA_CONTROL(obj) \
48         (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CAMERA_CONTROL, GstCameraControl))
49 #define GST_CAMERA_CONTROL_GET_CLASS(inst) \
50         (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_CAMERA_CONTROL, GstCameraControlClass))
51 #define GST_CAMERA_CONTROL_CLASS(klass) \
52         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CAMERA_CONTROL, GstCameraControlClass))
53 #define GST_IS_CAMERA_CONTROL(obj) \
54         (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CAMERA_CONTROL))
55 #define GST_IS_CAMERA_CONTROL_CLASS(klass) \
56         (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CAMERA_CONTROL))
57 #define GST_CAMERA_CONTROL_TYPE(klass) (klass->camera_control_type)     
58
59
60 typedef struct _GstCameraControl GstCameraControl;
61   
62 typedef enum
63 {
64         // TODO : V4L2 Extend
65         GST_CAMERA_CONTROL_HARDWARE,
66         GST_CAMERA_CONTROL_SOFTWARE,
67 } GstCameraControlType;
68
69 /**
70  * Enumerations for Camera control Exposure types.
71  */
72 typedef enum
73 {
74         GST_CAMERA_CONTROL_F_NUMBER,
75         GST_CAMERA_CONTROL_SHUTTER_SPEED,
76         GST_CAMERA_CONTROL_ISO,
77         GST_CAMERA_CONTROL_PROGRAM_MODE,
78         GST_CAMERA_CONTROL_EXPOSURE_MODE,
79         GST_CAMERA_CONTROL_EXPOSURE_VALUE,
80 } GstCameraControlExposureType;
81
82 /**
83  * Enumerations for Camera control Capture mode types.
84  */
85 typedef enum
86 {
87         GST_CAMERA_CONTROL_CAPTURE_MODE,
88         GST_CAMERA_CONTROL_OUTPUT_MODE,
89         GST_CAMERA_CONTROL_FRAME_COUNT,
90         GST_CAMERA_CONTROL_JPEG_QUALITY,
91 } GstCameraControlCaptureModeType;
92
93 /**
94  * Enumerations for Capture mode types.
95  */
96 typedef enum
97 {
98         CAPTURE_MODE_SINGLE_SHOT,
99         CAPTURE_MODE_MULTI_SHOT,
100         CAPTURE_MODE_ANTI_HANDSHAKE,
101 } CaptureModeType;
102
103 /**
104  * Enumerations for Camera control Strobe types.
105  */
106 typedef enum
107 {
108         GST_CAMERA_CONTROL_STROBE_CONTROL,
109         GST_CAMERA_CONTROL_STROBE_CAPABILITIES,
110         GST_CAMERA_CONTROL_STROBE_MODE,
111         GST_CAMERA_CONTROL_STROBE_STATUS,
112         GST_CAMERA_CONTROL_STROBE_EV,
113 } GstCameraControlStrobeType;
114
115 /**
116  * Enumerations for Camera control Face detection types.
117  */
118 typedef enum
119 {
120         GST_CAMERA_CONTROL_FACE_DETECT_MODE,
121         GST_CAMERA_CONTROL_FACE_DETECT_NUMBER,
122         GST_CAMERA_CONTROL_FACE_FOCUS_SELECT,
123         GST_CAMERA_CONTROL_FACE_SELECT_NUMBER,
124         GST_CAMERA_CONTROL_FACE_DETECT_STATUS,
125 } GstCameraControlFaceDetectType;
126
127 /**
128  * Enumerations for Camera control Zoom types.
129  */
130 typedef enum
131 {
132         GST_CAMERA_CONTROL_DIGITAL_ZOOM,
133         GST_CAMERA_CONTROL_OPTICAL_ZOOM,
134 } GstCameraControlZoomType;
135
136 /**
137  * Enumerations for Camera control Part color.
138  */
139 typedef enum
140 {
141         GST_CAMERA_CONTROL_PART_COLOR_SRC,
142         GST_CAMERA_CONTROL_PART_COLOR_DST,
143         GST_CAMERA_CONTROL_PART_COLOR_MODE,     
144 } GstCameraControlPartColorType;
145
146 /**
147  * Enumerations for Camera capture command.
148  */
149 typedef enum
150 {
151         GST_CAMERA_CONTROL_CAPTURE_COMMAND_NONE,
152         GST_CAMERA_CONTROL_CAPTURE_COMMAND_START,
153         GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP,
154         GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT,
155 } GstCameraControlCaptureCommand;
156
157
158
159 /////////////////////////////////
160 //  For Query functionalities  //
161 //  For Querying capabilities  //
162 /////////////////////////////////
163 /*! Use static size of structures for querying because of performance
164  */
165 /**
166  * Don't modify this sizes
167  * If want to modify this size, consider also under layer structure size
168  */
169 #define MAX_NUM_FMT_DESC        32
170 #define MAX_NUM_RESOLUTION      32
171 #define MAX_NUM_AVAILABLE_TPF   16
172 #define MAX_NUM_AVAILABLE_FPS   16
173 #define MAX_NUM_CTRL_LIST_INFO  64
174 #define MAX_NUM_CTRL_MENU       64
175 #define MAX_NUM_DETECTED_FACES  16
176 #define MAX_SZ_CTRL_NAME_STRING 32
177 #define MAX_SZ_DEV_NAME_STRING  32
178
179 /*! @struct GstCameraControlFracType
180  *  @brief For timeperframe as fraction type
181  *  Elapse time consumed by one frame, reverse of FPS
182  */
183 typedef struct _GstCameraControlFracType {
184         gint num;
185         gint den;
186 } GstCameraControlFracType;
187
188 /*! @struct GstCameraControlRectType
189  *  @brief For touch auto focusing area and face detection area
190  */
191 typedef struct _GstCameraControlRectType {
192         gint x;
193         gint y;
194         gint width;
195         gint height;
196 } GstCameraControlRectType;
197
198 /*! @struct GstCameraControlResolutionType
199  *  @brief For querying supported resolutions
200  */
201 typedef struct _GstCameraControlResolutionType {
202     gint w;
203     gint h;
204
205     /* Available time per frame(tpf) as each pixelformat */
206     gint num_avail_tpf;
207     GstCameraControlFracType tpf[MAX_NUM_AVAILABLE_TPF];
208 } GstCameraControlResolutionType;
209
210 /*! @struct GstCameraControlFraction
211  *  @brief Time per frame or frame per second will be expressed by this structure
212  *  Time per frame or frame per second will be expressed by this structure
213  */
214 typedef struct _GstCameraControlFraction {
215     int numerator;             /**< Upper number of fraction*/
216     int denominator;           /**< Lower number of fraction*/
217 } GstCameraControlFraction;
218
219 /*! @struct GstCameraControlFmtDescType
220  *  @brief For querying supported format type
221  */
222 typedef struct _GstCameraControlFmtDescType {
223     /* fourcc name of each pixelformat */
224     guint fcc;
225     gint fcc_use;
226
227     /* Available resolutions as each pixelformat */
228     gint num_resolution;
229     GstCameraControlResolutionType resolutions[MAX_NUM_RESOLUTION];
230 } GstCameraControlFmtDescType;
231
232 /*! @struct GstCameraControlCapsInfoType
233  *  @brief For querying image input capabilities
234  */
235 typedef struct _GstCameraControlCapsInfoType {
236     char dev_name[MAX_SZ_DEV_NAME_STRING];
237     int input_idx;
238     gint num_fmt_desc;
239     GstCameraControlFmtDescType fmt_desc[MAX_NUM_FMT_DESC];
240
241     int num_preview_resolution;
242     int preview_resolution_width[MAX_NUM_RESOLUTION];
243     int preview_resolution_height[MAX_NUM_RESOLUTION];
244
245     int num_capture_resolution;
246     int capture_resolution_width[MAX_NUM_RESOLUTION];
247     int capture_resolution_height[MAX_NUM_RESOLUTION];
248
249     int num_preview_fmt;
250     unsigned int preview_fmt[MAX_NUM_FMT_DESC];
251
252     int num_capture_fmt;
253     unsigned int capture_fmt[MAX_NUM_FMT_DESC];
254
255     int num_fps;
256     GstCameraControlFraction fps[MAX_NUM_AVAILABLE_FPS];
257 } GstCameraControlCapsInfoType;
258
259 /*! @struct GstCameraControlFaceInfo
260  *  @brief For face information
261  */
262 typedef struct _GstCameraControlFaceInfo {
263         int id;
264         int score;
265         GstCameraControlRectType rect;
266 } GstCameraControlFaceInfo;
267
268 /*! @struct GstCameraControlFaceDetectInfo
269  *  @brief For face detect information
270  */
271 typedef struct _GstCameraControlFaceDetectInfo {
272         int num_of_faces;
273         GstCameraControlFaceInfo face_info[MAX_NUM_DETECTED_FACES];
274 } GstCameraControlFaceDetectInfo;
275
276 /////////////////////////////
277 //  For Querying controls  //
278 /////////////////////////////
279 enum {
280     GST_CAMERA_CTRL_TYPE_RANGE = 0,
281     GST_CAMERA_CTRL_TYPE_BOOL,
282     GST_CAMERA_CTRL_TYPE_ARRAY,
283     GST_CAMERA_CTRL_TYPE_UNKNOWN,
284     GST_CAMERA_CTRL_TYPE_NUM,
285 };
286
287 /*! @struct GstCameraControlCtrlMenuType
288  *  @brief For querying menu of specified controls
289  */
290 typedef struct _GstCameraControlCtrlMenuType {
291     gint menu_index;
292     gchar menu_name[MAX_SZ_CTRL_NAME_STRING];
293 } GstCameraControlCtrlMenuType;
294
295 /*! @struct GstCameraControlCtrlInfoType
296  *  @brief For querying controls detail
297  */
298 typedef struct _GstCameraControlCtrlInfoType {
299     gint avsys_ctrl_id;
300     gint v4l2_ctrl_id;
301     gint ctrl_type;
302     gchar ctrl_name[MAX_SZ_CTRL_NAME_STRING];
303     gint min;
304     gint max;
305     gint step;
306     gint default_val;
307     gint num_ctrl_menu;
308     GstCameraControlCtrlMenuType ctrl_menu[MAX_NUM_CTRL_MENU];
309 } GstCameraControlCtrlInfoType;
310
311 /*! @struct GstCameraControlCtrlListInfoType
312  *  @brief For querying controls
313  */
314 typedef struct _GstCameraControlCtrlListInfoType {
315     gint num_ctrl_list_info;
316     GstCameraControlCtrlInfoType ctrl_info[MAX_NUM_CTRL_LIST_INFO];
317 } GstCameraControlCtrlListInfoType;
318
319 /* capabilities field */
320 #define GST_CAMERA_STROBE_CAP_NONE              0x0000  /* No strobe supported */
321 #define GST_CAMERA_STROBE_CAP_OFF               0x0001  /* Always flash off mode */
322 #define GST_CAMERA_STROBE_CAP_ON                0x0002  /* Always use flash light mode */
323 #define GST_CAMERA_STROBE_CAP_AUTO              0x0004  /* Flashlight works automatic */
324 #define GST_CAMERA_STROBE_CAP_REDEYE            0x0008  /* Red-eye reduction */
325 #define GST_CAMERA_STROBE_CAP_SLOWSYNC          0x0010  /* Slow sync */
326 #define GST_CAMERA_STROBE_CAP_FRONT_CURTAIN     0x0020  /* Front curtain */
327 #define GST_CAMERA_STROBE_CAP_REAR_CURTAIN      0x0040  /* Rear curtain */
328 #define GST_CAMERA_STROBE_CAP_PERMANENT         0x0080  /* keep turned on until turning off */
329 #define GST_CAMERA_STROBE_CAP_EXTERNAL          0x0100  /* use external strobe */
330
331 typedef struct _GstCameraControlExtraInfoType {
332     guint strobe_caps;                                   /**< Use above caps field */
333     guint detection_caps;                                /**< Just boolean */
334     guint reserved[4];
335 } GstCameraControlExtraInfoType;
336 /////////////////////////////////////
337 //  END For Query functionalities  //
338 /////////////////////////////////////
339
340
341 /**
342  * Enumerations for Camera control Part color.
343  */
344 typedef struct _GstCameraControlExifInfo {
345         /* Dynamic value */
346         guint32 exposure_time_numerator;    /* Exposure time, given in seconds */
347         guint32 exposure_time_denominator;
348         gint shutter_speed_numerator;       /* Shutter speed, given in APEX(Additive System Photographic Exposure) */
349         gint shutter_speed_denominator;
350         gint brigtness_numerator;           /* Value of brightness, before firing flash, given in APEX value */
351         gint brightness_denominator;
352         guint16 iso;                        /* Sensitivity value of sensor */
353         guint16 flash;                      /* Whether flash is fired(1) or not(0) */
354         gint metering_mode;                 /* metering mode in EXIF 2.2 */
355         gint exif_image_width;              /* Size of image */
356         gint exif_image_height;
357         gint exposure_bias_in_APEX;         /* Exposure bias in APEX standard */
358         gint software_used;                 /* Firmware S/W version */
359
360         /* Fixed value */
361         gint component_configuration;       /* color components arrangement */
362         gint colorspace;                    /* colorspace information */
363         gint focal_len_numerator;           /* Lens focal length */
364         gint focal_len_denominator;
365         gint aperture_f_num_numerator;      /* Aperture value */
366         gint aperture_f_num_denominator;
367         gint aperture_in_APEX;              /* Aperture value in APEX standard */
368         gint max_lens_aperture_in_APEX;     /* Max aperture value in APEX standard */
369 } GstCameraControlExifInfo;
370
371
372 typedef struct _GstCameraControlClass {
373         GTypeInterface klass;
374         GstCameraControlType camera_control_type;
375
376         /* virtual functions */
377         const GList*(*list_channels)                   (GstCameraControl *control);
378
379         gboolean        (*set_value)                   (GstCameraControl *control, GstCameraControlChannel *control_channel);
380         gboolean        (*get_value)                   (GstCameraControl *control, GstCameraControlChannel *control_channel);
381         gboolean        (*set_exposure)                (GstCameraControl *control, gint type, gint value1, gint value2);
382         gboolean        (*get_exposure)                (GstCameraControl *control, gint type, gint *value1, gint *value2);
383         gboolean        (*set_capture_mode)            (GstCameraControl *control, gint type, gint value);
384         gboolean        (*get_capture_mode)            (GstCameraControl *control, gint type, gint *value);
385         gboolean        (*set_strobe)                  (GstCameraControl *control, gint type, gint value);
386         gboolean        (*get_strobe)                  (GstCameraControl *control, gint type, gint *value);
387         gboolean        (*set_detect)                  (GstCameraControl *control, gint type, gint value);
388         gboolean        (*get_detect)                  (GstCameraControl *control, gint type, gint *value);
389         gboolean        (*set_zoom)                    (GstCameraControl *control, gint type, gint value);
390         gboolean        (*get_zoom)                    (GstCameraControl *control, gint type, gint *value);
391         gboolean        (*set_focus)                   (GstCameraControl *control, gint mode, gint range);
392         gboolean        (*get_focus)                   (GstCameraControl *control, gint *mode, gint *range);
393         gboolean        (*start_auto_focus)            (GstCameraControl *control);
394         gboolean        (*stop_auto_focus)             (GstCameraControl *control);
395         gboolean        (*set_focus_level)             (GstCameraControl *control, gint manual_level);
396         gboolean        (*get_focus_level)             (GstCameraControl *control, gint *manual_level);
397         gboolean        (*set_auto_focus_area)         (GstCameraControl *control, GstCameraControlRectType rect);
398         gboolean        (*get_auto_focus_area)         (GstCameraControl *control, GstCameraControlRectType *rect);
399         gboolean        (*set_wdr)                     (GstCameraControl *control, gint value);
400         gboolean        (*get_wdr)                     (GstCameraControl *control, gint *value);
401         gboolean        (*set_ahs)                     (GstCameraControl *control, gint value);
402         gboolean        (*get_ahs)                     (GstCameraControl *control, gint *value);
403         gboolean        (*set_part_color)              (GstCameraControl *control, gint type, gint value);
404         gboolean        (*get_part_color)              (GstCameraControl *control, gint type, gint *value);
405         gboolean        (*get_exif_info)               (GstCameraControl *control, GstCameraControlExifInfo *info);
406         gboolean        (*get_basic_dev_info)          (GstCameraControl *control, gint dev_id, GstCameraControlCapsInfoType *info);
407         gboolean        (*get_misc_dev_info)           (GstCameraControl *control, gint dev_id, GstCameraControlCtrlListInfoType *info);
408         gboolean        (*get_extra_dev_info)          (GstCameraControl *control, gint dev_id, GstCameraControlExtraInfoType *info);
409         void            (*set_capture_command)         (GstCameraControl *control, GstCameraControlCaptureCommand cmd);
410         gboolean        (*start_face_zoom)             (GstCameraControl *control, gint x, gint y, gint zoom_level);
411         gboolean        (*stop_face_zoom)              (GstCameraControl *control);
412
413         /* signals */
414         void (* value_changed)                          (GstCameraControl *control, GstCameraControlChannel *channel, gint value);
415 } GstCameraControlClass;
416
417 GType gst_camera_control_get_type(void);
418
419 /* virtual class function wrappers */
420 const GList*    gst_camera_control_list_channels        (GstCameraControl *control);
421
422 gboolean        gst_camera_control_set_value            (GstCameraControl *control, GstCameraControlChannel *control_channel);
423 gboolean        gst_camera_control_get_value            (GstCameraControl *control, GstCameraControlChannel *control_channel);
424 gboolean        gst_camera_control_set_exposure         (GstCameraControl *control, gint type, gint value1, gint value2);
425 gboolean        gst_camera_control_get_exposure         (GstCameraControl *control, gint type, gint *value1, gint *value2);
426 gboolean        gst_camera_control_set_capture_mode     (GstCameraControl *control, gint type, gint value);
427 gboolean        gst_camera_control_get_capture_mode     (GstCameraControl *control, gint type, gint *value);
428 gboolean        gst_camera_control_set_strobe           (GstCameraControl *control, gint type, gint value);
429 gboolean        gst_camera_control_get_strobe           (GstCameraControl *control, gint type, gint *value);
430 gboolean        gst_camera_control_set_detect           (GstCameraControl *control, gint type, gint value);
431 gboolean        gst_camera_control_get_detect           (GstCameraControl *control, gint type, gint *value);
432 gboolean        gst_camera_control_set_zoom             (GstCameraControl *control, gint type, gint value);
433 gboolean        gst_camera_control_get_zoom             (GstCameraControl *control, gint type, gint *value);
434 gboolean        gst_camera_control_set_focus            (GstCameraControl *control, gint mode, gint range);
435 gboolean        gst_camera_control_get_focus            (GstCameraControl *control, gint *mode, gint *range);
436 gboolean        gst_camera_control_start_auto_focus     (GstCameraControl *control);
437 gboolean        gst_camera_control_stop_auto_focus      (GstCameraControl *control);
438 gboolean        gst_camera_control_set_focus_level      (GstCameraControl *control, gint manual_level);
439 gboolean        gst_camera_control_get_focus_level      (GstCameraControl *control, gint *manual_level);
440 gboolean        gst_camera_control_set_auto_focus_area  (GstCameraControl *control, GstCameraControlRectType rect);
441 gboolean        gst_camera_control_get_auto_focus_area  (GstCameraControl *control, GstCameraControlRectType *rect);
442 gboolean        gst_camera_control_set_wdr              (GstCameraControl *control, gint value);
443 gboolean        gst_camera_control_get_wdr              (GstCameraControl *control, gint *value);
444 gboolean        gst_camera_control_set_ahs              (GstCameraControl *control, gint value);
445 gboolean        gst_camera_control_get_ahs              (GstCameraControl *control, gint *value);
446 gboolean        gst_camera_control_set_part_color       (GstCameraControl *control, gint type, gint value);
447 gboolean        gst_camera_control_get_part_color       (GstCameraControl *control, gint type, gint *value);
448 gboolean        gst_camera_control_get_exif_info        (GstCameraControl *control, GstCameraControlExifInfo *info);
449 gboolean        gst_camera_control_get_basic_dev_info   (GstCameraControl *control, gint dev_id, GstCameraControlCapsInfoType *info);
450 gboolean        gst_camera_control_get_misc_dev_info    (GstCameraControl *control, gint dev_id, GstCameraControlCtrlListInfoType *info);
451 gboolean        gst_camera_control_get_extra_dev_info   (GstCameraControl *control, gint dev_id, GstCameraControlExtraInfoType *info);
452 void            gst_camera_control_set_capture_command  (GstCameraControl *control, GstCameraControlCaptureCommand cmd);
453 gboolean        gst_camera_control_start_face_zoom      (GstCameraControl *control, gint x, gint y, gint zoom_level);
454 gboolean        gst_camera_control_stop_face_zoom       (GstCameraControl *control);
455
456
457 /* trigger signal */
458 void            gst_camera_control_value_changed        (GstCameraControl *control, GstCameraControlChannel *control_channel, gint value);
459
460 G_END_DECLS
461
462 #endif /* __GST_CAMERA_CONTROL_H__ */