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/cameracontrolchannel.h>
44 #define GST_TYPE_CAMERA_CONTROL \
45 (gst_camera_control_get_type())
46 #define GST_CAMERA_CONTROL(obj) \
47 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CAMERA_CONTROL, GstCameraControl))
48 #define GST_IS_CAMERA_CONTROL(obj) \
49 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CAMERA_CONTROL))
50 #define GST_CAMERA_CONTROL_GET_INTERFACE(inst) \
51 (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_CAMERA_CONTROL, GstCameraControlInterface))
52 #define GST_CAMERA_CONTROL_TYPE(iface) (iface->camera_control_type)
55 typedef struct _GstCameraControl GstCameraControl;
56 typedef struct _GstCameraControlInterface GstCameraControlInterface;
60 GST_CAMERA_CONTROL_HARDWARE,
61 GST_CAMERA_CONTROL_SOFTWARE
62 } GstCameraControlType;
64 /* enumerations for Camera control Exposure types */
67 GST_CAMERA_CONTROL_F_NUMBER,
68 GST_CAMERA_CONTROL_SHUTTER_SPEED,
69 GST_CAMERA_CONTROL_ISO,
70 GST_CAMERA_CONTROL_PROGRAM_MODE,
71 GST_CAMERA_CONTROL_EXPOSURE_MODE,
72 GST_CAMERA_CONTROL_EXPOSURE_VALUE
73 } GstCameraControlExposureType;
75 /* enumerations for Camera control Capture mode types */
78 GST_CAMERA_CONTROL_CAPTURE_MODE,
79 GST_CAMERA_CONTROL_OUTPUT_MODE,
80 GST_CAMERA_CONTROL_FRAME_COUNT,
81 GST_CAMERA_CONTROL_JPEG_QUALITY
82 } GstCameraControlCaptureModeType;
84 /* enumerations for Camera control Strobe types */
87 GST_CAMERA_CONTROL_STROBE_CONTROL,
88 GST_CAMERA_CONTROL_STROBE_CAPABILITIES,
89 GST_CAMERA_CONTROL_STROBE_MODE,
90 GST_CAMERA_CONTROL_STROBE_STATUS,
91 GST_CAMERA_CONTROL_STROBE_EV,
92 GST_CAMERA_CONTROL_STROBE_BRIGHTNESS
93 } GstCameraControlStrobeType;
95 /* enumerations for Camera control Face detection types */
98 GST_CAMERA_CONTROL_FACE_DETECT_MODE,
99 GST_CAMERA_CONTROL_FACE_DETECT_NUMBER,
100 GST_CAMERA_CONTROL_FACE_FOCUS_SELECT,
101 GST_CAMERA_CONTROL_FACE_SELECT_NUMBER,
102 GST_CAMERA_CONTROL_FACE_DETECT_STATUS
103 } GstCameraControlFaceDetectType;
105 /* enumerations for Camera control Zoom types */
108 GST_CAMERA_CONTROL_DIGITAL_ZOOM,
109 GST_CAMERA_CONTROL_OPTICAL_ZOOM
110 } GstCameraControlZoomType;
112 /* enumerations for Camera control Part color */
115 GST_CAMERA_CONTROL_PART_COLOR_SRC,
116 GST_CAMERA_CONTROL_PART_COLOR_DST,
117 GST_CAMERA_CONTROL_PART_COLOR_MODE
118 } GstCameraControlPartColorType;
120 /* enumerations for Camera capture command */
123 GST_CAMERA_CONTROL_CAPTURE_COMMAND_NONE,
124 GST_CAMERA_CONTROL_CAPTURE_COMMAND_START,
125 GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP,
126 GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT
127 } GstCameraControlCaptureCommand;
129 /* enumerations for Camera record command */
132 GST_CAMERA_CONTROL_RECORD_COMMAND_NONE,
133 GST_CAMERA_CONTROL_RECORD_COMMAND_START,
134 GST_CAMERA_CONTROL_RECORD_COMMAND_STOP
135 } GstCameraControlRecordCommand;
140 GST_CAMERA_CONTROL_IMAGE_FORMAT_NV12,
141 GST_CAMERA_CONTROL_IMAGE_FORMAT_NV21,
142 GST_CAMERA_CONTROL_IMAGE_FORMAT_I420,
143 GST_CAMERA_CONTROL_IMAGE_FORMAT_YV12,
144 GST_CAMERA_CONTROL_IMAGE_FORMAT_YUYV,
145 GST_CAMERA_CONTROL_IMAGE_FORMAT_UYVY,
148 GST_CAMERA_CONTROL_IMAGE_FORMAT_BGRA,
149 GST_CAMERA_CONTROL_IMAGE_FORMAT_ARGB,
152 GST_CAMERA_CONTROL_IMAGE_FORMAT_JPEG,
153 GST_CAMERA_CONTROL_IMAGE_FORMAT_H264,
154 GST_CAMERA_CONTROL_IMAGE_FORMAT_MJPEG,
155 GST_CAMERA_CONTROL_IMAGE_FORMAT_VP8,
156 GST_CAMERA_CONTROL_IMAGE_FORMAT_VP9
157 } GstCameraControlImageFormat;
160 /////////////////////////////////
161 // For Query functionalities //
162 // For Querying capabilities //
163 /////////////////////////////////
164 #define GST_CAMERA_CONTROL_MAX_NUM_FMT_DESC 32
165 #define GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION 32
166 #define GST_CAMERA_CONTROL_MAX_NUM_AVAILABLE_TPF 16
167 #define GST_CAMERA_CONTROL_MAX_NUM_AVAILABLE_FPS 16
168 #define GST_CAMERA_CONTROL_MAX_NUM_CTRL_LIST_INFO 64
169 #define GST_CAMERA_CONTROL_MAX_NUM_CTRL_MENU 64
170 #define GST_CAMERA_CONTROL_MAX_NUM_DETECTED_FACES 16
171 #define GST_CAMERA_CONTROL_MAX_SZ_CTRL_NAME_STRING 32
172 #define GST_CAMERA_CONTROL_MAX_SZ_DEV_NAME_STRING 32
174 /*! @struct GstCameraControlFracType
175 * @brief For timeperframe as fraction type
176 * Elapse time consumed by one frame, reverse of FPS
178 typedef struct _GstCameraControlFracType {
181 } GstCameraControlFracType;
183 /*! @struct GstCameraControlRectType
184 * @brief For touch auto focusing area and face detection area
186 typedef struct _GstCameraControlRectType {
191 } GstCameraControlRectType;
193 /*! @struct GstCameraControlResolutionType
194 * @brief For querying supported resolutions
196 typedef struct _GstCameraControlResolutionType {
200 /* Available time per frame(tpf) as each pixelformat */
202 GstCameraControlFracType tpf[GST_CAMERA_CONTROL_MAX_NUM_AVAILABLE_TPF];
203 } GstCameraControlResolutionType;
205 /*! @struct GstCameraControlFmtDescType
206 * @brief For querying supported format type
208 typedef struct _GstCameraControlFmtDescType {
209 /* fourcc name of each pixelformat */
213 /* Available resolutions as each pixelformat */
215 GstCameraControlResolutionType resolutions[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
216 } GstCameraControlFmtDescType;
218 /*! @struct GstCameraControlCapsInfoType
219 * @brief For querying image input capabilities
221 typedef struct _GstCameraControlCapsInfoType {
222 char dev_name[GST_CAMERA_CONTROL_MAX_SZ_DEV_NAME_STRING];
225 GstCameraControlFmtDescType fmt_desc[GST_CAMERA_CONTROL_MAX_NUM_FMT_DESC];
227 int num_preview_resolution;
228 int preview_resolution_width[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
229 int preview_resolution_height[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
231 int num_capture_resolution;
232 int capture_resolution_width[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
233 int capture_resolution_height[GST_CAMERA_CONTROL_MAX_NUM_RESOLUTION];
236 unsigned int preview_fmt[GST_CAMERA_CONTROL_MAX_NUM_FMT_DESC];
239 unsigned int capture_fmt[GST_CAMERA_CONTROL_MAX_NUM_FMT_DESC];
242 GstCameraControlFracType fps[GST_CAMERA_CONTROL_MAX_NUM_AVAILABLE_FPS];
243 } GstCameraControlCapsInfoType;
245 /*! @struct GstCameraControlFaceInfo
246 * @brief For face information
248 typedef struct _GstCameraControlFaceInfo {
251 GstCameraControlRectType rect;
252 } GstCameraControlFaceInfo;
254 /*! @struct GstCameraControlFaceDetectInfo
255 * @brief For face detect information
257 typedef struct _GstCameraControlFaceDetectInfo {
259 GstCameraControlFaceInfo face_info[GST_CAMERA_CONTROL_MAX_NUM_DETECTED_FACES];
260 } GstCameraControlFaceDetectInfo;
262 /////////////////////////////
263 // For Querying controls //
264 /////////////////////////////
266 GST_CAMERA_CTRL_TYPE_RANGE = 0,
267 GST_CAMERA_CTRL_TYPE_BOOL,
268 GST_CAMERA_CTRL_TYPE_ARRAY,
269 GST_CAMERA_CTRL_TYPE_UNKNOWN,
270 GST_CAMERA_CTRL_TYPE_NUM,
273 /*! @struct GstCameraControlCtrlMenuType
274 * @brief For querying menu of specified controls
276 typedef struct _GstCameraControlCtrlMenuType {
278 gchar menu_name[GST_CAMERA_CONTROL_MAX_SZ_CTRL_NAME_STRING];
279 } GstCameraControlCtrlMenuType;
281 /*! @struct GstCameraControlCtrlInfoType
282 * @brief For querying controls detail
284 typedef struct _GstCameraControlCtrlInfoType {
288 gchar ctrl_name[GST_CAMERA_CONTROL_MAX_SZ_CTRL_NAME_STRING];
294 GstCameraControlCtrlMenuType ctrl_menu[GST_CAMERA_CONTROL_MAX_NUM_CTRL_MENU];
295 } GstCameraControlCtrlInfoType;
297 /*! @struct GstCameraControlCtrlListInfoType
298 * @brief For querying controls
300 typedef struct _GstCameraControlCtrlListInfoType {
301 gint num_ctrl_list_info;
302 GstCameraControlCtrlInfoType ctrl_info[GST_CAMERA_CONTROL_MAX_NUM_CTRL_LIST_INFO];
303 } GstCameraControlCtrlListInfoType;
305 /* capabilities field */
306 #define GST_CAMERA_STROBE_CAP_NONE 0x0000 /* No strobe supported */
307 #define GST_CAMERA_STROBE_CAP_OFF 0x0001 /* Always flash off mode */
308 #define GST_CAMERA_STROBE_CAP_ON 0x0002 /* Always use flash light mode */
309 #define GST_CAMERA_STROBE_CAP_AUTO 0x0004 /* Flashlight works automatic */
310 #define GST_CAMERA_STROBE_CAP_REDEYE 0x0008 /* Red-eye reduction */
311 #define GST_CAMERA_STROBE_CAP_SLOWSYNC 0x0010 /* Slow sync */
312 #define GST_CAMERA_STROBE_CAP_FRONT_CURTAIN 0x0020 /* Front curtain */
313 #define GST_CAMERA_STROBE_CAP_REAR_CURTAIN 0x0040 /* Rear curtain */
314 #define GST_CAMERA_STROBE_CAP_PERMANENT 0x0080 /* keep turned on until turning off */
315 #define GST_CAMERA_STROBE_CAP_EXTERNAL 0x0100 /* use external strobe */
317 typedef struct _GstCameraControlExtraInfoType {
318 guint strobe_caps; /* Use above caps field */
319 guint detection_caps; /* Just boolean */
321 } GstCameraControlExtraInfoType;
322 /////////////////////////////////////
323 // END For Query functionalities //
324 /////////////////////////////////////
327 /* structure for Camera control EXIF information */
328 typedef struct _GstCameraControlExifInfo {
330 guint32 exposure_time_numerator; /* Exposure time, given in seconds */
331 guint32 exposure_time_denominator;
332 gint shutter_speed_numerator; /* Shutter speed, given in APEX(Additive System Photographic Exposure) */
333 gint shutter_speed_denominator;
334 gint brigtness_numerator; /* Value of brightness, before firing flash, given in APEX value */
335 gint brightness_denominator;
336 guint16 iso; /* Sensitivity value of sensor */
337 guint16 flash; /* Whether flash is fired(1) or not(0) */
338 gint metering_mode; /* metering mode in EXIF 2.2 */
339 gint exif_image_width; /* Size of image */
340 gint exif_image_height;
341 gint exposure_bias_in_APEX; /* Exposure bias in APEX standard */
342 gint software_used; /* Firmware S/W version */
345 gint component_configuration; /* color components arrangement */
346 gint colorspace; /* colorspace information */
347 gint focal_len_numerator; /* Lens focal length */
348 gint focal_len_denominator;
349 gint aperture_f_num_numerator; /* Aperture value */
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;
355 /* structure for camera control interface */
356 struct _GstCameraControlInterface {
357 GTypeInterface iface;
358 GstCameraControlType camera_control_type;
360 /* virtual functions */
361 const GList *(*list_channels) (GstCameraControl *control);
362 gboolean (*set_value) (GstCameraControl *control, GstCameraControlChannel *control_channel, gint value);
363 gboolean (*get_value) (GstCameraControl *control, GstCameraControlChannel *control_channel, gint *value);
364 gboolean (*set_exposure) (GstCameraControl *control, gint type, gint value1, gint value2);
365 gboolean (*get_exposure) (GstCameraControl *control, gint type, gint *value1, gint *value2);
366 gboolean (*set_capture_mode) (GstCameraControl *control, gint type, gint value);
367 gboolean (*get_capture_mode) (GstCameraControl *control, gint type, gint *value);
368 gboolean (*set_strobe) (GstCameraControl *control, gint type, gint value);
369 gboolean (*get_strobe) (GstCameraControl *control, gint type, gint *value);
370 gboolean (*set_detect) (GstCameraControl *control, gint type, gint value);
371 gboolean (*get_detect) (GstCameraControl *control, gint type, gint *value);
372 gboolean (*set_zoom) (GstCameraControl *control, gint type, gint value);
373 gboolean (*get_zoom) (GstCameraControl *control, gint type, gint *value);
374 gboolean (*set_focus) (GstCameraControl *control, gint mode, gint range);
375 gboolean (*get_focus) (GstCameraControl *control, gint *mode, gint *range);
376 gboolean (*start_auto_focus) (GstCameraControl *control);
377 gboolean (*stop_auto_focus) (GstCameraControl *control);
378 gboolean (*set_focus_level) (GstCameraControl *control, gint manual_level);
379 gboolean (*get_focus_level) (GstCameraControl *control, gint *manual_level);
380 gboolean (*set_auto_focus_area) (GstCameraControl *control, GstCameraControlRectType rect);
381 gboolean (*get_auto_focus_area) (GstCameraControl *control, GstCameraControlRectType *rect);
382 gboolean (*set_wdr) (GstCameraControl *control, gint value);
383 gboolean (*get_wdr) (GstCameraControl *control, gint *value);
384 gboolean (*set_ahs) (GstCameraControl *control, gint value);
385 gboolean (*get_ahs) (GstCameraControl *control, gint *value);
386 gboolean (*set_part_color) (GstCameraControl *control, gint type, gint value);
387 gboolean (*get_part_color) (GstCameraControl *control, gint type, gint *value);
388 gboolean (*get_exif_info) (GstCameraControl *control, GstCameraControlExifInfo *info);
389 gboolean (*get_basic_dev_info) (GstCameraControl *control, gint dev_id, GstCameraControlCapsInfoType *info);
390 gboolean (*get_misc_dev_info) (GstCameraControl *control, gint dev_id, GstCameraControlCtrlListInfoType *info);
391 gboolean (*get_extra_dev_info) (GstCameraControl *control, gint dev_id, GstCameraControlExtraInfoType *info);
392 void (*set_capture_command) (GstCameraControl *control, GstCameraControlCaptureCommand cmd);
393 void (*set_record_command) (GstCameraControl *control, GstCameraControlRecordCommand cmd);
394 gboolean (*start_face_zoom) (GstCameraControl *control, gint x, gint y, gint zoom_level);
395 gboolean (*stop_face_zoom) (GstCameraControl *control);
396 gboolean (*set_ae_lock) (GstCameraControl *control, gboolean lock);
397 gboolean (*get_ae_lock) (GstCameraControl *control, gboolean *lock);
398 gboolean (*set_awb_lock) (GstCameraControl *control, gboolean lock);
399 gboolean (*get_awb_lock) (GstCameraControl *control, gboolean *lock);
400 gboolean (*set_user_buffer_fd) (GstCameraControl *control, int *fds, int number);
401 gboolean (*set_extra_preview_stream_format) (GstCameraControl *control, int stream_id, GstCameraControlImageFormat img_fmt, int width, int height, int fps);
402 gboolean (*get_extra_preview_stream_format) (GstCameraControl *control, int stream_id, GstCameraControlImageFormat *img_fmt, int *width, int *height, int *fps);
403 gboolean (*set_extra_preview_bitrate) (GstCameraControl *control, int stream_id, int bitrate);
404 gboolean (*get_extra_preview_bitrate) (GstCameraControl *control, int stream_id, int *bitrate);
407 void (* value_changed) (GstCameraControl *control, GstCameraControlChannel *channel, gint value);
411 GType gst_camera_control_get_type(void);
414 const GList *gst_camera_control_list_channels (GstCameraControl *control);
417 gboolean gst_camera_control_set_value (GstCameraControl *control, GstCameraControlChannel *control_channel, gint value);
420 gboolean gst_camera_control_get_value (GstCameraControl *control, GstCameraControlChannel *control_channel, gint *value);
423 gboolean gst_camera_control_set_exposure (GstCameraControl *control, gint type, gint value1, gint value2);
426 gboolean gst_camera_control_get_exposure (GstCameraControl *control, gint type, gint *value1, gint *value2);
429 gboolean gst_camera_control_set_capture_mode (GstCameraControl *control, gint type, gint value);
432 gboolean gst_camera_control_get_capture_mode (GstCameraControl *control, gint type, gint *value);
435 gboolean gst_camera_control_set_strobe (GstCameraControl *control, gint type, gint value);
438 gboolean gst_camera_control_get_strobe (GstCameraControl *control, gint type, gint *value);
441 gboolean gst_camera_control_set_detect (GstCameraControl *control, gint type, gint value);
444 gboolean gst_camera_control_get_detect (GstCameraControl *control, gint type, gint *value);
447 gboolean gst_camera_control_set_zoom (GstCameraControl *control, gint type, gint value);
450 gboolean gst_camera_control_get_zoom (GstCameraControl *control, gint type, gint *value);
453 gboolean gst_camera_control_set_focus (GstCameraControl *control, gint mode, gint range);
456 gboolean gst_camera_control_get_focus (GstCameraControl *control, gint *mode, gint *range);
459 gboolean gst_camera_control_start_auto_focus (GstCameraControl *control);
462 gboolean gst_camera_control_stop_auto_focus (GstCameraControl *control);
465 gboolean gst_camera_control_set_focus_level (GstCameraControl *control, gint manual_level);
468 gboolean gst_camera_control_get_focus_level (GstCameraControl *control, gint *manual_level);
471 gboolean gst_camera_control_set_auto_focus_area (GstCameraControl *control, GstCameraControlRectType rect);
474 gboolean gst_camera_control_get_auto_focus_area (GstCameraControl *control, GstCameraControlRectType *rect);
477 gboolean gst_camera_control_set_wdr (GstCameraControl *control, gint value);
480 gboolean gst_camera_control_get_wdr (GstCameraControl *control, gint *value);
483 gboolean gst_camera_control_set_ahs (GstCameraControl *control, gint value);
486 gboolean gst_camera_control_get_ahs (GstCameraControl *control, gint *value);
489 gboolean gst_camera_control_set_part_color (GstCameraControl *control, gint type, gint value);
492 gboolean gst_camera_control_get_part_color (GstCameraControl *control, gint type, gint *value);
495 gboolean gst_camera_control_get_exif_info (GstCameraControl *control, GstCameraControlExifInfo *info);
498 gboolean gst_camera_control_get_basic_dev_info (GstCameraControl *control, gint dev_id, GstCameraControlCapsInfoType *info);
501 gboolean gst_camera_control_get_misc_dev_info (GstCameraControl *control, gint dev_id, GstCameraControlCtrlListInfoType *info);
504 gboolean gst_camera_control_get_extra_dev_info (GstCameraControl *control, gint dev_id, GstCameraControlExtraInfoType *info);
507 void gst_camera_control_set_capture_command (GstCameraControl *control, GstCameraControlCaptureCommand cmd);
510 void gst_camera_control_set_record_command (GstCameraControl *control, GstCameraControlRecordCommand cmd);
513 gboolean gst_camera_control_start_face_zoom (GstCameraControl *control, gint x, gint y, gint zoom_level);
516 gboolean gst_camera_control_stop_face_zoom (GstCameraControl *control);
519 gboolean gst_camera_control_set_ae_lock (GstCameraControl *control, gboolean lock);
522 gboolean gst_camera_control_get_ae_lock (GstCameraControl *control, gboolean *lock);
525 gboolean gst_camera_control_set_awb_lock (GstCameraControl *control, gboolean lock);
528 gboolean gst_camera_control_get_awb_lock (GstCameraControl *control, gboolean *lock);
531 gboolean gst_camera_control_set_user_buffer_fd (GstCameraControl *control, int *fds, int number);
534 gboolean gst_camera_control_set_extra_preview_stream_format (GstCameraControl *control, int stream_id, GstCameraControlImageFormat img_fmt, int width, int height, int fps);
537 gboolean gst_camera_control_get_extra_preview_stream_format (GstCameraControl *control, int stream_id, GstCameraControlImageFormat *img_fmt, int *width, int *height, int *fps);
540 gboolean gst_camera_control_set_extra_preview_bitrate (GstCameraControl *control, int stream_id, int bitrate);
543 gboolean gst_camera_control_get_extra_preview_bitrate (GstCameraControl *control, int stream_id, int *bitrate);
547 void gst_camera_control_value_changed (GstCameraControl *control, GstCameraControlChannel *control_channel, gint value);
551 #endif /* __GST_CAMERA_CONTROL_H__ */