2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <mm_camcorder.h>
26 #include <camera_private.h>
33 #define LOG_TAG "TIZEN_N_CAMERA"
35 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data);
36 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data);
39 static int __convert_camera_error_code(const char* func, int code){
40 int ret = CAMERA_ERROR_NONE;
41 char *errorstr = NULL;
45 ret = CAMERA_ERROR_NONE;
46 errorstr = "ERROR_NONE";
48 case MM_ERROR_CAMCORDER_INVALID_ARGUMENT :
49 case MM_ERROR_COMMON_INVALID_ATTRTYPE :
50 case MM_ERROR_COMMON_INVALID_PERMISSION :
51 case MM_ERROR_COMMON_OUT_OF_ARRAY :
52 case MM_ERROR_COMMON_OUT_OF_RANGE :
53 case MM_ERROR_COMMON_ATTR_NOT_EXIST :
54 ret = CAMERA_ERROR_INVALID_PARAMETER;
55 errorstr = "INVALID_PARAMETER";
57 case MM_ERROR_CAMCORDER_NOT_INITIALIZED :
58 case MM_ERROR_CAMCORDER_INVALID_STATE :
59 ret = CAMERA_ERROR_INVALID_STATE;
60 errorstr = "INVALID_STATE";
62 case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND :
63 ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
64 errorstr = "DEVICE_NOT_FOUND";
66 case MM_ERROR_CAMCORDER_DEVICE_BUSY :
67 case MM_ERROR_CAMCORDER_DEVICE_OPEN :
68 case MM_ERROR_CAMCORDER_CMD_IS_RUNNING :
69 ret = CAMERA_ERROR_DEVICE_BUSY;
70 errorstr = "DEVICE_BUSY";
72 case MM_ERROR_CAMCORDER_DEVICE :
73 case MM_ERROR_CAMCORDER_DEVICE_IO :
74 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT :
75 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE :
76 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG :
77 case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER :
78 ret = CAMERA_ERROR_DEVICE;
79 errorstr = "ERROR_DEVICE";
82 case MM_ERROR_CAMCORDER_GST_CORE :
83 case MM_ERROR_CAMCORDER_GST_LIBRARY :
84 case MM_ERROR_CAMCORDER_GST_RESOURCE :
85 case MM_ERROR_CAMCORDER_GST_STREAM :
86 case MM_ERROR_CAMCORDER_GST_STATECHANGE :
87 case MM_ERROR_CAMCORDER_GST_NEGOTIATION :
88 case MM_ERROR_CAMCORDER_GST_LINK :
89 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR :
90 case MM_ERROR_CAMCORDER_ENCODER :
91 case MM_ERROR_CAMCORDER_ENCODER_BUFFER :
92 case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE :
93 case MM_ERROR_CAMCORDER_ENCODER_WORKING :
94 case MM_ERROR_CAMCORDER_INTERNAL :
95 case MM_ERROR_CAMCORDER_NOT_SUPPORTED :
96 case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT :
97 case MM_ERROR_CAMCORDER_DSP_FAIL :
98 case MM_ERROR_CAMCORDER_AUDIO_EMPTY :
99 case MM_ERROR_CAMCORDER_CREATE_CONFIGURE :
100 case MM_ERROR_CAMCORDER_FILE_SIZE_OVER :
101 case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF :
102 case MM_ERROR_CAMCORDER_INVALID_CONDITION :
103 ret = CAMERA_ERROR_INVALID_OPERATION;
104 errorstr = "INVALID_OPERATION";
107 case MM_ERROR_CAMCORDER_RESOURCE_CREATION :
108 case MM_ERROR_COMMON_OUT_OF_MEMORY:
109 ret = CAMERA_ERROR_OUT_OF_MEMORY;
110 errorstr = "OUT_OF_MEMORY";
113 case MM_ERROR_POLICY_BLOCKED:
114 ret = CAMERA_ERROR_SOUND_POLICY;
115 errorstr = "ERROR_SOUND_POLICY";
117 case MM_ERROR_POLICY_RESTRICTED:
118 ret = CAMERA_ERROR_SECURITY_RESTRICTED;
119 errorstr = "ERROR_RESTRICTED";
123 ret = CAMERA_ERROR_INVALID_OPERATION;
124 errorstr = "INVALID_OPERATION";
126 LOGE( "[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code);
131 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data){
132 if( user_data == NULL || stream == NULL)
135 camera_s * handle = (camera_s*)user_data;
136 if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] ){
137 camera_preview_data_s frame;
138 frame.format = stream->format;
139 if( frame.format == (camera_pixel_format_e)MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
140 frame.format = MM_PIXEL_FORMAT_UYVY;
141 frame.width = stream->width;
142 frame.height = stream->height;
143 frame.timestamp = stream->timestamp;
144 frame.num_of_planes = stream->num_planes;
145 switch( stream->data_type ){
146 case MM_CAM_STREAM_DATA_YUV420 :
147 frame.data.single_plane.yuv = stream->data.yuv420.yuv;
148 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
150 case MM_CAM_STREAM_DATA_YUV422 :
151 frame.data.single_plane.yuv = stream->data.yuv422.yuv;
152 frame.data.single_plane.size = stream->data.yuv422.length_yuv;
154 case MM_CAM_STREAM_DATA_YUV420SP :
155 frame.data.double_plane.y = stream->data.yuv420sp.y;
156 frame.data.double_plane.uv = stream->data.yuv420sp.uv;
157 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
158 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
160 case MM_CAM_STREAM_DATA_YUV420P :
161 frame.data.triple_plane.y = stream->data.yuv420p.y;
162 frame.data.triple_plane.u = stream->data.yuv420p.u;
163 frame.data.triple_plane.v = stream->data.yuv420p.v;
164 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
165 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
166 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
168 case MM_CAM_STREAM_DATA_YUV422P :
169 frame.data.triple_plane.y = stream->data.yuv422p.y;
170 frame.data.triple_plane.u = stream->data.yuv422p.u;
171 frame.data.triple_plane.v = stream->data.yuv422p.v;
172 frame.data.triple_plane.y_size = stream->data.yuv422p.length_y;
173 frame.data.triple_plane.u_size = stream->data.yuv422p.length_u;
174 frame.data.triple_plane.v_size = stream->data.yuv422p.length_v;
177 ((camera_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW])(&frame, handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW]);
181 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data){
182 if( user_data == NULL || frame == NULL)
185 camera_s * handle = (camera_s*)user_data;
186 handle->current_capture_count++;
187 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] ){
188 MMCamcorderCaptureDataType *scrnl = NULL;
190 camera_image_data_s image = { NULL, 0, 0, 0, 0, NULL, 0 };
191 camera_image_data_s thumb = { NULL, 0, 0, 0, 0, NULL, 0 };
192 camera_image_data_s postview = { NULL, 0, 0, 0, 0, NULL, 0 };
197 image.data = frame->data;
198 image.size = frame->length;
199 image.width = frame->width;
200 image.height = frame->height;
201 image.format = frame->format;
202 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, "captured-exif-raw-data", &exif, &exif_size, NULL);
205 image.exif_size = exif_size;
210 thumb.data = thumbnail->data;
211 thumb.size = thumbnail->length;
212 thumb.width = thumbnail->width;
213 thumb.height = thumbnail->height;
214 thumb.format = thumbnail->format;
216 mm_camcorder_get_attributes( handle->mm_handle, NULL, "captured-screennail", &scrnl, &size,NULL );
218 postview.data = scrnl->data;
219 postview.size = scrnl->length;
220 postview.width = scrnl->width;
221 postview.height = scrnl->height;
222 postview.format = scrnl->format;
225 ((camera_capturing_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE])(&image, scrnl ? &postview : NULL, thumbnail ? &thumb : NULL, handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE]);
227 // update captured state
228 if( handle->capture_count == 1 && handle->hdr_keep_mode ){
229 if( handle->current_capture_count == 2 )
230 handle->is_capture_completed = true;
231 }else if( handle->capture_count == handle->current_capture_count || handle->is_continuous_shot_break)
232 handle->is_capture_completed = true;
236 static camera_state_e __camera_state_convert(MMCamcorderStateType mm_state)
238 camera_state_e state = CAMERA_STATE_NONE;
241 case MM_CAMCORDER_STATE_NONE:
242 state = CAMERA_STATE_NONE;
244 case MM_CAMCORDER_STATE_NULL:
245 state = CAMERA_STATE_CREATED;
247 case MM_CAMCORDER_STATE_READY:
248 state = CAMERA_STATE_CREATED;
250 case MM_CAMCORDER_STATE_PREPARE:
251 state = CAMERA_STATE_PREVIEW;
253 case MM_CAMCORDER_STATE_CAPTURING:
254 state = CAMERA_STATE_CAPTURING;
256 case MM_CAMCORDER_STATE_RECORDING:
257 state = CAMERA_STATE_PREVIEW;
259 case MM_CAMCORDER_STATE_PAUSED:
260 state = CAMERA_STATE_PREVIEW;
263 state = CAMERA_STATE_NONE;
271 static int __mm_camera_message_callback(int message, void *param, void *user_data){
272 if( user_data == NULL || param == NULL )
275 camera_s * handle = (camera_s*)user_data;
277 if( handle->relay_message_callback )
278 handle->relay_message_callback(message, param, handle->relay_user_data);
280 MMMessageParamType *m = (MMMessageParamType*)param;
281 camera_state_e previous_state;
285 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
286 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
287 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
288 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) ){
289 LOGI( "Invalid state changed message");
293 previous_state = handle->state;
294 handle->state = __camera_state_convert(m->state.current );
295 camera_policy_e policy = CAMERA_POLICY_NONE;
296 if(message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM )
297 policy = CAMERA_POLICY_SOUND;
298 else if( message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY )
299 policy = CAMERA_POLICY_SECURITY;
301 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
302 ((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]);
305 // should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state
306 if( policy != CAMERA_POLICY_NONE ){
307 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] )
308 ((camera_interrupted_cb)handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED])(policy, previous_state, handle->state, handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED]);
309 if( m->state.previous == MM_CAMCORDER_STATE_PREPARE && m->state.current == MM_CAMCORDER_STATE_READY ){
310 mm_camcorder_unrealize(handle->mm_handle);
315 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED :
316 if( handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] ){
317 ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])( m->code, handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
320 case MM_MESSAGE_CAMCORDER_CAPTURED:
322 handle->current_capture_complete_count = m->code;
323 if( handle->capture_count == 1 || m->code == handle->capture_count ||(handle->is_continuous_shot_break && handle->state == CAMERA_STATE_CAPTURING) ){
324 //pseudo state change
325 previous_state = handle->state ;
326 handle->state = CAMERA_STATE_CAPTURED;
327 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
328 ((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]);
330 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
331 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
336 case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
337 case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
339 MMCamRecordingReport *report = (MMCamRecordingReport *)m ->data;
340 if( report != NULL && report->recording_filename ){
341 free(report->recording_filename );
342 report->recording_filename = NULL;
350 case MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED:
352 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
353 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
357 case MM_MESSAGE_CAMCORDER_ERROR:
359 int errorcode = m->code;
360 int camera_error = 0;
362 case MM_ERROR_CAMCORDER_DEVICE :
363 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT :
364 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE :
365 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG :
366 camera_error = CAMERA_ERROR_DEVICE;
368 case MM_ERROR_CAMCORDER_GST_CORE :
369 case MM_ERROR_CAMCORDER_GST_LIBRARY :
370 case MM_ERROR_CAMCORDER_GST_RESOURCE :
371 case MM_ERROR_CAMCORDER_GST_STREAM :
372 case MM_ERROR_CAMCORDER_GST_NEGOTIATION :
373 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR :
374 case MM_ERROR_CAMCORDER_ENCODER :
375 case MM_ERROR_CAMCORDER_ENCODER_BUFFER :
376 case MM_ERROR_CAMCORDER_ENCODER_WORKING :
377 case MM_ERROR_CAMCORDER_MNOTE_CREATION :
378 case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY :
379 case MM_ERROR_CAMCORDER_INTERNAL :
380 case MM_ERROR_FILE_NOT_FOUND:
381 case MM_ERROR_FILE_READ:
382 camera_error = CAMERA_ERROR_INVALID_OPERATION;
384 case MM_ERROR_CAMCORDER_LOW_MEMORY :
385 case MM_ERROR_CAMCORDER_MNOTE_MALLOC :
386 camera_error = CAMERA_ERROR_OUT_OF_MEMORY;
389 if( camera_error != 0 && handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] )
390 ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(camera_error, handle->state , handle->user_data[_CAMERA_EVENT_TYPE_ERROR]);
394 case MM_MESSAGE_CAMCORDER_HDR_PROGRESS:
396 int percent = m->code;
397 if( handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] )
398 ((camera_attr_hdr_progress_cb)handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS])(percent, handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
401 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
403 MMCamFaceDetectInfo *cam_fd_info = (MMCamFaceDetectInfo *)(m->data);
405 camera_detected_face_s faces[cam_fd_info->num_of_faces];
406 handle->num_of_faces = cam_fd_info->num_of_faces > MAX_DETECTED_FACE ? MAX_DETECTED_FACE : cam_fd_info->num_of_faces;
408 for(i=0; i < handle->num_of_faces ; i++){
409 faces[i].id = cam_fd_info->face_info[i].id;
410 faces[i].score = cam_fd_info->face_info[i].score;
411 faces[i].x = cam_fd_info->face_info[i].rect.x;
412 faces[i].y = cam_fd_info->face_info[i].rect.y;
413 faces[i].width = cam_fd_info->face_info[i].rect.width;
414 faces[i].height = cam_fd_info->face_info[i].rect.height;
415 handle->faceinfo[i] = faces[i]; //cache face coordinate
417 if( handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] )
418 ((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]);
420 handle->num_of_faces = 0;
429 static int __capture_completed_event_cb(void *data){
430 camera_s *handle = (camera_s*)data;
431 if( handle->current_capture_count > 0 && handle->current_capture_count == handle->current_capture_complete_count && handle->state == CAMERA_STATE_CAPTURING ){
432 //pseudo state change
433 camera_state_e previous_state = handle->state;
434 handle->state = CAMERA_STATE_CAPTURED;
435 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
436 ((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]);
438 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
439 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
445 int camera_create( camera_device_e device, camera_h* camera){
448 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
449 return CAMERA_ERROR_INVALID_PARAMETER;
457 if( device == CAMERA_DEVICE_CAMERA1 )
458 info.videodev_type= MM_VIDEO_DEVICE_CAMERA1;
460 info.videodev_type= MM_VIDEO_DEVICE_CAMERA0;
462 camera_s* handle = (camera_s*)malloc( sizeof(camera_s) );
464 LOGE("[%s] malloc fail",__func__);
465 return CAMERA_ERROR_OUT_OF_MEMORY;
467 memset(handle, 0 , sizeof(camera_s));
469 ret = mm_camcorder_create(&handle->mm_handle, &info);
470 if( ret != MM_ERROR_NONE){
472 return __convert_camera_error_code(__func__,ret);
475 preview_format = MM_PIXEL_FORMAT_YUYV;
476 rotation = MM_DISPLAY_ROTATION_NONE;
477 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
478 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
479 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
480 MMCAM_CAPTURE_WIDTH, &handle->capture_width,
481 MMCAM_CAPTURE_HEIGHT, &handle->capture_height,
485 ret = mm_camcorder_set_attributes(handle->mm_handle, &error,
486 MMCAM_MODE , MM_CAMCORDER_MODE_VIDEO_CAPTURE,
487 MMCAM_CAMERA_FORMAT, preview_format,
488 MMCAM_IMAGE_ENCODER , MM_IMAGE_CODEC_JPEG,
489 MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
490 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL,
491 MMCAM_DISPLAY_ROTATION, rotation,
492 MMCAM_CAPTURE_COUNT, 1,
495 handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
497 if( ret != MM_ERROR_NONE){
498 LOGE("[%s] mm_camcorder_set_attributes fail(%x, %s)",__func__, ret, error);
499 mm_camcorder_destroy(handle->mm_handle);
502 return __convert_camera_error_code(__func__, ret);
505 handle->state = CAMERA_STATE_CREATED;
506 handle->relay_message_callback = NULL;
507 handle->relay_user_data = NULL;
508 handle->capture_resolution_modified = false;
509 handle->hdr_keep_mode = false;
510 handle->focus_area_valid = false;
511 handle->is_used_in_recorder = false;
512 handle->on_continuous_focusing = false;
513 handle->cached_focus_mode = -1;
514 mm_camcorder_set_message_callback(handle->mm_handle, __mm_camera_message_callback, (void*)handle);
516 *camera = (camera_h)handle;
517 return __convert_camera_error_code(__func__, ret);
520 int camera_destroy(camera_h camera){
522 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
523 return CAMERA_ERROR_INVALID_PARAMETER;
527 camera_s *handle = (camera_s*)camera;
528 if( handle->is_used_in_recorder ){
529 LOGE("[%s] camera is using in another recorder.", __func__);
530 return CAMERA_ERROR_INVALID_OPERATION;
533 ret = mm_camcorder_destroy(handle->mm_handle);
535 if( ret == MM_ERROR_NONE)
538 return __convert_camera_error_code(__func__, ret);
542 int camera_start_preview(camera_h camera){
543 LOGE("%s - start", __func__);
545 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
546 return CAMERA_ERROR_INVALID_PARAMETER;
551 camera_s *handle = (camera_s*)camera;
552 camera_state_e capi_state;
553 camera_get_state(camera, &capi_state);
555 if( capi_state == CAMERA_STATE_CAPTURED )
557 ret = mm_camcorder_capture_stop(handle->mm_handle);
558 return __convert_camera_error_code(__func__, ret);
563 //for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback
564 mm_camcorder_set_video_capture_callback( handle->mm_handle, (mm_camcorder_video_capture_callback)__mm_capture_callback, (void*)handle);
566 MMCamcorderStateType state ;
567 mm_camcorder_get_state(handle->mm_handle, &state);
568 if( state != MM_CAMCORDER_STATE_READY){
569 ret = mm_camcorder_realize(handle->mm_handle);
570 if( ret != MM_ERROR_NONE )
571 return __convert_camera_error_code(__func__, ret);
574 ret = mm_camcorder_start(handle->mm_handle);
577 if( ret != MM_ERROR_NONE && state != MM_CAMCORDER_STATE_READY){
578 mm_camcorder_unrealize(handle->mm_handle);
581 return __convert_camera_error_code(__func__, ret);
584 int camera_stop_preview(camera_h camera){
586 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
587 return CAMERA_ERROR_INVALID_PARAMETER;
592 camera_s *handle = (camera_s*)camera;
593 MMCamcorderStateType state ;
594 mm_camcorder_get_state(handle->mm_handle, &state);
596 if( state == MM_CAMCORDER_STATE_PREPARE ){
597 ret = mm_camcorder_stop(handle->mm_handle);
598 if( ret != MM_ERROR_NONE)
599 return __convert_camera_error_code(__func__, ret);
601 camera_stop_face_detection(camera);
602 ret = mm_camcorder_unrealize(handle->mm_handle);
603 return __convert_camera_error_code(__func__, ret);
606 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb , camera_capture_completed_cb completed_cb , void *user_data){
608 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
609 return CAMERA_ERROR_INVALID_PARAMETER;
612 camera_s * handle = (camera_s*)camera;
614 MMCamcorderStateType state;
615 mm_camcorder_get_state(handle->mm_handle, &state);
616 if( state != MM_CAMCORDER_STATE_PREPARE && state != MM_CAMCORDER_STATE_RECORDING && state != MM_CAMCORDER_STATE_PAUSED){
617 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
618 return CAMERA_ERROR_INVALID_STATE;
621 if( handle->capture_resolution_modified ){
622 mm_camcorder_set_attributes(handle->mm_handle, NULL,
623 MMCAM_CAPTURE_WIDTH, handle->capture_width,
624 MMCAM_CAPTURE_HEIGHT, handle->capture_height,
626 handle->capture_resolution_modified = false;
628 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAPTURE_COUNT , 1,NULL);
630 handle->capture_count = 1;
631 handle->is_continuous_shot_break = false;
632 handle->current_capture_count = 0;
633 handle->current_capture_complete_count = 0;
634 handle->is_capture_completed = false;
636 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
637 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
638 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
639 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
640 ret = mm_camcorder_capture_start(handle->mm_handle);
642 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
643 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
644 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
645 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
648 return __convert_camera_error_code(__func__, ret);
651 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){
653 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
654 return CAMERA_ERROR_INVALID_PARAMETER;
657 if( count < 2 || interval < 0 ){
658 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
659 return CAMERA_ERROR_INVALID_PARAMETER;
662 camera_s * handle = (camera_s*)camera;
664 MMCamcorderStateType state;
665 mm_camcorder_get_state(handle->mm_handle, &state);
666 if( state != MM_CAMCORDER_STATE_PREPARE ){
667 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
668 return CAMERA_ERROR_INVALID_STATE;
675 int current_preview_format;
676 bool supported_ZSL = false;
678 int ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
679 MMCAM_CAPTURE_COUNT , count,
680 MMCAM_CAPTURE_INTERVAL, interval,
683 LOGE("[%s] (%x) error set continuous shot attribute", ret);
684 return __convert_camera_error_code(__func__, ret);
686 handle->capture_count = count;
687 handle->is_continuous_shot_break = false;
688 handle->current_capture_count = 0;
689 handle->current_capture_complete_count = 0;
690 handle->is_capture_completed = false;
692 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FORMAT, ¤t_preview_format,NULL);
693 if( current_preview_format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
694 supported_ZSL = true;
697 LOGE("[%s] (%x) error get continuous shot attribute", ret);
700 if( !supported_ZSL ){
701 mm_camcorder_get_attributes(handle->mm_handle, NULL,
702 MMCAM_CAMERA_WIDTH, &preview_width,
703 MMCAM_CAMERA_HEIGHT, &preview_height,
704 MMCAM_CAPTURE_WIDTH, &capture_width,
705 MMCAM_CAPTURE_HEIGHT, &capture_height,
707 if( preview_width != capture_width || preview_height != capture_height ){
708 mm_camcorder_set_attributes(handle->mm_handle, NULL,
709 MMCAM_CAPTURE_WIDTH, preview_width,
710 MMCAM_CAPTURE_HEIGHT, preview_height,
712 handle->capture_resolution_modified = true;
716 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
717 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
718 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
719 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
721 ret = mm_camcorder_capture_start(handle->mm_handle);
723 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
724 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
725 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
726 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
729 return __convert_camera_error_code(__func__,ret);
733 int camera_stop_continuous_capture(camera_h camera){
735 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
736 return CAMERA_ERROR_INVALID_PARAMETER;
738 camera_s *handle = (camera_s*)camera;
740 camera_state_e state;
741 camera_get_state(camera, &state);
742 if( state != CAMERA_STATE_CAPTURING && handle->capture_count > 1 ){
743 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
744 return CAMERA_ERROR_INVALID_STATE;
747 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, "capture-break-cont-shot", 1, NULL);
749 handle->is_continuous_shot_break = true;
750 if( handle->current_capture_count > 0 )
751 handle->is_capture_completed = true;
752 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
755 return __convert_camera_error_code(__func__,ret);
758 bool camera_is_supported_face_detection(camera_h camera){
760 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
764 camera_s * handle = (camera_s*)camera;
766 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
768 if( info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY){
769 for( i =0; i < info.int_array.count ; i++){
770 if( info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON )
777 bool camera_is_supported_zero_shutter_lag(camera_h camera){
779 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
783 camera_s * handle = (camera_s*)camera;
785 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &info);
787 if( info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY){
788 for( i =0; i < info.int_array.count ; i++){
789 if( info.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
796 int camera_get_device_count(camera_h camera, int *device_count) {
797 int ret = MM_ERROR_NONE;
798 camera_s *handle = (camera_s *)camera;
800 if (camera == NULL || device_count == NULL) {
801 LOGE("[%s] INVALID_PARAMETER(0x%08x)", __func__, CAMERA_ERROR_INVALID_PARAMETER);
802 return CAMERA_ERROR_INVALID_PARAMETER;
805 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
806 MMCAM_CAMERA_DEVICE_COUNT, device_count,
809 return __convert_camera_error_code(__func__, ret);
812 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void * user_data){
814 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
815 return CAMERA_ERROR_INVALID_PARAMETER;
817 camera_s * handle = (camera_s*)camera;
818 camera_state_e state = CAMERA_STATE_NONE;
820 camera_get_state(camera, &state);
821 if( state != CAMERA_STATE_PREVIEW ){
822 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
823 return CAMERA_ERROR_INVALID_STATE;
825 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON, NULL);
827 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)callback;
828 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)user_data;
829 handle->num_of_faces = 0;
831 return __convert_camera_error_code(__func__,ret);
834 int camera_stop_face_detection(camera_h camera){
836 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
837 return CAMERA_ERROR_INVALID_PARAMETER;
839 camera_s * handle = (camera_s*)camera;
841 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF, NULL);
842 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
843 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
844 handle->num_of_faces = 0;
845 return __convert_camera_error_code(__func__,ret);
848 int camera_face_zoom(camera_h camera, int face_id){
850 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
851 return CAMERA_ERROR_INVALID_PARAMETER;
853 camera_s * handle = (camera_s*)camera;
859 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FACE_ZOOM_MODE , ¤t_mode, NULL);
861 if( current_mode == MM_CAMCORDER_FACE_ZOOM_MODE_ON )
862 return CAMERA_ERROR_INVALID_STATE;
864 for( i = 0 ; i < handle->num_of_faces ; i++){
865 if( handle->faceinfo[i].id == face_id ){
871 return CAMERA_ERROR_INVALID_PARAMETER;
872 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FACE_ZOOM_MODE, MM_CAMCORDER_FACE_ZOOM_MODE_ON,
873 MMCAM_CAMERA_FACE_ZOOM_X, handle->faceinfo[find].x+(handle->faceinfo[find].width>>1),
874 MMCAM_CAMERA_FACE_ZOOM_Y, handle->faceinfo[find].y+(handle->faceinfo[find].height>>1),
877 return __convert_camera_error_code(__func__,ret);
880 int camera_cancel_face_zoom(camera_h camera){
882 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
883 return CAMERA_ERROR_INVALID_PARAMETER;
885 camera_s * handle = (camera_s*)camera;
887 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FACE_ZOOM_MODE, MM_CAMCORDER_FACE_ZOOM_MODE_OFF, NULL);
888 return __convert_camera_error_code(__func__,ret);
892 int camera_get_state(camera_h camera, camera_state_e * state){
893 if( camera == NULL || state == NULL){
894 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
895 return CAMERA_ERROR_INVALID_PARAMETER;
898 camera_s *handle = (camera_s*)camera;
899 camera_state_e capi_state;
900 MMCamcorderStateType mmstate ;
901 mm_camcorder_get_state(handle->mm_handle, &mmstate);
903 capi_state = __camera_state_convert(mmstate);
905 if( ( handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed ) && mmstate == MM_CAMCORDER_STATE_CAPTURING )
906 capi_state = CAMERA_STATE_CAPTURED;
909 return CAMERA_ERROR_NONE;
912 int camera_start_focusing( camera_h camera, bool continuous ){
914 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
915 return CAMERA_ERROR_INVALID_PARAMETER;
917 camera_s *handle = (camera_s*)camera;
919 if( handle->cached_focus_mode != -1){
920 LOGD("[%s] apply cached focus mode %d", __func__, handle->cached_focus_mode);
921 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , handle->cached_focus_mode, NULL);
922 handle->cached_focus_mode = -1;
926 return __camera_start_continuous_focusing(camera);
928 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);
929 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s*)camera)->mm_handle));
933 int __camera_start_continuous_focusing(camera_h camera){
934 if( camera == NULL ){
935 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
936 return CAMERA_ERROR_INVALID_PARAMETER;
938 camera_s *handle = (camera_s*)camera;
941 handle->on_continuous_focusing = true;
942 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , &mode, NULL);
943 if( mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS )
944 ret = mm_camcorder_start_focusing(handle->mm_handle);
946 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS, NULL);
947 return __convert_camera_error_code(__func__, ret);
950 int camera_cancel_focusing( camera_h camera ){
952 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
953 return CAMERA_ERROR_INVALID_PARAMETER;
955 camera_s *handle = (camera_s*)camera;
956 handle->on_continuous_focusing = false;
957 return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
959 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display){
961 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
962 return CAMERA_ERROR_INVALID_PARAMETER;
965 camera_s * handle = (camera_s*)camera;
966 handle->display_handle = display;
967 handle->display_type = type;
968 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL,
969 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
970 MMCAM_DISPLAY_SURFACE ,type, NULL );
971 if( ret == 0 && type != CAMERA_DISPLAY_TYPE_NONE)
972 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL,
973 MMCAM_DISPLAY_HANDLE , type == CAMERA_DISPLAY_TYPE_X11 ? &handle->display_handle : display , sizeof(display) ,
975 return __convert_camera_error_code(__func__, ret);
978 int camera_set_preview_resolution(camera_h camera, int width, int height){
980 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
981 return CAMERA_ERROR_INVALID_PARAMETER;
984 camera_s * handle = (camera_s*)camera;
985 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width ,MMCAM_CAMERA_HEIGHT ,height, NULL);
986 return __convert_camera_error_code(__func__, ret);
988 int camera_set_x11_display_rotation(camera_h camera, camera_rotation_e rotation){
990 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
991 return CAMERA_ERROR_INVALID_PARAMETER;
994 if( rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270 )
995 return CAMERA_ERROR_INVALID_PARAMETER;
998 camera_s * handle = (camera_s*)camera;
1000 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL);
1001 return __convert_camera_error_code(__func__, ret);
1004 int camera_set_x11_display_flip(camera_h camera, camera_flip_e flip){
1005 if( camera == NULL){
1006 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1007 return CAMERA_ERROR_INVALID_PARAMETER;
1010 if( flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH )
1011 return CAMERA_ERROR_INVALID_PARAMETER;
1014 camera_s * handle = (camera_s*)camera;
1015 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_FLIP , flip, NULL);
1016 return __convert_camera_error_code(__func__, ret);
1019 int camera_get_x11_display_flip(camera_h camera, camera_flip_e *flip){
1020 if( camera == NULL || flip == NULL ){
1021 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1022 return CAMERA_ERROR_INVALID_PARAMETER;
1026 camera_s * handle = (camera_s*)camera;
1028 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_FLIP , flip, NULL);
1029 return __convert_camera_error_code(__func__, ret);
1032 int camera_set_capture_resolution(camera_h camera, int width, int height){
1033 if( camera == NULL){
1034 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1035 return CAMERA_ERROR_INVALID_PARAMETER;
1038 camera_s * handle = (camera_s*)camera;
1039 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_WIDTH, width ,MMCAM_CAPTURE_HEIGHT , height, NULL);
1041 handle->capture_width = width;
1042 handle->capture_height = height;
1044 return __convert_camera_error_code(__func__, ret);
1047 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format){
1048 if( camera == NULL){
1049 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1050 return CAMERA_ERROR_INVALID_PARAMETER;
1053 camera_s * handle = (camera_s*)camera;
1054 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL);
1055 return __convert_camera_error_code(__func__, ret);
1058 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format){
1059 if( camera == NULL){
1060 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1061 return CAMERA_ERROR_INVALID_PARAMETER;
1064 camera_s * handle = (camera_s*)camera;
1066 if( format == CAMERA_PIXEL_FORMAT_UYVY ){
1067 bool supported_ITLV_UYVY = false;
1068 MMCamAttrsInfo supported_format;
1069 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1071 for( i=0 ; i < supported_format.int_array.count ; i++){
1072 if( supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1073 supported_ITLV_UYVY = true;
1075 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);
1077 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL);
1079 return __convert_camera_error_code(__func__, ret);
1082 int camera_get_preview_resolution(camera_h camera, int *width, int *height){
1083 if( camera == NULL || width == NULL || height == NULL){
1084 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1085 return CAMERA_ERROR_INVALID_PARAMETER;
1089 camera_s * handle = (camera_s*)camera;
1090 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width,MMCAM_CAMERA_HEIGHT, height, NULL);
1091 return __convert_camera_error_code(__func__, ret);
1095 int camera_get_x11_display_rotation( camera_h camera, camera_rotation_e *rotation){
1096 if( camera == NULL || rotation == NULL ){
1097 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1098 return CAMERA_ERROR_INVALID_PARAMETER;
1102 camera_s * handle = (camera_s*)camera;
1104 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL);
1105 return __convert_camera_error_code(__func__, ret);
1108 int camera_set_x11_display_visible(camera_h camera, bool visible){
1109 if( camera == NULL){
1110 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1111 return CAMERA_ERROR_INVALID_PARAMETER;
1114 camera_s * handle = (camera_s*)camera;
1116 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_VISIBLE , visible, NULL);
1117 return __convert_camera_error_code(__func__, ret);
1120 int camera_is_x11_display_visible(camera_h camera, bool* visible){
1121 if( camera == NULL || visible == NULL){
1122 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1123 return CAMERA_ERROR_INVALID_PARAMETER;
1128 camera_s * handle = (camera_s*)camera;
1130 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_VISIBLE , &result, NULL);
1133 return __convert_camera_error_code(__func__, ret);
1136 int camera_set_x11_display_mode( camera_h camera , camera_display_mode_e ratio){
1137 if( camera == NULL){
1138 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1139 return CAMERA_ERROR_INVALID_PARAMETER;
1142 if( ratio < CAMERA_DISPLAY_MODE_LETTER_BOX || ratio > CAMERA_DISPLAY_MODE_CROPPED_FULL )
1143 return CAMERA_ERROR_INVALID_PARAMETER;
1146 camera_s * handle = (camera_s*)camera;
1148 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_GEOMETRY_METHOD , ratio, NULL);
1149 return __convert_camera_error_code(__func__, ret);
1152 int camera_get_x11_display_mode( camera_h camera , camera_display_mode_e* ratio){
1153 if( camera == NULL || ratio == NULL){
1154 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1155 return CAMERA_ERROR_INVALID_PARAMETER;
1159 camera_s * handle = (camera_s*)camera;
1161 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_GEOMETRY_METHOD , ratio, NULL);
1162 return __convert_camera_error_code(__func__, ret);
1166 int camera_get_capture_resolution(camera_h camera, int *width, int *height){
1167 if( camera == NULL || width== NULL || height == NULL){
1168 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1169 return CAMERA_ERROR_INVALID_PARAMETER;
1171 camera_s * handle = (camera_s*)camera;
1172 *width = handle->capture_width;
1173 *height = handle->capture_height;
1174 return CAMERA_ERROR_NONE;
1177 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format){
1178 if( camera == NULL || format == NULL){
1179 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1180 return CAMERA_ERROR_INVALID_PARAMETER;
1184 camera_s * handle = (camera_s*)camera;
1185 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL);
1186 return __convert_camera_error_code(__func__, ret);
1189 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format){
1190 if( camera == NULL || format == NULL){
1191 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1192 return CAMERA_ERROR_INVALID_PARAMETER;
1196 camera_s * handle = (camera_s*)camera;
1197 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL);
1198 if( (MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1199 *format = CAMERA_PIXEL_FORMAT_UYVY;
1200 return __convert_camera_error_code(__func__, ret);
1203 int camera_set_preview_cb( camera_h camera, camera_preview_cb callback, void* user_data ){
1204 if( camera == NULL || callback == NULL){
1205 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1206 return CAMERA_ERROR_INVALID_PARAMETER;
1209 camera_s * handle = (camera_s*)camera;
1210 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)callback;
1211 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)user_data;
1212 mm_camcorder_set_video_stream_callback( handle->mm_handle, (mm_camcorder_video_stream_callback)__mm_videostream_callback, (void*)handle);
1213 return CAMERA_ERROR_NONE;
1215 int camera_unset_preview_cb( camera_h camera){
1216 if( camera == NULL){
1217 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1218 return CAMERA_ERROR_INVALID_PARAMETER;
1220 camera_s * handle = (camera_s*)camera;
1221 mm_camcorder_set_video_stream_callback( handle->mm_handle, (mm_camcorder_video_stream_callback)NULL, (void*)NULL);
1222 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)NULL;
1223 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)NULL;
1224 return CAMERA_ERROR_NONE;
1227 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data){
1228 if( camera == NULL || callback == NULL){
1229 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1230 return CAMERA_ERROR_INVALID_PARAMETER;
1233 camera_s * handle = (camera_s*)camera;
1234 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)callback;
1235 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)user_data;
1236 return CAMERA_ERROR_NONE;
1238 int camera_unset_state_changed_cb(camera_h camera){
1239 if( camera == NULL){
1240 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1241 return CAMERA_ERROR_INVALID_PARAMETER;
1243 camera_s * handle = (camera_s*)camera;
1244 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1245 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1246 return CAMERA_ERROR_NONE;
1249 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data){
1250 if( camera == NULL || callback == NULL){
1251 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1252 return CAMERA_ERROR_INVALID_PARAMETER;
1255 camera_s * handle = (camera_s*)camera;
1256 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)callback;
1257 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)user_data;
1258 return CAMERA_ERROR_NONE;
1261 int camera_unset_interrupted_cb(camera_h camera){
1262 if( camera == NULL){
1263 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1264 return CAMERA_ERROR_INVALID_PARAMETER;
1266 camera_s * handle = (camera_s*)camera;
1267 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1268 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1269 return CAMERA_ERROR_NONE;
1272 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data){
1273 if( camera == NULL || callback == NULL){
1274 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1275 return CAMERA_ERROR_INVALID_PARAMETER;
1277 camera_s * handle = (camera_s*)camera;
1278 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)callback;
1279 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)user_data;
1280 return CAMERA_ERROR_NONE;
1282 int camera_unset_focus_changed_cb(camera_h camera){
1283 if( camera == NULL){
1284 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1285 return CAMERA_ERROR_INVALID_PARAMETER;
1287 camera_s * handle = (camera_s*)camera;
1288 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1289 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1290 return CAMERA_ERROR_NONE;
1293 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data){
1294 if( camera == NULL || callback == NULL){
1295 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1296 return CAMERA_ERROR_INVALID_PARAMETER;
1299 camera_s * handle = (camera_s*)camera;
1300 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)callback;
1301 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)user_data;
1302 return CAMERA_ERROR_NONE;
1305 int camera_unset_error_cb(camera_h camera){
1306 if( camera == NULL){
1307 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1308 return CAMERA_ERROR_INVALID_PARAMETER;
1311 camera_s * handle = (camera_s*)camera;
1312 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1313 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1314 return CAMERA_ERROR_NONE;
1317 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data){
1318 if( camera == NULL || foreach_cb == NULL){
1319 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1320 return CAMERA_ERROR_INVALID_PARAMETER;
1324 camera_s * handle = (camera_s*)camera;
1325 MMCamAttrsInfo preview_width;
1326 MMCamAttrsInfo preview_height;
1327 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH , &preview_width);
1328 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT , &preview_height);
1330 if( ret != CAMERA_ERROR_NONE )
1331 return __convert_camera_error_code(__func__, ret);
1334 for( i=0 ; i < preview_width.int_array.count ; i++)
1336 if ( !foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i],user_data) )
1339 return CAMERA_ERROR_NONE;
1342 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_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;
1348 camera_s * handle = (camera_s*)camera;
1349 MMCamAttrsInfo capture_width;
1350 MMCamAttrsInfo capture_height;
1351 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH , &capture_width);
1352 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT , &capture_height);
1354 if( ret != CAMERA_ERROR_NONE )
1355 return __convert_camera_error_code(__func__, ret);
1358 for( i=0 ; i < capture_width.int_array.count ; i++)
1360 if ( !foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i],user_data) )
1363 return CAMERA_ERROR_NONE;
1366 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data){
1367 if( camera == NULL || foreach_cb == NULL){
1368 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1369 return CAMERA_ERROR_INVALID_PARAMETER;
1373 camera_s * handle = (camera_s*)camera;
1374 MMCamAttrsInfo format;
1375 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT , &format);
1377 if( ret != CAMERA_ERROR_NONE )
1378 return __convert_camera_error_code(__func__, ret);
1381 for( i=0 ; i < format.int_array.count ; i++)
1383 if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1384 if ( !foreach_cb(format.int_array.array[i], user_data) )
1387 return CAMERA_ERROR_NONE;
1392 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data){
1393 if( camera == NULL || foreach_cb == NULL){
1394 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1395 return CAMERA_ERROR_INVALID_PARAMETER;
1398 camera_s * handle = (camera_s*)camera;
1399 MMCamAttrsInfo format;
1400 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &format);
1402 if( ret != CAMERA_ERROR_NONE )
1403 return __convert_camera_error_code(__func__, ret);
1406 for( i=0 ; i < format.int_array.count ; i++)
1408 if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY /* || format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_NV12 */)
1409 if ( !foreach_cb(format.int_array.array[i], user_data) )
1412 return CAMERA_ERROR_NONE;
1417 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height){
1418 if( camera == NULL ){
1419 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1420 return CAMERA_ERROR_INVALID_PARAMETER;
1423 enum MMCamcorderPreviewType wide;
1424 int capture_w, capture_h;
1427 camera_s * handle = (camera_s*)camera;
1429 camera_get_capture_resolution(camera, &capture_w, &capture_h);
1430 ratio = (double)capture_w/(double)capture_h;
1432 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
1434 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
1436 MMCamAttrsInfo width_info, height_info;
1437 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH , &width_info);
1438 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
1440 return __convert_camera_error_code(__func__, ret);
1443 *width = width_info.int_array.array[wide];
1446 *height = height_info.int_array.array[wide];
1448 return CAMERA_ERROR_NONE;
1453 int camera_attr_get_lens_orientation(camera_h camera, int *angle) {
1454 if( camera == NULL || angle == NULL){
1455 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1456 return CAMERA_ERROR_INVALID_PARAMETER;
1460 camera_s * handle = (camera_s*)camera;
1462 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation , NULL);
1464 switch( rotation ) {
1465 case MM_DISPLAY_ROTATION_NONE:
1468 case MM_DISPLAY_ROTATION_90:
1471 case MM_DISPLAY_ROTATION_180:
1474 case MM_DISPLAY_ROTATION_270:
1479 return __convert_camera_error_code(__func__, ret);
1482 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode){
1483 if( camera == NULL){
1484 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1485 return CAMERA_ERROR_INVALID_PARAMETER;
1488 camera_s * handle = (camera_s*)camera;
1489 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE, mode, NULL);
1490 return __convert_camera_error_code(__func__, ret);
1493 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode){
1494 if( camera == NULL || mode == NULL){
1495 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1496 return CAMERA_ERROR_INVALID_PARAMETER;
1499 camera_s * handle = (camera_s*)camera;
1500 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE , mode, NULL);
1501 return __convert_camera_error_code(__func__, ret);
1504 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps){
1505 if( camera == NULL){
1506 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1507 return CAMERA_ERROR_INVALID_PARAMETER;
1510 camera_s * handle = (camera_s*)camera;
1512 if( fps == CAMERA_ATTR_FPS_AUTO ){
1513 MMCamAttrsInfo info;
1514 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info);
1517 for( i=0 ; i < info.int_array.count ; i++)
1519 if ( info.int_array.array[i] > maxfps && info.int_array.array[i] <= 60 )
1520 maxfps = info.int_array.array[i];
1522 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS_AUTO , 1, MMCAM_CAMERA_FPS, maxfps , NULL);
1525 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS_AUTO , 0, MMCAM_CAMERA_FPS , fps, NULL);
1527 return __convert_camera_error_code(__func__, ret);
1532 int camera_attr_set_image_quality(camera_h camera, int quality){
1534 if( camera == NULL){
1535 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1536 return CAMERA_ERROR_INVALID_PARAMETER;
1540 camera_s * handle = (camera_s*)camera;
1541 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
1542 return __convert_camera_error_code(__func__, ret);
1545 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps){
1546 if( camera == NULL || fps == NULL){
1547 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1548 return CAMERA_ERROR_INVALID_PARAMETER;
1553 camera_s * handle = (camera_s*)camera;
1555 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS , &mm_fps, MMCAM_CAMERA_FPS_AUTO , &is_auto, NULL);
1557 *fps = CAMERA_ATTR_FPS_AUTO;
1561 return __convert_camera_error_code(__func__, ret);
1564 int camera_attr_get_image_quality(camera_h camera, int *quality){
1565 if( camera == NULL || quality == NULL){
1566 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1567 return CAMERA_ERROR_INVALID_PARAMETER;
1571 camera_s * handle = (camera_s*)camera;
1572 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
1573 return __convert_camera_error_code(__func__, ret);
1578 int camera_attr_set_zoom(camera_h camera, int zoom){
1579 if( camera == NULL){
1580 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1581 return CAMERA_ERROR_INVALID_PARAMETER;
1584 camera_s * handle = (camera_s*)camera;
1585 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL);
1586 return __convert_camera_error_code(__func__, ret);
1590 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode){
1591 if( camera == NULL){
1592 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1593 return CAMERA_ERROR_INVALID_PARAMETER;
1595 int ret = CAMERA_ERROR_INVALID_PARAMETER;
1596 camera_s * handle = (camera_s*)camera;
1598 bool should_change_focus_mode = false;
1599 mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE, &focus_mode, NULL);
1600 if( focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO && focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO )
1601 should_change_focus_mode = true;
1603 if( mode != CAMERA_ATTR_AF_NONE && focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && !handle->on_continuous_focusing){
1604 handle->cached_focus_mode = mode;
1605 LOGD("[%s] af mode will be set actually start focusing",__func__);
1606 return __convert_camera_error_code(__func__, 0);
1608 handle->cached_focus_mode = -1;
1610 if( mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode ){
1611 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO, NULL);
1615 case CAMERA_ATTR_AF_NONE:
1616 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
1617 MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_NORMAL, NULL);
1619 case CAMERA_ATTR_AF_NORMAL:
1620 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_NORMAL, NULL);
1622 case CAMERA_ATTR_AF_MACRO:
1623 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_MACRO, NULL);
1625 case CAMERA_ATTR_AF_FULL:
1626 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_FULL, NULL);
1632 return __convert_camera_error_code(__func__, ret);
1635 int camera_attr_set_af_area(camera_h camera, int x, int y){
1636 if( camera == NULL){
1637 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1638 return CAMERA_ERROR_INVALID_PARAMETER;
1640 int ret = CAMERA_ERROR_INVALID_PARAMETER;
1641 camera_s * handle = (camera_s*)camera;
1642 camera_attr_af_mode_e mode;
1643 camera_attr_get_af_mode(camera, &mode);
1644 if( mode == CAMERA_ATTR_AF_NONE ){
1645 LOGE( "[%s] INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE",__func__,CAMERA_ERROR_INVALID_OPERATION);
1646 return CAMERA_ERROR_INVALID_OPERATION;
1648 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1649 MMCAM_CAMERA_AF_TOUCH_X, x,
1650 MMCAM_CAMERA_AF_TOUCH_Y, y,
1653 handle->focus_area_valid = true;
1654 return __convert_camera_error_code(__func__, ret);
1657 int camera_attr_clear_af_area(camera_h camera){
1658 if( camera == NULL){
1659 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__, CAMERA_ERROR_INVALID_PARAMETER);
1660 return CAMERA_ERROR_INVALID_PARAMETER;
1662 camera_s * handle = (camera_s*)camera;
1663 if( !handle->focus_area_valid ){
1664 LOGE( "[%s] INVALID_OPERATION(0x%08x) AF area was not set",__func__,CAMERA_ERROR_INVALID_OPERATION);
1665 return CAMERA_ERROR_INVALID_OPERATION;
1667 handle->focus_area_valid = false;
1671 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode){
1672 if( camera == NULL){
1673 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1674 return CAMERA_ERROR_INVALID_PARAMETER;
1676 int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, //CAMCORDER_EXPOSURE_MODE_OFF
1677 MM_CAMCORDER_AUTO_EXPOSURE_ALL, //CAMCORDER_EXPOSURE_MODE_ALL
1678 MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, //CAMCORDER_EXPOSURE_MODE_CENTER
1679 MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, //CAMCORDER_EXPOSURE_MODE_SPOT
1680 MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1,//CAMCORDER_EXPOSURE_MODE_CUSTOM
1684 camera_s * handle = (camera_s*)camera;
1685 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_MODE , maptable[abs(mode%5)], NULL);
1686 return __convert_camera_error_code(__func__, ret);
1690 int camera_attr_set_exposure(camera_h camera, int value){
1691 if( camera == NULL){
1692 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1693 return CAMERA_ERROR_INVALID_PARAMETER;
1697 camera_s * handle = (camera_s*)camera;
1698 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_VALUE , value, NULL);
1699 return __convert_camera_error_code(__func__, ret);
1703 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso){
1704 if( camera == NULL){
1705 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1706 return CAMERA_ERROR_INVALID_PARAMETER;
1709 camera_s * handle = (camera_s*)camera;
1710 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ISO , iso, NULL);
1711 return __convert_camera_error_code(__func__, ret);
1713 int camera_attr_set_brightness(camera_h camera, int level){
1714 if( camera == NULL){
1715 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1716 return CAMERA_ERROR_INVALID_PARAMETER;
1720 camera_s * handle = (camera_s*)camera;
1721 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_BRIGHTNESS , level, NULL);
1722 return __convert_camera_error_code(__func__, ret);
1726 int camera_attr_set_contrast(camera_h camera, int level){
1727 if( camera == NULL){
1728 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1729 return CAMERA_ERROR_INVALID_PARAMETER;
1733 camera_s * handle = (camera_s*)camera;
1734 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_CONTRAST , level, NULL);
1736 return __convert_camera_error_code(__func__, ret);
1739 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb){
1740 if( camera == NULL){
1741 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1742 return CAMERA_ERROR_INVALID_PARAMETER;
1745 camera_s * handle = (camera_s*)camera;
1746 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_WB , wb, NULL);
1747 return __convert_camera_error_code(__func__, ret);
1751 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect){
1752 if( camera == NULL){
1753 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1754 return CAMERA_ERROR_INVALID_PARAMETER;
1757 camera_s * handle = (camera_s*)camera;
1758 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_COLOR_TONE , effect, NULL);
1759 return __convert_camera_error_code(__func__, ret);
1761 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode){
1762 if( camera == NULL){
1763 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1764 return CAMERA_ERROR_INVALID_PARAMETER;
1767 camera_s * handle = (camera_s*)camera;
1768 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_SCENE_MODE , mode, NULL);
1769 return __convert_camera_error_code(__func__, ret);
1774 int camera_attr_enable_tag(camera_h camera, bool enable){
1775 if( camera == NULL){
1776 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1777 return CAMERA_ERROR_INVALID_PARAMETER;
1780 camera_s * handle = (camera_s*)camera;
1781 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ENABLE , enable, NULL);
1782 return __convert_camera_error_code(__func__, ret);
1786 int camera_attr_set_tag_image_description(camera_h camera, const char *description){
1787 if( camera == NULL){
1788 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1789 return CAMERA_ERROR_INVALID_PARAMETER;
1792 camera_s * handle = (camera_s*)camera;
1793 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_IMAGE_DESCRIPTION , description, strlen(description), NULL);
1794 return __convert_camera_error_code(__func__, ret);
1798 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation){
1799 if( camera == NULL){
1800 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1801 return CAMERA_ERROR_INVALID_PARAMETER;
1804 camera_s * handle = (camera_s*)camera;
1805 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ORIENTATION , orientation, NULL);
1806 return __convert_camera_error_code(__func__, ret);
1810 int camera_attr_set_tag_software(camera_h camera, const char *software){
1811 if( camera == NULL){
1812 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1813 return CAMERA_ERROR_INVALID_PARAMETER;
1816 camera_s * handle = (camera_s*)camera;
1817 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_SOFTWARE , software, strlen(software), NULL);
1818 return __convert_camera_error_code(__func__, ret);
1822 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude){
1823 if( camera == NULL){
1824 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1825 return CAMERA_ERROR_INVALID_PARAMETER;
1828 camera_s * handle = (camera_s*)camera;
1829 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_GPS_ENABLE, 1,
1830 MMCAM_TAG_LATITUDE, latitude,
1831 MMCAM_TAG_LONGITUDE, longitude,
1832 MMCAM_TAG_ALTITUDE, altitude,
1834 return __convert_camera_error_code(__func__, ret);
1837 int camera_attr_remove_geotag(camera_h camera){
1838 if( camera == NULL){
1839 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1840 return CAMERA_ERROR_INVALID_PARAMETER;
1843 camera_s * handle = (camera_s*)camera;
1844 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_GPS_ENABLE, 0, NULL);
1845 return __convert_camera_error_code(__func__, ret);
1848 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode){
1849 if( camera == NULL){
1850 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1851 return CAMERA_ERROR_INVALID_PARAMETER;
1854 camera_s * handle = (camera_s*)camera;
1855 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_STROBE_MODE , mode, NULL);
1856 return __convert_camera_error_code(__func__, ret);
1860 int camera_attr_get_zoom(camera_h camera, int *zoom){
1861 if( camera == NULL || zoom == NULL){
1862 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1863 return CAMERA_ERROR_INVALID_PARAMETER;
1867 camera_s * handle = (camera_s*)camera;
1868 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL);
1869 return __convert_camera_error_code(__func__, ret);
1873 int camera_attr_get_zoom_range(camera_h camera , int *min , int *max){
1874 if( camera == NULL || min == NULL || max == NULL ){
1875 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1876 return CAMERA_ERROR_INVALID_PARAMETER;
1880 camera_s * handle = (camera_s*)camera;
1881 MMCamAttrsInfo ainfo;
1882 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
1884 *min = ainfo.int_range.min;
1886 *max = ainfo.int_range.max;
1888 return __convert_camera_error_code(__func__, ret);
1892 int camera_attr_get_af_mode( camera_h camera, camera_attr_af_mode_e *mode){
1893 if( camera == NULL || mode == NULL){
1894 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1895 return CAMERA_ERROR_INVALID_PARAMETER;
1902 camera_s * handle = (camera_s*)camera;
1903 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);
1904 if( ret == CAMERA_ERROR_NONE){
1905 switch( focus_mode ){
1906 case MM_CAMCORDER_FOCUS_MODE_NONE :
1907 case MM_CAMCORDER_FOCUS_MODE_PAN :
1908 case MM_CAMCORDER_FOCUS_MODE_MANUAL :
1909 *mode = CAMERA_ATTR_AF_NONE;
1911 case MM_CAMCORDER_FOCUS_MODE_AUTO:
1912 case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
1913 case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
1914 switch ( af_range ){
1915 case MM_CAMCORDER_AUTO_FOCUS_NONE :
1916 *mode = CAMERA_ATTR_AF_NORMAL;
1918 case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
1919 *mode = CAMERA_ATTR_AF_NORMAL;
1921 case MM_CAMCORDER_AUTO_FOCUS_MACRO:
1922 *mode = CAMERA_ATTR_AF_MACRO;
1924 case MM_CAMCORDER_AUTO_FOCUS_FULL:
1925 *mode = CAMERA_ATTR_AF_FULL;
1932 return __convert_camera_error_code(__func__, ret);
1935 int camera_attr_get_exposure_mode( camera_h camera, camera_attr_exposure_mode_e *mode){
1936 if( camera == NULL|| mode == NULL){
1937 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1938 return CAMERA_ERROR_INVALID_PARAMETER;
1942 CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
1943 CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
1944 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
1945 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
1946 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
1947 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
1948 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
1949 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
1950 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM //MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
1954 camera_s * handle = (camera_s*)camera;
1955 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_MODE , &exposure_mode, NULL);
1956 if( ret == CAMERA_ERROR_NONE ){
1957 *mode = maptable[abs(exposure_mode%9)];
1959 return __convert_camera_error_code(__func__, ret);
1963 int camera_attr_get_exposure(camera_h camera, int *value){
1964 if( camera == NULL || value == NULL){
1965 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1966 return CAMERA_ERROR_INVALID_PARAMETER;
1970 camera_s * handle = (camera_s*)camera;
1971 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_VALUE , value, NULL);
1972 return __convert_camera_error_code(__func__, ret);
1976 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max){
1977 if( camera == NULL || min == NULL || max == NULL ){
1978 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1979 return CAMERA_ERROR_INVALID_PARAMETER;
1983 camera_s * handle = (camera_s*)camera;
1984 MMCamAttrsInfo ainfo;
1985 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
1987 *min = ainfo.int_range.min;
1989 *max = ainfo.int_range.max;
1991 return __convert_camera_error_code(__func__, ret);
1995 int camera_attr_get_iso( camera_h camera, camera_attr_iso_e *iso){
1996 if( camera == NULL || iso == NULL){
1997 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1998 return CAMERA_ERROR_INVALID_PARAMETER;
2002 camera_s * handle = (camera_s*)camera;
2003 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ISO , iso, NULL);
2004 return __convert_camera_error_code(__func__, ret);
2008 int camera_attr_get_brightness(camera_h camera, int *level){
2009 if( camera == NULL || level == NULL){
2010 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2011 return CAMERA_ERROR_INVALID_PARAMETER;
2014 camera_s * handle = (camera_s*)camera;
2015 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_BRIGHTNESS , level, NULL);
2016 return __convert_camera_error_code(__func__, ret);
2020 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max){
2021 if( camera == NULL || min == NULL || max == NULL ){
2022 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2023 return CAMERA_ERROR_INVALID_PARAMETER;
2027 camera_s * handle = (camera_s*)camera;
2028 MMCamAttrsInfo ainfo;
2029 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
2031 *min = ainfo.int_range.min;
2033 *max = ainfo.int_range.max;
2035 return __convert_camera_error_code(__func__, ret);
2039 int camera_attr_get_contrast(camera_h camera, int *level){
2040 if( camera == NULL || level == NULL){
2041 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2042 return CAMERA_ERROR_INVALID_PARAMETER;
2047 camera_s * handle = (camera_s*)camera;
2048 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_CONTRAST , level, NULL);
2049 return __convert_camera_error_code(__func__, ret);
2052 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max){
2053 if( camera == NULL || min == NULL || max == NULL ){
2054 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2055 return CAMERA_ERROR_INVALID_PARAMETER;
2059 camera_s * handle = (camera_s*)camera;
2060 MMCamAttrsInfo ainfo;
2061 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
2063 *min = ainfo.int_range.min;
2065 *max = ainfo.int_range.max;
2067 return __convert_camera_error_code(__func__, ret);
2071 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb){
2072 if( camera == NULL || wb == NULL){
2073 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2074 return CAMERA_ERROR_INVALID_PARAMETER;
2078 camera_s * handle = (camera_s*)camera;
2079 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_WB , wb, NULL);
2080 return __convert_camera_error_code(__func__, ret);
2084 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect){
2086 if( camera == NULL || effect == NULL ){
2087 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2088 return CAMERA_ERROR_INVALID_PARAMETER;
2092 camera_s * handle = (camera_s*)camera;
2094 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_COLOR_TONE , &tone, NULL);
2096 if( ret != CAMERA_ERROR_NONE )
2097 return __convert_camera_error_code(__func__, ret);
2099 *effect = (camera_attr_effect_mode_e)tone;
2101 return __convert_camera_error_code(__func__, ret);
2104 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode){
2105 if( camera == NULL || mode == NULL){
2106 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2107 return CAMERA_ERROR_INVALID_PARAMETER;
2111 camera_s * handle = (camera_s*)camera;
2112 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_SCENE_MODE , mode, NULL);
2113 return __convert_camera_error_code(__func__, ret);
2118 int camera_attr_is_enabled_tag(camera_h camera, bool *enable){
2119 if( camera == NULL || enable == NULL){
2120 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2121 return CAMERA_ERROR_INVALID_PARAMETER;
2125 camera_s * handle = (camera_s*)camera;
2127 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ENABLE , enable, NULL);
2129 return __convert_camera_error_code(__func__, ret);
2133 int camera_attr_get_tag_image_description(camera_h camera, char **description){
2134 if( camera == NULL || description == NULL){
2135 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2136 return CAMERA_ERROR_INVALID_PARAMETER;
2140 camera_s * handle = (camera_s*)camera;
2141 char *ndescription = NULL;
2143 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_IMAGE_DESCRIPTION , &ndescription, &desc_size, NULL);
2144 if( ret == CAMERA_ERROR_NONE ){
2145 if( ndescription != NULL )
2146 *description = strdup(ndescription);
2148 *description = strdup("");
2151 return __convert_camera_error_code(__func__, ret);
2155 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation){
2157 if( camera == NULL || orientation == NULL){
2158 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2159 return CAMERA_ERROR_INVALID_PARAMETER;
2163 camera_s * handle = (camera_s*)camera;
2164 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ORIENTATION , orientation, NULL);
2165 return __convert_camera_error_code(__func__, ret);
2168 int camera_attr_get_tag_software(camera_h camera, char **software){
2169 if( camera == NULL || software == NULL ){
2170 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2171 return CAMERA_ERROR_INVALID_PARAMETER;
2175 camera_s * handle = (camera_s*)camera;
2178 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_SOFTWARE , &soft, &soft_size, NULL);
2179 if( ret == CAMERA_ERROR_NONE ){
2181 *software = strdup(soft);
2183 *software = strdup("");
2185 return __convert_camera_error_code(__func__, ret);
2188 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude){
2189 if( camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL){
2190 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2191 return CAMERA_ERROR_INVALID_PARAMETER;
2194 camera_s * handle = (camera_s*)camera;
2195 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_LATITUDE , latitude,
2196 MMCAM_TAG_LONGITUDE, longitude,
2197 MMCAM_TAG_ALTITUDE, altitude,
2199 return __convert_camera_error_code(__func__, ret);
2202 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode){
2203 if( camera == NULL || mode == NULL){
2204 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2205 return CAMERA_ERROR_INVALID_PARAMETER;
2209 camera_s * handle = (camera_s*)camera;
2210 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_STROBE_MODE , mode, NULL);
2211 return __convert_camera_error_code(__func__, ret);
2214 int camera_attr_foreach_supported_af_mode( camera_h camera, camera_attr_supported_af_mode_cb foreach_cb , void *user_data){
2215 if( camera == NULL || foreach_cb == NULL){
2216 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2217 return CAMERA_ERROR_INVALID_PARAMETER;
2223 camera_s * handle = (camera_s*)camera;
2224 MMCamAttrsInfo af_range;
2225 MMCamAttrsInfo focus_mode;
2227 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE , &af_range);
2228 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE , &focus_mode);
2230 if( ret != CAMERA_ERROR_NONE )
2231 return __convert_camera_error_code(__func__, ret);
2233 for( i=0 ; i < af_range.int_array.count ; i++)
2235 if ( !foreach_cb(af_range.int_array.array[i],user_data) )
2241 return CAMERA_ERROR_NONE;
2245 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data){
2246 if( camera == NULL || foreach_cb == NULL){
2247 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2248 return CAMERA_ERROR_INVALID_PARAMETER;
2252 CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
2253 CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
2254 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
2255 -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
2256 -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
2257 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
2258 -1, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
2259 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
2260 -1//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
2263 camera_s * handle = (camera_s*)camera;
2264 MMCamAttrsInfo info;
2265 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE , &info);
2266 if( ret != CAMERA_ERROR_NONE )
2267 return __convert_camera_error_code(__func__, ret);
2270 for( i=0 ; i < info.int_array.count ; i++)
2272 if( maptable[info.int_array.array[i]] != -1){
2273 if ( !foreach_cb(maptable[info.int_array.array[i]],user_data) )
2277 return CAMERA_ERROR_NONE;
2280 int camera_attr_foreach_supported_iso( camera_h camera, camera_attr_supported_iso_cb foreach_cb , void *user_data){
2281 if( camera == NULL || foreach_cb == NULL){
2282 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2283 return CAMERA_ERROR_INVALID_PARAMETER;
2286 camera_s * handle = (camera_s*)camera;
2287 MMCamAttrsInfo info;
2288 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO , &info);
2289 if( ret != CAMERA_ERROR_NONE )
2290 return __convert_camera_error_code(__func__, ret);
2293 for( i=0 ; i < info.int_array.count ; i++)
2295 if ( !foreach_cb(info.int_array.array[i],user_data) )
2298 return CAMERA_ERROR_NONE;
2302 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data){
2303 if( camera == NULL || foreach_cb == NULL){
2304 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2305 return CAMERA_ERROR_INVALID_PARAMETER;
2308 camera_s * handle = (camera_s*)camera;
2309 MMCamAttrsInfo info;
2310 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB , &info);
2311 if( ret != CAMERA_ERROR_NONE )
2312 return __convert_camera_error_code(__func__, ret);
2315 for( i=0 ; i < info.int_array.count ; i++)
2317 if ( !foreach_cb(info.int_array.array[i],user_data) )
2320 return CAMERA_ERROR_NONE;
2323 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data){
2324 if( camera == NULL || foreach_cb == NULL){
2325 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2326 return CAMERA_ERROR_INVALID_PARAMETER;
2330 camera_s * handle = (camera_s*)camera;
2331 MMCamAttrsInfo info;
2332 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE , &info);
2333 if( ret != CAMERA_ERROR_NONE )
2334 return __convert_camera_error_code(__func__, ret);
2337 for( i=0 ; i < info.int_array.count ; i++)
2339 int effect = info.int_array.array[i];
2340 if ( !foreach_cb(effect,user_data) )
2343 return CAMERA_ERROR_NONE;
2346 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data){
2347 if( camera == NULL || foreach_cb == NULL){
2348 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2349 return CAMERA_ERROR_INVALID_PARAMETER;
2353 camera_s * handle = (camera_s*)camera;
2354 MMCamAttrsInfo info;
2355 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE , &info);
2356 if( ret != CAMERA_ERROR_NONE )
2357 return __convert_camera_error_code(__func__, ret);
2360 for( i=0 ; i < info.int_array.count ; i++)
2362 if ( !foreach_cb(info.int_array.array[i],user_data) )
2365 return CAMERA_ERROR_NONE;
2369 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data){
2370 if( camera == NULL || foreach_cb == NULL){
2371 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2372 return CAMERA_ERROR_INVALID_PARAMETER;
2375 camera_s * handle = (camera_s*)camera;
2376 MMCamAttrsInfo info;
2377 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE , &info);
2378 if( ret != CAMERA_ERROR_NONE )
2379 return __convert_camera_error_code(__func__, ret);
2382 for( i=0 ; i < info.int_array.count ; i++)
2384 if ( !foreach_cb(info.int_array.array[i],user_data) )
2387 return CAMERA_ERROR_NONE;
2390 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data){
2391 if( camera == NULL || foreach_cb == NULL){
2392 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2393 return CAMERA_ERROR_INVALID_PARAMETER;
2396 camera_s * handle = (camera_s*)camera;
2397 MMCamAttrsInfo info;
2398 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info);
2399 if( ret != CAMERA_ERROR_NONE )
2400 return __convert_camera_error_code(__func__, ret);
2403 //if (foreach_cb(CAMERA_ATTR_FPS_AUTO, user_data) < 0 )
2404 // return CAMERA_ERROR_NONE;
2405 for( i=0 ; i < info.int_array.count ; i++)
2407 if ( !foreach_cb(info.int_array.array[i],user_data) )
2410 return CAMERA_ERROR_NONE;
2414 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation){
2415 if( camera == NULL){
2416 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2417 return CAMERA_ERROR_INVALID_PARAMETER;
2420 if( rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270 )
2421 return CAMERA_ERROR_INVALID_PARAMETER;
2424 camera_s * handle = (camera_s*)camera;
2426 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ROTATION , rotation, NULL);
2427 return __convert_camera_error_code(__func__, ret);
2430 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation){
2431 if( camera == NULL || rotation == NULL ){
2432 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2433 return CAMERA_ERROR_INVALID_PARAMETER;
2437 camera_s * handle = (camera_s*)camera;
2439 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ROTATION , rotation, NULL);
2440 return __convert_camera_error_code(__func__, ret);
2443 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip){
2444 if( camera == NULL){
2445 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2446 return CAMERA_ERROR_INVALID_PARAMETER;
2449 if( flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH )
2450 return CAMERA_ERROR_INVALID_PARAMETER;
2453 camera_s * handle = (camera_s*)camera;
2454 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FLIP , flip , NULL);
2455 return __convert_camera_error_code(__func__, ret);
2458 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip){
2459 if( camera == NULL || flip == NULL ){
2460 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2461 return CAMERA_ERROR_INVALID_PARAMETER;
2464 camera_s * handle = (camera_s*)camera;
2465 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FLIP , flip , NULL);
2466 return __convert_camera_error_code(__func__, ret);
2469 int _camera_set_use(camera_h camera, bool used){
2470 camera_s * handle = (camera_s*)camera;
2471 handle->is_used_in_recorder = used;
2475 bool _camera_is_used(camera_h camera){
2476 camera_s * handle = (camera_s*)camera;
2477 return handle->is_used_in_recorder;
2481 int _camera_get_mm_handle(camera_h camera , MMHandleType *handle){
2482 if( camera == NULL || handle == NULL ){
2483 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2484 return CAMERA_ERROR_INVALID_PARAMETER;
2486 camera_s *camera_handle = (camera_s*)camera;
2487 *handle = camera_handle->mm_handle;
2488 return CAMERA_ERROR_NONE;
2491 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data){
2492 if( camera == NULL ){
2493 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2494 return CAMERA_ERROR_INVALID_PARAMETER;
2497 camera_s *handle = (camera_s*)camera;
2498 handle->relay_message_callback = callback;
2499 handle->relay_user_data = user_data;
2501 return CAMERA_ERROR_NONE;
2504 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode){
2505 if( camera == NULL){
2506 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2507 return CAMERA_ERROR_INVALID_PARAMETER;
2510 camera_s * handle = (camera_s*)camera;
2511 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , mode, NULL);
2513 if( mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL )
2514 handle->hdr_keep_mode = true;
2516 handle->hdr_keep_mode = false;
2518 return __convert_camera_error_code(__func__, ret);
2521 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode){
2522 if( camera == NULL || mode == NULL ){
2523 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2524 return CAMERA_ERROR_INVALID_PARAMETER;
2528 camera_s * handle = (camera_s*)camera;
2529 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , &result, NULL);
2533 return __convert_camera_error_code(__func__, ret);
2537 int camera_attr_enable_hdr_capture(camera_h camera, bool enable){
2538 if( camera == NULL){
2539 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2540 return CAMERA_ERROR_INVALID_PARAMETER;
2543 camera_s * handle = (camera_s*)camera;
2544 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , enable, NULL);
2545 return __convert_camera_error_code(__func__, ret);
2548 int camera_attr_is_enabled_hdr_capture(camera_h camera, bool *enabled){
2549 if( camera == NULL || enabled == NULL ){
2550 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2551 return CAMERA_ERROR_INVALID_PARAMETER;
2555 camera_s * handle = (camera_s*)camera;
2556 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , &result, NULL);
2558 if( result >= MM_CAMCORDER_HDR_ON )
2563 return __convert_camera_error_code(__func__, ret);
2566 bool camera_attr_is_supported_hdr_capture(camera_h camera){
2567 if( camera == NULL){
2568 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2573 camera_s * handle = (camera_s*)camera;
2574 MMCamAttrsInfo hdr_info;
2575 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE , &hdr_info);
2576 for (i = 0; i < hdr_info.int_array.count ; i++) {
2577 if (hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON) {
2584 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void* user_data){
2585 if( camera == NULL || callback == NULL){
2586 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2587 return CAMERA_ERROR_INVALID_PARAMETER;
2590 camera_s * handle = (camera_s*)camera;
2591 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)callback;
2592 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)user_data;
2593 return CAMERA_ERROR_NONE;
2596 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera){
2597 if( camera == NULL){
2598 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2599 return CAMERA_ERROR_INVALID_PARAMETER;
2601 camera_s * handle = (camera_s*)camera;
2602 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
2603 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
2604 return CAMERA_ERROR_NONE;
2607 int camera_attr_enable_anti_shake(camera_h camera, bool enable){
2608 if( camera == NULL){
2609 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2610 return CAMERA_ERROR_INVALID_PARAMETER;
2613 int mode = MM_CAMCORDER_AHS_OFF;
2615 mode = MM_CAMCORDER_AHS_ON;
2617 camera_s * handle = (camera_s*)camera;
2618 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ANTI_HANDSHAKE , mode, NULL);
2619 return __convert_camera_error_code(__func__, ret);
2622 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled){
2623 if( camera == NULL || enabled == NULL ){
2624 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2625 return CAMERA_ERROR_INVALID_PARAMETER;
2628 int mode = MM_CAMCORDER_AHS_OFF;
2629 camera_s * handle = (camera_s*)camera;
2630 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ANTI_HANDSHAKE , &mode, NULL);
2633 return __convert_camera_error_code(__func__, ret);
2636 bool camera_attr_is_supported_anti_shake(camera_h camera){
2637 if( camera == NULL){
2638 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2642 camera_s * handle = (camera_s*)camera;
2643 MMCamAttrsInfo ash_info;
2644 mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE , &ash_info);
2646 for( i=0 ; i < ash_info.int_array.count ; i++)
2648 if ( ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON)
2654 int camera_attr_enable_video_stabilization(camera_h camera, bool enable){
2655 if( camera == NULL){
2656 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2657 return CAMERA_ERROR_INVALID_PARAMETER;
2660 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
2662 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
2664 camera_s * handle = (camera_s*)camera;
2665 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_VIDEO_STABILIZATION , mode, NULL);
2666 return __convert_camera_error_code(__func__, ret);
2669 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled){
2670 if( camera == NULL || enabled == NULL ){
2671 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2672 return CAMERA_ERROR_INVALID_PARAMETER;
2675 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
2676 camera_s * handle = (camera_s*)camera;
2677 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_VIDEO_STABILIZATION , &mode, NULL);
2679 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
2680 return __convert_camera_error_code(__func__, ret);
2683 bool camera_attr_is_supported_video_stabilization(camera_h camera){
2684 if( camera == NULL){
2685 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2689 camera_s * handle = (camera_s*)camera;
2690 MMCamAttrsInfo vs_info;
2691 mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION , &vs_info);
2693 for( i=0 ; i < vs_info.int_array.count ; i++)
2695 if ( vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON)
2703 int camera_attr_enable_auto_contrast(camera_h camera, bool enable){
2704 if( camera == NULL){
2705 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2706 return CAMERA_ERROR_INVALID_PARAMETER;
2709 int mode = MM_CAMCORDER_WDR_OFF;
2711 mode = MM_CAMCORDER_WDR_ON;
2713 camera_s * handle = (camera_s*)camera;
2714 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WDR , mode, NULL);
2715 return __convert_camera_error_code(__func__, ret);
2718 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled){
2719 if( camera == NULL || enabled == NULL ){
2720 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2721 return CAMERA_ERROR_INVALID_PARAMETER;
2724 int mode = MM_CAMCORDER_WDR_OFF;
2725 camera_s * handle = (camera_s*)camera;
2726 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WDR , &mode, NULL);
2729 return __convert_camera_error_code(__func__, ret);
2732 int camera_attr_disable_shutter_sound(camera_h camera, bool disable){
2733 if( camera == NULL){
2734 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2735 return CAMERA_ERROR_INVALID_PARAMETER;
2738 camera_s * handle = (camera_s*)camera;
2739 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "capture-sound-enable" , !disable, NULL);
2741 LOGE("[%s] CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound", __func__);
2742 return CAMERA_ERROR_INVALID_OPERATION;
2744 return CAMERA_ERROR_NONE;