2 * GStreamer Camera Control Interface
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
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 ============================================================================================*/
41 #include "cameracontrol.h"
42 #include "interfaces-marshal.h"
45 * SECTION:gstcameracontrol
46 * @short_description: Interface for camera control
50 CONTROL_VALUE_CHANGED,
54 static void gst_camera_control_class_init(GstCameraControlClass *klass);
56 static guint gst_camera_control_signals[CONTROL_LAST_SIGNAL] = { 0 };
58 GType gst_camera_control_get_type(void)
60 static GType gst_camera_control_type = 0;
62 if (!gst_camera_control_type) {
63 static const GTypeInfo gst_camera_control_info =
65 sizeof(GstCameraControlClass),
66 (GBaseInitFunc)gst_camera_control_class_init,
76 gst_camera_control_type = g_type_register_static(G_TYPE_INTERFACE,
78 &gst_camera_control_info,
80 g_type_interface_add_prerequisite(gst_camera_control_type, GST_TYPE_IMPLEMENTS_INTERFACE);
83 return gst_camera_control_type;
86 static void gst_camera_control_class_init(GstCameraControlClass *klass)
88 static gboolean initialized = FALSE;
91 gst_camera_control_signals[CONTROL_VALUE_CHANGED] =
92 g_signal_new("control-value-changed",
93 GST_TYPE_CAMERA_CONTROL, G_SIGNAL_RUN_LAST,
94 G_STRUCT_OFFSET(GstCameraControlClass, value_changed),
96 gst_interfaces_marshal_VOID__OBJECT_INT,
97 G_TYPE_NONE, 2, GST_TYPE_CAMERA_CONTROL_CHANNEL, G_TYPE_INT);
103 klass->camera_control_type = 0;
105 /* defauld virtual functions */
106 klass->list_channels = NULL;
107 klass->set_exposure = NULL;
108 klass->get_exposure = NULL;
109 klass->set_capture_mode = NULL;
110 klass->get_capture_mode = NULL;
111 klass->set_strobe = NULL;
112 klass->get_strobe = NULL;
113 klass->set_detect = NULL;
114 klass->get_detect = NULL;
115 klass->set_value = NULL;
116 klass->get_value = NULL;
117 klass->set_zoom = NULL;
118 klass->get_zoom = NULL;
119 klass->set_focus = NULL;
120 klass->get_focus = NULL;
121 klass->start_auto_focus = NULL;
122 klass->stop_auto_focus = NULL;
123 klass->set_focus_level = NULL;
124 klass->get_focus_level = NULL;
125 klass->set_auto_focus_area = NULL;
126 klass->get_auto_focus_area = NULL;
127 klass->set_wdr = NULL;
128 klass->get_wdr = NULL;
129 klass->set_ahs = NULL;
130 klass->get_ahs = NULL;
131 klass->set_part_color = NULL;
132 klass->get_part_color = NULL;
133 klass->get_exif_info = NULL;
134 klass->set_capture_command = NULL;
135 klass->start_face_zoom = NULL;
136 klass->stop_face_zoom = NULL;
139 const GList* gst_camera_control_list_channels(GstCameraControl *control)
141 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
143 if (klass->list_channels) {
144 return klass->list_channels(control);
151 gboolean gst_camera_control_set_value(GstCameraControl *control, GstCameraControlChannel *control_channel)
153 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
155 if (klass->set_value) {
156 return klass->set_value(control, control_channel);
162 gboolean gst_camera_control_get_value(GstCameraControl *control, GstCameraControlChannel *control_channel)
164 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
166 if (klass->get_value) {
167 return klass->get_value(control, control_channel);
175 gboolean gst_camera_control_set_exposure(GstCameraControl *control, gint type, gint value1, gint value2)
177 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
179 if (klass->set_exposure) {
180 return klass->set_exposure(control, type, value1, value2);
186 gboolean gst_camera_control_get_exposure(GstCameraControl *control, gint type, gint *value1, gint *value2)
188 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
190 if (klass->get_exposure) {
191 return klass->get_exposure(control, type, value1, value2);
197 gboolean gst_camera_control_set_capture_mode(GstCameraControl *control, gint type, gint value)
199 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
201 if (klass->set_capture_mode) {
202 return klass->set_capture_mode(control, type, value);
208 gboolean gst_camera_control_get_capture_mode(GstCameraControl *control, gint type, gint *value)
210 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
212 if (klass->get_capture_mode) {
213 return klass->get_capture_mode(control, type, value);
219 gboolean gst_camera_control_set_strobe(GstCameraControl *control, gint type, gint value)
221 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
223 if (klass->set_strobe) {
224 return klass->set_strobe(control, type, value);
230 gboolean gst_camera_control_get_strobe(GstCameraControl *control, gint type, gint *value)
232 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
234 if (klass->get_strobe) {
235 return klass->get_strobe(control, type, value);
241 gboolean gst_camera_control_set_detect(GstCameraControl *control, gint type, gint value)
243 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
245 if (klass->set_detect) {
246 return klass->set_detect(control, type, value);
252 gboolean gst_camera_control_get_detect(GstCameraControl *control, gint type, gint *value)
254 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
256 if (klass->get_detect) {
257 return klass->get_detect(control, type, value);
263 gboolean gst_camera_control_set_zoom(GstCameraControl *control, gint type, gint value)
265 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
267 if (klass->set_zoom) {
268 return klass->set_zoom(control, type, value);
274 gboolean gst_camera_control_get_zoom(GstCameraControl *control, gint type, gint *value)
276 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
278 if (klass->get_zoom) {
279 return klass->get_zoom(control, type, value);
285 gboolean gst_camera_control_set_focus(GstCameraControl *control, gint mode, gint range)
287 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
289 if (klass->set_focus) {
290 return klass->set_focus(control, mode, range);
296 gboolean gst_camera_control_get_focus(GstCameraControl *control, gint *mode, gint *range)
298 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
300 if (klass->get_focus) {
301 return klass->get_focus(control, mode, range);
307 gboolean gst_camera_control_start_auto_focus(GstCameraControl *control)
309 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
311 if (klass->start_auto_focus) {
312 return klass->start_auto_focus(control);
318 gboolean gst_camera_control_stop_auto_focus(GstCameraControl *control)
320 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
322 if (klass->stop_auto_focus) {
323 return klass->stop_auto_focus(control);
329 gboolean gst_camera_control_set_focus_level(GstCameraControl *control, gint manual_level)
331 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
333 if (klass->set_focus_level) {
334 return klass->set_focus_level(control, manual_level);
340 gboolean gst_camera_control_get_focus_level(GstCameraControl *control, gint *manual_level)
342 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
344 if (klass->get_focus_level) {
345 return klass->get_focus_level(control, manual_level);
351 gboolean gst_camera_control_set_auto_focus_area(GstCameraControl *control, GstCameraControlRectType rect)
353 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
355 if (klass->set_auto_focus_area) {
356 return klass->set_auto_focus_area(control, rect);
362 gboolean gst_camera_control_get_auto_focus_area(GstCameraControl *control, GstCameraControlRectType *rect)
364 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
366 if (klass->get_auto_focus_area) {
367 return klass->get_auto_focus_area(control, rect);
373 gboolean gst_camera_control_set_wdr(GstCameraControl *control, gint value)
375 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
377 if (klass->set_wdr) {
378 return klass->set_wdr(control, value);
384 gboolean gst_camera_control_get_wdr(GstCameraControl *control, gint *value)
386 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
388 if (klass->get_wdr) {
389 return klass->get_wdr(control, value);
395 gboolean gst_camera_control_set_ahs(GstCameraControl *control, gint value)
397 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
399 if (klass->set_ahs) {
400 return klass->set_ahs(control, value);
406 gboolean gst_camera_control_get_ahs(GstCameraControl *control, gint *value)
408 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
410 if (klass->get_ahs) {
411 return klass->get_ahs(control, value);
417 gboolean gst_camera_control_set_part_color(GstCameraControl *control, gint type, gint value)
419 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
421 if (klass->set_part_color) {
422 return klass->set_part_color(control, type, value);
428 gboolean gst_camera_control_get_part_color(GstCameraControl *control, gint type, gint *value)
430 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
432 if (klass->get_part_color) {
433 return klass->get_part_color(control, type, value);
440 gst_camera_control_get_exif_info(GstCameraControl *control, GstCameraControlExifInfo *info)
442 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
444 if (klass->get_exif_info) {
445 return klass->get_exif_info(control, info);
452 gboolean gst_camera_control_get_basic_dev_info(GstCameraControl *control, gint dev_id, GstCameraControlCapsInfoType *info)
454 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
456 if (klass->get_basic_dev_info) {
457 return klass->get_basic_dev_info(control, dev_id, info);
463 gboolean gst_camera_control_get_misc_dev_info(GstCameraControl *control, gint dev_id, GstCameraControlCtrlListInfoType *info)
465 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
467 if( klass->get_misc_dev_info )
469 return klass->get_misc_dev_info( control, dev_id, info );
475 gboolean gst_camera_control_get_extra_dev_info(GstCameraControl *control, gint dev_id, GstCameraControlExtraInfoType *info)
477 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
479 if (klass->get_extra_dev_info) {
480 return klass->get_extra_dev_info(control, dev_id, info);
486 void gst_camera_control_set_capture_command(GstCameraControl *control, GstCameraControlCaptureCommand cmd)
488 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
490 if (klass->set_capture_command) {
491 klass->set_capture_command(control, cmd);
497 gboolean gst_camera_control_start_face_zoom(GstCameraControl *control, gint x, gint y, gint zoom_level)
499 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
501 if (klass->start_face_zoom) {
502 return klass->start_face_zoom(control, x, y, zoom_level);
508 gboolean gst_camera_control_stop_face_zoom(GstCameraControl *control)
510 GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS(control);
512 if (klass->stop_face_zoom) {
513 return klass->stop_face_zoom(control);
519 void gst_camera_control_value_changed(GstCameraControl *control, GstCameraControlChannel *control_channel, gint value)
521 g_signal_emit(G_OBJECT(control), gst_camera_control_signals[CONTROL_VALUE_CHANGED], 0, control_channel, value);
522 g_signal_emit_by_name(G_OBJECT(control_channel), "control-value-changed", value);