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 ============================================================================================*/
41 #include "cameracontrol.h"
44 * SECTION:gstcameracontrol
45 * @short_description: Interface for camera control
49 CONTROL_VALUE_CHANGED,
53 static void gst_camera_control_base_init(GstCameraControlInterface *iface);
55 static guint gst_camera_control_signals[CONTROL_LAST_SIGNAL] = { 0 };
57 GType gst_camera_control_get_type(void)
59 static GType gst_camera_control_type = 0;
61 if (!gst_camera_control_type) {
62 static const GTypeInfo gst_camera_control_info =
64 sizeof(GstCameraControlInterface),
65 (GBaseInitFunc)gst_camera_control_base_init,
75 gst_camera_control_type = g_type_register_static(G_TYPE_INTERFACE,
76 "GstCameraControl", &gst_camera_control_info, 0);
79 return gst_camera_control_type;
82 static void gst_camera_control_base_init(GstCameraControlInterface *iface)
84 static gboolean initialized = FALSE;
87 gst_camera_control_signals[CONTROL_VALUE_CHANGED] =
88 g_signal_new("control-value-changed",
89 GST_TYPE_CAMERA_CONTROL, G_SIGNAL_RUN_LAST,
90 G_STRUCT_OFFSET(GstCameraControlInterface, value_changed),
92 G_TYPE_NONE, 2, GST_TYPE_CAMERA_CONTROL_CHANNEL, G_TYPE_INT);
98 iface->camera_control_type = 0;
100 /* default virtual functions */
101 iface->list_channels = NULL;
102 iface->set_exposure = NULL;
103 iface->get_exposure = NULL;
104 iface->set_capture_mode = NULL;
105 iface->get_capture_mode = NULL;
106 iface->set_strobe = NULL;
107 iface->get_strobe = NULL;
108 iface->set_detect = NULL;
109 iface->get_detect = NULL;
110 iface->set_value = NULL;
111 iface->get_value = NULL;
112 iface->set_zoom = NULL;
113 iface->get_zoom = NULL;
114 iface->set_focus = NULL;
115 iface->get_focus = NULL;
116 iface->start_auto_focus = NULL;
117 iface->stop_auto_focus = NULL;
118 iface->set_focus_level = NULL;
119 iface->get_focus_level = NULL;
120 iface->set_auto_focus_area = NULL;
121 iface->get_auto_focus_area = NULL;
122 iface->set_wdr = NULL;
123 iface->get_wdr = NULL;
124 iface->set_ahs = NULL;
125 iface->get_ahs = NULL;
126 iface->set_part_color = NULL;
127 iface->get_part_color = NULL;
128 iface->get_exif_info = NULL;
129 iface->set_capture_command = NULL;
130 iface->set_record_command = NULL;
131 iface->start_face_zoom = NULL;
132 iface->stop_face_zoom = NULL;
133 iface->set_ae_lock = NULL;
134 iface->get_ae_lock = NULL;
135 iface->set_awb_lock = NULL;
136 iface->get_awb_lock = NULL;
140 * gst_camera_control_list_channels:
141 * @control: A #GstCameraControl instance
143 * Retrieve a list of the available channels.
145 * Returns: (element-type GstCameraControlChannel) (transfer none): A
146 * GList containing pointers to #GstCameraControlChannel
147 * objects. The list is owned by the #GstCameraControl
148 * instance and must not be freed.
150 const GList *gst_camera_control_list_channels(GstCameraControl *control)
152 GstCameraControlInterface *iface;
154 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), NULL);
156 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
158 if (iface->list_channels)
159 return iface->list_channels(control);
165 gboolean gst_camera_control_set_value(GstCameraControl *control, GstCameraControlChannel *control_channel, gint value)
167 GstCameraControlInterface *iface;
169 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
171 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
173 if (iface->set_value)
174 return iface->set_value(control, control_channel, value);
179 gboolean gst_camera_control_get_value(GstCameraControl *control, GstCameraControlChannel *control_channel, gint *value)
181 GstCameraControlInterface *iface;
183 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
185 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
187 if (iface->get_value)
188 return iface->get_value(control, control_channel, value);
195 gboolean gst_camera_control_set_exposure(GstCameraControl *control, gint type, gint value1, gint value2)
197 GstCameraControlInterface *iface;
199 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
201 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
203 if (iface->set_exposure)
204 return iface->set_exposure(control, type, value1, value2);
209 gboolean gst_camera_control_get_exposure(GstCameraControl *control, gint type, gint *value1, gint *value2)
211 GstCameraControlInterface *iface;
213 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
215 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
217 if (iface->get_exposure)
218 return iface->get_exposure(control, type, value1, value2);
223 gboolean gst_camera_control_set_capture_mode(GstCameraControl *control, gint type, gint value)
225 GstCameraControlInterface *iface;
227 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
229 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
231 if (iface->set_capture_mode)
232 return iface->set_capture_mode(control, type, value);
237 gboolean gst_camera_control_get_capture_mode(GstCameraControl *control, gint type, gint *value)
239 GstCameraControlInterface *iface;
241 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
243 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
245 if (iface->get_capture_mode)
246 return iface->get_capture_mode(control, type, value);
251 gboolean gst_camera_control_set_strobe(GstCameraControl *control, gint type, gint value)
253 GstCameraControlInterface *iface;
255 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
257 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
259 if (iface->set_strobe)
260 return iface->set_strobe(control, type, value);
265 gboolean gst_camera_control_get_strobe(GstCameraControl *control, gint type, gint *value)
267 GstCameraControlInterface *iface;
269 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
271 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
273 if (iface->get_strobe)
274 return iface->get_strobe(control, type, value);
279 gboolean gst_camera_control_set_detect(GstCameraControl *control, gint type, gint value)
281 GstCameraControlInterface *iface;
283 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
285 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
287 if (iface->set_detect)
288 return iface->set_detect(control, type, value);
293 gboolean gst_camera_control_get_detect(GstCameraControl *control, gint type, gint *value)
295 GstCameraControlInterface *iface;
297 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
299 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
301 if (iface->get_detect)
302 return iface->get_detect(control, type, value);
307 gboolean gst_camera_control_set_zoom(GstCameraControl *control, gint type, gint value)
309 GstCameraControlInterface *iface;
311 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
313 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
316 return iface->set_zoom(control, type, value);
321 gboolean gst_camera_control_get_zoom(GstCameraControl *control, gint type, gint *value)
323 GstCameraControlInterface *iface;
325 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
327 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
330 return iface->get_zoom(control, type, value);
335 gboolean gst_camera_control_set_focus(GstCameraControl *control, gint mode, gint range)
337 GstCameraControlInterface *iface;
339 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
341 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
343 if (iface->set_focus)
344 return iface->set_focus(control, mode, range);
349 gboolean gst_camera_control_get_focus(GstCameraControl *control, gint *mode, gint *range)
351 GstCameraControlInterface *iface;
353 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
355 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
357 if (iface->get_focus)
358 return iface->get_focus(control, mode, range);
363 gboolean gst_camera_control_start_auto_focus(GstCameraControl *control)
365 GstCameraControlInterface *iface;
367 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
369 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
371 if (iface->start_auto_focus)
372 return iface->start_auto_focus(control);
377 gboolean gst_camera_control_stop_auto_focus(GstCameraControl *control)
379 GstCameraControlInterface *iface;
381 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
383 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
385 if (iface->stop_auto_focus)
386 return iface->stop_auto_focus(control);
391 gboolean gst_camera_control_set_focus_level(GstCameraControl *control, gint manual_level)
393 GstCameraControlInterface *iface;
395 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
397 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
399 if (iface->set_focus_level)
400 return iface->set_focus_level(control, manual_level);
405 gboolean gst_camera_control_get_focus_level(GstCameraControl *control, gint *manual_level)
407 GstCameraControlInterface *iface;
409 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
411 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
413 if (iface->get_focus_level)
414 return iface->get_focus_level(control, manual_level);
419 gboolean gst_camera_control_set_auto_focus_area(GstCameraControl *control, GstCameraControlRectType rect)
421 GstCameraControlInterface *iface;
423 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
425 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
427 if (iface->set_auto_focus_area)
428 return iface->set_auto_focus_area(control, rect);
433 gboolean gst_camera_control_get_auto_focus_area(GstCameraControl *control, GstCameraControlRectType *rect)
435 GstCameraControlInterface *iface;
437 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
439 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
441 if (iface->get_auto_focus_area)
442 return iface->get_auto_focus_area(control, rect);
447 gboolean gst_camera_control_set_wdr(GstCameraControl *control, gint value)
449 GstCameraControlInterface *iface;
451 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
453 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
456 return iface->set_wdr(control, value);
461 gboolean gst_camera_control_get_wdr(GstCameraControl *control, gint *value)
463 GstCameraControlInterface *iface;
465 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
467 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
470 return iface->get_wdr(control, value);
475 gboolean gst_camera_control_set_ahs(GstCameraControl *control, gint value)
477 GstCameraControlInterface *iface;
479 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
481 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
484 return iface->set_ahs(control, value);
489 gboolean gst_camera_control_get_ahs(GstCameraControl *control, gint *value)
491 GstCameraControlInterface *iface;
493 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
495 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
498 return iface->get_ahs(control, value);
503 gboolean gst_camera_control_set_part_color(GstCameraControl *control, gint type, gint value)
505 GstCameraControlInterface *iface;
507 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
509 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
511 if (iface->set_part_color)
512 return iface->set_part_color(control, type, value);
517 gboolean gst_camera_control_get_part_color(GstCameraControl *control, gint type, gint *value)
519 GstCameraControlInterface *iface;
521 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
523 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
525 if (iface->get_part_color)
526 return iface->get_part_color(control, type, value);
532 gst_camera_control_get_exif_info(GstCameraControl *control, GstCameraControlExifInfo *info)
534 GstCameraControlInterface *iface;
536 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
538 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
540 if (iface->get_exif_info)
541 return iface->get_exif_info(control, info);
547 gboolean gst_camera_control_get_basic_dev_info(GstCameraControl *control, gint dev_id, GstCameraControlCapsInfoType *info)
549 GstCameraControlInterface *iface;
551 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
553 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
555 if (iface->get_basic_dev_info)
556 return iface->get_basic_dev_info(control, dev_id, info);
561 gboolean gst_camera_control_get_misc_dev_info(GstCameraControl *control, gint dev_id, GstCameraControlCtrlListInfoType *info)
563 GstCameraControlInterface *iface;
565 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
567 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
569 if (iface->get_misc_dev_info)
570 return iface->get_misc_dev_info(control, dev_id, info);
575 gboolean gst_camera_control_get_extra_dev_info(GstCameraControl *control, gint dev_id, GstCameraControlExtraInfoType *info)
577 GstCameraControlInterface *iface;
579 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
581 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
583 if (iface->get_extra_dev_info)
584 return iface->get_extra_dev_info(control, dev_id, info);
589 void gst_camera_control_set_capture_command(GstCameraControl *control, GstCameraControlCaptureCommand cmd)
591 GstCameraControlInterface *iface;
593 g_return_if_fail(GST_IS_CAMERA_CONTROL(control));
595 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
597 if (iface->set_capture_command)
598 iface->set_capture_command(control, cmd);
603 void gst_camera_control_set_record_command(GstCameraControl *control, GstCameraControlRecordCommand cmd)
605 GstCameraControlInterface *iface;
607 g_return_if_fail(GST_IS_CAMERA_CONTROL(control));
609 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
611 if (iface->set_record_command)
612 iface->set_record_command(control, cmd);
617 gboolean gst_camera_control_start_face_zoom(GstCameraControl *control, gint x, gint y, gint zoom_level)
619 GstCameraControlInterface *iface;
621 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
623 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
625 if (iface->start_face_zoom)
626 return iface->start_face_zoom(control, x, y, zoom_level);
631 gboolean gst_camera_control_stop_face_zoom(GstCameraControl *control)
633 GstCameraControlInterface *iface;
635 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
637 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
639 if (iface->stop_face_zoom)
640 return iface->stop_face_zoom(control);
645 gboolean gst_camera_control_set_ae_lock(GstCameraControl *control, gboolean lock)
647 GstCameraControlInterface *iface;
649 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
651 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
653 if (iface->set_ae_lock)
654 return iface->set_ae_lock(control, lock);
659 gboolean gst_camera_control_get_ae_lock(GstCameraControl *control, gboolean *lock)
661 GstCameraControlInterface *iface;
663 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
665 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
667 if (iface->get_ae_lock)
668 return iface->get_ae_lock(control, lock);
673 gboolean gst_camera_control_set_awb_lock(GstCameraControl *control, gboolean lock)
675 GstCameraControlInterface *iface;
677 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
679 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
681 if (iface->set_awb_lock)
682 return iface->set_awb_lock(control, lock);
687 gboolean gst_camera_control_get_awb_lock(GstCameraControl *control, gboolean *lock)
689 GstCameraControlInterface *iface;
691 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
693 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
695 if (iface->get_awb_lock)
696 return iface->get_awb_lock(control, lock);
701 gboolean gst_camera_control_set_user_buffer_fd(GstCameraControl *control, int *fds, int number)
703 GstCameraControlInterface *iface;
705 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
707 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
709 if (iface->set_user_buffer_fd)
710 return iface->set_user_buffer_fd(control, fds, number);
715 gboolean gst_camera_control_set_extra_preview_stream_format(GstCameraControl *control, int stream_id, GstCameraControlImageFormat img_fmt, int width, int height, int fps)
717 GstCameraControlInterface *iface;
719 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
721 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
723 if (iface->set_extra_preview_stream_format)
724 return iface->set_extra_preview_stream_format(control, stream_id, img_fmt, width, height, fps);
729 gboolean gst_camera_control_get_extra_preview_stream_format(GstCameraControl *control, int stream_id, GstCameraControlImageFormat *img_fmt, int *width, int *height, int *fps)
731 GstCameraControlInterface *iface;
733 g_return_val_if_fail(GST_IS_CAMERA_CONTROL(control), FALSE);
735 iface = GST_CAMERA_CONTROL_GET_INTERFACE(control);
737 if (iface->get_extra_preview_stream_format)
738 return iface->get_extra_preview_stream_format(control, stream_id, img_fmt, width, height, fps);
743 void gst_camera_control_value_changed(GstCameraControl *control, GstCameraControlChannel *control_channel, gint value)
745 g_signal_emit(G_OBJECT(control), gst_camera_control_signals[CONTROL_VALUE_CHANGED], 0, control_channel, value);
746 g_signal_emit_by_name(G_OBJECT(control_channel), "control-value-changed", value);