Git init
[framework/multimedia/gst-plugins-base0.10.git] / gst-libs / gst / interfaces / cameracontrol.h
1 /*
2  * GStreamer Camera Control
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_SZ_CTRL_NAME_STRING 32
176 #define MAX_SZ_DEV_NAME_STRING  32
177
178 /*! @struct GstCameraControlFracType
179  *  @brief For timeperframe as fraction type
180  *  Elapse time consumed by one frame, reverse of FPS
181  */
182 typedef struct {
183     gint num;
184     gint den;
185 }GstCameraControlFracType;
186
187 /*! @struct GstCameraControlRectType
188  *  @brief For touch auto focusing area
189  */
190 typedef struct {
191         gint x;
192         gint y;
193         gint width;
194         gint height;
195 }GstCameraControlRectType;
196
197 /*! @struct GstCameraControlResolutionType
198  *  @brief For querying supported resolutions
199  */
200 typedef struct {
201     gint w;
202     gint h;
203
204     /* Available time per frame(tpf) as each pixelformat */
205     gint num_avail_tpf;
206     GstCameraControlFracType tpf[MAX_NUM_AVAILABLE_TPF];
207 } GstCameraControlResolutionType;
208
209 /*! @struct GstCameraControlFraction
210  *  @brief Time per frame or frame per second will be expressed by this structure
211  *  Time per frame or frame per second will be expressed by this structure
212  */
213 typedef struct {
214     int numerator;             /**< Upper number of fraction*/
215     int denominator;           /**< Lower number of fraction*/
216 } GstCameraControlFraction;
217
218 /*! @struct GstCameraControlFmtDescType
219  *  @brief For querying supported format type
220  */
221 typedef struct {
222     /* fourcc name of each pixelformat */
223     guint fcc;
224     gint fcc_use;
225
226     /* Available resolutions as each pixelformat */
227     gint num_resolution;
228     GstCameraControlResolutionType resolutions[MAX_NUM_RESOLUTION];
229 } GstCameraControlFmtDescType;
230
231 /*! @struct GstCameraControlCapsInfoType
232  *  @brief For querying image input capabilities
233  */
234 typedef struct {
235     char dev_name[MAX_SZ_DEV_NAME_STRING];
236     int input_idx;
237     gint num_fmt_desc;
238     GstCameraControlFmtDescType fmt_desc[MAX_NUM_FMT_DESC];
239
240     int num_preview_resolution;
241     int preview_resolution_width[MAX_NUM_RESOLUTION];
242     int preview_resolution_height[MAX_NUM_RESOLUTION];
243
244     int num_capture_resolution;
245     int capture_resolution_width[MAX_NUM_RESOLUTION];
246     int capture_resolution_height[MAX_NUM_RESOLUTION];
247
248     int num_preview_fmt;
249     unsigned int preview_fmt[MAX_NUM_FMT_DESC];
250
251     int num_capture_fmt;
252     unsigned int capture_fmt[MAX_NUM_FMT_DESC];
253
254     int num_fps;
255     GstCameraControlFraction fps[MAX_NUM_AVAILABLE_FPS];
256 } GstCameraControlCapsInfoType;
257
258 /////////////////////////////
259 //  For Querying controls  //
260 /////////////////////////////
261 enum {
262     GST_CAMERA_CTRL_TYPE_RANGE = 0,
263     GST_CAMERA_CTRL_TYPE_BOOL,
264     GST_CAMERA_CTRL_TYPE_ARRAY,
265     GST_CAMERA_CTRL_TYPE_UNKNOWN,
266     GST_CAMERA_CTRL_TYPE_NUM,
267 };
268
269 /*! @struct GstCameraControlCtrlMenuType
270  *  @brief For querying menu of specified controls
271  */
272 typedef struct {
273     gint menu_index;
274     gchar menu_name[MAX_SZ_CTRL_NAME_STRING];
275 }GstCameraControlCtrlMenuType;
276
277 /*! @struct GstCameraControlCtrlInfoType
278  *  @brief For querying controls detail
279  */
280 typedef struct {
281     gint avsys_ctrl_id;
282     gint v4l2_ctrl_id;
283     gint ctrl_type;
284     gchar ctrl_name[MAX_SZ_CTRL_NAME_STRING];
285     gint min;
286     gint max;
287     gint step;
288     gint default_val;
289     gint num_ctrl_menu;
290     GstCameraControlCtrlMenuType ctrl_menu[MAX_NUM_CTRL_MENU];
291 } GstCameraControlCtrlInfoType;
292
293 /*! @struct GstCameraControlCtrlListInfoType
294  *  @brief For querying controls
295  */
296 typedef struct {
297     gint num_ctrl_list_info;
298     GstCameraControlCtrlInfoType ctrl_info[MAX_NUM_CTRL_LIST_INFO];
299 } GstCameraControlCtrlListInfoType;
300
301 /* capabilities field */
302 #define GST_CAMERA_STROBE_CAP_NONE              0x0000  /* No strobe supported */
303 #define GST_CAMERA_STROBE_CAP_OFF               0x0001  /* Always flash off mode */
304 #define GST_CAMERA_STROBE_CAP_ON                0x0002  /* Always use flash light mode */
305 #define GST_CAMERA_STROBE_CAP_AUTO              0x0004  /* Flashlight works automatic */
306 #define GST_CAMERA_STROBE_CAP_REDEYE            0x0008  /* Red-eye reduction */
307 #define GST_CAMERA_STROBE_CAP_SLOWSYNC          0x0010  /* Slow sync */
308 #define GST_CAMERA_STROBE_CAP_FRONT_CURTAIN     0x0020  /* Front curtain */
309 #define GST_CAMERA_STROBE_CAP_REAR_CURTAIN      0x0040  /* Rear curtain */
310 #define GST_CAMERA_STROBE_CAP_PERMANENT         0x0080  /* keep turned on until turning off */
311 #define GST_CAMERA_STROBE_CAP_EXTERNAL          0x0100  /* use external strobe */
312
313 typedef struct {
314     guint strobe_caps;                                   /**< Use above caps field */
315     guint detection_caps;                                /**< Just boolean */
316     guint reserved[4];
317 } GstCameraControlExtraInfoType;
318 /////////////////////////////////////
319 //  END For Query functionalities  //
320 /////////////////////////////////////
321
322
323 /**
324  * Enumerations for Camera control Part color.
325  */
326 typedef struct _GstCameraControlExifInfo
327 {
328     /* Dynamic value */
329     guint32 exposure_time_numerator;       //Exposure time, given in seconds
330     guint32 exposure_time_denominator;
331     gint shutter_speed_numerator;                //Shutter speed, given in APEX(Additive System Photographic Exposure)
332     gint shutter_speed_denominator;
333     gint brigtness_numerator;                    //Value of brightness, before firing flash, given in APEX value
334     gint brightness_denominator;
335     guint16 iso;                     //Sensitivity value of sensor
336     guint16 flash;                   //Whether flash is fired(1) or not(0)
337     gint metering_mode;                          //metering mode in EXIF 2.2
338     gint exif_image_width;                       //Size of image
339     gint exif_image_height;                      //
340     gint exposure_bias_in_APEX;                  //Exposure bias in APEX standard
341     gint software_used;                          //Firmware S/W version
342
343
344     /* Fixed value */
345     gint component_configuration;                //color components arrangement (YCbCr = 1230)
346     gint colorspace;                             //colorspace information (sRGB=1)
347     gint focal_len_numerator;                    //Lens focal length (f = 4.5mm)
348     gint focal_len_denominator;
349     gint aperture_f_num_numerator;               //Aperture value (f_num = 2.8)
350     gint aperture_f_num_denominator;
351     gint aperture_in_APEX;                       //Aperture value in APEX standard
352     gint max_lens_aperture_in_APEX;              //Max aperture value in APEX standard
353 } GstCameraControlExifInfo;
354
355
356 typedef struct _GstCameraControlClass {
357         GTypeInterface klass;
358         GstCameraControlType camera_control_type;
359
360         /* virtual functions */
361         const GList*(* list_channels)           ( GstCameraControl* control );
362
363         gboolean        (* set_value)                   ( GstCameraControl* control, GstCameraControlChannel* control_channel );
364         gboolean        (* get_value)                   ( GstCameraControl* control, GstCameraControlChannel* control_channel );
365         gboolean        (* set_exposure)                ( GstCameraControl* control, gint type, gint value1, gint value2 );
366         gboolean        (* get_exposure)                ( GstCameraControl* control, gint type, gint* value1, gint* value2 );
367         gboolean        (* set_capture_mode)    ( GstCameraControl* control, gint type, gint value );
368         gboolean        (* get_capture_mode)    ( GstCameraControl* control, gint type, gint* value );  
369         gboolean        (* set_strobe)                  ( GstCameraControl* control, gint type, gint value );
370         gboolean        (* get_strobe)                  ( GstCameraControl* control, gint type, gint *value );
371         gboolean        (* set_detect)                  ( GstCameraControl* control, gint type, gint value );
372         gboolean        (* get_detect)                  ( GstCameraControl* control, gint type, gint* value );  
373         gboolean        (* set_zoom)                    ( GstCameraControl* control, gint type, gint value );
374         gboolean        (* get_zoom)                    ( GstCameraControl* control, gint type, gint* value );
375         gboolean        (* set_focus)                   ( GstCameraControl* control, gint mode, gint range );
376         gboolean        (* get_focus)                   ( GstCameraControl* control, gint* mode, gint* range );
377         gboolean        (* start_auto_focus)    ( GstCameraControl* control);
378         gboolean        (* stop_auto_focus)             ( GstCameraControl* control);
379         gboolean        (* set_focus_level)             ( GstCameraControl* control, gint manual_level);
380         gboolean        (* get_focus_level)             ( GstCameraControl* control, gint* manual_level);
381         gboolean        (* set_auto_focus_area) ( GstCameraControl* control, GstCameraControlRectType rect );
382         gboolean        (* get_auto_focus_area) ( GstCameraControl* control, GstCameraControlRectType* rect );
383         gboolean        (* set_wdr)                             ( GstCameraControl* control, gint value);
384         gboolean        (* get_wdr)                             ( GstCameraControl* control, gint *value);
385         gboolean        (* set_ahs)                             ( GstCameraControl* control, gint value);
386         gboolean        (* get_ahs)                             ( GstCameraControl* control, gint *value);
387         gboolean        (* set_part_color)              ( GstCameraControl* control, gint type, gint value);
388         gboolean        (* get_part_color)              ( GstCameraControl* control, gint type, gint* value);
389         gboolean        (* get_exif_info)               ( GstCameraControl* control, GstCameraControlExifInfo* info);
390         gboolean        (* get_basic_dev_info)          ( GstCameraControl* control, gint dev_id, GstCameraControlCapsInfoType* info);
391         gboolean        (* get_misc_dev_info)           ( GstCameraControl* control, gint dev_id, GstCameraControlCtrlListInfoType* info);
392         gboolean        (* get_extra_dev_info)          ( GstCameraControl* control, gint dev_id, GstCameraControlExtraInfoType* info);
393         void            (* set_capture_command)         ( GstCameraControl* control, GstCameraControlCaptureCommand cmd );
394
395         /* signals */
396         void (* value_changed)                          ( GstCameraControl* control, GstCameraControlChannel* channel, gint value );
397 } GstCameraControlClass;
398
399 GType   gst_camera_control_get_type      (void);
400
401 /* virtual class function wrappers */
402 const GList*    gst_camera_control_list_channels        ( GstCameraControl* control );
403
404 gboolean        gst_camera_control_set_value            ( GstCameraControl* control, GstCameraControlChannel* control_channel );
405 gboolean        gst_camera_control_get_value            ( GstCameraControl* control, GstCameraControlChannel* control_channel );
406 gboolean        gst_camera_control_set_exposure         ( GstCameraControl* control, gint type, gint value1, gint value2 );
407 gboolean        gst_camera_control_get_exposure         ( GstCameraControl* control, gint type, gint* value1, gint* value2 );
408 gboolean        gst_camera_control_set_capture_mode     ( GstCameraControl* control, gint type, gint value );
409 gboolean        gst_camera_control_get_capture_mode     ( GstCameraControl* control, gint type, gint* value );
410 gboolean        gst_camera_control_set_strobe           ( GstCameraControl* control, gint type, gint value );
411 gboolean        gst_camera_control_get_strobe           ( GstCameraControl* control, gint type, gint *value );
412 gboolean        gst_camera_control_set_detect           ( GstCameraControl* control, gint type, gint value );
413 gboolean        gst_camera_control_get_detect           ( GstCameraControl* control, gint type, gint* value );
414 gboolean        gst_camera_control_set_zoom                     ( GstCameraControl* control, gint type, gint value );
415 gboolean        gst_camera_control_get_zoom                     ( GstCameraControl* control, gint type, gint* value );
416 gboolean        gst_camera_control_set_focus            ( GstCameraControl* control, gint mode, gint range );
417 gboolean        gst_camera_control_get_focus            ( GstCameraControl* control, gint* mode, gint* range );
418 gboolean        gst_camera_control_start_auto_focus     ( GstCameraControl* control);
419 gboolean        gst_camera_control_stop_auto_focus      ( GstCameraControl* control);
420 gboolean        gst_camera_control_set_focus_level      ( GstCameraControl* control, gint manual_level );
421 gboolean        gst_camera_control_get_focus_level      ( GstCameraControl* control, gint* manual_level );
422 gboolean        gst_camera_control_set_auto_focus_area  ( GstCameraControl* control, GstCameraControlRectType rect );
423 gboolean        gst_camera_control_get_auto_focus_area  ( GstCameraControl* control, GstCameraControlRectType* rect );
424 gboolean        gst_camera_control_set_wdr                      ( GstCameraControl* control, gint value);
425 gboolean        gst_camera_control_get_wdr                      ( GstCameraControl* control, gint* value);
426 gboolean        gst_camera_control_set_ahs                      ( GstCameraControl* control, gint value);
427 gboolean        gst_camera_control_get_ahs                      ( GstCameraControl* control, gint* value);
428 gboolean        gst_camera_control_set_part_color       ( GstCameraControl* control, gint type, gint value);
429 gboolean        gst_camera_control_get_part_color       ( GstCameraControl* control, gint type, gint* value);
430 gboolean        gst_camera_control_get_exif_info        ( GstCameraControl* control, GstCameraControlExifInfo* info);
431 gboolean        gst_camera_control_get_basic_dev_info   ( GstCameraControl* control, gint dev_id, GstCameraControlCapsInfoType* info);
432 gboolean        gst_camera_control_get_misc_dev_info    ( GstCameraControl* control, gint dev_id, GstCameraControlCtrlListInfoType* info);
433 gboolean        gst_camera_control_get_extra_dev_info   ( GstCameraControl* control, gint dev_id, GstCameraControlExtraInfoType* info);
434 void            gst_camera_control_set_capture_command  ( GstCameraControl* control, GstCameraControlCaptureCommand cmd );
435
436
437 /* trigger signal */
438 void            gst_camera_control_value_changed        ( GstCameraControl* control, GstCameraControlChannel* control_channel, gint value );
439
440 G_END_DECLS
441
442 #endif /* __GST_CAMERA_CONTROL_H__ */