Update code for sound policy error
[platform/core/api/camera.git] / src / camera.c
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <mm.h>
22 #include <audio-session-manager-types.h>
23 #include <mm_camcorder.h>
24 #include <mm_types.h>
25 #include <math.h>
26 #include <camera.h>
27 #include <camera_private.h>
28 #include <glib.h>
29 #include <dlog.h>
30
31 #ifdef LOG_TAG
32 #undef LOG_TAG
33 #endif
34 #define LOG_TAG "TIZEN_N_CAMERA"
35
36 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data);
37 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data);
38
39
40 static int __convert_camera_error_code(const char* func, int code){
41         int ret = CAMERA_ERROR_NONE;
42         char *errorstr = NULL;
43         switch(code)
44         {
45                 case MM_ERROR_NONE:
46                         ret = CAMERA_ERROR_NONE;
47                         errorstr = "ERROR_NONE";
48                         break;
49                 case MM_ERROR_CAMCORDER_INVALID_ARGUMENT :
50                 case MM_ERROR_COMMON_INVALID_ATTRTYPE :
51                 case MM_ERROR_COMMON_INVALID_PERMISSION :
52                 case MM_ERROR_COMMON_OUT_OF_ARRAY :
53                 case MM_ERROR_COMMON_OUT_OF_RANGE :
54                 case MM_ERROR_COMMON_ATTR_NOT_EXIST :
55                         ret = CAMERA_ERROR_INVALID_PARAMETER;
56                         errorstr = "INVALID_PARAMETER";
57                         break;
58                 case MM_ERROR_CAMCORDER_NOT_INITIALIZED :
59                 case MM_ERROR_CAMCORDER_INVALID_STATE :
60                         ret = CAMERA_ERROR_INVALID_STATE;
61                         errorstr = "INVALID_STATE";
62                         break;
63                 case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND :
64                         ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
65                         errorstr = "DEVICE_NOT_FOUND";
66                         break;
67                 case MM_ERROR_CAMCORDER_DEVICE_BUSY :
68                 case MM_ERROR_CAMCORDER_DEVICE_OPEN :
69                 case MM_ERROR_CAMCORDER_CMD_IS_RUNNING :
70                         ret = CAMERA_ERROR_DEVICE_BUSY;
71                         errorstr = "DEVICE_BUSY";
72                         break;
73                 case MM_ERROR_CAMCORDER_DEVICE :
74                 case MM_ERROR_CAMCORDER_DEVICE_IO :
75                 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT  :
76                 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE :
77                 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG        :
78                 case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER :
79                         ret = CAMERA_ERROR_DEVICE;
80                         errorstr = "ERROR_DEVICE";
81                         break;
82
83                 case MM_ERROR_CAMCORDER_GST_CORE :
84                 case MM_ERROR_CAMCORDER_GST_LIBRARY :
85                 case MM_ERROR_CAMCORDER_GST_RESOURCE :
86                 case MM_ERROR_CAMCORDER_GST_STREAM :
87                 case MM_ERROR_CAMCORDER_GST_STATECHANGE :
88                 case MM_ERROR_CAMCORDER_GST_NEGOTIATION :
89                 case MM_ERROR_CAMCORDER_GST_LINK :
90                 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR :
91                 case MM_ERROR_CAMCORDER_ENCODER :
92                 case MM_ERROR_CAMCORDER_ENCODER_BUFFER :
93                 case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE :
94                 case MM_ERROR_CAMCORDER_ENCODER_WORKING :
95                 case MM_ERROR_CAMCORDER_INTERNAL :
96                 case MM_ERROR_CAMCORDER_NOT_SUPPORTED :
97                 case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT :
98                 case MM_ERROR_CAMCORDER_DSP_FAIL :
99                 case MM_ERROR_CAMCORDER_AUDIO_EMPTY :
100                 case MM_ERROR_CAMCORDER_CREATE_CONFIGURE :
101                 case MM_ERROR_CAMCORDER_FILE_SIZE_OVER :
102                 case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF :
103                 case MM_ERROR_CAMCORDER_INVALID_CONDITION :
104                         ret = CAMERA_ERROR_INVALID_OPERATION;
105                         errorstr = "INVALID_OPERATION";
106                         break;
107
108                 case MM_ERROR_CAMCORDER_RESOURCE_CREATION :
109                 case MM_ERROR_COMMON_OUT_OF_MEMORY:
110                         ret = CAMERA_ERROR_OUT_OF_MEMORY;
111                         errorstr = "OUT_OF_MEMORY";
112                         break;
113
114                 case MM_ERROR_POLICY_BLOCKED:
115                         ret = CAMERA_ERROR_SOUND_POLICY;
116                         errorstr = "ERROR_SOUND_POLICY";
117                         break;
118                 case MM_ERROR_POLICY_BLOCKED_BY_CALL:
119                         ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
120                         errorstr = "ERROR_SOUND_POLICY_BY_CALL";
121                         break;
122                 case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
123                         ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
124                         errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
125                         break;
126                 case MM_ERROR_POLICY_RESTRICTED:
127                         ret = CAMERA_ERROR_SECURITY_RESTRICTED;
128                         errorstr = "ERROR_RESTRICTED";
129                         break;
130
131                 default:
132                         ret = CAMERA_ERROR_INVALID_OPERATION;
133                         errorstr = "INVALID_OPERATION";
134         }
135         LOGE( "[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code);
136         return ret;
137 }
138
139
140 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data){
141         if( user_data == NULL || stream == NULL)
142                 return 0;
143
144         camera_s * handle = (camera_s*)user_data;
145         if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] ){
146                 camera_preview_data_s frame;
147                 frame.format = stream->format;
148                 if( frame.format  == (camera_pixel_format_e)MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
149                         frame.format  = MM_PIXEL_FORMAT_UYVY;
150                 frame.width = stream->width;
151                 frame.height = stream->height;
152                 frame.timestamp = stream->timestamp;
153                 frame.num_of_planes = stream->num_planes;
154                 switch( stream->data_type ){
155                         case MM_CAM_STREAM_DATA_YUV420 :
156                                 frame.data.single_plane.yuv = stream->data.yuv420.yuv;
157                                 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
158                                 break;
159                         case MM_CAM_STREAM_DATA_YUV422 :
160                                 frame.data.single_plane.yuv = stream->data.yuv422.yuv;
161                                 frame.data.single_plane.size = stream->data.yuv422.length_yuv;
162                                 break;
163                         case MM_CAM_STREAM_DATA_YUV420SP :
164                                 frame.data.double_plane.y = stream->data.yuv420sp.y;
165                                 frame.data.double_plane.uv = stream->data.yuv420sp.uv;
166                                 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
167                                 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
168                                 break;
169                         case MM_CAM_STREAM_DATA_YUV420P :
170                                 frame.data.triple_plane.y = stream->data.yuv420p.y;
171                                 frame.data.triple_plane.u = stream->data.yuv420p.u;
172                                 frame.data.triple_plane.v = stream->data.yuv420p.v;
173                                 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
174                                 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
175                                 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
176                                 break;
177                         case MM_CAM_STREAM_DATA_YUV422P :
178                                 frame.data.triple_plane.y = stream->data.yuv422p.y;
179                                 frame.data.triple_plane.u = stream->data.yuv422p.u;
180                                 frame.data.triple_plane.v = stream->data.yuv422p.v;
181                                 frame.data.triple_plane.y_size = stream->data.yuv422p.length_y;
182                                 frame.data.triple_plane.u_size = stream->data.yuv422p.length_u;
183                                 frame.data.triple_plane.v_size = stream->data.yuv422p.length_v;
184                                 break;
185                 }
186                 ((camera_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW])(&frame, handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW]);
187         }
188         return 1;
189 }
190 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data){
191         if( user_data == NULL || frame == NULL)
192                 return 0;
193
194         camera_s * handle = (camera_s*)user_data;
195         handle->current_capture_count++;
196         if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] ){
197                 MMCamcorderCaptureDataType *scrnl = NULL;
198                 int size = 0;
199                 camera_image_data_s image = { NULL, 0, 0, 0, 0, NULL, 0 };
200                 camera_image_data_s thumb = { NULL, 0, 0, 0, 0, NULL, 0 };
201                 camera_image_data_s postview = { NULL, 0, 0, 0, 0, NULL, 0 };
202                 if( frame ){
203                         int ret;
204                         unsigned char *exif;
205                         int exif_size;
206                         image.data = frame->data;
207                         image.size = frame->length;
208                         image.width = frame->width;
209                         image.height = frame->height;
210                         image.format = frame->format;
211                         ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, "captured-exif-raw-data", &exif, &exif_size, NULL);
212                         if( ret == 0 ){
213                                 image.exif = exif;
214                                 image.exif_size = exif_size;
215                         }
216                 }
217
218                 if( thumbnail ){
219                         thumb.data = thumbnail->data;
220                         thumb.size = thumbnail->length;
221                         thumb.width = thumbnail->width;
222                         thumb.height = thumbnail->height;
223                         thumb.format = thumbnail->format;
224                 }
225                 mm_camcorder_get_attributes( handle->mm_handle, NULL, "captured-screennail", &scrnl, &size,NULL );
226                 if( scrnl ){
227                         postview.data = scrnl->data;
228                         postview.size = scrnl->length;
229                         postview.width = scrnl->width;
230                         postview.height = scrnl->height;
231                         postview.format = scrnl->format;
232                 }
233
234                 ((camera_capturing_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE])(&image, scrnl ? &postview : NULL, thumbnail ? &thumb : NULL, handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE]);
235         }
236         // update captured state
237         if( handle->capture_count == 1 && handle->hdr_keep_mode ){
238                 if( handle->current_capture_count == 2 )
239                         handle->is_capture_completed = true;
240         }else if( handle->capture_count == handle->current_capture_count || handle->is_continuous_shot_break)
241                 handle->is_capture_completed = true;
242         return 1;
243 }
244
245 static camera_state_e __camera_state_convert(MMCamcorderStateType mm_state)
246 {
247         camera_state_e state = CAMERA_STATE_NONE;
248
249         switch( mm_state ){
250                 case MM_CAMCORDER_STATE_NONE:
251                         state = CAMERA_STATE_NONE;
252                         break;
253                 case MM_CAMCORDER_STATE_NULL:
254                         state = CAMERA_STATE_CREATED;
255                         break;
256                 case MM_CAMCORDER_STATE_READY:
257                         state = CAMERA_STATE_CREATED;
258                         break;
259                 case MM_CAMCORDER_STATE_PREPARE:
260                         state = CAMERA_STATE_PREVIEW;
261                         break;
262                 case MM_CAMCORDER_STATE_CAPTURING:
263                         state = CAMERA_STATE_CAPTURING;
264                         break;
265                 case MM_CAMCORDER_STATE_RECORDING:
266                         state = CAMERA_STATE_PREVIEW;
267                         break;
268                 case MM_CAMCORDER_STATE_PAUSED:
269                         state = CAMERA_STATE_PREVIEW;
270                         break;
271                 default:
272                         state = CAMERA_STATE_NONE;
273                         break;
274         }
275
276         return state;
277 }
278
279
280 static int __mm_camera_message_callback(int message, void *param, void *user_data){
281         if( user_data == NULL || param == NULL )
282                 return 0;
283
284         camera_s * handle = (camera_s*)user_data;
285
286         if( handle->relay_message_callback )
287                 handle->relay_message_callback(message, param, handle->relay_user_data);
288
289         MMMessageParamType *m = (MMMessageParamType*)param;
290         camera_state_e previous_state;
291
292
293         switch(message){
294                 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
295                 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
296                 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
297                         if( message == MM_MESSAGE_CAMCORDER_STATE_CHANGED && (m->state.previous < MM_CAMCORDER_STATE_NONE ||  m->state.previous > MM_CAMCORDER_STATE_PAUSED || m->state.code != 0) ){
298                                 LOGI( "Invalid state changed message");
299                                 break;
300                         }
301
302                         previous_state = handle->state;
303                         handle->state = __camera_state_convert(m->state.current );
304                         camera_policy_e policy = CAMERA_POLICY_NONE;
305                         if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
306                                 switch (m->state.code) {
307                                 case ASM_EVENT_SOURCE_CALL_START:
308                                         policy = CAMERA_POLICY_SOUND_BY_CALL;
309                                         LOGE("CAMERA_POLICY_SOUND_BY_CALL");
310                                         break;
311                                 case ASM_EVENT_SOURCE_ALARM_START:
312                                 case ASM_EVENT_SOURCE_ALARM_END:
313                                         policy = CAMERA_POLICY_SOUND_BY_ALARM;
314                                         LOGE("CAMERA_POLICY_SOUND_BY_ALARM");
315                                         break;
316                                 default:
317                                         policy = CAMERA_POLICY_SOUND;
318                                         LOGE("CAMERA_POLICY_SOUND");
319                                         break;
320                                 }
321                         } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
322                                 policy = CAMERA_POLICY_SECURITY;
323                                 LOGE("CAMERA_POLICY_SECURITY");
324                         }
325
326                         if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
327                                 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, policy, handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
328                         }
329
330                         // should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state
331                         if( policy != CAMERA_POLICY_NONE ){
332                                 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] )
333                                         ((camera_interrupted_cb)handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED])(policy, previous_state, handle->state, handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED]);
334                                 if( m->state.previous == MM_CAMCORDER_STATE_PREPARE && m->state.current == MM_CAMCORDER_STATE_READY ){
335                                         mm_camcorder_unrealize(handle->mm_handle);
336                                 }
337                         }
338
339                         break;
340                 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED :
341                         if( handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] ){
342                                 ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])( m->code, handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
343                         }
344                         break;
345                 case MM_MESSAGE_CAMCORDER_CAPTURED:
346                 {
347                         handle->current_capture_complete_count = m->code;
348                         if(  handle->capture_count == 1 || m->code == handle->capture_count ||(handle->is_continuous_shot_break && handle->state == CAMERA_STATE_CAPTURING) ){
349                                 //pseudo state change
350                                 previous_state = handle->state ;
351                                 handle->state = CAMERA_STATE_CAPTURED;
352                                 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
353                                         ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state,  0 , handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
354                                 }
355                                 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
356                                         ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
357                                 }
358                         }
359                         break;
360                 }
361                 case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
362                 case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
363                 {
364                         MMCamRecordingReport *report = (MMCamRecordingReport *)m ->data;
365                         if( report != NULL && report->recording_filename ){
366                                 free(report->recording_filename );
367                                 report->recording_filename = NULL;
368                         }
369                         if( report ){
370                                 free(report);
371                                 report = NULL;
372                         }
373                         break;
374                 }
375                 case MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED:
376                 {
377                         if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
378                                 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
379                         }
380                         break;
381                 }
382                 case MM_MESSAGE_CAMCORDER_ERROR:
383                 {
384                         int errorcode = m->code;
385                         int camera_error = 0;
386                         switch( errorcode ){
387                                 case MM_ERROR_CAMCORDER_DEVICE :
388                                 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT :
389                                 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE :
390                                 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG :
391                                         camera_error = CAMERA_ERROR_DEVICE;
392                                         break;
393                                 case MM_ERROR_CAMCORDER_GST_CORE :
394                                 case MM_ERROR_CAMCORDER_GST_LIBRARY :
395                                 case MM_ERROR_CAMCORDER_GST_RESOURCE :
396                                 case MM_ERROR_CAMCORDER_GST_STREAM :
397                                 case MM_ERROR_CAMCORDER_GST_NEGOTIATION :
398                                 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR :
399                                 case MM_ERROR_CAMCORDER_ENCODER :
400                                 case MM_ERROR_CAMCORDER_ENCODER_BUFFER :
401                                 case MM_ERROR_CAMCORDER_ENCODER_WORKING :
402                                 case MM_ERROR_CAMCORDER_MNOTE_CREATION :
403                                 case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY :
404                                 case MM_ERROR_CAMCORDER_INTERNAL :
405                                 case MM_ERROR_FILE_NOT_FOUND:
406                                 case MM_ERROR_FILE_READ:
407                                         camera_error = CAMERA_ERROR_INVALID_OPERATION;
408                                         break;
409                                 case MM_ERROR_CAMCORDER_LOW_MEMORY :
410                                 case MM_ERROR_CAMCORDER_MNOTE_MALLOC :
411                                         camera_error = CAMERA_ERROR_OUT_OF_MEMORY;
412                                         break;
413                         }
414                         if( camera_error != 0 && handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] )
415                                 ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(camera_error, handle->state , handle->user_data[_CAMERA_EVENT_TYPE_ERROR]);
416
417                         break;
418                 }
419                 case MM_MESSAGE_CAMCORDER_HDR_PROGRESS:
420                 {
421                         int percent = m->code;
422                         if( handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] )
423                                 ((camera_attr_hdr_progress_cb)handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS])(percent, handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
424                         break;
425                 }
426                 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
427                 {
428                         MMCamFaceDetectInfo *cam_fd_info = (MMCamFaceDetectInfo *)(m->data);
429                         if ( cam_fd_info ) {
430                                 camera_detected_face_s faces[cam_fd_info->num_of_faces];
431                                 handle->num_of_faces = cam_fd_info->num_of_faces > MAX_DETECTED_FACE ? MAX_DETECTED_FACE : cam_fd_info->num_of_faces;
432                                 int i;
433                                 for(i=0; i < handle->num_of_faces ; i++){
434                                         faces[i].id = cam_fd_info->face_info[i].id;
435                                         faces[i].score = cam_fd_info->face_info[i].score;
436                                         faces[i].x = cam_fd_info->face_info[i].rect.x;
437                                         faces[i].y = cam_fd_info->face_info[i].rect.y;
438                                         faces[i].width = cam_fd_info->face_info[i].rect.width;
439                                         faces[i].height = cam_fd_info->face_info[i].rect.height;
440                                         handle->faceinfo[i] = faces[i]; //cache face coordinate
441                                 }
442                                 if( handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] )
443                                         ((camera_face_detected_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces, handle->num_of_faces, handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION]);
444                         }else{
445                                 handle->num_of_faces = 0;
446                         }
447                         break;
448                 }
449         }
450
451         return 1;
452 }
453
454 static int __capture_completed_event_cb(void *data){
455         camera_s *handle = (camera_s*)data;
456         if( handle->current_capture_count > 0 && handle->current_capture_count == handle->current_capture_complete_count && handle->state == CAMERA_STATE_CAPTURING ){
457                 //pseudo state change
458                 camera_state_e previous_state = handle->state;
459                 handle->state = CAMERA_STATE_CAPTURED;
460                 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
461                         ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state,  0 , handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
462                 }
463                 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
464                         ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
465                 }
466         }
467         return false;
468 }
469
470 int camera_create( camera_device_e device, camera_h* camera){
471
472         if( camera == NULL){
473                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
474                 return CAMERA_ERROR_INVALID_PARAMETER;
475         }
476
477         int ret;
478         MMCamPreset info;
479         int preview_format;
480         int rotation;
481
482         if( device == CAMERA_DEVICE_CAMERA1 )
483                 info.videodev_type= MM_VIDEO_DEVICE_CAMERA1;
484         else
485                 info.videodev_type= MM_VIDEO_DEVICE_CAMERA0;
486
487         camera_s* handle = (camera_s*)malloc( sizeof(camera_s) );
488         if(handle==NULL){
489                 LOGE("[%s] malloc fail",__func__);
490                 return CAMERA_ERROR_OUT_OF_MEMORY;
491         }
492         memset(handle, 0 , sizeof(camera_s));
493
494         ret = mm_camcorder_create(&handle->mm_handle, &info);
495         if( ret != MM_ERROR_NONE){
496                 free(handle);
497                 return __convert_camera_error_code(__func__,ret);
498         }
499
500         preview_format = MM_PIXEL_FORMAT_YUYV;
501         rotation = MM_DISPLAY_ROTATION_NONE;
502         ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
503                                                                                                                                 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
504                                                                                                                                 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
505                                                                                                                                 MMCAM_CAPTURE_WIDTH, &handle->capture_width,
506                                                                                                                                 MMCAM_CAPTURE_HEIGHT, &handle->capture_height,
507                                                                                                                                 NULL);
508
509         char *error;
510         ret = mm_camcorder_set_attributes(handle->mm_handle, &error,
511                                                                                                                                 MMCAM_MODE , MM_CAMCORDER_MODE_VIDEO_CAPTURE,
512                                                                                                                                 MMCAM_CAMERA_FORMAT,  preview_format,
513                                                                                                                                 MMCAM_IMAGE_ENCODER , MM_IMAGE_CODEC_JPEG,
514                                                                                                                                 MMCAM_CAPTURE_FORMAT,  MM_PIXEL_FORMAT_ENCODED,
515                                                                                                                                 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL,
516                                                                                                                                 MMCAM_DISPLAY_ROTATION, rotation,
517                                                                                                                                 MMCAM_CAPTURE_COUNT, 1,
518                                                                                                                                 (void*)NULL);
519
520         handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
521
522         if( ret != MM_ERROR_NONE){
523                 LOGE("[%s] mm_camcorder_set_attributes fail(%x, %s)",__func__, ret, error);
524                 mm_camcorder_destroy(handle->mm_handle);
525                 free(error);
526                 free(handle);
527                 return __convert_camera_error_code(__func__, ret);
528         }
529
530         handle->state = CAMERA_STATE_CREATED;
531         handle->relay_message_callback = NULL;
532         handle->relay_user_data = NULL;
533         handle->capture_resolution_modified = false;
534         handle->hdr_keep_mode = false;
535         handle->focus_area_valid = false;
536         handle->is_used_in_recorder = false;
537         handle->on_continuous_focusing = false;
538         handle->cached_focus_mode = -1;
539         mm_camcorder_set_message_callback(handle->mm_handle, __mm_camera_message_callback, (void*)handle);
540
541         *camera = (camera_h)handle;
542         return __convert_camera_error_code(__func__, ret);
543 }
544
545  int camera_destroy(camera_h camera){
546         if( camera == NULL){
547                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
548                 return CAMERA_ERROR_INVALID_PARAMETER;
549         }
550
551         int ret;
552         camera_s *handle = (camera_s*)camera;
553         if( handle->is_used_in_recorder ){
554                 LOGE("[%s] camera is using in another recorder.", __func__);
555                 return CAMERA_ERROR_INVALID_OPERATION;
556         }
557
558         ret = mm_camcorder_destroy(handle->mm_handle);
559
560         if( ret == MM_ERROR_NONE)
561                 free(handle);
562
563         return __convert_camera_error_code(__func__, ret);
564
565 }
566
567 int camera_start_preview(camera_h camera){
568         LOGE("%s - start", __func__);
569         if( camera == NULL){
570                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
571                 return CAMERA_ERROR_INVALID_PARAMETER;
572         }
573
574
575         int ret;
576         camera_s *handle = (camera_s*)camera;
577         camera_state_e capi_state;
578         camera_get_state(camera, &capi_state);
579
580         if( capi_state == CAMERA_STATE_CAPTURED )
581         {
582                 ret = mm_camcorder_capture_stop(handle->mm_handle);
583                 return __convert_camera_error_code(__func__, ret);
584         }
585
586
587
588         //for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback
589         mm_camcorder_set_video_capture_callback( handle->mm_handle, (mm_camcorder_video_capture_callback)__mm_capture_callback, (void*)handle);
590
591         MMCamcorderStateType state ;
592         mm_camcorder_get_state(handle->mm_handle, &state);
593         if( state != MM_CAMCORDER_STATE_READY){
594                 ret = mm_camcorder_realize(handle->mm_handle);
595                 if( ret != MM_ERROR_NONE )
596                         return __convert_camera_error_code(__func__, ret);
597         }
598
599         ret = mm_camcorder_start(handle->mm_handle);
600
601         //start fail.
602         if( ret != MM_ERROR_NONE &&  state != MM_CAMCORDER_STATE_READY){
603                 mm_camcorder_unrealize(handle->mm_handle);
604         }
605
606         return __convert_camera_error_code(__func__, ret);
607 }
608
609 int camera_stop_preview(camera_h camera){
610         if( camera == NULL){
611                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
612                 return CAMERA_ERROR_INVALID_PARAMETER;
613         }
614
615
616         int ret;
617         camera_s *handle = (camera_s*)camera;
618         MMCamcorderStateType state ;
619         mm_camcorder_get_state(handle->mm_handle, &state);
620
621         if( state == MM_CAMCORDER_STATE_PREPARE ){
622                 ret = mm_camcorder_stop(handle->mm_handle);
623                 if( ret != MM_ERROR_NONE)
624                         return __convert_camera_error_code(__func__, ret);
625         }
626         camera_stop_face_detection(camera);
627         ret = mm_camcorder_unrealize(handle->mm_handle);
628         return __convert_camera_error_code(__func__, ret);
629 }
630
631 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb , camera_capture_completed_cb completed_cb , void *user_data){
632         if( camera == NULL){
633                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
634                 return CAMERA_ERROR_INVALID_PARAMETER;
635         }
636
637         camera_s * handle = (camera_s*)camera;
638         int ret;
639         MMCamcorderStateType state;
640         mm_camcorder_get_state(handle->mm_handle, &state);
641         if( state != MM_CAMCORDER_STATE_PREPARE && state != MM_CAMCORDER_STATE_RECORDING && state != MM_CAMCORDER_STATE_PAUSED){
642                 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
643                 return CAMERA_ERROR_INVALID_STATE;
644         }
645
646         if( handle->capture_resolution_modified ){
647                 mm_camcorder_set_attributes(handle->mm_handle, NULL,
648                                                                                                                         MMCAM_CAPTURE_WIDTH, handle->capture_width,
649                                                                                                                         MMCAM_CAPTURE_HEIGHT, handle->capture_height,
650                                                                                                                         NULL);
651                 handle->capture_resolution_modified = false;
652         }
653         mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAPTURE_COUNT , 1,NULL);
654
655         handle->capture_count = 1;
656         handle->is_continuous_shot_break = false;
657         handle->current_capture_count = 0;
658         handle->current_capture_complete_count = 0;
659         handle->is_capture_completed = false;
660
661         handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
662         handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
663         handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
664         handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
665         ret = mm_camcorder_capture_start(handle->mm_handle);
666         if( ret != 0 ){
667                 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
668                 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
669                 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
670                 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
671         }
672
673         return __convert_camera_error_code(__func__, ret);
674 }
675
676 int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb , void *user_data){
677         if( camera == NULL){
678                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
679                 return CAMERA_ERROR_INVALID_PARAMETER;
680         }
681
682         if( count < 2 || interval < 0 ){
683                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
684                 return CAMERA_ERROR_INVALID_PARAMETER;
685         }
686
687         camera_s * handle = (camera_s*)camera;
688
689         MMCamcorderStateType state;
690         mm_camcorder_get_state(handle->mm_handle, &state);
691         if( state != MM_CAMCORDER_STATE_PREPARE ){
692                 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
693                 return CAMERA_ERROR_INVALID_STATE;
694         }
695
696         int preview_width;
697         int preview_height;
698         int capture_width;
699         int capture_height;
700         int current_preview_format;
701         bool supported_ZSL = false;
702
703         int ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
704                                                                                                                                 MMCAM_CAPTURE_COUNT , count,
705                                                                                                                                 MMCAM_CAPTURE_INTERVAL, interval,
706                                                                                                                                 NULL);
707         if( ret != 0 ){
708                 LOGE("[%s] (%x) error set continuous shot attribute", ret);
709                 return __convert_camera_error_code(__func__, ret);
710         }
711         handle->capture_count = count;
712         handle->is_continuous_shot_break = false;
713         handle->current_capture_count = 0;
714         handle->current_capture_complete_count = 0;
715         handle->is_capture_completed = false;
716
717         ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FORMAT, &current_preview_format,NULL);
718         if( current_preview_format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
719                 supported_ZSL = true;
720
721         if( ret != 0 ){
722                 LOGE("[%s] (%x) error get continuous shot attribute", ret);
723         }
724
725         if( !supported_ZSL ){
726                 mm_camcorder_get_attributes(handle->mm_handle, NULL,
727                                                                                                                                         MMCAM_CAMERA_WIDTH, &preview_width,
728                                                                                                                                         MMCAM_CAMERA_HEIGHT, &preview_height,
729                                                                                                                                         MMCAM_CAPTURE_WIDTH, &capture_width,
730                                                                                                                                         MMCAM_CAPTURE_HEIGHT, &capture_height,
731                                                                                                                                         NULL);
732                 if( preview_width != capture_width || preview_height != capture_height ){
733                         mm_camcorder_set_attributes(handle->mm_handle, NULL,
734                                                                                                                                                 MMCAM_CAPTURE_WIDTH, preview_width,
735                                                                                                                                                 MMCAM_CAPTURE_HEIGHT, preview_height,
736                                                                                                                                                 NULL);
737                         handle->capture_resolution_modified = true;
738                 }
739         }
740
741         handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
742         handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
743         handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
744         handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
745
746         ret = mm_camcorder_capture_start(handle->mm_handle);
747         if( ret != 0 ){
748                 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
749                 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
750                 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
751                 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
752         }
753
754         return __convert_camera_error_code(__func__,ret);
755
756 }
757
758 int camera_stop_continuous_capture(camera_h camera){
759         if( camera == NULL){
760                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
761                 return CAMERA_ERROR_INVALID_PARAMETER;
762         }
763         camera_s *handle = (camera_s*)camera;
764         int ret;
765         camera_state_e state;
766         camera_get_state(camera, &state);
767         if( state != CAMERA_STATE_CAPTURING && handle->capture_count > 1 ){
768                 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
769                 return CAMERA_ERROR_INVALID_STATE;
770         }
771
772         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, "capture-break-cont-shot", 1, NULL);
773         if( ret == 0){
774                 handle->is_continuous_shot_break = true;
775                 if( handle->current_capture_count > 0 )
776                         handle->is_capture_completed = true;
777                 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
778         }
779
780         return __convert_camera_error_code(__func__,ret);
781 }
782
783 bool camera_is_supported_face_detection(camera_h camera){
784         if( camera == NULL){
785                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
786                 return false;
787         }
788         int ret;
789         camera_s * handle = (camera_s*)camera;
790         MMCamAttrsInfo info;
791         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
792         int i=0;
793         if( info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY){
794                 for( i =0; i < info.int_array.count ; i++){
795                         if( info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON )
796                                 return true;
797                 }
798         }
799         return false;
800 }
801
802 bool camera_is_supported_zero_shutter_lag(camera_h camera){
803         if( camera == NULL){
804                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
805                 return false;
806         }
807         int ret;
808         camera_s * handle = (camera_s*)camera;
809         MMCamAttrsInfo info;
810         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &info);
811         int i=0;
812         if( info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY){
813                 for( i =0; i < info.int_array.count ; i++){
814                         if( info.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
815                                 return true;
816                 }
817         }
818         return false;
819 }
820
821 int camera_get_device_count(camera_h camera, int *device_count) {
822         int ret = MM_ERROR_NONE;
823         camera_s *handle = (camera_s *)camera;
824
825         if (camera == NULL || device_count == NULL) {
826                 LOGE("[%s] INVALID_PARAMETER(0x%08x)", __func__, CAMERA_ERROR_INVALID_PARAMETER);
827                 return CAMERA_ERROR_INVALID_PARAMETER;
828         }
829
830         ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
831                                           MMCAM_CAMERA_DEVICE_COUNT, device_count,
832                                           NULL);
833
834         return __convert_camera_error_code(__func__, ret);
835 }
836
837 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void * user_data){
838         if( camera == NULL){
839                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
840                 return CAMERA_ERROR_INVALID_PARAMETER;
841         }
842         camera_s * handle = (camera_s*)camera;
843         camera_state_e state = CAMERA_STATE_NONE;
844         int ret;
845         camera_get_state(camera, &state);
846         if( state != CAMERA_STATE_PREVIEW ){
847                 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
848                 return CAMERA_ERROR_INVALID_STATE;
849         }
850         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON, NULL);
851         if( ret == 0 ){
852                 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)callback;
853                 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)user_data;
854                 handle->num_of_faces = 0;
855         }
856         return __convert_camera_error_code(__func__,ret);
857 }
858
859 int camera_stop_face_detection(camera_h camera){
860         if( camera == NULL){
861                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
862                 return CAMERA_ERROR_INVALID_PARAMETER;
863         }
864         camera_s * handle = (camera_s*)camera;
865         int ret;
866         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF, NULL);
867         handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
868         handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
869         handle->num_of_faces = 0;
870         return __convert_camera_error_code(__func__,ret);
871 }
872
873 int camera_face_zoom(camera_h camera, int face_id){
874         if( camera == NULL){
875                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
876                 return CAMERA_ERROR_INVALID_PARAMETER;
877         }
878         camera_s * handle = (camera_s*)camera;
879         int ret;
880         int find = -1;
881         int i;
882         int current_mode;
883
884         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FACE_ZOOM_MODE , &current_mode, NULL);
885
886         if( current_mode == MM_CAMCORDER_FACE_ZOOM_MODE_ON )
887                 return CAMERA_ERROR_INVALID_STATE;
888
889         for( i = 0 ; i < handle->num_of_faces ; i++){
890                 if( handle->faceinfo[i].id == face_id ){
891                         find = i;
892                         break;
893                 }
894         }
895         if( find == -1 )
896                 return CAMERA_ERROR_INVALID_PARAMETER;
897         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FACE_ZOOM_MODE, MM_CAMCORDER_FACE_ZOOM_MODE_ON,
898                                  MMCAM_CAMERA_FACE_ZOOM_X, handle->faceinfo[find].x+(handle->faceinfo[find].width>>1),
899                                  MMCAM_CAMERA_FACE_ZOOM_Y, handle->faceinfo[find].y+(handle->faceinfo[find].height>>1),
900                                  NULL);
901
902         return __convert_camera_error_code(__func__,ret);
903 }
904
905 int camera_cancel_face_zoom(camera_h camera){
906         if( camera == NULL){
907                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
908                 return CAMERA_ERROR_INVALID_PARAMETER;
909         }
910         camera_s * handle = (camera_s*)camera;
911         int ret;
912         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FACE_ZOOM_MODE, MM_CAMCORDER_FACE_ZOOM_MODE_OFF, NULL);
913         return __convert_camera_error_code(__func__,ret);
914 }
915
916
917 int camera_get_state(camera_h camera, camera_state_e * state){
918         if( camera == NULL || state == NULL){
919                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
920                 return CAMERA_ERROR_INVALID_PARAMETER;
921         }
922
923         camera_s *handle = (camera_s*)camera;
924         camera_state_e capi_state;
925         MMCamcorderStateType mmstate ;
926         mm_camcorder_get_state(handle->mm_handle, &mmstate);
927
928         capi_state = __camera_state_convert(mmstate);
929
930         if( ( handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed ) && mmstate == MM_CAMCORDER_STATE_CAPTURING )
931                 capi_state = CAMERA_STATE_CAPTURED;
932
933         *state = capi_state;
934         return CAMERA_ERROR_NONE;
935 }
936
937 int camera_start_focusing( camera_h camera, bool continuous ){
938         if( camera == NULL){
939                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
940                 return CAMERA_ERROR_INVALID_PARAMETER;
941         }
942         camera_s *handle = (camera_s*)camera;
943
944         if( handle->cached_focus_mode != -1){
945                 LOGD("[%s] apply cached focus mode %d", __func__, handle->cached_focus_mode);
946                 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE  , handle->cached_focus_mode, NULL);
947                 handle->cached_focus_mode = -1;
948         }
949
950         if( continuous )
951                 return __camera_start_continuous_focusing(camera);
952         else{
953                 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, handle->focus_area_valid ? MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO : MM_CAMCORDER_FOCUS_MODE_AUTO, NULL);
954                 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s*)camera)->mm_handle));
955         }
956 }
957
958 int __camera_start_continuous_focusing(camera_h camera){
959         if( camera == NULL ){
960                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
961                 return CAMERA_ERROR_INVALID_PARAMETER;
962         }
963         camera_s *handle = (camera_s*)camera;
964         int ret;
965         int mode;
966         handle->on_continuous_focusing = true;
967         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , &mode, NULL);
968         if( mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS )
969                 ret = mm_camcorder_start_focusing(handle->mm_handle);
970         else
971                 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS, NULL);
972         return __convert_camera_error_code(__func__, ret);
973 }
974
975 int camera_cancel_focusing( camera_h camera ){
976         if( camera == NULL){
977                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
978                 return CAMERA_ERROR_INVALID_PARAMETER;
979         }
980         camera_s *handle = (camera_s*)camera;
981         handle->on_continuous_focusing = false;
982         return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
983 }
984 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display){
985         if( camera == NULL){
986                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
987                 return CAMERA_ERROR_INVALID_PARAMETER;
988         }
989         int ret;
990         camera_s * handle = (camera_s*)camera;
991         handle->display_handle = display;
992         handle->display_type = type;
993         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL,
994                 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
995                 MMCAM_DISPLAY_SURFACE  ,type, NULL );
996         if( ret == 0 && type != CAMERA_DISPLAY_TYPE_NONE)
997                 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL,
998                 MMCAM_DISPLAY_HANDLE  , type == CAMERA_DISPLAY_TYPE_X11 ? &handle->display_handle : display , sizeof(display) ,
999                 NULL);
1000         return __convert_camera_error_code(__func__, ret);
1001 }
1002
1003 int camera_set_preview_resolution(camera_h camera,  int width, int height){
1004         if( camera == NULL){
1005                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1006                 return CAMERA_ERROR_INVALID_PARAMETER;
1007         }
1008         int ret;
1009         camera_s * handle = (camera_s*)camera;
1010         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH  , width ,MMCAM_CAMERA_HEIGHT ,height,  NULL);
1011         return __convert_camera_error_code(__func__, ret);
1012 }
1013 int camera_set_x11_display_rotation(camera_h camera,  camera_rotation_e rotation){
1014         if( camera == NULL){
1015                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1016                 return CAMERA_ERROR_INVALID_PARAMETER;
1017         }
1018
1019         if( rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270 )
1020                 return CAMERA_ERROR_INVALID_PARAMETER;
1021
1022         int ret;
1023         camera_s * handle = (camera_s*)camera;
1024
1025         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL);
1026         return __convert_camera_error_code(__func__, ret);
1027 }
1028
1029 int camera_set_x11_display_flip(camera_h camera, camera_flip_e flip){
1030         if( camera == NULL){
1031                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1032                 return CAMERA_ERROR_INVALID_PARAMETER;
1033         }
1034
1035         if( flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH )
1036                 return CAMERA_ERROR_INVALID_PARAMETER;
1037
1038         int ret;
1039         camera_s * handle = (camera_s*)camera;
1040         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_FLIP , flip, NULL);
1041         return __convert_camera_error_code(__func__, ret);
1042 }
1043
1044 int camera_get_x11_display_flip(camera_h camera, camera_flip_e *flip){
1045         if( camera == NULL || flip == NULL ){
1046                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1047                 return CAMERA_ERROR_INVALID_PARAMETER;
1048         }
1049
1050         int ret;
1051         camera_s * handle = (camera_s*)camera;
1052
1053         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_FLIP , flip, NULL);
1054         return __convert_camera_error_code(__func__, ret);
1055 }
1056
1057 int camera_set_capture_resolution(camera_h camera,  int width, int height){
1058         if( camera == NULL){
1059                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1060                 return CAMERA_ERROR_INVALID_PARAMETER;
1061         }
1062         int ret;
1063         camera_s * handle = (camera_s*)camera;
1064         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_WIDTH, width  ,MMCAM_CAPTURE_HEIGHT , height, NULL);
1065         if( ret == 0 ){
1066                 handle->capture_width = width;
1067                 handle->capture_height = height;
1068         }
1069         return __convert_camera_error_code(__func__, ret);
1070 }
1071
1072 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format){
1073         if( camera == NULL){
1074                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1075                 return CAMERA_ERROR_INVALID_PARAMETER;
1076         }
1077         int ret;
1078         camera_s * handle = (camera_s*)camera;
1079         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL);
1080         return __convert_camera_error_code(__func__, ret);
1081 }
1082
1083 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format){
1084         if( camera == NULL){
1085                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1086                 return CAMERA_ERROR_INVALID_PARAMETER;
1087         }
1088         int ret;
1089         camera_s * handle = (camera_s*)camera;
1090
1091         if( format == CAMERA_PIXEL_FORMAT_UYVY ){
1092                 bool supported_ITLV_UYVY = false;
1093                 MMCamAttrsInfo supported_format;
1094                 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1095                 int i;
1096                 for( i=0 ; i < supported_format.int_array.count ; i++){
1097                         if( supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1098                                 supported_ITLV_UYVY = true;
1099                 }
1100                 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ?  MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY , NULL);
1101         }else
1102                 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL);
1103
1104         return __convert_camera_error_code(__func__, ret);
1105 }
1106
1107 int camera_get_preview_resolution(camera_h camera,  int *width, int *height){
1108         if( camera == NULL || width == NULL || height == NULL){
1109                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1110                 return CAMERA_ERROR_INVALID_PARAMETER;
1111         }
1112
1113         int ret;
1114         camera_s * handle = (camera_s*)camera;
1115         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width,MMCAM_CAMERA_HEIGHT, height,  NULL);
1116         return __convert_camera_error_code(__func__, ret);
1117
1118 }
1119
1120 int camera_get_x11_display_rotation( camera_h camera,  camera_rotation_e *rotation){
1121         if( camera == NULL || rotation == NULL ){
1122                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1123                 return CAMERA_ERROR_INVALID_PARAMETER;
1124         }
1125
1126         int ret;
1127         camera_s * handle = (camera_s*)camera;
1128
1129         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL);
1130         return __convert_camera_error_code(__func__, ret);
1131 }
1132
1133 int camera_set_x11_display_visible(camera_h camera, bool visible){
1134         if( camera == NULL){
1135                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1136                 return CAMERA_ERROR_INVALID_PARAMETER;
1137         }
1138         int ret;
1139         camera_s * handle = (camera_s*)camera;
1140
1141         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_VISIBLE , visible, NULL);
1142         return __convert_camera_error_code(__func__, ret);
1143 }
1144
1145 int camera_is_x11_display_visible(camera_h camera, bool* visible){
1146         if( camera == NULL || visible == NULL){
1147                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1148                 return CAMERA_ERROR_INVALID_PARAMETER;
1149         }
1150
1151         int ret;
1152         int result;
1153         camera_s * handle = (camera_s*)camera;
1154
1155         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_VISIBLE , &result, NULL);
1156         if( ret == 0)
1157                 *visible = result;
1158         return __convert_camera_error_code(__func__, ret);
1159 }
1160
1161 int camera_set_x11_display_mode( camera_h camera , camera_display_mode_e ratio){
1162         if( camera == NULL){
1163                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1164                 return CAMERA_ERROR_INVALID_PARAMETER;
1165         }
1166
1167         if( ratio < CAMERA_DISPLAY_MODE_LETTER_BOX || ratio > CAMERA_DISPLAY_MODE_CROPPED_FULL )
1168                 return CAMERA_ERROR_INVALID_PARAMETER;
1169
1170         int ret;
1171         camera_s * handle = (camera_s*)camera;
1172
1173         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_GEOMETRY_METHOD , ratio, NULL);
1174         return __convert_camera_error_code(__func__, ret);
1175 }
1176
1177 int camera_get_x11_display_mode( camera_h camera , camera_display_mode_e* ratio){
1178         if( camera == NULL || ratio == NULL){
1179                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1180                 return CAMERA_ERROR_INVALID_PARAMETER;
1181         }
1182
1183         int ret;
1184         camera_s * handle = (camera_s*)camera;
1185
1186         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_GEOMETRY_METHOD , ratio, NULL);
1187         return __convert_camera_error_code(__func__, ret);
1188 }
1189
1190
1191 int camera_get_capture_resolution(camera_h camera, int *width, int *height){
1192         if( camera == NULL || width== NULL || height == NULL){
1193                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1194                 return CAMERA_ERROR_INVALID_PARAMETER;
1195         }
1196         camera_s * handle = (camera_s*)camera;
1197         *width = handle->capture_width;
1198         *height = handle->capture_height;
1199         return CAMERA_ERROR_NONE;
1200 }
1201
1202 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format){
1203         if( camera == NULL || format == NULL){
1204                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1205                 return CAMERA_ERROR_INVALID_PARAMETER;
1206         }
1207
1208         int ret;
1209         camera_s * handle = (camera_s*)camera;
1210         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL);
1211         return __convert_camera_error_code(__func__, ret);
1212 }
1213
1214 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format){
1215         if( camera == NULL || format == NULL){
1216                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1217                 return CAMERA_ERROR_INVALID_PARAMETER;
1218         }
1219
1220         int ret;
1221         camera_s * handle = (camera_s*)camera;
1222         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL);
1223         if( (MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1224                 *format = CAMERA_PIXEL_FORMAT_UYVY;
1225         return __convert_camera_error_code(__func__, ret);
1226 }
1227
1228 int camera_set_preview_cb( camera_h camera, camera_preview_cb callback, void* user_data ){
1229         if( camera == NULL || callback == NULL){
1230                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1231                 return CAMERA_ERROR_INVALID_PARAMETER;
1232         }
1233
1234         camera_s * handle = (camera_s*)camera;
1235         handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)callback;
1236         handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)user_data;
1237         mm_camcorder_set_video_stream_callback( handle->mm_handle, (mm_camcorder_video_stream_callback)__mm_videostream_callback, (void*)handle);
1238         return CAMERA_ERROR_NONE;
1239 }
1240 int camera_unset_preview_cb( camera_h camera){
1241         if( camera == NULL){
1242                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1243                 return CAMERA_ERROR_INVALID_PARAMETER;
1244         }
1245         camera_s * handle = (camera_s*)camera;
1246         mm_camcorder_set_video_stream_callback( handle->mm_handle, (mm_camcorder_video_stream_callback)NULL, (void*)NULL);
1247         handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)NULL;
1248         handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)NULL;
1249         return CAMERA_ERROR_NONE;
1250 }
1251
1252 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data){
1253         if( camera == NULL || callback == NULL){
1254                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1255                 return CAMERA_ERROR_INVALID_PARAMETER;
1256         }
1257
1258         camera_s * handle = (camera_s*)camera;
1259         handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)callback;
1260         handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)user_data;
1261         return CAMERA_ERROR_NONE;
1262 }
1263 int camera_unset_state_changed_cb(camera_h camera){
1264         if( camera == NULL){
1265                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1266                 return CAMERA_ERROR_INVALID_PARAMETER;
1267         }
1268         camera_s * handle = (camera_s*)camera;
1269         handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1270         handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1271         return CAMERA_ERROR_NONE;
1272 }
1273
1274 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data){
1275         if( camera == NULL || callback == NULL){
1276                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1277                 return CAMERA_ERROR_INVALID_PARAMETER;
1278         }
1279
1280         camera_s * handle = (camera_s*)camera;
1281         handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)callback;
1282         handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)user_data;
1283         return CAMERA_ERROR_NONE;
1284 }
1285
1286 int camera_unset_interrupted_cb(camera_h camera){
1287         if( camera == NULL){
1288                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1289                 return CAMERA_ERROR_INVALID_PARAMETER;
1290         }
1291         camera_s * handle = (camera_s*)camera;
1292         handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1293         handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1294         return CAMERA_ERROR_NONE;
1295 }
1296
1297 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data){
1298         if( camera == NULL || callback == NULL){
1299                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1300                 return CAMERA_ERROR_INVALID_PARAMETER;
1301         }
1302         camera_s * handle = (camera_s*)camera;
1303         handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)callback;
1304         handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)user_data;
1305         return CAMERA_ERROR_NONE;
1306 }
1307 int camera_unset_focus_changed_cb(camera_h camera){
1308         if( camera == NULL){
1309                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1310                 return CAMERA_ERROR_INVALID_PARAMETER;
1311         }
1312         camera_s * handle = (camera_s*)camera;
1313         handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1314         handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1315         return CAMERA_ERROR_NONE;
1316 }
1317
1318 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data){
1319         if( camera == NULL || callback == NULL){
1320                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1321                 return CAMERA_ERROR_INVALID_PARAMETER;
1322         }
1323
1324         camera_s * handle = (camera_s*)camera;
1325         handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)callback;
1326         handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)user_data;
1327         return CAMERA_ERROR_NONE;
1328 }
1329
1330 int camera_unset_error_cb(camera_h camera){
1331         if( camera == NULL){
1332                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1333                 return CAMERA_ERROR_INVALID_PARAMETER;
1334         }
1335
1336         camera_s * handle = (camera_s*)camera;
1337         handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1338         handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1339         return CAMERA_ERROR_NONE;
1340 }
1341
1342 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data){
1343         if( camera == NULL || foreach_cb == NULL){
1344                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1345                 return CAMERA_ERROR_INVALID_PARAMETER;
1346         }
1347
1348         int ret;
1349         camera_s * handle = (camera_s*)camera;
1350         MMCamAttrsInfo preview_width;
1351         MMCamAttrsInfo preview_height;
1352         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH , &preview_width);
1353         ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT , &preview_height);
1354
1355         if( ret != CAMERA_ERROR_NONE )
1356                 return __convert_camera_error_code(__func__, ret);
1357
1358         int i;
1359         for( i=0 ; i < preview_width.int_array.count ; i++)
1360         {
1361                 if ( !foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i],user_data) )
1362                         break;
1363         }
1364         return CAMERA_ERROR_NONE;
1365
1366 }
1367 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data){
1368         if( camera == NULL || foreach_cb == NULL){
1369                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1370                 return CAMERA_ERROR_INVALID_PARAMETER;
1371         }
1372         int ret;
1373         camera_s * handle = (camera_s*)camera;
1374         MMCamAttrsInfo capture_width;
1375         MMCamAttrsInfo capture_height;
1376         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH , &capture_width);
1377         ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT , &capture_height);
1378
1379         if( ret != CAMERA_ERROR_NONE )
1380                 return __convert_camera_error_code(__func__, ret);
1381
1382         int i;
1383         for( i=0 ; i < capture_width.int_array.count ; i++)
1384         {
1385                 if ( !foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i],user_data) )
1386                         break;
1387         }
1388         return CAMERA_ERROR_NONE;
1389 }
1390
1391 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data){
1392         if( camera == NULL || foreach_cb == NULL){
1393                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1394                 return CAMERA_ERROR_INVALID_PARAMETER;
1395         }
1396
1397         int ret;
1398         camera_s * handle = (camera_s*)camera;
1399         MMCamAttrsInfo format;
1400         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT , &format);
1401
1402         if( ret != CAMERA_ERROR_NONE )
1403                 return __convert_camera_error_code(__func__, ret);
1404
1405         int i;
1406         for( i=0 ; i < format.int_array.count ; i++)
1407         {
1408                 if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1409                         if ( !foreach_cb(format.int_array.array[i], user_data) )
1410                                 break;
1411         }
1412         return CAMERA_ERROR_NONE;
1413
1414 }
1415
1416
1417 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data){
1418         if( camera == NULL || foreach_cb == NULL){
1419                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1420                 return CAMERA_ERROR_INVALID_PARAMETER;
1421         }
1422         int ret;
1423         camera_s * handle = (camera_s*)camera;
1424         MMCamAttrsInfo format;
1425         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &format);
1426
1427         if( ret != CAMERA_ERROR_NONE )
1428                 return __convert_camera_error_code(__func__, ret);
1429
1430         int i;
1431         for( i=0 ; i < format.int_array.count ; i++)
1432         {
1433                 if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY /* || format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_NV12 */)
1434                         if ( !foreach_cb(format.int_array.array[i], user_data) )
1435                                 break;
1436         }
1437         return CAMERA_ERROR_NONE;
1438
1439 }
1440
1441
1442 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height){
1443         if( camera == NULL ){
1444                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1445                 return CAMERA_ERROR_INVALID_PARAMETER;
1446         }
1447
1448         enum MMCamcorderPreviewType wide;
1449         int capture_w, capture_h;
1450         double ratio;
1451         int ret;
1452         camera_s * handle = (camera_s*)camera;
1453
1454         camera_get_capture_resolution(camera, &capture_w, &capture_h);
1455         ratio = (double)capture_w/(double)capture_h;
1456         if( ratio > 1.5 )
1457                 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
1458         else
1459                 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
1460
1461         MMCamAttrsInfo width_info, height_info;
1462         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH , &width_info);
1463         ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
1464         if( ret != 0 )
1465                 return __convert_camera_error_code(__func__, ret);
1466
1467         if( width )
1468                 *width = width_info.int_array.array[wide];
1469
1470         if( height )
1471                 *height = height_info.int_array.array[wide];
1472
1473         return CAMERA_ERROR_NONE;
1474 }
1475
1476
1477
1478 int camera_attr_get_lens_orientation(camera_h camera, int *angle) {
1479         if( camera == NULL || angle == NULL){
1480                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1481                 return CAMERA_ERROR_INVALID_PARAMETER;
1482         }
1483
1484         int ret;
1485         camera_s * handle = (camera_s*)camera;
1486         int rotation;
1487         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation , NULL);
1488
1489         switch( rotation ) {
1490                 case MM_DISPLAY_ROTATION_NONE:
1491                         *angle = 0;
1492                         break;
1493                 case MM_DISPLAY_ROTATION_90:
1494                         *angle = 270;
1495                         break;
1496                 case MM_DISPLAY_ROTATION_180:
1497                         *angle = 180;
1498                         break;
1499                 case MM_DISPLAY_ROTATION_270:
1500                         *angle = 90;
1501                         break;
1502         }
1503
1504         return __convert_camera_error_code(__func__, ret);
1505 }
1506
1507 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode){
1508         if( camera == NULL){
1509                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1510                 return CAMERA_ERROR_INVALID_PARAMETER;
1511         }
1512         int ret;
1513         camera_s * handle = (camera_s*)camera;
1514         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE, mode, NULL);
1515         return __convert_camera_error_code(__func__, ret);
1516 }
1517
1518 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode){
1519         if( camera == NULL || mode == NULL){
1520                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1521                 return CAMERA_ERROR_INVALID_PARAMETER;
1522         }
1523         int ret;
1524         camera_s * handle = (camera_s*)camera;
1525         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE , mode, NULL);
1526         return __convert_camera_error_code(__func__, ret);
1527 }
1528
1529 int camera_attr_set_preview_fps(camera_h camera,  camera_attr_fps_e fps){
1530         if( camera == NULL){
1531                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1532                 return CAMERA_ERROR_INVALID_PARAMETER;
1533         }
1534         int ret;
1535         camera_s * handle = (camera_s*)camera;
1536
1537         if( fps == CAMERA_ATTR_FPS_AUTO ){
1538                 MMCamAttrsInfo info;
1539                 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info);
1540                 int maxfps = 0;
1541                 int i;
1542                 for( i=0 ; i < info.int_array.count ; i++)
1543                 {
1544                         if ( info.int_array.array[i] > maxfps && info.int_array.array[i] <= 60 )
1545                                 maxfps = info.int_array.array[i];
1546                 }
1547                 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS_AUTO  , 1, MMCAM_CAMERA_FPS, maxfps , NULL);
1548         }
1549         else
1550                 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS_AUTO  , 0, MMCAM_CAMERA_FPS  , fps, NULL);
1551
1552         return __convert_camera_error_code(__func__, ret);
1553
1554 }
1555
1556
1557 int camera_attr_set_image_quality(camera_h camera,  int quality){
1558
1559         if( camera == NULL){
1560                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1561                 return CAMERA_ERROR_INVALID_PARAMETER;
1562         }
1563
1564         int ret;
1565         camera_s * handle = (camera_s*)camera;
1566         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
1567         return __convert_camera_error_code(__func__, ret);
1568
1569 }
1570 int camera_attr_get_preview_fps(camera_h camera,  camera_attr_fps_e *fps){
1571         if( camera == NULL || fps == NULL){
1572                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1573                 return CAMERA_ERROR_INVALID_PARAMETER;
1574         }
1575         int ret;
1576         int mm_fps;
1577         int is_auto;
1578         camera_s * handle = (camera_s*)camera;
1579
1580         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS , &mm_fps, MMCAM_CAMERA_FPS_AUTO , &is_auto, NULL);
1581         if( is_auto )
1582                 *fps = CAMERA_ATTR_FPS_AUTO;
1583         else
1584                 *fps = mm_fps;
1585
1586         return __convert_camera_error_code(__func__, ret);
1587
1588 }
1589 int camera_attr_get_image_quality(camera_h camera,  int *quality){
1590         if( camera == NULL || quality == NULL){
1591                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1592                 return CAMERA_ERROR_INVALID_PARAMETER;
1593         }
1594
1595         int ret;
1596         camera_s * handle = (camera_s*)camera;
1597         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY   , quality, NULL);
1598         return __convert_camera_error_code(__func__, ret);
1599
1600 }
1601
1602
1603 int camera_attr_set_zoom(camera_h camera,  int zoom){
1604         if( camera == NULL){
1605                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1606                 return CAMERA_ERROR_INVALID_PARAMETER;
1607         }
1608         int ret;
1609         camera_s * handle = (camera_s*)camera;
1610         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM  , zoom, NULL);
1611         return __convert_camera_error_code(__func__, ret);
1612
1613 }
1614
1615 int camera_attr_set_af_mode(camera_h camera,  camera_attr_af_mode_e mode){
1616         if( camera == NULL){
1617                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1618                 return CAMERA_ERROR_INVALID_PARAMETER;
1619         }
1620         int ret = CAMERA_ERROR_INVALID_PARAMETER;
1621         camera_s * handle = (camera_s*)camera;
1622         int focus_mode;
1623         bool should_change_focus_mode = false;
1624         mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE, &focus_mode, NULL);
1625         if( focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO && focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO )
1626                 should_change_focus_mode = true;
1627
1628         if( mode != CAMERA_ATTR_AF_NONE && focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && !handle->on_continuous_focusing){
1629                 handle->cached_focus_mode = mode;
1630                 LOGD("[%s] af mode will be set actually start focusing",__func__);
1631                 return __convert_camera_error_code(__func__, 0);
1632         }else
1633                 handle->cached_focus_mode = -1;
1634
1635         if( mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode ){
1636                 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO, NULL);
1637         }
1638
1639         switch(mode){
1640                 case CAMERA_ATTR_AF_NONE:
1641                         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
1642                                                                                                                                                                                                                                                 MMCAM_CAMERA_AF_SCAN_RANGE  , MM_CAMCORDER_AUTO_FOCUS_NORMAL, NULL);
1643                         break;
1644                 case CAMERA_ATTR_AF_NORMAL:
1645                         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE  , MM_CAMCORDER_AUTO_FOCUS_NORMAL, NULL);
1646                         break;
1647                 case CAMERA_ATTR_AF_MACRO:
1648                         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE  , MM_CAMCORDER_AUTO_FOCUS_MACRO, NULL);
1649                         break;
1650                 case CAMERA_ATTR_AF_FULL:
1651                         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE  , MM_CAMCORDER_AUTO_FOCUS_FULL, NULL);
1652                         break;
1653                 default:
1654                         return ret;
1655         }
1656
1657         return __convert_camera_error_code(__func__, ret);
1658 }
1659
1660 int camera_attr_set_af_area(camera_h camera, int x, int y){
1661         if( camera == NULL){
1662                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1663                 return CAMERA_ERROR_INVALID_PARAMETER;
1664         }
1665         int ret = CAMERA_ERROR_INVALID_PARAMETER;
1666         camera_s * handle = (camera_s*)camera;
1667         camera_attr_af_mode_e mode;
1668         camera_attr_get_af_mode(camera, &mode);
1669         if( mode == CAMERA_ATTR_AF_NONE ){
1670                 LOGE( "[%s] INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE",__func__,CAMERA_ERROR_INVALID_OPERATION);
1671                 return CAMERA_ERROR_INVALID_OPERATION;
1672         }
1673         ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1674                                           MMCAM_CAMERA_AF_TOUCH_X, x,
1675                                           MMCAM_CAMERA_AF_TOUCH_Y, y,
1676                                           NULL);
1677         if( ret == 0 )
1678                 handle->focus_area_valid = true;
1679         return __convert_camera_error_code(__func__, ret);
1680 }
1681
1682 int camera_attr_clear_af_area(camera_h camera){
1683         if( camera == NULL){
1684                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__, CAMERA_ERROR_INVALID_PARAMETER);
1685                 return CAMERA_ERROR_INVALID_PARAMETER;
1686         }
1687         camera_s * handle = (camera_s*)camera;
1688         if( !handle->focus_area_valid ){
1689                 LOGE( "[%s] INVALID_OPERATION(0x%08x) AF area was not set",__func__,CAMERA_ERROR_INVALID_OPERATION);
1690                 return CAMERA_ERROR_INVALID_OPERATION;
1691         }
1692         handle->focus_area_valid = false;
1693         return 0;
1694 }
1695
1696 int camera_attr_set_exposure_mode(camera_h camera,  camera_attr_exposure_mode_e mode){
1697         if( camera == NULL){
1698                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1699                 return CAMERA_ERROR_INVALID_PARAMETER;
1700         }
1701         int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, //CAMCORDER_EXPOSURE_MODE_OFF
1702                                                                         MM_CAMCORDER_AUTO_EXPOSURE_ALL, //CAMCORDER_EXPOSURE_MODE_ALL
1703                                                                         MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, //CAMCORDER_EXPOSURE_MODE_CENTER
1704                                                                         MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, //CAMCORDER_EXPOSURE_MODE_SPOT
1705                                                                         MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1,//CAMCORDER_EXPOSURE_MODE_CUSTOM
1706                 };
1707
1708         int ret;
1709         camera_s * handle = (camera_s*)camera;
1710         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_MODE  , maptable[abs(mode%5)], NULL);
1711         return __convert_camera_error_code(__func__, ret);
1712
1713 }
1714
1715 int camera_attr_set_exposure(camera_h camera, int value){
1716         if( camera == NULL){
1717                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1718                 return CAMERA_ERROR_INVALID_PARAMETER;
1719         }
1720         int ret;
1721
1722         camera_s * handle = (camera_s*)camera;
1723         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_VALUE  , value, NULL);
1724         return __convert_camera_error_code(__func__, ret);
1725
1726 }
1727
1728 int camera_attr_set_iso(camera_h camera,  camera_attr_iso_e iso){
1729         if( camera == NULL){
1730                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1731                 return CAMERA_ERROR_INVALID_PARAMETER;
1732         }
1733         int ret;
1734         camera_s * handle = (camera_s*)camera;
1735         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ISO  , iso, NULL);
1736         return __convert_camera_error_code(__func__, ret);
1737 }
1738 int camera_attr_set_brightness(camera_h camera,  int level){
1739         if( camera == NULL){
1740                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1741                 return CAMERA_ERROR_INVALID_PARAMETER;
1742         }
1743         int ret;
1744
1745         camera_s * handle = (camera_s*)camera;
1746         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_BRIGHTNESS  , level, NULL);
1747         return __convert_camera_error_code(__func__, ret);
1748
1749 }
1750
1751 int camera_attr_set_contrast(camera_h camera,  int level){
1752         if( camera == NULL){
1753                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1754                 return CAMERA_ERROR_INVALID_PARAMETER;
1755         }
1756         int ret;
1757
1758         camera_s * handle = (camera_s*)camera;
1759         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_CONTRAST  , level, NULL);
1760
1761         return __convert_camera_error_code(__func__, ret);
1762
1763 }
1764 int camera_attr_set_whitebalance(camera_h camera,  camera_attr_whitebalance_e wb){
1765         if( camera == NULL){
1766                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1767                 return CAMERA_ERROR_INVALID_PARAMETER;
1768         }
1769         int ret;
1770         camera_s * handle = (camera_s*)camera;
1771         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_WB  , wb, NULL);
1772         return __convert_camera_error_code(__func__, ret);
1773
1774 }
1775
1776 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect){
1777         if( camera == NULL){
1778                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1779                 return CAMERA_ERROR_INVALID_PARAMETER;
1780         }
1781         int ret;
1782         camera_s * handle = (camera_s*)camera;
1783         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_COLOR_TONE , effect, NULL);
1784         return __convert_camera_error_code(__func__, ret);
1785 }
1786 int camera_attr_set_scene_mode(camera_h camera,  camera_attr_scene_mode_e mode){
1787         if( camera == NULL){
1788                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1789                 return CAMERA_ERROR_INVALID_PARAMETER;
1790         }
1791         int ret;
1792         camera_s * handle = (camera_s*)camera;
1793         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_SCENE_MODE  , mode, NULL);
1794         return __convert_camera_error_code(__func__, ret);
1795
1796 }
1797
1798
1799 int camera_attr_enable_tag(camera_h camera,  bool enable){
1800         if( camera == NULL){
1801                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1802                 return CAMERA_ERROR_INVALID_PARAMETER;
1803         }
1804         int ret;
1805         camera_s * handle = (camera_s*)camera;
1806         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ENABLE  , enable, NULL);
1807         return __convert_camera_error_code(__func__, ret);
1808
1809 }
1810
1811 int camera_attr_set_tag_image_description(camera_h camera,  const char *description){
1812         if( camera == NULL){
1813                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1814                 return CAMERA_ERROR_INVALID_PARAMETER;
1815         }
1816         int ret;
1817         camera_s * handle = (camera_s*)camera;
1818         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_IMAGE_DESCRIPTION    , description, strlen(description), NULL);
1819         return __convert_camera_error_code(__func__, ret);
1820
1821 }
1822
1823 int camera_attr_set_tag_orientation(camera_h camera,  camera_attr_tag_orientation_e orientation){
1824         if( camera == NULL){
1825                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1826                 return CAMERA_ERROR_INVALID_PARAMETER;
1827         }
1828         int ret;
1829         camera_s * handle = (camera_s*)camera;
1830         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ORIENTATION  , orientation, NULL);
1831         return __convert_camera_error_code(__func__, ret);
1832
1833 }
1834
1835 int camera_attr_set_tag_software(camera_h camera,  const char *software){
1836         if( camera == NULL){
1837                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1838                 return CAMERA_ERROR_INVALID_PARAMETER;
1839         }
1840         int ret;
1841         camera_s * handle = (camera_s*)camera;
1842         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_SOFTWARE   , software, strlen(software), NULL);
1843         return __convert_camera_error_code(__func__, ret);
1844
1845 }
1846
1847 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude){
1848         if( camera == NULL){
1849                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1850                 return CAMERA_ERROR_INVALID_PARAMETER;
1851         }
1852         int ret;
1853         camera_s * handle = (camera_s*)camera;
1854         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_GPS_ENABLE, 1,
1855                                                                                                   MMCAM_TAG_LATITUDE, latitude,
1856                                                                                                   MMCAM_TAG_LONGITUDE, longitude,
1857                                                                                                   MMCAM_TAG_ALTITUDE, altitude,
1858                                                                                                   NULL);
1859         return __convert_camera_error_code(__func__, ret);
1860 }
1861
1862 int camera_attr_remove_geotag(camera_h camera){
1863         if( camera == NULL){
1864                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1865                 return CAMERA_ERROR_INVALID_PARAMETER;
1866         }
1867         int ret;
1868         camera_s * handle = (camera_s*)camera;
1869         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_GPS_ENABLE, 0, NULL);
1870         return __convert_camera_error_code(__func__, ret);
1871 }
1872
1873 int camera_attr_set_flash_mode(camera_h camera,  camera_attr_flash_mode_e mode){
1874         if( camera == NULL){
1875                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1876                 return CAMERA_ERROR_INVALID_PARAMETER;
1877         }
1878         int ret;
1879         camera_s * handle = (camera_s*)camera;
1880         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_STROBE_MODE  , mode, NULL);
1881         return __convert_camera_error_code(__func__, ret);
1882 }
1883
1884
1885 int camera_attr_get_zoom(camera_h camera,  int *zoom){
1886         if( camera == NULL || zoom == NULL){
1887                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1888                 return CAMERA_ERROR_INVALID_PARAMETER;
1889         }
1890
1891         int ret;
1892         camera_s * handle = (camera_s*)camera;
1893         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL);
1894         return __convert_camera_error_code(__func__, ret);
1895
1896 }
1897
1898 int camera_attr_get_zoom_range(camera_h camera , int *min , int *max){
1899         if( camera == NULL || min == NULL || max == NULL ){
1900                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1901                 return CAMERA_ERROR_INVALID_PARAMETER;
1902         }
1903
1904         int ret;
1905         camera_s * handle = (camera_s*)camera;
1906         MMCamAttrsInfo ainfo;
1907         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
1908         if( min )
1909                 *min = ainfo.int_range.min;
1910         if( max )
1911                 *max = ainfo.int_range.max;
1912
1913         return __convert_camera_error_code(__func__, ret);
1914 }
1915
1916
1917 int camera_attr_get_af_mode( camera_h camera,  camera_attr_af_mode_e *mode){
1918         if( camera == NULL || mode == NULL){
1919                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1920                 return CAMERA_ERROR_INVALID_PARAMETER;
1921         }
1922
1923         int ret;
1924         int focus_mode;
1925         int af_range;
1926         int detect_mode;
1927         camera_s * handle = (camera_s*)camera;
1928         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , &focus_mode, MMCAM_CAMERA_AF_SCAN_RANGE , &af_range, MMCAM_DETECT_MODE , &detect_mode, NULL);
1929         if( ret == CAMERA_ERROR_NONE){
1930                 switch( focus_mode ){
1931                         case MM_CAMCORDER_FOCUS_MODE_NONE :
1932                         case MM_CAMCORDER_FOCUS_MODE_PAN :
1933                         case MM_CAMCORDER_FOCUS_MODE_MANUAL :
1934                                 *mode = CAMERA_ATTR_AF_NONE;
1935                                 break;
1936                         case MM_CAMCORDER_FOCUS_MODE_AUTO:
1937                         case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
1938                         case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
1939                                 switch ( af_range ){
1940                                         case MM_CAMCORDER_AUTO_FOCUS_NONE :
1941                                                 *mode = CAMERA_ATTR_AF_NORMAL;
1942                                                 break;
1943                                         case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
1944                                                 *mode = CAMERA_ATTR_AF_NORMAL;
1945                                                 break;
1946                                         case MM_CAMCORDER_AUTO_FOCUS_MACRO:
1947                                                 *mode = CAMERA_ATTR_AF_MACRO;
1948                                                 break;
1949                                         case MM_CAMCORDER_AUTO_FOCUS_FULL:
1950                                                 *mode = CAMERA_ATTR_AF_FULL;
1951                                                 break;
1952                                 }
1953                                 break;
1954                 }
1955
1956         }
1957         return __convert_camera_error_code(__func__, ret);
1958 }
1959
1960 int camera_attr_get_exposure_mode( camera_h camera,  camera_attr_exposure_mode_e *mode){
1961         if( camera == NULL|| mode == NULL){
1962                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1963                 return CAMERA_ERROR_INVALID_PARAMETER;
1964         }
1965
1966         int maptable[] = {
1967                         CAMERA_ATTR_EXPOSURE_MODE_OFF,  //MM_CAMCORDER_AUTO_EXPOSURE_OFF
1968                         CAMERA_ATTR_EXPOSURE_MODE_ALL,  //MM_CAMCORDER_AUTO_EXPOSURE_ALL
1969                         CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
1970                         CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
1971                         CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
1972                         CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
1973                         CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
1974                         CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
1975                         CAMERA_ATTR_EXPOSURE_MODE_CUSTOM //MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
1976                 };
1977         int ret;
1978         int exposure_mode;
1979         camera_s * handle = (camera_s*)camera;
1980         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_MODE , &exposure_mode, NULL);
1981         if( ret == CAMERA_ERROR_NONE ){
1982                 *mode = maptable[abs(exposure_mode%9)];
1983         }
1984         return __convert_camera_error_code(__func__, ret);
1985
1986 }
1987
1988 int camera_attr_get_exposure(camera_h camera, int *value){
1989         if( camera == NULL || value == NULL){
1990                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1991                 return CAMERA_ERROR_INVALID_PARAMETER;
1992         }
1993
1994         int ret;
1995         camera_s * handle = (camera_s*)camera;
1996         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_VALUE , value, NULL);
1997         return __convert_camera_error_code(__func__, ret);
1998 }
1999
2000
2001 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max){
2002         if( camera == NULL || min == NULL || max == NULL ){
2003                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2004                 return CAMERA_ERROR_INVALID_PARAMETER;
2005         }
2006
2007         int ret;
2008         camera_s * handle = (camera_s*)camera;
2009         MMCamAttrsInfo ainfo;
2010         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
2011         if( min )
2012                 *min = ainfo.int_range.min;
2013         if( max )
2014                 *max = ainfo.int_range.max;
2015
2016         return __convert_camera_error_code(__func__, ret);
2017 }
2018
2019
2020 int camera_attr_get_iso( camera_h camera,  camera_attr_iso_e *iso){
2021         if( camera == NULL || iso == NULL){
2022                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2023                 return CAMERA_ERROR_INVALID_PARAMETER;
2024         }
2025
2026         int ret;
2027         camera_s * handle = (camera_s*)camera;
2028         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ISO , iso, NULL);
2029         return __convert_camera_error_code(__func__, ret);
2030
2031 }
2032
2033 int camera_attr_get_brightness(camera_h camera,  int *level){
2034         if( camera == NULL || level == NULL){
2035                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2036                 return CAMERA_ERROR_INVALID_PARAMETER;
2037         }
2038         int ret;
2039         camera_s * handle = (camera_s*)camera;
2040         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_BRIGHTNESS , level, NULL);
2041         return __convert_camera_error_code(__func__, ret);
2042
2043 }
2044
2045 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max){
2046         if( camera == NULL || min == NULL || max == NULL ){
2047                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2048                 return CAMERA_ERROR_INVALID_PARAMETER;
2049         }
2050
2051         int ret;
2052         camera_s * handle = (camera_s*)camera;
2053         MMCamAttrsInfo ainfo;
2054         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
2055         if( min )
2056                 *min = ainfo.int_range.min;
2057         if( max )
2058                 *max = ainfo.int_range.max;
2059
2060         return __convert_camera_error_code(__func__, ret);
2061 }
2062
2063
2064 int camera_attr_get_contrast(camera_h camera,  int *level){
2065         if( camera == NULL || level == NULL){
2066                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2067                 return CAMERA_ERROR_INVALID_PARAMETER;
2068         }
2069
2070
2071         int ret;
2072         camera_s * handle = (camera_s*)camera;
2073         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_CONTRAST , level, NULL);
2074         return __convert_camera_error_code(__func__, ret);
2075 }
2076
2077 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max){
2078         if( camera == NULL || min == NULL || max == NULL ){
2079                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2080                 return CAMERA_ERROR_INVALID_PARAMETER;
2081         }
2082
2083         int ret;
2084         camera_s * handle = (camera_s*)camera;
2085         MMCamAttrsInfo ainfo;
2086         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
2087         if( min )
2088                 *min = ainfo.int_range.min;
2089         if( max )
2090                 *max = ainfo.int_range.max;
2091
2092         return __convert_camera_error_code(__func__, ret);
2093 }
2094
2095
2096 int camera_attr_get_whitebalance(camera_h camera,  camera_attr_whitebalance_e *wb){
2097         if( camera == NULL || wb == NULL){
2098                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2099                 return CAMERA_ERROR_INVALID_PARAMETER;
2100         }
2101
2102         int ret;
2103         camera_s * handle = (camera_s*)camera;
2104         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_WB , wb, NULL);
2105         return __convert_camera_error_code(__func__, ret);
2106
2107 }
2108
2109 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect){
2110
2111         if( camera == NULL || effect == NULL ){
2112                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2113                 return CAMERA_ERROR_INVALID_PARAMETER;
2114         }
2115
2116         int ret;
2117         camera_s * handle = (camera_s*)camera;
2118         int tone;
2119         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_COLOR_TONE , &tone, NULL);
2120
2121         if( ret != CAMERA_ERROR_NONE )
2122                 return __convert_camera_error_code(__func__, ret);
2123
2124         *effect = (camera_attr_effect_mode_e)tone;
2125
2126         return __convert_camera_error_code(__func__, ret);
2127 }
2128
2129 int camera_attr_get_scene_mode(camera_h camera,  camera_attr_scene_mode_e *mode){
2130         if( camera == NULL || mode == NULL){
2131                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2132                 return CAMERA_ERROR_INVALID_PARAMETER;
2133         }
2134
2135         int ret;
2136         camera_s * handle = (camera_s*)camera;
2137         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_SCENE_MODE , mode, NULL);
2138         return __convert_camera_error_code(__func__, ret);
2139
2140 }
2141
2142
2143 int camera_attr_is_enabled_tag(camera_h camera,  bool *enable){
2144         if( camera == NULL || enable == NULL){
2145                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2146                 return CAMERA_ERROR_INVALID_PARAMETER;
2147         }
2148
2149         int ret;
2150         camera_s * handle = (camera_s*)camera;
2151
2152         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ENABLE , enable, NULL);
2153
2154         return __convert_camera_error_code(__func__, ret);
2155
2156 }
2157
2158 int camera_attr_get_tag_image_description(camera_h camera,  char **description){
2159         if( camera == NULL || description == NULL){
2160                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2161                 return CAMERA_ERROR_INVALID_PARAMETER;
2162         }
2163
2164         int ret;
2165         camera_s * handle = (camera_s*)camera;
2166         char *ndescription = NULL;
2167         int desc_size;
2168         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_IMAGE_DESCRIPTION , &ndescription, &desc_size, NULL);
2169         if( ret == CAMERA_ERROR_NONE ){
2170                 if( ndescription != NULL )
2171                         *description = strdup(ndescription);
2172                 else
2173                         *description = strdup("");
2174         }
2175
2176         return __convert_camera_error_code(__func__, ret);
2177
2178 }
2179
2180 int camera_attr_get_tag_orientation(camera_h camera,  camera_attr_tag_orientation_e *orientation){
2181
2182         if( camera == NULL || orientation == NULL){
2183                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2184                 return CAMERA_ERROR_INVALID_PARAMETER;
2185         }
2186
2187         int ret;
2188         camera_s * handle = (camera_s*)camera;
2189         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ORIENTATION , orientation, NULL);
2190         return __convert_camera_error_code(__func__, ret);
2191
2192 }
2193 int camera_attr_get_tag_software(camera_h camera,  char **software){
2194         if( camera == NULL || software == NULL ){
2195                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2196                 return CAMERA_ERROR_INVALID_PARAMETER;
2197         }
2198
2199         int ret;
2200         camera_s * handle = (camera_s*)camera;
2201         char *soft;
2202         int soft_size;
2203         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_SOFTWARE , &soft, &soft_size, NULL);
2204         if( ret == CAMERA_ERROR_NONE ){
2205                 if( soft != NULL )
2206                         *software = strdup(soft);
2207                 else
2208                         *software = strdup("");
2209         }
2210         return __convert_camera_error_code(__func__, ret);
2211 }
2212
2213 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude){
2214         if( camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL){
2215                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2216                 return CAMERA_ERROR_INVALID_PARAMETER;
2217         }
2218         int ret;
2219         camera_s * handle = (camera_s*)camera;
2220         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_LATITUDE , latitude,
2221                                                                                                   MMCAM_TAG_LONGITUDE, longitude,
2222                                                                                                   MMCAM_TAG_ALTITUDE, altitude,
2223                                                                                                   NULL);
2224         return __convert_camera_error_code(__func__, ret);
2225 }
2226
2227 int camera_attr_get_flash_mode(camera_h camera,  camera_attr_flash_mode_e *mode){
2228         if( camera == NULL || mode == NULL){
2229                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2230                 return CAMERA_ERROR_INVALID_PARAMETER;
2231         }
2232
2233         int ret;
2234         camera_s * handle = (camera_s*)camera;
2235         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_STROBE_MODE , mode, NULL);
2236         return __convert_camera_error_code(__func__, ret);
2237 }
2238
2239 int camera_attr_foreach_supported_af_mode( camera_h camera, camera_attr_supported_af_mode_cb foreach_cb , void *user_data){
2240         if( camera == NULL || foreach_cb == NULL){
2241                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2242                 return CAMERA_ERROR_INVALID_PARAMETER;
2243         }
2244
2245
2246         int ret;
2247         int i;
2248         camera_s * handle = (camera_s*)camera;
2249         MMCamAttrsInfo af_range;
2250         MMCamAttrsInfo focus_mode;
2251
2252         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE , &af_range);
2253         ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE , &focus_mode);
2254
2255         if( ret != CAMERA_ERROR_NONE )
2256                 return __convert_camera_error_code(__func__, ret);
2257
2258         for( i=0 ; i < af_range.int_array.count ; i++)
2259         {
2260                 if ( !foreach_cb(af_range.int_array.array[i],user_data) )
2261                         goto ENDCALLBACK;
2262         }
2263
2264         ENDCALLBACK:
2265
2266         return CAMERA_ERROR_NONE;
2267
2268 }
2269
2270 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data){
2271         if( camera == NULL || foreach_cb == NULL){
2272                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2273                 return CAMERA_ERROR_INVALID_PARAMETER;
2274         }
2275
2276         int maptable[] = {
2277                         CAMERA_ATTR_EXPOSURE_MODE_OFF,  //MM_CAMCORDER_AUTO_EXPOSURE_OFF
2278                         CAMERA_ATTR_EXPOSURE_MODE_ALL,  //MM_CAMCORDER_AUTO_EXPOSURE_ALL
2279                         CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
2280                         -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
2281                         -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
2282                         CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
2283                         -1, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
2284                         CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
2285                         -1//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
2286                 };
2287         int ret;
2288         camera_s * handle = (camera_s*)camera;
2289         MMCamAttrsInfo info;
2290         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE , &info);
2291         if( ret != CAMERA_ERROR_NONE )
2292                 return __convert_camera_error_code(__func__, ret);
2293
2294         int i;
2295         for( i=0 ; i < info.int_array.count ; i++)
2296         {
2297                 if( maptable[info.int_array.array[i]] != -1){
2298                         if ( !foreach_cb(maptable[info.int_array.array[i]],user_data) )
2299                                 break;
2300                 }
2301         }
2302         return CAMERA_ERROR_NONE;
2303
2304 }
2305 int camera_attr_foreach_supported_iso( camera_h camera, camera_attr_supported_iso_cb foreach_cb , void *user_data){
2306         if( camera == NULL || foreach_cb == NULL){
2307                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2308                 return CAMERA_ERROR_INVALID_PARAMETER;
2309         }
2310         int ret;
2311         camera_s * handle = (camera_s*)camera;
2312         MMCamAttrsInfo info;
2313         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO , &info);
2314         if( ret != CAMERA_ERROR_NONE )
2315                 return __convert_camera_error_code(__func__, ret);
2316
2317         int i;
2318         for( i=0 ; i < info.int_array.count ; i++)
2319         {
2320                 if ( !foreach_cb(info.int_array.array[i],user_data) )
2321                         break;
2322         }
2323         return CAMERA_ERROR_NONE;
2324
2325 }
2326
2327 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data){
2328         if( camera == NULL || foreach_cb == NULL){
2329                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2330                 return CAMERA_ERROR_INVALID_PARAMETER;
2331         }
2332         int ret;
2333         camera_s * handle = (camera_s*)camera;
2334         MMCamAttrsInfo info;
2335         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB , &info);
2336         if( ret != CAMERA_ERROR_NONE )
2337                 return __convert_camera_error_code(__func__, ret);
2338
2339         int i;
2340         for( i=0 ; i < info.int_array.count ; i++)
2341         {
2342                 if ( !foreach_cb(info.int_array.array[i],user_data)  )
2343                         break;
2344         }
2345         return CAMERA_ERROR_NONE;
2346
2347 }
2348 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data){
2349         if( camera == NULL || foreach_cb == NULL){
2350                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2351                 return CAMERA_ERROR_INVALID_PARAMETER;
2352         }
2353
2354         int ret;
2355         camera_s * handle = (camera_s*)camera;
2356         MMCamAttrsInfo info;
2357         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE , &info);
2358         if( ret != CAMERA_ERROR_NONE )
2359                 return __convert_camera_error_code(__func__, ret);
2360
2361         int i;
2362         for( i=0 ; i < info.int_array.count ; i++)
2363         {
2364                 int effect = info.int_array.array[i];
2365                 if ( !foreach_cb(effect,user_data) )
2366                                 break;
2367         }
2368         return CAMERA_ERROR_NONE;
2369
2370 }
2371 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data){
2372         if( camera == NULL || foreach_cb == NULL){
2373                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2374                 return CAMERA_ERROR_INVALID_PARAMETER;
2375         }
2376
2377         int ret;
2378         camera_s * handle = (camera_s*)camera;
2379         MMCamAttrsInfo info;
2380         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE  , &info);
2381         if( ret != CAMERA_ERROR_NONE )
2382                 return __convert_camera_error_code(__func__, ret);
2383
2384         int i;
2385         for( i=0 ; i < info.int_array.count ; i++)
2386         {
2387                 if ( !foreach_cb(info.int_array.array[i],user_data) )
2388                         break;
2389         }
2390         return CAMERA_ERROR_NONE;
2391
2392 }
2393
2394 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data){
2395         if( camera == NULL || foreach_cb == NULL){
2396                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2397                 return CAMERA_ERROR_INVALID_PARAMETER;
2398         }
2399         int ret;
2400         camera_s * handle = (camera_s*)camera;
2401         MMCamAttrsInfo info;
2402         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE  , &info);
2403         if( ret != CAMERA_ERROR_NONE )
2404                 return __convert_camera_error_code(__func__, ret);
2405
2406         int i;
2407         for( i=0 ; i < info.int_array.count ; i++)
2408         {
2409                 if ( !foreach_cb(info.int_array.array[i],user_data) )
2410                         break;
2411         }
2412         return CAMERA_ERROR_NONE;
2413
2414 }
2415 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data){
2416         if( camera == NULL || foreach_cb == NULL){
2417                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2418                 return CAMERA_ERROR_INVALID_PARAMETER;
2419         }
2420         int ret;
2421         camera_s * handle = (camera_s*)camera;
2422         MMCamAttrsInfo info;
2423         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info);
2424         if( ret != CAMERA_ERROR_NONE )
2425                 return __convert_camera_error_code(__func__, ret);
2426
2427         int i;
2428         //if (foreach_cb(CAMERA_ATTR_FPS_AUTO, user_data) < 0 )
2429         //      return CAMERA_ERROR_NONE;
2430         for( i=0 ; i < info.int_array.count ; i++)
2431         {
2432                 if ( !foreach_cb(info.int_array.array[i],user_data) )
2433                         break;
2434         }
2435         return CAMERA_ERROR_NONE;
2436
2437 }
2438
2439 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation){
2440         if( camera == NULL){
2441                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2442                 return CAMERA_ERROR_INVALID_PARAMETER;
2443         }
2444
2445         if( rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270 )
2446                 return CAMERA_ERROR_INVALID_PARAMETER;
2447
2448         int ret;
2449         camera_s * handle = (camera_s*)camera;
2450
2451         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ROTATION , rotation, NULL);
2452         return __convert_camera_error_code(__func__, ret);
2453 }
2454
2455 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation){
2456         if( camera == NULL || rotation == NULL ){
2457                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2458                 return CAMERA_ERROR_INVALID_PARAMETER;
2459         }
2460
2461         int ret;
2462         camera_s * handle = (camera_s*)camera;
2463
2464         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ROTATION , rotation, NULL);
2465         return __convert_camera_error_code(__func__, ret);
2466 }
2467
2468 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip){
2469         if( camera == NULL){
2470                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2471                 return CAMERA_ERROR_INVALID_PARAMETER;
2472         }
2473
2474         if( flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH )
2475                 return CAMERA_ERROR_INVALID_PARAMETER;
2476
2477         int ret;
2478         camera_s * handle = (camera_s*)camera;
2479         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FLIP , flip , NULL);
2480         return __convert_camera_error_code(__func__, ret);
2481 }
2482
2483 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip){
2484         if( camera == NULL || flip == NULL ){
2485                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2486                 return CAMERA_ERROR_INVALID_PARAMETER;
2487         }
2488         int ret;
2489         camera_s * handle = (camera_s*)camera;
2490         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FLIP , flip , NULL);
2491         return __convert_camera_error_code(__func__, ret);
2492 }
2493
2494 int _camera_set_use(camera_h camera, bool used){
2495         camera_s * handle = (camera_s*)camera;
2496         handle->is_used_in_recorder = used;
2497         return 0;
2498 }
2499
2500 bool _camera_is_used(camera_h camera){
2501         camera_s * handle = (camera_s*)camera;
2502         return handle->is_used_in_recorder;
2503 }
2504
2505
2506 int _camera_get_mm_handle(camera_h camera , MMHandleType *handle){
2507         if( camera == NULL || handle == NULL ){
2508                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2509                 return CAMERA_ERROR_INVALID_PARAMETER;
2510         }
2511         camera_s *camera_handle = (camera_s*)camera;
2512         *handle =  camera_handle->mm_handle;
2513         return CAMERA_ERROR_NONE;
2514 }
2515
2516 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data){
2517         if( camera == NULL ){
2518                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2519                 return CAMERA_ERROR_INVALID_PARAMETER;
2520         }
2521
2522         camera_s *handle = (camera_s*)camera;
2523         handle->relay_message_callback = callback;
2524         handle->relay_user_data = user_data;
2525
2526         return CAMERA_ERROR_NONE;
2527 }
2528
2529 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode){
2530         if( camera == NULL){
2531                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2532                 return CAMERA_ERROR_INVALID_PARAMETER;
2533         }
2534         int ret;
2535         camera_s * handle = (camera_s*)camera;
2536         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , mode, NULL);
2537         if( ret == 0 ){
2538                 if( mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL )
2539                         handle->hdr_keep_mode = true;
2540                 else
2541                         handle->hdr_keep_mode = false;
2542         }
2543         return __convert_camera_error_code(__func__, ret);
2544 }
2545
2546 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode){
2547         if( camera == NULL || mode == NULL ){
2548                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2549                 return CAMERA_ERROR_INVALID_PARAMETER;
2550         }
2551         int ret;
2552         int result;
2553         camera_s * handle = (camera_s*)camera;
2554         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , &result, NULL);
2555         if( ret == 0 ){
2556                 *mode = result;
2557         }
2558         return __convert_camera_error_code(__func__, ret);
2559 }
2560
2561
2562 int camera_attr_enable_hdr_capture(camera_h camera, bool enable){
2563         if( camera == NULL){
2564                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2565                 return CAMERA_ERROR_INVALID_PARAMETER;
2566         }
2567         int ret;
2568         camera_s * handle = (camera_s*)camera;
2569         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , enable, NULL);
2570         return __convert_camera_error_code(__func__, ret);
2571 }
2572
2573 int camera_attr_is_enabled_hdr_capture(camera_h camera, bool *enabled){
2574         if( camera == NULL || enabled == NULL ){
2575                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2576                 return CAMERA_ERROR_INVALID_PARAMETER;
2577         }
2578         int ret;
2579         int result;
2580         camera_s * handle = (camera_s*)camera;
2581         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , &result, NULL);
2582         if( ret == 0 ){
2583                 if( result >= MM_CAMCORDER_HDR_ON )
2584                         *enabled = true;
2585                 else
2586                         *enabled = false;
2587         }
2588         return __convert_camera_error_code(__func__, ret);
2589 }
2590
2591 bool camera_attr_is_supported_hdr_capture(camera_h camera){
2592         if( camera == NULL){
2593                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2594                 return false;
2595         }
2596         int ret;
2597         int i;
2598         camera_s * handle = (camera_s*)camera;
2599         MMCamAttrsInfo hdr_info;
2600         ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE , &hdr_info);
2601         for (i = 0; i < hdr_info.int_array.count ; i++) {
2602                 if (hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON) {
2603                         return true;
2604                 }
2605         }
2606         return false;
2607 }
2608
2609 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void* user_data){
2610         if( camera == NULL || callback == NULL){
2611                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2612                 return CAMERA_ERROR_INVALID_PARAMETER;
2613         }
2614
2615         camera_s * handle = (camera_s*)camera;
2616         handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)callback;
2617         handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)user_data;
2618         return CAMERA_ERROR_NONE;
2619 }
2620
2621 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera){
2622         if( camera == NULL){
2623                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2624                 return CAMERA_ERROR_INVALID_PARAMETER;
2625         }
2626         camera_s * handle = (camera_s*)camera;
2627         handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
2628         handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
2629         return CAMERA_ERROR_NONE;
2630 }
2631
2632 int camera_attr_enable_anti_shake(camera_h camera, bool enable){
2633         if( camera == NULL){
2634                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2635                 return CAMERA_ERROR_INVALID_PARAMETER;
2636         }
2637         int ret;
2638         int mode = MM_CAMCORDER_AHS_OFF;
2639         if( enable )
2640                 mode = MM_CAMCORDER_AHS_ON;
2641
2642         camera_s * handle = (camera_s*)camera;
2643         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ANTI_HANDSHAKE , mode, NULL);
2644         return __convert_camera_error_code(__func__, ret);
2645 }
2646
2647 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled){
2648         if( camera == NULL || enabled == NULL ){
2649                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2650                 return CAMERA_ERROR_INVALID_PARAMETER;
2651         }
2652         int ret;
2653         int mode = MM_CAMCORDER_AHS_OFF;
2654         camera_s * handle = (camera_s*)camera;
2655         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ANTI_HANDSHAKE , &mode, NULL);
2656         if( ret == 0 )
2657                 *enabled = mode;
2658         return __convert_camera_error_code(__func__, ret);
2659 }
2660
2661 bool camera_attr_is_supported_anti_shake(camera_h camera){
2662         if( camera == NULL){
2663                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2664                 return false;
2665         }
2666         int i;
2667         camera_s * handle = (camera_s*)camera;
2668         MMCamAttrsInfo ash_info;
2669         mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE , &ash_info);
2670
2671         for( i=0 ; i < ash_info.int_array.count ; i++)
2672         {
2673                 if ( ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON)
2674                         return true;
2675         }
2676         return false;
2677 }
2678
2679 int camera_attr_enable_video_stabilization(camera_h camera, bool enable){
2680         if( camera == NULL){
2681                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2682                 return CAMERA_ERROR_INVALID_PARAMETER;
2683         }
2684         int ret;
2685         int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
2686         if( enable )
2687                 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
2688
2689         camera_s * handle = (camera_s*)camera;
2690         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_VIDEO_STABILIZATION , mode, NULL);
2691         return __convert_camera_error_code(__func__, ret);
2692 }
2693
2694 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled){
2695         if( camera == NULL || enabled == NULL ){
2696                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2697                 return CAMERA_ERROR_INVALID_PARAMETER;
2698         }
2699         int ret;
2700         int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
2701         camera_s * handle = (camera_s*)camera;
2702         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_VIDEO_STABILIZATION , &mode, NULL);
2703         if( ret == 0 )
2704                 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
2705         return __convert_camera_error_code(__func__, ret);
2706 }
2707
2708 bool camera_attr_is_supported_video_stabilization(camera_h camera){
2709         if( camera == NULL){
2710                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2711                 return false;
2712         }
2713         int i;
2714         camera_s * handle = (camera_s*)camera;
2715         MMCamAttrsInfo vs_info;
2716         mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION , &vs_info);
2717
2718         for( i=0 ; i < vs_info.int_array.count ; i++)
2719         {
2720                 if ( vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON)
2721                         return true;
2722         }
2723         return false;
2724 }
2725
2726
2727
2728 int camera_attr_enable_auto_contrast(camera_h camera, bool enable){
2729         if( camera == NULL){
2730                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2731                 return CAMERA_ERROR_INVALID_PARAMETER;
2732         }
2733         int ret;
2734         int mode = MM_CAMCORDER_WDR_OFF;
2735         if( enable )
2736                 mode = MM_CAMCORDER_WDR_ON;
2737
2738         camera_s * handle = (camera_s*)camera;
2739         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL,  MMCAM_CAMERA_WDR  , mode, NULL);
2740         return __convert_camera_error_code(__func__, ret);
2741 }
2742
2743 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled){
2744         if( camera == NULL || enabled == NULL ){
2745                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2746                 return CAMERA_ERROR_INVALID_PARAMETER;
2747         }
2748         int ret;
2749         int mode = MM_CAMCORDER_WDR_OFF;
2750         camera_s * handle = (camera_s*)camera;
2751         ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WDR , &mode, NULL);
2752         if( ret == 0 )
2753                 *enabled = mode;
2754         return __convert_camera_error_code(__func__, ret);
2755 }
2756
2757 int camera_attr_disable_shutter_sound(camera_h camera, bool disable){
2758         if( camera == NULL){
2759                 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2760                 return CAMERA_ERROR_INVALID_PARAMETER;
2761         }
2762         int ret;
2763         camera_s * handle = (camera_s*)camera;
2764         ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL,  "capture-sound-enable"  , !disable, NULL);
2765         if( ret != 0 ){
2766                 LOGE("[%s] CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound", __func__);
2767                 return CAMERA_ERROR_INVALID_OPERATION;
2768         }
2769         return CAMERA_ERROR_NONE;
2770 }