2 * GStreamer Camera Control Interface
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
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)
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.
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
24 /* ===========================================================================================
25 EDIT HISTORY FOR MODULE
27 This section contains comments describing changes made to the module.
28 Notice that changes are listed in reverse chronological order.
30 when who what, where, why
31 --------- ------------------------ ------------------------------------------------------
32 12/09/08 jm80.yang@samsung.com Created
34 =========================================================================================== */
36 #ifndef __GST_CAMERA_CONTROL_H__
37 #define __GST_CAMERA_CONTROL_H__
40 #include <gst/video/video-prelude.h>
41 #include <gst/video/cameracontrolchannel.h>
42 //#include <gst/interfaces/interfaces-enumtypes.h>
46 #define GST_TYPE_CAMERA_CONTROL \
47 (gst_camera_control_get_type())
48 #define GST_CAMERA_CONTROL(obj) \
49 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CAMERA_CONTROL, GstCameraControl))
50 #define GST_CAMERA_CONTROL_GET_CLASS(inst) \
51 (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_CAMERA_CONTROL, GstCameraControlClass))
52 #define GST_CAMERA_CONTROL_CLASS(klass) \
53 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CAMERA_CONTROL, GstCameraControlClass))
54 #define GST_IS_CAMERA_CONTROL(obj) \
55 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CAMERA_CONTROL))
56 #define GST_IS_CAMERA_CONTROL_CLASS(klass) \
57 (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CAMERA_CONTROL))
58 #define GST_CAMERA_CONTROL_TYPE(klass) (klass->camera_control_type)
61 typedef struct _GstCameraControl GstCameraControl;
66 GST_CAMERA_CONTROL_HARDWARE,
67 GST_CAMERA_CONTROL_SOFTWARE
68 } GstCameraControlType;
70 /* enumerations for Camera control Exposure types */
73 GST_CAMERA_CONTROL_F_NUMBER,
74 GST_CAMERA_CONTROL_SHUTTER_SPEED,
75 GST_CAMERA_CONTROL_ISO,
76 GST_CAMERA_CONTROL_PROGRAM_MODE,
77 GST_CAMERA_CONTROL_EXPOSURE_MODE,
78 GST_CAMERA_CONTROL_EXPOSURE_VALUE
79 } GstCameraControlExposureType;
81 /* enumerations for Camera control Capture mode types */
84 GST_CAMERA_CONTROL_CAPTURE_MODE,
85 GST_CAMERA_CONTROL_OUTPUT_MODE,
86 GST_CAMERA_CONTROL_FRAME_COUNT,
87 GST_CAMERA_CONTROL_JPEG_QUALITY
88 } GstCameraControlCaptureModeType;
90 /* enumerations for Camera control Strobe types */
93 GST_CAMERA_CONTROL_STROBE_CONTROL,
94 GST_CAMERA_CONTROL_STROBE_CAPABILITIES,
95 GST_CAMERA_CONTROL_STROBE_MODE,
96 GST_CAMERA_CONTROL_STROBE_STATUS,
97 GST_CAMERA_CONTROL_STROBE_EV
98 } GstCameraControlStrobeType;
100 /* enumerations for Camera control Face detection types */
103 GST_CAMERA_CONTROL_FACE_DETECT_MODE,
104 GST_CAMERA_CONTROL_FACE_DETECT_NUMBER,
105 GST_CAMERA_CONTROL_FACE_FOCUS_SELECT,
106 GST_CAMERA_CONTROL_FACE_SELECT_NUMBER,
107 GST_CAMERA_CONTROL_FACE_DETECT_STATUS
108 } GstCameraControlFaceDetectType;
110 /* enumerations for Camera control Zoom types */
113 GST_CAMERA_CONTROL_DIGITAL_ZOOM,
114 GST_CAMERA_CONTROL_OPTICAL_ZOOM
115 } GstCameraControlZoomType;
117 /* enumerations for Camera control Part color */
120 GST_CAMERA_CONTROL_PART_COLOR_SRC,
121 GST_CAMERA_CONTROL_PART_COLOR_DST,
122 GST_CAMERA_CONTROL_PART_COLOR_MODE
123 } GstCameraControlPartColorType;
125 /* enumerations for Camera capture command */
128 GST_CAMERA_CONTROL_CAPTURE_COMMAND_NONE,
129 GST_CAMERA_CONTROL_CAPTURE_COMMAND_START,
130 GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP,
131 GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT
132 } GstCameraControlCaptureCommand;
134 /* enumerations for Camera record command */
137 GST_CAMERA_CONTROL_RECORD_COMMAND_NONE,
138 GST_CAMERA_CONTROL_RECORD_COMMAND_START,
139 GST_CAMERA_CONTROL_RECORD_COMMAND_STOP
140 } GstCameraControlRecordCommand;
142 /////////////////////////////////
143 // For Query functionalities //
144 // For Querying capabilities //
145 /////////////////////////////////
146 #define GST_CAMERA_CONTROL_MAX_NUM_FMT_DESC 32
147 #define GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION 32
148 #define GST_CAMERA_CONTROL_MAX_NUM_AVAILABLE_TPF 16
149 #define GST_CAMERA_CONTROL_MAX_NUM_AVAILABLE_FPS 16
150 #define GST_CAMERA_CONTROL_MAX_NUM_CTRL_LIST_INFO 64
151 #define GST_CAMERA_CONTROL_MAX_NUM_CTRL_MENU 64
152 #define GST_CAMERA_CONTROL_MAX_NUM_DETECTED_FACES 16
153 #define GST_CAMERA_CONTROL_MAX_SZ_CTRL_NAME_STRING 32
154 #define GST_CAMERA_CONTROL_MAX_SZ_DEV_NAME_STRING 32
156 /*! @struct GstCameraControlFracType
157 * @brief For timeperframe as fraction type
158 * Elapse time consumed by one frame, reverse of FPS
160 typedef struct _GstCameraControlFracType {
163 } GstCameraControlFracType;
165 /*! @struct GstCameraControlRectType
166 * @brief For touch auto focusing area and face detection area
168 typedef struct _GstCameraControlRectType {
173 } GstCameraControlRectType;
175 /*! @struct GstCameraControlResolutionType
176 * @brief For querying supported resolutions
178 typedef struct _GstCameraControlResolutionType {
182 /* Available time per frame(tpf) as each pixelformat */
184 GstCameraControlFracType tpf[GST_CAMERA_CONTROL_MAX_NUM_AVAILABLE_TPF];
185 } GstCameraControlResolutionType;
187 /*! @struct GstCameraControlFmtDescType
188 * @brief For querying supported format type
190 typedef struct _GstCameraControlFmtDescType {
191 /* fourcc name of each pixelformat */
195 /* Available resolutions as each pixelformat */
197 GstCameraControlResolutionType resolutions[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
198 } GstCameraControlFmtDescType;
200 /*! @struct GstCameraControlCapsInfoType
201 * @brief For querying image input capabilities
203 typedef struct _GstCameraControlCapsInfoType {
204 char dev_name[GST_CAMERA_CONTROL_MAX_SZ_DEV_NAME_STRING];
207 GstCameraControlFmtDescType fmt_desc[GST_CAMERA_CONTROL_MAX_NUM_FMT_DESC];
209 int num_preview_resolution;
210 int preview_resolution_width[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
211 int preview_resolution_height[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
213 int num_capture_resolution;
214 int capture_resolution_width[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
215 int capture_resolution_height[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
218 unsigned int preview_fmt[GST_CAMERA_CONTROL_MAX_NUM_FMT_DESC];
221 unsigned int capture_fmt[GST_CAMERA_CONTROL_MAX_NUM_FMT_DESC];
224 GstCameraControlFracType fps[GST_CAMERA_CONTROL_MAX_NUM_AVAILABLE_FPS];
225 } GstCameraControlCapsInfoType;
227 /*! @struct GstCameraControlFaceInfo
228 * @brief For face information
230 typedef struct _GstCameraControlFaceInfo {
233 GstCameraControlRectType rect;
234 } GstCameraControlFaceInfo;
236 /*! @struct GstCameraControlFaceDetectInfo
237 * @brief For face detect information
239 typedef struct _GstCameraControlFaceDetectInfo {
241 GstCameraControlFaceInfo face_info[GST_CAMERA_CONTROL_MAX_NUM_DETECTED_FACES];
242 } GstCameraControlFaceDetectInfo;
244 /////////////////////////////
245 // For Querying controls //
246 /////////////////////////////
248 GST_CAMERA_CTRL_TYPE_RANGE = 0,
249 GST_CAMERA_CTRL_TYPE_BOOL,
250 GST_CAMERA_CTRL_TYPE_ARRAY,
251 GST_CAMERA_CTRL_TYPE_UNKNOWN,
252 GST_CAMERA_CTRL_TYPE_NUM,
255 /*! @struct GstCameraControlCtrlMenuType
256 * @brief For querying menu of specified controls
258 typedef struct _GstCameraControlCtrlMenuType {
260 gchar menu_name[GST_CAMERA_CONTROL_MAX_SZ_CTRL_NAME_STRING];
261 } GstCameraControlCtrlMenuType;
263 /*! @struct GstCameraControlCtrlInfoType
264 * @brief For querying controls detail
266 typedef struct _GstCameraControlCtrlInfoType {
270 gchar ctrl_name[GST_CAMERA_CONTROL_MAX_SZ_CTRL_NAME_STRING];
276 GstCameraControlCtrlMenuType ctrl_menu[GST_CAMERA_CONTROL_MAX_NUM_CTRL_MENU];
277 } GstCameraControlCtrlInfoType;
279 /*! @struct GstCameraControlCtrlListInfoType
280 * @brief For querying controls
282 typedef struct _GstCameraControlCtrlListInfoType {
283 gint num_ctrl_list_info;
284 GstCameraControlCtrlInfoType ctrl_info[GST_CAMERA_CONTROL_MAX_NUM_CTRL_LIST_INFO];
285 } GstCameraControlCtrlListInfoType;
287 /* capabilities field */
288 #define GST_CAMERA_STROBE_CAP_NONE 0x0000 /* No strobe supported */
289 #define GST_CAMERA_STROBE_CAP_OFF 0x0001 /* Always flash off mode */
290 #define GST_CAMERA_STROBE_CAP_ON 0x0002 /* Always use flash light mode */
291 #define GST_CAMERA_STROBE_CAP_AUTO 0x0004 /* Flashlight works automatic */
292 #define GST_CAMERA_STROBE_CAP_REDEYE 0x0008 /* Red-eye reduction */
293 #define GST_CAMERA_STROBE_CAP_SLOWSYNC 0x0010 /* Slow sync */
294 #define GST_CAMERA_STROBE_CAP_FRONT_CURTAIN 0x0020 /* Front curtain */
295 #define GST_CAMERA_STROBE_CAP_REAR_CURTAIN 0x0040 /* Rear curtain */
296 #define GST_CAMERA_STROBE_CAP_PERMANENT 0x0080 /* keep turned on until turning off */
297 #define GST_CAMERA_STROBE_CAP_EXTERNAL 0x0100 /* use external strobe */
299 typedef struct _GstCameraControlExtraInfoType {
300 guint strobe_caps; /* Use above caps field */
301 guint detection_caps; /* Just boolean */
303 } GstCameraControlExtraInfoType;
304 /////////////////////////////////////
305 // END For Query functionalities //
306 /////////////////////////////////////
309 /* structure for Camera control EXIF information */
310 typedef struct _GstCameraControlExifInfo {
312 guint32 exposure_time_numerator; /* Exposure time, given in seconds */
313 guint32 exposure_time_denominator;
314 gint shutter_speed_numerator; /* Shutter speed, given in APEX(Additive System Photographic Exposure) */
315 gint shutter_speed_denominator;
316 gint brigtness_numerator; /* Value of brightness, before firing flash, given in APEX value */
317 gint brightness_denominator;
318 guint16 iso; /* Sensitivity value of sensor */
319 guint16 flash; /* Whether flash is fired(1) or not(0) */
320 gint metering_mode; /* metering mode in EXIF 2.2 */
321 gint exif_image_width; /* Size of image */
322 gint exif_image_height;
323 gint exposure_bias_in_APEX; /* Exposure bias in APEX standard */
324 gint software_used; /* Firmware S/W version */
327 gint component_configuration; /* color components arrangement */
328 gint colorspace; /* colorspace information */
329 gint focal_len_numerator; /* Lens focal length */
330 gint focal_len_denominator;
331 gint aperture_f_num_numerator; /* Aperture value */
332 gint aperture_f_num_denominator;
333 gint aperture_in_APEX; /* Aperture value in APEX standard */
334 gint max_lens_aperture_in_APEX; /* Max aperture value in APEX standard */
335 } GstCameraControlExifInfo;
337 /* structure for camera control class */
338 typedef struct _GstCameraControlClass {
339 GTypeInterface klass;
340 GstCameraControlType camera_control_type;
342 /* virtual functions */
343 const GList* (*list_channels) (GstCameraControl *control);
344 gboolean (*set_value) (GstCameraControl *control, GstCameraControlChannel *control_channel, gint value);
345 gboolean (*get_value) (GstCameraControl *control, GstCameraControlChannel *control_channel, gint *value);
346 gboolean (*set_exposure) (GstCameraControl *control, gint type, gint value1, gint value2);
347 gboolean (*get_exposure) (GstCameraControl *control, gint type, gint *value1, gint *value2);
348 gboolean (*set_capture_mode) (GstCameraControl *control, gint type, gint value);
349 gboolean (*get_capture_mode) (GstCameraControl *control, gint type, gint *value);
350 gboolean (*set_strobe) (GstCameraControl *control, gint type, gint value);
351 gboolean (*get_strobe) (GstCameraControl *control, gint type, gint *value);
352 gboolean (*set_detect) (GstCameraControl *control, gint type, gint value);
353 gboolean (*get_detect) (GstCameraControl *control, gint type, gint *value);
354 gboolean (*set_zoom) (GstCameraControl *control, gint type, gint value);
355 gboolean (*get_zoom) (GstCameraControl *control, gint type, gint *value);
356 gboolean (*set_focus) (GstCameraControl *control, gint mode, gint range);
357 gboolean (*get_focus) (GstCameraControl *control, gint *mode, gint *range);
358 gboolean (*start_auto_focus) (GstCameraControl *control);
359 gboolean (*stop_auto_focus) (GstCameraControl *control);
360 gboolean (*set_focus_level) (GstCameraControl *control, gint manual_level);
361 gboolean (*get_focus_level) (GstCameraControl *control, gint *manual_level);
362 gboolean (*set_auto_focus_area) (GstCameraControl *control, GstCameraControlRectType rect);
363 gboolean (*get_auto_focus_area) (GstCameraControl *control, GstCameraControlRectType *rect);
364 gboolean (*set_wdr) (GstCameraControl *control, gint value);
365 gboolean (*get_wdr) (GstCameraControl *control, gint *value);
366 gboolean (*set_ahs) (GstCameraControl *control, gint value);
367 gboolean (*get_ahs) (GstCameraControl *control, gint *value);
368 gboolean (*set_part_color) (GstCameraControl *control, gint type, gint value);
369 gboolean (*get_part_color) (GstCameraControl *control, gint type, gint *value);
370 gboolean (*get_exif_info) (GstCameraControl *control, GstCameraControlExifInfo *info);
371 gboolean (*get_basic_dev_info) (GstCameraControl *control, gint dev_id, GstCameraControlCapsInfoType *info);
372 gboolean (*get_misc_dev_info) (GstCameraControl *control, gint dev_id, GstCameraControlCtrlListInfoType *info);
373 gboolean (*get_extra_dev_info) (GstCameraControl *control, gint dev_id, GstCameraControlExtraInfoType *info);
374 void (*set_capture_command) (GstCameraControl *control, GstCameraControlCaptureCommand cmd);
375 void (*set_record_command) (GstCameraControl *control, GstCameraControlRecordCommand cmd);
376 gboolean (*start_face_zoom) (GstCameraControl *control, gint x, gint y, gint zoom_level);
377 gboolean (*stop_face_zoom) (GstCameraControl *control);
378 gboolean (*set_ae_lock) (GstCameraControl *control, gboolean lock);
379 gboolean (*get_ae_lock) (GstCameraControl *control, gboolean *lock);
380 gboolean (*set_awb_lock) (GstCameraControl *control, gboolean lock);
381 gboolean (*get_awb_lock) (GstCameraControl *control, gboolean *lock);
382 gboolean (*set_user_buffer_fd) (GstCameraControl *control, int *fds, int number);
385 void (* value_changed) (GstCameraControl *control, GstCameraControlChannel *channel, gint value);
386 } GstCameraControlClass;
389 GType gst_camera_control_get_type(void);
392 const GList* gst_camera_control_list_channels (GstCameraControl *control);
395 gboolean gst_camera_control_set_value (GstCameraControl *control, GstCameraControlChannel *control_channel, gint value);
398 gboolean gst_camera_control_get_value (GstCameraControl *control, GstCameraControlChannel *control_channel, gint *value);
401 gboolean gst_camera_control_set_exposure (GstCameraControl *control, gint type, gint value1, gint value2);
404 gboolean gst_camera_control_get_exposure (GstCameraControl *control, gint type, gint *value1, gint *value2);
407 gboolean gst_camera_control_set_capture_mode (GstCameraControl *control, gint type, gint value);
410 gboolean gst_camera_control_get_capture_mode (GstCameraControl *control, gint type, gint *value);
413 gboolean gst_camera_control_set_strobe (GstCameraControl *control, gint type, gint value);
416 gboolean gst_camera_control_get_strobe (GstCameraControl *control, gint type, gint *value);
419 gboolean gst_camera_control_set_detect (GstCameraControl *control, gint type, gint value);
422 gboolean gst_camera_control_get_detect (GstCameraControl *control, gint type, gint *value);
425 gboolean gst_camera_control_set_zoom (GstCameraControl *control, gint type, gint value);
428 gboolean gst_camera_control_get_zoom (GstCameraControl *control, gint type, gint *value);
431 gboolean gst_camera_control_set_focus (GstCameraControl *control, gint mode, gint range);
434 gboolean gst_camera_control_get_focus (GstCameraControl *control, gint *mode, gint *range);
437 gboolean gst_camera_control_start_auto_focus (GstCameraControl *control);
440 gboolean gst_camera_control_stop_auto_focus (GstCameraControl *control);
443 gboolean gst_camera_control_set_focus_level (GstCameraControl *control, gint manual_level);
446 gboolean gst_camera_control_get_focus_level (GstCameraControl *control, gint *manual_level);
449 gboolean gst_camera_control_set_auto_focus_area (GstCameraControl *control, GstCameraControlRectType rect);
452 gboolean gst_camera_control_get_auto_focus_area (GstCameraControl *control, GstCameraControlRectType *rect);
455 gboolean gst_camera_control_set_wdr (GstCameraControl *control, gint value);
458 gboolean gst_camera_control_get_wdr (GstCameraControl *control, gint *value);
461 gboolean gst_camera_control_set_ahs (GstCameraControl *control, gint value);
464 gboolean gst_camera_control_get_ahs (GstCameraControl *control, gint *value);
467 gboolean gst_camera_control_set_part_color (GstCameraControl *control, gint type, gint value);
470 gboolean gst_camera_control_get_part_color (GstCameraControl *control, gint type, gint *value);
473 gboolean gst_camera_control_get_exif_info (GstCameraControl *control, GstCameraControlExifInfo *info);
476 gboolean gst_camera_control_get_basic_dev_info (GstCameraControl *control, gint dev_id, GstCameraControlCapsInfoType *info);
479 gboolean gst_camera_control_get_misc_dev_info (GstCameraControl *control, gint dev_id, GstCameraControlCtrlListInfoType *info);
482 gboolean gst_camera_control_get_extra_dev_info (GstCameraControl *control, gint dev_id, GstCameraControlExtraInfoType *info);
485 void gst_camera_control_set_capture_command (GstCameraControl *control, GstCameraControlCaptureCommand cmd);
488 void gst_camera_control_set_record_command (GstCameraControl *control, GstCameraControlRecordCommand cmd);
491 gboolean gst_camera_control_start_face_zoom (GstCameraControl *control, gint x, gint y, gint zoom_level);
494 gboolean gst_camera_control_stop_face_zoom (GstCameraControl *control);
497 gboolean gst_camera_control_set_ae_lock (GstCameraControl *control, gboolean lock);
500 gboolean gst_camera_control_get_ae_lock (GstCameraControl *control, gboolean *lock);
503 gboolean gst_camera_control_set_awb_lock (GstCameraControl *control, gboolean lock);
506 gboolean gst_camera_control_get_awb_lock (GstCameraControl *control, gboolean *lock);
509 gboolean gst_camera_control_set_user_buffer_fd (GstCameraControl *control, int *fds, int number);
513 void gst_camera_control_value_changed (GstCameraControl *control, GstCameraControlChannel *control_channel, gint value);
517 #endif /* __GST_CAMERA_CONTROL_H__ */