56dc444cffc08934d021304c1308544054a04cb1
[framework/multimedia/gst-plugins-base0.10.git] / gst-libs / gst / interfaces / cameracontrol.c
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
37 #ifdef HAVE_CONFIG_H
38 #include "config.h"
39 #endif
40
41 #include "cameracontrol.h"
42 #include "interfaces-marshal.h"
43
44 /**
45  * SECTION:gstcameracontrol
46  * @short_description: Interface for camera control
47  */
48
49 enum
50 {
51         CONTROL_VALUE_CHANGED,
52         CONTROL_LAST_SIGNAL
53 };
54
55 static void gst_camera_control_class_init( GstCameraControlClass *klass );
56
57 static guint gst_camera_control_signals[CONTROL_LAST_SIGNAL] = { 0 };
58
59 GType
60 gst_camera_control_get_type( void )
61 {
62         static GType gst_camera_control_type = 0;
63
64         if( !gst_camera_control_type )
65         {
66                 static const GTypeInfo gst_camera_control_info =
67                 {
68                         sizeof( GstCameraControlClass ),
69                         (GBaseInitFunc) gst_camera_control_class_init,
70                         NULL,
71                         NULL,
72                         NULL,
73                         NULL,
74                         0,
75                         0,
76                         NULL,
77                 };
78
79                 gst_camera_control_type = g_type_register_static( G_TYPE_INTERFACE, "GstCameraControl", &gst_camera_control_info, 0 );
80                 g_type_interface_add_prerequisite( gst_camera_control_type, GST_TYPE_IMPLEMENTS_INTERFACE );
81         }
82
83         return gst_camera_control_type;
84 }
85
86 static void
87 gst_camera_control_class_init( GstCameraControlClass *klass )
88 {
89         static gboolean initialized = FALSE;
90
91         if( !initialized )
92         {
93                 gst_camera_control_signals[CONTROL_VALUE_CHANGED] =
94                         g_signal_new ( "control-value-changed",
95                                        GST_TYPE_CAMERA_CONTROL, G_SIGNAL_RUN_LAST,
96                                        G_STRUCT_OFFSET( GstCameraControlClass, value_changed ),
97                                        NULL, NULL,
98                                        gst_interfaces_marshal_VOID__OBJECT_INT,
99                                        G_TYPE_NONE, 2, GST_TYPE_CAMERA_CONTROL_CHANNEL, G_TYPE_INT);
100
101                 initialized = TRUE;
102         }
103
104         // TODO : 
105         klass->camera_control_type      = 0;
106
107         /* defauld virtual functions */
108         klass->list_channels            = NULL;
109         klass->set_exposure                     = NULL;
110         klass->get_exposure                     = NULL;
111         klass->set_capture_mode         = NULL;
112         klass->get_capture_mode         = NULL;
113         klass->set_strobe                       = NULL;
114         klass->get_strobe                       = NULL;
115         klass->set_detect                       = NULL;
116         klass->get_detect                       = NULL;
117         klass->set_value                        = NULL;
118         klass->get_value                        = NULL;
119         klass->set_zoom                         = NULL;
120         klass->get_zoom                         = NULL;
121         klass->set_focus                        = NULL;
122         klass->get_focus                        = NULL;
123         klass->start_auto_focus         = NULL;
124         klass->stop_auto_focus          = NULL;
125         klass->set_focus_level          = NULL;
126         klass->get_focus_level          = NULL; 
127         klass->set_auto_focus_area      = NULL;
128         klass->get_auto_focus_area      = NULL;
129         klass->set_wdr                          = NULL;
130         klass->get_wdr                          = NULL; 
131         klass->set_ahs                          = NULL;
132         klass->get_ahs                          = NULL;
133         klass->set_part_color           = NULL;
134         klass->get_part_color           = NULL;
135         klass->get_exif_info        = NULL;
136         klass->set_capture_command      = NULL;
137 }
138
139 const GList*
140 gst_camera_control_list_channels( GstCameraControl *control )
141 {
142         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
143
144         if( klass->list_channels )
145         {
146                 return klass->list_channels( control );
147         }
148
149         return NULL;
150 }
151
152
153 gboolean
154 gst_camera_control_set_value( GstCameraControl *control, GstCameraControlChannel *control_channel )
155 {
156         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
157
158         if( klass->set_value )
159         {
160                 return klass->set_value( control, control_channel );
161         }
162
163         return FALSE;
164 }
165
166 gboolean
167 gst_camera_control_get_value( GstCameraControl *control, GstCameraControlChannel *control_channel )
168 {
169         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
170
171         if( klass->get_value )
172         {
173                 return klass->get_value( control, control_channel );
174         }
175
176         return FALSE;
177 }
178
179
180
181 gboolean
182 gst_camera_control_set_exposure( GstCameraControl *control, gint type, gint value1, gint value2 )
183 {
184         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
185
186         if( klass->set_exposure )
187         {
188                 return klass->set_exposure( control, type, value1, value2 );
189         }
190
191         return FALSE;
192 }
193
194 gboolean
195 gst_camera_control_get_exposure( GstCameraControl *control, gint type, gint* value1, gint* value2 )
196 {
197         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
198
199         if( klass->get_exposure )
200         {
201                 return klass->get_exposure( control, type, value1, value2 );
202         }
203
204         return FALSE;
205 }
206
207 gboolean
208 gst_camera_control_set_capture_mode( GstCameraControl *control, gint type, gint value )
209 {
210         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
211
212         if( klass->set_capture_mode )
213         {
214                 return klass->set_capture_mode( control, type, value );
215         }
216
217         return FALSE;   
218 }
219
220 gboolean
221 gst_camera_control_get_capture_mode( GstCameraControl *control, gint type, gint *value )
222 {
223         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
224
225         if( klass->get_capture_mode )
226         {
227                 return klass->get_capture_mode( control, type, value );
228         }
229
230         return FALSE;   
231 }
232
233 gboolean
234 gst_camera_control_set_strobe( GstCameraControl *control, gint type, gint value )
235 {
236         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
237
238         if( klass->set_strobe )
239         {
240                 return klass->set_strobe( control, type, value );
241         }
242
243         return FALSE;           
244 }
245
246 gboolean
247 gst_camera_control_get_strobe( GstCameraControl *control, gint type, gint *value )
248 {
249         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
250
251         if( klass->get_strobe )
252         {
253                 return klass->get_strobe( control, type, value );
254         }
255
256         return FALSE;           
257 }
258
259 gboolean
260 gst_camera_control_set_detect( GstCameraControl *control, gint type, gint value )
261 {
262         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
263
264         if( klass->set_detect )
265         {
266                 return klass->set_detect( control, type, value );
267         }
268
269         return FALSE;
270 }
271
272 gboolean
273 gst_camera_control_get_detect( GstCameraControl *control, gint type, gint *value )
274 {
275         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
276
277         if( klass->get_detect )
278         {
279                 return klass->get_detect( control, type, value );
280         }
281
282         //for prevent MISSING_RETURN :+: yoserb.yi 2009-06-25
283         
284         return FALSE;
285 }
286
287 gboolean
288 gst_camera_control_set_zoom( GstCameraControl *control, gint type, gint value )
289 {
290         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
291
292         if( klass->set_zoom )
293         {
294                 return klass->set_zoom( control, type, value );
295         }
296
297         return FALSE;
298 }
299
300 gboolean
301 gst_camera_control_get_zoom( GstCameraControl *control, gint type, gint *value )
302 {
303         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
304
305         if( klass->get_zoom )
306         {
307                 return klass->get_zoom( control, type, value );
308         }
309
310         return FALSE;
311 }
312
313 gboolean
314 gst_camera_control_set_focus( GstCameraControl *control, gint mode, gint range )
315 {
316         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
317
318         if( klass->set_focus )
319         {
320                 return klass->set_focus( control, mode, range );
321         }
322
323         return FALSE;
324 }
325
326 gboolean
327 gst_camera_control_get_focus( GstCameraControl *control, gint *mode, gint *range )
328 {
329         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
330
331         if( klass->get_focus )
332         {
333                 return klass->get_focus( control, mode, range );
334         }
335
336         return FALSE;
337 }
338
339 gboolean        
340 gst_camera_control_start_auto_focus( GstCameraControl *control )
341 {
342         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
343
344         if( klass->start_auto_focus )
345         {
346                 return klass->start_auto_focus( control );
347         }
348
349         return FALSE;
350 }
351
352 gboolean        
353 gst_camera_control_stop_auto_focus( GstCameraControl *control )
354 {
355         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
356
357         if( klass->stop_auto_focus )
358         {
359                 return klass->stop_auto_focus( control );
360         }
361
362         return FALSE;
363 }
364
365 gboolean        
366 gst_camera_control_set_focus_level( GstCameraControl *control, gint manual_level)
367 {
368         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
369
370         if( klass->set_focus_level )
371         {
372                 return klass->set_focus_level( control, manual_level );
373         }
374
375         return FALSE;
376 }
377
378 gboolean
379 gst_camera_control_get_focus_level( GstCameraControl *control, gint *manual_level)
380 {
381         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
382
383         if( klass->get_focus_level )
384         {
385                 return klass->get_focus_level( control, manual_level );
386         }
387
388         return FALSE;
389 }
390
391 gboolean
392 gst_camera_control_set_auto_focus_area( GstCameraControl *control, GstCameraControlRectType rect )
393 {
394         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
395
396         if( klass->set_auto_focus_area )
397         {
398                 return klass->set_auto_focus_area( control, rect );
399         }
400
401         return FALSE;
402 }
403
404 gboolean
405 gst_camera_control_get_auto_focus_area( GstCameraControl *control, GstCameraControlRectType* rect )
406 {
407         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
408
409         if( klass->get_auto_focus_area )
410         {
411                 return klass->get_auto_focus_area( control, rect );
412         }
413
414         return FALSE;
415 }
416
417 gboolean
418 gst_camera_control_set_wdr( GstCameraControl *control, gint value)
419 {
420         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
421
422         if( klass->set_wdr )
423         {
424                 return klass->set_wdr( control, value );
425         }
426
427         return FALSE;
428 }
429
430 gboolean
431 gst_camera_control_get_wdr( GstCameraControl *control, gint *value)
432 {
433         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
434
435         if( klass->get_wdr )
436         {
437                 return klass->get_wdr( control, value );
438         }
439
440         return FALSE;
441 }
442
443 gboolean
444 gst_camera_control_set_ahs( GstCameraControl *control, gint value)
445 {
446         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
447
448         if( klass->set_ahs )
449         {
450                 return klass->set_ahs( control, value );
451         }
452
453         return FALSE;
454 }
455
456 gboolean
457 gst_camera_control_get_ahs( GstCameraControl *control, gint *value)
458 {
459         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
460
461         if( klass->get_ahs )
462         {
463                 return klass->get_ahs( control, value );
464         }
465
466         return FALSE;
467 }
468
469 gboolean
470 gst_camera_control_set_part_color( GstCameraControl *control, gint type, gint value)
471 {
472         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
473
474         if( klass->set_part_color )
475         {
476                 return klass->set_part_color( control, type, value );
477         }
478
479         return FALSE;
480 }
481
482 gboolean
483 gst_camera_control_get_part_color( GstCameraControl *control, gint type, gint *value)
484 {
485         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
486
487         if( klass->get_part_color )
488         {
489                 return klass->get_part_color( control, type, value );
490         }
491
492         return FALSE;
493 }
494
495 gboolean
496 gst_camera_control_get_exif_info     ( GstCameraControl* control, GstCameraControlExifInfo* info)
497 {
498         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
499
500         if( klass->get_exif_info )
501         {
502                 return klass->get_exif_info( control, info );
503         }
504
505         return FALSE;
506 }
507
508
509 gboolean
510 gst_camera_control_get_basic_dev_info     ( GstCameraControl* control, gint dev_id, GstCameraControlCapsInfoType* info)
511 {
512         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
513
514         if( klass->get_basic_dev_info )
515         {
516                 return klass->get_basic_dev_info( control, dev_id, info );
517         }
518
519         return FALSE;
520 }
521
522 gboolean
523 gst_camera_control_get_misc_dev_info     ( GstCameraControl* control, gint dev_id, GstCameraControlCtrlListInfoType* info)
524 {
525         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
526
527         if( klass->get_misc_dev_info )
528         {
529                 return klass->get_misc_dev_info( control, dev_id, info );
530         }
531
532         return FALSE;
533 }
534
535 gboolean
536 gst_camera_control_get_extra_dev_info     ( GstCameraControl* control, gint dev_id, GstCameraControlExtraInfoType* info)
537 {
538         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
539
540         if( klass->get_extra_dev_info )
541         {
542                 return klass->get_extra_dev_info( control, dev_id, info );
543         }
544
545         return FALSE;
546 }
547
548 void
549 gst_camera_control_set_capture_command( GstCameraControl* control, GstCameraControlCaptureCommand cmd )
550 {
551         GstCameraControlClass *klass = GST_CAMERA_CONTROL_GET_CLASS( control );
552
553         if( klass->set_capture_command )
554         {
555                 klass->set_capture_command( control, cmd );
556         }
557
558         return;
559 }
560
561 void
562 gst_camera_control_value_changed( GstCameraControl *control, GstCameraControlChannel *control_channel, gint value )
563 {
564         g_signal_emit( G_OBJECT( control ), gst_camera_control_signals[CONTROL_VALUE_CHANGED], 0, control_channel, value );
565
566         g_signal_emit_by_name( G_OBJECT( control_channel ), "control-value-changed", value );
567 }
568