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 <audio-session-manager-types.h>
23 #include <mm_camcorder.h>
27 #include <camera_private.h>
34 #define LOG_TAG "TIZEN_N_CAMERA"
36 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data);
37 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data);
40 static int __convert_camera_error_code(const char* func, int code){
41 int ret = CAMERA_ERROR_NONE;
42 char *errorstr = NULL;
46 ret = CAMERA_ERROR_NONE;
47 errorstr = "ERROR_NONE";
49 case MM_ERROR_CAMCORDER_INVALID_ARGUMENT :
50 case MM_ERROR_COMMON_INVALID_ATTRTYPE :
51 case MM_ERROR_COMMON_INVALID_PERMISSION :
52 case MM_ERROR_COMMON_OUT_OF_ARRAY :
53 case MM_ERROR_COMMON_OUT_OF_RANGE :
54 case MM_ERROR_COMMON_ATTR_NOT_EXIST :
55 ret = CAMERA_ERROR_INVALID_PARAMETER;
56 errorstr = "INVALID_PARAMETER";
58 case MM_ERROR_CAMCORDER_NOT_INITIALIZED :
59 case MM_ERROR_CAMCORDER_INVALID_STATE :
60 ret = CAMERA_ERROR_INVALID_STATE;
61 errorstr = "INVALID_STATE";
63 case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND :
64 ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
65 errorstr = "DEVICE_NOT_FOUND";
67 case MM_ERROR_CAMCORDER_DEVICE_BUSY :
68 case MM_ERROR_CAMCORDER_DEVICE_OPEN :
69 case MM_ERROR_CAMCORDER_CMD_IS_RUNNING :
70 ret = CAMERA_ERROR_DEVICE_BUSY;
71 errorstr = "DEVICE_BUSY";
73 case MM_ERROR_CAMCORDER_DEVICE :
74 case MM_ERROR_CAMCORDER_DEVICE_IO :
75 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT :
76 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE :
77 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG :
78 case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER :
79 ret = CAMERA_ERROR_DEVICE;
80 errorstr = "ERROR_DEVICE";
83 case MM_ERROR_CAMCORDER_GST_CORE :
84 case MM_ERROR_CAMCORDER_GST_LIBRARY :
85 case MM_ERROR_CAMCORDER_GST_RESOURCE :
86 case MM_ERROR_CAMCORDER_GST_STREAM :
87 case MM_ERROR_CAMCORDER_GST_STATECHANGE :
88 case MM_ERROR_CAMCORDER_GST_NEGOTIATION :
89 case MM_ERROR_CAMCORDER_GST_LINK :
90 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR :
91 case MM_ERROR_CAMCORDER_ENCODER :
92 case MM_ERROR_CAMCORDER_ENCODER_BUFFER :
93 case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE :
94 case MM_ERROR_CAMCORDER_ENCODER_WORKING :
95 case MM_ERROR_CAMCORDER_INTERNAL :
96 case MM_ERROR_CAMCORDER_NOT_SUPPORTED :
97 case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT :
98 case MM_ERROR_CAMCORDER_DSP_FAIL :
99 case MM_ERROR_CAMCORDER_AUDIO_EMPTY :
100 case MM_ERROR_CAMCORDER_CREATE_CONFIGURE :
101 case MM_ERROR_CAMCORDER_FILE_SIZE_OVER :
102 case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF :
103 case MM_ERROR_CAMCORDER_INVALID_CONDITION :
104 ret = CAMERA_ERROR_INVALID_OPERATION;
105 errorstr = "INVALID_OPERATION";
108 case MM_ERROR_CAMCORDER_RESOURCE_CREATION :
109 case MM_ERROR_COMMON_OUT_OF_MEMORY:
110 ret = CAMERA_ERROR_OUT_OF_MEMORY;
111 errorstr = "OUT_OF_MEMORY";
114 case MM_ERROR_POLICY_BLOCKED:
115 ret = CAMERA_ERROR_SOUND_POLICY;
116 errorstr = "ERROR_SOUND_POLICY";
118 case MM_ERROR_POLICY_BLOCKED_BY_CALL:
119 ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
120 errorstr = "ERROR_SOUND_POLICY_BY_CALL";
122 case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
123 ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
124 errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
126 case MM_ERROR_POLICY_RESTRICTED:
127 ret = CAMERA_ERROR_SECURITY_RESTRICTED;
128 errorstr = "ERROR_RESTRICTED";
132 ret = CAMERA_ERROR_INVALID_OPERATION;
133 errorstr = "INVALID_OPERATION";
135 LOGE( "[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code);
140 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data){
141 if( user_data == NULL || stream == NULL)
144 camera_s * handle = (camera_s*)user_data;
145 if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] ){
146 camera_preview_data_s frame;
147 frame.format = stream->format;
148 if( frame.format == (camera_pixel_format_e)MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
149 frame.format = MM_PIXEL_FORMAT_UYVY;
150 frame.width = stream->width;
151 frame.height = stream->height;
152 frame.timestamp = stream->timestamp;
153 frame.num_of_planes = stream->num_planes;
154 switch( stream->data_type ){
155 case MM_CAM_STREAM_DATA_YUV420 :
156 frame.data.single_plane.yuv = stream->data.yuv420.yuv;
157 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
159 case MM_CAM_STREAM_DATA_YUV422 :
160 frame.data.single_plane.yuv = stream->data.yuv422.yuv;
161 frame.data.single_plane.size = stream->data.yuv422.length_yuv;
163 case MM_CAM_STREAM_DATA_YUV420SP :
164 frame.data.double_plane.y = stream->data.yuv420sp.y;
165 frame.data.double_plane.uv = stream->data.yuv420sp.uv;
166 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
167 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
169 case MM_CAM_STREAM_DATA_YUV420P :
170 frame.data.triple_plane.y = stream->data.yuv420p.y;
171 frame.data.triple_plane.u = stream->data.yuv420p.u;
172 frame.data.triple_plane.v = stream->data.yuv420p.v;
173 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
174 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
175 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
177 case MM_CAM_STREAM_DATA_YUV422P :
178 frame.data.triple_plane.y = stream->data.yuv422p.y;
179 frame.data.triple_plane.u = stream->data.yuv422p.u;
180 frame.data.triple_plane.v = stream->data.yuv422p.v;
181 frame.data.triple_plane.y_size = stream->data.yuv422p.length_y;
182 frame.data.triple_plane.u_size = stream->data.yuv422p.length_u;
183 frame.data.triple_plane.v_size = stream->data.yuv422p.length_v;
186 ((camera_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW])(&frame, handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW]);
190 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data){
191 if( user_data == NULL || frame == NULL)
194 camera_s * handle = (camera_s*)user_data;
195 handle->current_capture_count++;
196 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] ){
197 MMCamcorderCaptureDataType *scrnl = NULL;
199 camera_image_data_s image = { NULL, 0, 0, 0, 0, NULL, 0 };
200 camera_image_data_s thumb = { NULL, 0, 0, 0, 0, NULL, 0 };
201 camera_image_data_s postview = { NULL, 0, 0, 0, 0, NULL, 0 };
206 image.data = frame->data;
207 image.size = frame->length;
208 image.width = frame->width;
209 image.height = frame->height;
210 image.format = frame->format;
211 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, "captured-exif-raw-data", &exif, &exif_size, NULL);
214 image.exif_size = exif_size;
219 thumb.data = thumbnail->data;
220 thumb.size = thumbnail->length;
221 thumb.width = thumbnail->width;
222 thumb.height = thumbnail->height;
223 thumb.format = thumbnail->format;
225 mm_camcorder_get_attributes( handle->mm_handle, NULL, "captured-screennail", &scrnl, &size,NULL );
227 postview.data = scrnl->data;
228 postview.size = scrnl->length;
229 postview.width = scrnl->width;
230 postview.height = scrnl->height;
231 postview.format = scrnl->format;
234 ((camera_capturing_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE])(&image, scrnl ? &postview : NULL, thumbnail ? &thumb : NULL, handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE]);
236 // update captured state
237 if( handle->capture_count == 1 && handle->hdr_keep_mode ){
238 if( handle->current_capture_count == 2 )
239 handle->is_capture_completed = true;
240 }else if( handle->capture_count == handle->current_capture_count || handle->is_continuous_shot_break)
241 handle->is_capture_completed = true;
245 static camera_state_e __camera_state_convert(MMCamcorderStateType mm_state)
247 camera_state_e state = CAMERA_STATE_NONE;
250 case MM_CAMCORDER_STATE_NONE:
251 state = CAMERA_STATE_NONE;
253 case MM_CAMCORDER_STATE_NULL:
254 state = CAMERA_STATE_CREATED;
256 case MM_CAMCORDER_STATE_READY:
257 state = CAMERA_STATE_CREATED;
259 case MM_CAMCORDER_STATE_PREPARE:
260 state = CAMERA_STATE_PREVIEW;
262 case MM_CAMCORDER_STATE_CAPTURING:
263 state = CAMERA_STATE_CAPTURING;
265 case MM_CAMCORDER_STATE_RECORDING:
266 state = CAMERA_STATE_PREVIEW;
268 case MM_CAMCORDER_STATE_PAUSED:
269 state = CAMERA_STATE_PREVIEW;
272 state = CAMERA_STATE_NONE;
280 static int __mm_camera_message_callback(int message, void *param, void *user_data){
281 if( user_data == NULL || param == NULL )
284 camera_s * handle = (camera_s*)user_data;
286 if( handle->relay_message_callback )
287 handle->relay_message_callback(message, param, handle->relay_user_data);
289 MMMessageParamType *m = (MMMessageParamType*)param;
290 camera_state_e previous_state;
294 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
295 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
296 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
297 if( message == MM_MESSAGE_CAMCORDER_STATE_CHANGED && (m->state.previous < MM_CAMCORDER_STATE_NONE || m->state.previous > MM_CAMCORDER_STATE_PAUSED || m->state.code != 0) ){
298 LOGI( "Invalid state changed message");
302 previous_state = handle->state;
303 handle->state = __camera_state_convert(m->state.current );
304 camera_policy_e policy = CAMERA_POLICY_NONE;
305 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
306 switch (m->state.code) {
307 case ASM_EVENT_SOURCE_CALL_START:
308 policy = CAMERA_POLICY_SOUND_BY_CALL;
309 LOGE("CAMERA_POLICY_SOUND_BY_CALL");
311 case ASM_EVENT_SOURCE_ALARM_START:
312 case ASM_EVENT_SOURCE_ALARM_END:
313 policy = CAMERA_POLICY_SOUND_BY_ALARM;
314 LOGE("CAMERA_POLICY_SOUND_BY_ALARM");
317 policy = CAMERA_POLICY_SOUND;
318 LOGE("CAMERA_POLICY_SOUND");
321 } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
322 policy = CAMERA_POLICY_SECURITY;
323 LOGE("CAMERA_POLICY_SECURITY");
326 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
327 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, policy, handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
330 // should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state
331 if( policy != CAMERA_POLICY_NONE ){
332 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] )
333 ((camera_interrupted_cb)handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED])(policy, previous_state, handle->state, handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED]);
334 if( m->state.previous == MM_CAMCORDER_STATE_PREPARE && m->state.current == MM_CAMCORDER_STATE_READY ){
335 mm_camcorder_unrealize(handle->mm_handle);
340 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED :
341 if( handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] ){
342 ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])( m->code, handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
345 case MM_MESSAGE_CAMCORDER_CAPTURED:
347 handle->current_capture_complete_count = m->code;
348 if( handle->capture_count == 1 || m->code == handle->capture_count ||(handle->is_continuous_shot_break && handle->state == CAMERA_STATE_CAPTURING) ){
349 //pseudo state change
350 previous_state = handle->state ;
351 handle->state = CAMERA_STATE_CAPTURED;
352 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
353 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, 0 , handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
355 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
356 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
361 case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
362 case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
364 MMCamRecordingReport *report = (MMCamRecordingReport *)m ->data;
365 if( report != NULL && report->recording_filename ){
366 free(report->recording_filename );
367 report->recording_filename = NULL;
375 case MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED:
377 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
378 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
382 case MM_MESSAGE_CAMCORDER_ERROR:
384 int errorcode = m->code;
385 int camera_error = 0;
387 case MM_ERROR_CAMCORDER_DEVICE :
388 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT :
389 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE :
390 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG :
391 camera_error = CAMERA_ERROR_DEVICE;
393 case MM_ERROR_CAMCORDER_GST_CORE :
394 case MM_ERROR_CAMCORDER_GST_LIBRARY :
395 case MM_ERROR_CAMCORDER_GST_RESOURCE :
396 case MM_ERROR_CAMCORDER_GST_STREAM :
397 case MM_ERROR_CAMCORDER_GST_NEGOTIATION :
398 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR :
399 case MM_ERROR_CAMCORDER_ENCODER :
400 case MM_ERROR_CAMCORDER_ENCODER_BUFFER :
401 case MM_ERROR_CAMCORDER_ENCODER_WORKING :
402 case MM_ERROR_CAMCORDER_MNOTE_CREATION :
403 case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY :
404 case MM_ERROR_CAMCORDER_INTERNAL :
405 case MM_ERROR_FILE_NOT_FOUND:
406 case MM_ERROR_FILE_READ:
407 camera_error = CAMERA_ERROR_INVALID_OPERATION;
409 case MM_ERROR_CAMCORDER_LOW_MEMORY :
410 case MM_ERROR_CAMCORDER_MNOTE_MALLOC :
411 camera_error = CAMERA_ERROR_OUT_OF_MEMORY;
414 if( camera_error != 0 && handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] )
415 ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(camera_error, handle->state , handle->user_data[_CAMERA_EVENT_TYPE_ERROR]);
419 case MM_MESSAGE_CAMCORDER_HDR_PROGRESS:
421 int percent = m->code;
422 if( handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] )
423 ((camera_attr_hdr_progress_cb)handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS])(percent, handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
426 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
428 MMCamFaceDetectInfo *cam_fd_info = (MMCamFaceDetectInfo *)(m->data);
430 camera_detected_face_s faces[cam_fd_info->num_of_faces];
431 handle->num_of_faces = cam_fd_info->num_of_faces > MAX_DETECTED_FACE ? MAX_DETECTED_FACE : cam_fd_info->num_of_faces;
433 for(i=0; i < handle->num_of_faces ; i++){
434 faces[i].id = cam_fd_info->face_info[i].id;
435 faces[i].score = cam_fd_info->face_info[i].score;
436 faces[i].x = cam_fd_info->face_info[i].rect.x;
437 faces[i].y = cam_fd_info->face_info[i].rect.y;
438 faces[i].width = cam_fd_info->face_info[i].rect.width;
439 faces[i].height = cam_fd_info->face_info[i].rect.height;
440 handle->faceinfo[i] = faces[i]; //cache face coordinate
442 if( handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] )
443 ((camera_face_detected_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces, handle->num_of_faces, handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION]);
445 handle->num_of_faces = 0;
454 static int __capture_completed_event_cb(void *data){
455 camera_s *handle = (camera_s*)data;
456 if( handle->current_capture_count > 0 && handle->current_capture_count == handle->current_capture_complete_count && handle->state == CAMERA_STATE_CAPTURING ){
457 //pseudo state change
458 camera_state_e previous_state = handle->state;
459 handle->state = CAMERA_STATE_CAPTURED;
460 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
461 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, 0 , handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
463 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
464 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
470 int camera_create( camera_device_e device, camera_h* camera){
473 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
474 return CAMERA_ERROR_INVALID_PARAMETER;
482 if( device == CAMERA_DEVICE_CAMERA1 )
483 info.videodev_type= MM_VIDEO_DEVICE_CAMERA1;
485 info.videodev_type= MM_VIDEO_DEVICE_CAMERA0;
487 camera_s* handle = (camera_s*)malloc( sizeof(camera_s) );
489 LOGE("[%s] malloc fail",__func__);
490 return CAMERA_ERROR_OUT_OF_MEMORY;
492 memset(handle, 0 , sizeof(camera_s));
494 ret = mm_camcorder_create(&handle->mm_handle, &info);
495 if( ret != MM_ERROR_NONE){
497 return __convert_camera_error_code(__func__,ret);
500 preview_format = MM_PIXEL_FORMAT_YUYV;
501 rotation = MM_DISPLAY_ROTATION_NONE;
502 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
503 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
504 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
505 MMCAM_CAPTURE_WIDTH, &handle->capture_width,
506 MMCAM_CAPTURE_HEIGHT, &handle->capture_height,
510 ret = mm_camcorder_set_attributes(handle->mm_handle, &error,
511 MMCAM_MODE , MM_CAMCORDER_MODE_VIDEO_CAPTURE,
512 MMCAM_CAMERA_FORMAT, preview_format,
513 MMCAM_IMAGE_ENCODER , MM_IMAGE_CODEC_JPEG,
514 MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
515 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL,
516 MMCAM_DISPLAY_ROTATION, rotation,
517 MMCAM_CAPTURE_COUNT, 1,
520 handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
522 if( ret != MM_ERROR_NONE){
523 LOGE("[%s] mm_camcorder_set_attributes fail(%x, %s)",__func__, ret, error);
524 mm_camcorder_destroy(handle->mm_handle);
527 return __convert_camera_error_code(__func__, ret);
530 handle->state = CAMERA_STATE_CREATED;
531 handle->relay_message_callback = NULL;
532 handle->relay_user_data = NULL;
533 handle->capture_resolution_modified = false;
534 handle->hdr_keep_mode = false;
535 handle->focus_area_valid = false;
536 handle->is_used_in_recorder = false;
537 handle->on_continuous_focusing = false;
538 handle->cached_focus_mode = -1;
539 mm_camcorder_set_message_callback(handle->mm_handle, __mm_camera_message_callback, (void*)handle);
541 *camera = (camera_h)handle;
542 return __convert_camera_error_code(__func__, ret);
545 int camera_destroy(camera_h camera){
547 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
548 return CAMERA_ERROR_INVALID_PARAMETER;
552 camera_s *handle = (camera_s*)camera;
553 if( handle->is_used_in_recorder ){
554 LOGE("[%s] camera is using in another recorder.", __func__);
555 return CAMERA_ERROR_INVALID_OPERATION;
558 ret = mm_camcorder_destroy(handle->mm_handle);
560 if( ret == MM_ERROR_NONE)
563 return __convert_camera_error_code(__func__, ret);
567 int camera_start_preview(camera_h camera){
568 LOGE("%s - start", __func__);
570 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
571 return CAMERA_ERROR_INVALID_PARAMETER;
576 camera_s *handle = (camera_s*)camera;
577 camera_state_e capi_state;
578 camera_get_state(camera, &capi_state);
580 if( capi_state == CAMERA_STATE_CAPTURED )
582 ret = mm_camcorder_capture_stop(handle->mm_handle);
583 return __convert_camera_error_code(__func__, ret);
588 //for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback
589 mm_camcorder_set_video_capture_callback( handle->mm_handle, (mm_camcorder_video_capture_callback)__mm_capture_callback, (void*)handle);
591 MMCamcorderStateType state ;
592 mm_camcorder_get_state(handle->mm_handle, &state);
593 if( state != MM_CAMCORDER_STATE_READY){
594 ret = mm_camcorder_realize(handle->mm_handle);
595 if( ret != MM_ERROR_NONE )
596 return __convert_camera_error_code(__func__, ret);
599 ret = mm_camcorder_start(handle->mm_handle);
602 if( ret != MM_ERROR_NONE && state != MM_CAMCORDER_STATE_READY){
603 mm_camcorder_unrealize(handle->mm_handle);
606 return __convert_camera_error_code(__func__, ret);
609 int camera_stop_preview(camera_h camera){
611 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
612 return CAMERA_ERROR_INVALID_PARAMETER;
617 camera_s *handle = (camera_s*)camera;
618 MMCamcorderStateType state ;
619 mm_camcorder_get_state(handle->mm_handle, &state);
621 if( state == MM_CAMCORDER_STATE_PREPARE ){
622 ret = mm_camcorder_stop(handle->mm_handle);
623 if( ret != MM_ERROR_NONE)
624 return __convert_camera_error_code(__func__, ret);
626 camera_stop_face_detection(camera);
627 ret = mm_camcorder_unrealize(handle->mm_handle);
628 return __convert_camera_error_code(__func__, ret);
631 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb , camera_capture_completed_cb completed_cb , void *user_data){
633 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
634 return CAMERA_ERROR_INVALID_PARAMETER;
637 camera_s * handle = (camera_s*)camera;
639 MMCamcorderStateType state;
640 mm_camcorder_get_state(handle->mm_handle, &state);
641 if( state != MM_CAMCORDER_STATE_PREPARE && state != MM_CAMCORDER_STATE_RECORDING && state != MM_CAMCORDER_STATE_PAUSED){
642 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
643 return CAMERA_ERROR_INVALID_STATE;
646 if( handle->capture_resolution_modified ){
647 mm_camcorder_set_attributes(handle->mm_handle, NULL,
648 MMCAM_CAPTURE_WIDTH, handle->capture_width,
649 MMCAM_CAPTURE_HEIGHT, handle->capture_height,
651 handle->capture_resolution_modified = false;
653 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAPTURE_COUNT , 1,NULL);
655 handle->capture_count = 1;
656 handle->is_continuous_shot_break = false;
657 handle->current_capture_count = 0;
658 handle->current_capture_complete_count = 0;
659 handle->is_capture_completed = false;
661 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
662 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
663 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
664 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
665 ret = mm_camcorder_capture_start(handle->mm_handle);
667 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
668 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
669 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
670 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
673 return __convert_camera_error_code(__func__, ret);
676 int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb , void *user_data){
678 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
679 return CAMERA_ERROR_INVALID_PARAMETER;
682 if( count < 2 || interval < 0 ){
683 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
684 return CAMERA_ERROR_INVALID_PARAMETER;
687 camera_s * handle = (camera_s*)camera;
689 MMCamcorderStateType state;
690 mm_camcorder_get_state(handle->mm_handle, &state);
691 if( state != MM_CAMCORDER_STATE_PREPARE ){
692 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
693 return CAMERA_ERROR_INVALID_STATE;
700 int current_preview_format;
701 bool supported_ZSL = false;
703 int ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
704 MMCAM_CAPTURE_COUNT , count,
705 MMCAM_CAPTURE_INTERVAL, interval,
708 LOGE("[%s] (%x) error set continuous shot attribute", ret);
709 return __convert_camera_error_code(__func__, ret);
711 handle->capture_count = count;
712 handle->is_continuous_shot_break = false;
713 handle->current_capture_count = 0;
714 handle->current_capture_complete_count = 0;
715 handle->is_capture_completed = false;
717 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FORMAT, ¤t_preview_format,NULL);
718 if( current_preview_format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
719 supported_ZSL = true;
722 LOGE("[%s] (%x) error get continuous shot attribute", ret);
725 if( !supported_ZSL ){
726 mm_camcorder_get_attributes(handle->mm_handle, NULL,
727 MMCAM_CAMERA_WIDTH, &preview_width,
728 MMCAM_CAMERA_HEIGHT, &preview_height,
729 MMCAM_CAPTURE_WIDTH, &capture_width,
730 MMCAM_CAPTURE_HEIGHT, &capture_height,
732 if( preview_width != capture_width || preview_height != capture_height ){
733 mm_camcorder_set_attributes(handle->mm_handle, NULL,
734 MMCAM_CAPTURE_WIDTH, preview_width,
735 MMCAM_CAPTURE_HEIGHT, preview_height,
737 handle->capture_resolution_modified = true;
741 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
742 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
743 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
744 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
746 ret = mm_camcorder_capture_start(handle->mm_handle);
748 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
749 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
750 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
751 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
754 return __convert_camera_error_code(__func__,ret);
758 int camera_stop_continuous_capture(camera_h camera){
760 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
761 return CAMERA_ERROR_INVALID_PARAMETER;
763 camera_s *handle = (camera_s*)camera;
765 camera_state_e state;
766 camera_get_state(camera, &state);
767 if( state != CAMERA_STATE_CAPTURING && handle->capture_count > 1 ){
768 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
769 return CAMERA_ERROR_INVALID_STATE;
772 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, "capture-break-cont-shot", 1, NULL);
774 handle->is_continuous_shot_break = true;
775 if( handle->current_capture_count > 0 )
776 handle->is_capture_completed = true;
777 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
780 return __convert_camera_error_code(__func__,ret);
783 bool camera_is_supported_face_detection(camera_h camera){
785 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
789 camera_s * handle = (camera_s*)camera;
791 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
793 if( info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY){
794 for( i =0; i < info.int_array.count ; i++){
795 if( info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON )
802 bool camera_is_supported_zero_shutter_lag(camera_h camera){
804 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
808 camera_s * handle = (camera_s*)camera;
810 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &info);
812 if( info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY){
813 for( i =0; i < info.int_array.count ; i++){
814 if( info.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
821 int camera_get_device_count(camera_h camera, int *device_count) {
822 int ret = MM_ERROR_NONE;
823 camera_s *handle = (camera_s *)camera;
825 if (camera == NULL || device_count == NULL) {
826 LOGE("[%s] INVALID_PARAMETER(0x%08x)", __func__, CAMERA_ERROR_INVALID_PARAMETER);
827 return CAMERA_ERROR_INVALID_PARAMETER;
830 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
831 MMCAM_CAMERA_DEVICE_COUNT, device_count,
834 return __convert_camera_error_code(__func__, ret);
837 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void * user_data){
839 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
840 return CAMERA_ERROR_INVALID_PARAMETER;
842 camera_s * handle = (camera_s*)camera;
843 camera_state_e state = CAMERA_STATE_NONE;
845 camera_get_state(camera, &state);
846 if( state != CAMERA_STATE_PREVIEW ){
847 LOGE( "[%s] INVALID_STATE(0x%08x)",__func__,CAMERA_ERROR_INVALID_STATE);
848 return CAMERA_ERROR_INVALID_STATE;
850 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON, NULL);
852 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)callback;
853 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)user_data;
854 handle->num_of_faces = 0;
856 return __convert_camera_error_code(__func__,ret);
859 int camera_stop_face_detection(camera_h camera){
861 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
862 return CAMERA_ERROR_INVALID_PARAMETER;
864 camera_s * handle = (camera_s*)camera;
866 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF, NULL);
867 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
868 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
869 handle->num_of_faces = 0;
870 return __convert_camera_error_code(__func__,ret);
873 int camera_face_zoom(camera_h camera, int face_id){
875 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
876 return CAMERA_ERROR_INVALID_PARAMETER;
878 camera_s * handle = (camera_s*)camera;
884 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FACE_ZOOM_MODE , ¤t_mode, NULL);
886 if( current_mode == MM_CAMCORDER_FACE_ZOOM_MODE_ON )
887 return CAMERA_ERROR_INVALID_STATE;
889 for( i = 0 ; i < handle->num_of_faces ; i++){
890 if( handle->faceinfo[i].id == face_id ){
896 return CAMERA_ERROR_INVALID_PARAMETER;
897 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FACE_ZOOM_MODE, MM_CAMCORDER_FACE_ZOOM_MODE_ON,
898 MMCAM_CAMERA_FACE_ZOOM_X, handle->faceinfo[find].x+(handle->faceinfo[find].width>>1),
899 MMCAM_CAMERA_FACE_ZOOM_Y, handle->faceinfo[find].y+(handle->faceinfo[find].height>>1),
902 return __convert_camera_error_code(__func__,ret);
905 int camera_cancel_face_zoom(camera_h camera){
907 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
908 return CAMERA_ERROR_INVALID_PARAMETER;
910 camera_s * handle = (camera_s*)camera;
912 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FACE_ZOOM_MODE, MM_CAMCORDER_FACE_ZOOM_MODE_OFF, NULL);
913 return __convert_camera_error_code(__func__,ret);
917 int camera_get_state(camera_h camera, camera_state_e * state){
918 if( camera == NULL || state == NULL){
919 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
920 return CAMERA_ERROR_INVALID_PARAMETER;
923 camera_s *handle = (camera_s*)camera;
924 camera_state_e capi_state;
925 MMCamcorderStateType mmstate ;
926 mm_camcorder_get_state(handle->mm_handle, &mmstate);
928 capi_state = __camera_state_convert(mmstate);
930 if( ( handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed ) && mmstate == MM_CAMCORDER_STATE_CAPTURING )
931 capi_state = CAMERA_STATE_CAPTURED;
934 return CAMERA_ERROR_NONE;
937 int camera_start_focusing( camera_h camera, bool continuous ){
939 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
940 return CAMERA_ERROR_INVALID_PARAMETER;
942 camera_s *handle = (camera_s*)camera;
944 if( handle->cached_focus_mode != -1){
945 LOGD("[%s] apply cached focus mode %d", __func__, handle->cached_focus_mode);
946 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , handle->cached_focus_mode, NULL);
947 handle->cached_focus_mode = -1;
951 return __camera_start_continuous_focusing(camera);
953 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, handle->focus_area_valid ? MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO : MM_CAMCORDER_FOCUS_MODE_AUTO, NULL);
954 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s*)camera)->mm_handle));
958 int __camera_start_continuous_focusing(camera_h camera){
959 if( camera == NULL ){
960 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
961 return CAMERA_ERROR_INVALID_PARAMETER;
963 camera_s *handle = (camera_s*)camera;
966 handle->on_continuous_focusing = true;
967 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , &mode, NULL);
968 if( mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS )
969 ret = mm_camcorder_start_focusing(handle->mm_handle);
971 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS, NULL);
972 return __convert_camera_error_code(__func__, ret);
975 int camera_cancel_focusing( camera_h camera ){
977 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
978 return CAMERA_ERROR_INVALID_PARAMETER;
980 camera_s *handle = (camera_s*)camera;
981 handle->on_continuous_focusing = false;
982 return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
984 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display){
986 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
987 return CAMERA_ERROR_INVALID_PARAMETER;
990 camera_s * handle = (camera_s*)camera;
991 handle->display_handle = display;
992 handle->display_type = type;
993 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL,
994 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
995 MMCAM_DISPLAY_SURFACE ,type, NULL );
996 if( ret == 0 && type != CAMERA_DISPLAY_TYPE_NONE)
997 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL,
998 MMCAM_DISPLAY_HANDLE , type == CAMERA_DISPLAY_TYPE_X11 ? &handle->display_handle : display , sizeof(display) ,
1000 return __convert_camera_error_code(__func__, ret);
1003 int camera_set_preview_resolution(camera_h camera, int width, int height){
1004 if( camera == NULL){
1005 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1006 return CAMERA_ERROR_INVALID_PARAMETER;
1009 camera_s * handle = (camera_s*)camera;
1010 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width ,MMCAM_CAMERA_HEIGHT ,height, NULL);
1011 return __convert_camera_error_code(__func__, ret);
1013 int camera_set_x11_display_rotation(camera_h camera, camera_rotation_e rotation){
1014 if( camera == NULL){
1015 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1016 return CAMERA_ERROR_INVALID_PARAMETER;
1019 if( rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270 )
1020 return CAMERA_ERROR_INVALID_PARAMETER;
1023 camera_s * handle = (camera_s*)camera;
1025 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL);
1026 return __convert_camera_error_code(__func__, ret);
1029 int camera_set_x11_display_flip(camera_h camera, camera_flip_e flip){
1030 if( camera == NULL){
1031 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1032 return CAMERA_ERROR_INVALID_PARAMETER;
1035 if( flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH )
1036 return CAMERA_ERROR_INVALID_PARAMETER;
1039 camera_s * handle = (camera_s*)camera;
1040 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_FLIP , flip, NULL);
1041 return __convert_camera_error_code(__func__, ret);
1044 int camera_get_x11_display_flip(camera_h camera, camera_flip_e *flip){
1045 if( camera == NULL || flip == NULL ){
1046 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1047 return CAMERA_ERROR_INVALID_PARAMETER;
1051 camera_s * handle = (camera_s*)camera;
1053 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_FLIP , flip, NULL);
1054 return __convert_camera_error_code(__func__, ret);
1057 int camera_set_capture_resolution(camera_h camera, int width, int height){
1058 if( camera == NULL){
1059 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1060 return CAMERA_ERROR_INVALID_PARAMETER;
1063 camera_s * handle = (camera_s*)camera;
1064 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_WIDTH, width ,MMCAM_CAPTURE_HEIGHT , height, NULL);
1066 handle->capture_width = width;
1067 handle->capture_height = height;
1069 return __convert_camera_error_code(__func__, ret);
1072 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format){
1073 if( camera == NULL){
1074 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1075 return CAMERA_ERROR_INVALID_PARAMETER;
1078 camera_s * handle = (camera_s*)camera;
1079 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL);
1080 return __convert_camera_error_code(__func__, ret);
1083 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format){
1084 if( camera == NULL){
1085 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1086 return CAMERA_ERROR_INVALID_PARAMETER;
1089 camera_s * handle = (camera_s*)camera;
1091 if( format == CAMERA_PIXEL_FORMAT_UYVY ){
1092 bool supported_ITLV_UYVY = false;
1093 MMCamAttrsInfo supported_format;
1094 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1096 for( i=0 ; i < supported_format.int_array.count ; i++){
1097 if( supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1098 supported_ITLV_UYVY = true;
1100 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ? MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY , NULL);
1102 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL);
1104 return __convert_camera_error_code(__func__, ret);
1107 int camera_get_preview_resolution(camera_h camera, int *width, int *height){
1108 if( camera == NULL || width == NULL || height == NULL){
1109 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1110 return CAMERA_ERROR_INVALID_PARAMETER;
1114 camera_s * handle = (camera_s*)camera;
1115 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width,MMCAM_CAMERA_HEIGHT, height, NULL);
1116 return __convert_camera_error_code(__func__, ret);
1120 int camera_get_x11_display_rotation( camera_h camera, camera_rotation_e *rotation){
1121 if( camera == NULL || rotation == NULL ){
1122 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1123 return CAMERA_ERROR_INVALID_PARAMETER;
1127 camera_s * handle = (camera_s*)camera;
1129 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL);
1130 return __convert_camera_error_code(__func__, ret);
1133 int camera_set_x11_display_visible(camera_h camera, bool visible){
1134 if( camera == NULL){
1135 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1136 return CAMERA_ERROR_INVALID_PARAMETER;
1139 camera_s * handle = (camera_s*)camera;
1141 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_VISIBLE , visible, NULL);
1142 return __convert_camera_error_code(__func__, ret);
1145 int camera_is_x11_display_visible(camera_h camera, bool* visible){
1146 if( camera == NULL || visible == NULL){
1147 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1148 return CAMERA_ERROR_INVALID_PARAMETER;
1153 camera_s * handle = (camera_s*)camera;
1155 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_VISIBLE , &result, NULL);
1158 return __convert_camera_error_code(__func__, ret);
1161 int camera_set_x11_display_mode( camera_h camera , camera_display_mode_e ratio){
1162 if( camera == NULL){
1163 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1164 return CAMERA_ERROR_INVALID_PARAMETER;
1167 if( ratio < CAMERA_DISPLAY_MODE_LETTER_BOX || ratio > CAMERA_DISPLAY_MODE_CROPPED_FULL )
1168 return CAMERA_ERROR_INVALID_PARAMETER;
1171 camera_s * handle = (camera_s*)camera;
1173 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_GEOMETRY_METHOD , ratio, NULL);
1174 return __convert_camera_error_code(__func__, ret);
1177 int camera_get_x11_display_mode( camera_h camera , camera_display_mode_e* ratio){
1178 if( camera == NULL || ratio == NULL){
1179 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1180 return CAMERA_ERROR_INVALID_PARAMETER;
1184 camera_s * handle = (camera_s*)camera;
1186 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_GEOMETRY_METHOD , ratio, NULL);
1187 return __convert_camera_error_code(__func__, ret);
1191 int camera_get_capture_resolution(camera_h camera, int *width, int *height){
1192 if( camera == NULL || width== NULL || height == NULL){
1193 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1194 return CAMERA_ERROR_INVALID_PARAMETER;
1196 camera_s * handle = (camera_s*)camera;
1197 *width = handle->capture_width;
1198 *height = handle->capture_height;
1199 return CAMERA_ERROR_NONE;
1202 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format){
1203 if( camera == NULL || format == NULL){
1204 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1205 return CAMERA_ERROR_INVALID_PARAMETER;
1209 camera_s * handle = (camera_s*)camera;
1210 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL);
1211 return __convert_camera_error_code(__func__, ret);
1214 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format){
1215 if( camera == NULL || format == NULL){
1216 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1217 return CAMERA_ERROR_INVALID_PARAMETER;
1221 camera_s * handle = (camera_s*)camera;
1222 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL);
1223 if( (MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1224 *format = CAMERA_PIXEL_FORMAT_UYVY;
1225 return __convert_camera_error_code(__func__, ret);
1228 int camera_set_preview_cb( camera_h camera, camera_preview_cb callback, void* user_data ){
1229 if( camera == NULL || callback == NULL){
1230 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1231 return CAMERA_ERROR_INVALID_PARAMETER;
1234 camera_s * handle = (camera_s*)camera;
1235 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)callback;
1236 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)user_data;
1237 mm_camcorder_set_video_stream_callback( handle->mm_handle, (mm_camcorder_video_stream_callback)__mm_videostream_callback, (void*)handle);
1238 return CAMERA_ERROR_NONE;
1240 int camera_unset_preview_cb( camera_h camera){
1241 if( camera == NULL){
1242 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1243 return CAMERA_ERROR_INVALID_PARAMETER;
1245 camera_s * handle = (camera_s*)camera;
1246 mm_camcorder_set_video_stream_callback( handle->mm_handle, (mm_camcorder_video_stream_callback)NULL, (void*)NULL);
1247 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)NULL;
1248 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)NULL;
1249 return CAMERA_ERROR_NONE;
1252 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data){
1253 if( camera == NULL || callback == NULL){
1254 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1255 return CAMERA_ERROR_INVALID_PARAMETER;
1258 camera_s * handle = (camera_s*)camera;
1259 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)callback;
1260 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)user_data;
1261 return CAMERA_ERROR_NONE;
1263 int camera_unset_state_changed_cb(camera_h camera){
1264 if( camera == NULL){
1265 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1266 return CAMERA_ERROR_INVALID_PARAMETER;
1268 camera_s * handle = (camera_s*)camera;
1269 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1270 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1271 return CAMERA_ERROR_NONE;
1274 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data){
1275 if( camera == NULL || callback == NULL){
1276 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1277 return CAMERA_ERROR_INVALID_PARAMETER;
1280 camera_s * handle = (camera_s*)camera;
1281 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)callback;
1282 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)user_data;
1283 return CAMERA_ERROR_NONE;
1286 int camera_unset_interrupted_cb(camera_h camera){
1287 if( camera == NULL){
1288 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1289 return CAMERA_ERROR_INVALID_PARAMETER;
1291 camera_s * handle = (camera_s*)camera;
1292 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1293 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1294 return CAMERA_ERROR_NONE;
1297 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data){
1298 if( camera == NULL || callback == NULL){
1299 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1300 return CAMERA_ERROR_INVALID_PARAMETER;
1302 camera_s * handle = (camera_s*)camera;
1303 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)callback;
1304 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)user_data;
1305 return CAMERA_ERROR_NONE;
1307 int camera_unset_focus_changed_cb(camera_h camera){
1308 if( camera == NULL){
1309 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1310 return CAMERA_ERROR_INVALID_PARAMETER;
1312 camera_s * handle = (camera_s*)camera;
1313 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1314 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1315 return CAMERA_ERROR_NONE;
1318 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data){
1319 if( camera == NULL || callback == NULL){
1320 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1321 return CAMERA_ERROR_INVALID_PARAMETER;
1324 camera_s * handle = (camera_s*)camera;
1325 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)callback;
1326 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)user_data;
1327 return CAMERA_ERROR_NONE;
1330 int camera_unset_error_cb(camera_h camera){
1331 if( camera == NULL){
1332 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1333 return CAMERA_ERROR_INVALID_PARAMETER;
1336 camera_s * handle = (camera_s*)camera;
1337 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1338 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1339 return CAMERA_ERROR_NONE;
1342 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data){
1343 if( camera == NULL || foreach_cb == NULL){
1344 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1345 return CAMERA_ERROR_INVALID_PARAMETER;
1349 camera_s * handle = (camera_s*)camera;
1350 MMCamAttrsInfo preview_width;
1351 MMCamAttrsInfo preview_height;
1352 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH , &preview_width);
1353 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT , &preview_height);
1355 if( ret != CAMERA_ERROR_NONE )
1356 return __convert_camera_error_code(__func__, ret);
1359 for( i=0 ; i < preview_width.int_array.count ; i++)
1361 if ( !foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i],user_data) )
1364 return CAMERA_ERROR_NONE;
1367 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data){
1368 if( camera == NULL || foreach_cb == NULL){
1369 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1370 return CAMERA_ERROR_INVALID_PARAMETER;
1373 camera_s * handle = (camera_s*)camera;
1374 MMCamAttrsInfo capture_width;
1375 MMCamAttrsInfo capture_height;
1376 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH , &capture_width);
1377 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT , &capture_height);
1379 if( ret != CAMERA_ERROR_NONE )
1380 return __convert_camera_error_code(__func__, ret);
1383 for( i=0 ; i < capture_width.int_array.count ; i++)
1385 if ( !foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i],user_data) )
1388 return CAMERA_ERROR_NONE;
1391 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data){
1392 if( camera == NULL || foreach_cb == NULL){
1393 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1394 return CAMERA_ERROR_INVALID_PARAMETER;
1398 camera_s * handle = (camera_s*)camera;
1399 MMCamAttrsInfo format;
1400 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_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 )
1409 if ( !foreach_cb(format.int_array.array[i], user_data) )
1412 return CAMERA_ERROR_NONE;
1417 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data){
1418 if( camera == NULL || foreach_cb == NULL){
1419 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1420 return CAMERA_ERROR_INVALID_PARAMETER;
1423 camera_s * handle = (camera_s*)camera;
1424 MMCamAttrsInfo format;
1425 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &format);
1427 if( ret != CAMERA_ERROR_NONE )
1428 return __convert_camera_error_code(__func__, ret);
1431 for( i=0 ; i < format.int_array.count ; i++)
1433 if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY /* || format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_NV12 */)
1434 if ( !foreach_cb(format.int_array.array[i], user_data) )
1437 return CAMERA_ERROR_NONE;
1442 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height){
1443 if( camera == NULL ){
1444 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1445 return CAMERA_ERROR_INVALID_PARAMETER;
1448 enum MMCamcorderPreviewType wide;
1449 int capture_w, capture_h;
1452 camera_s * handle = (camera_s*)camera;
1454 camera_get_capture_resolution(camera, &capture_w, &capture_h);
1455 ratio = (double)capture_w/(double)capture_h;
1457 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
1459 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
1461 MMCamAttrsInfo width_info, height_info;
1462 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH , &width_info);
1463 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
1465 return __convert_camera_error_code(__func__, ret);
1468 *width = width_info.int_array.array[wide];
1471 *height = height_info.int_array.array[wide];
1473 return CAMERA_ERROR_NONE;
1478 int camera_attr_get_lens_orientation(camera_h camera, int *angle) {
1479 if( camera == NULL || angle == NULL){
1480 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1481 return CAMERA_ERROR_INVALID_PARAMETER;
1485 camera_s * handle = (camera_s*)camera;
1487 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation , NULL);
1489 switch( rotation ) {
1490 case MM_DISPLAY_ROTATION_NONE:
1493 case MM_DISPLAY_ROTATION_90:
1496 case MM_DISPLAY_ROTATION_180:
1499 case MM_DISPLAY_ROTATION_270:
1504 return __convert_camera_error_code(__func__, ret);
1507 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode){
1508 if( camera == NULL){
1509 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1510 return CAMERA_ERROR_INVALID_PARAMETER;
1513 camera_s * handle = (camera_s*)camera;
1514 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE, mode, NULL);
1515 return __convert_camera_error_code(__func__, ret);
1518 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode){
1519 if( camera == NULL || mode == NULL){
1520 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1521 return CAMERA_ERROR_INVALID_PARAMETER;
1524 camera_s * handle = (camera_s*)camera;
1525 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE , mode, NULL);
1526 return __convert_camera_error_code(__func__, ret);
1529 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps){
1530 if( camera == NULL){
1531 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1532 return CAMERA_ERROR_INVALID_PARAMETER;
1535 camera_s * handle = (camera_s*)camera;
1537 if( fps == CAMERA_ATTR_FPS_AUTO ){
1538 MMCamAttrsInfo info;
1539 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info);
1542 for( i=0 ; i < info.int_array.count ; i++)
1544 if ( info.int_array.array[i] > maxfps && info.int_array.array[i] <= 60 )
1545 maxfps = info.int_array.array[i];
1547 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS_AUTO , 1, MMCAM_CAMERA_FPS, maxfps , NULL);
1550 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS_AUTO , 0, MMCAM_CAMERA_FPS , fps, NULL);
1552 return __convert_camera_error_code(__func__, ret);
1557 int camera_attr_set_image_quality(camera_h camera, int quality){
1559 if( camera == NULL){
1560 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1561 return CAMERA_ERROR_INVALID_PARAMETER;
1565 camera_s * handle = (camera_s*)camera;
1566 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
1567 return __convert_camera_error_code(__func__, ret);
1570 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps){
1571 if( camera == NULL || fps == NULL){
1572 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1573 return CAMERA_ERROR_INVALID_PARAMETER;
1578 camera_s * handle = (camera_s*)camera;
1580 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS , &mm_fps, MMCAM_CAMERA_FPS_AUTO , &is_auto, NULL);
1582 *fps = CAMERA_ATTR_FPS_AUTO;
1586 return __convert_camera_error_code(__func__, ret);
1589 int camera_attr_get_image_quality(camera_h camera, int *quality){
1590 if( camera == NULL || quality == NULL){
1591 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1592 return CAMERA_ERROR_INVALID_PARAMETER;
1596 camera_s * handle = (camera_s*)camera;
1597 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
1598 return __convert_camera_error_code(__func__, ret);
1603 int camera_attr_set_zoom(camera_h camera, int zoom){
1604 if( camera == NULL){
1605 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1606 return CAMERA_ERROR_INVALID_PARAMETER;
1609 camera_s * handle = (camera_s*)camera;
1610 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL);
1611 return __convert_camera_error_code(__func__, ret);
1615 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode){
1616 if( camera == NULL){
1617 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1618 return CAMERA_ERROR_INVALID_PARAMETER;
1620 int ret = CAMERA_ERROR_INVALID_PARAMETER;
1621 camera_s * handle = (camera_s*)camera;
1623 bool should_change_focus_mode = false;
1624 mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE, &focus_mode, NULL);
1625 if( focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO && focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO )
1626 should_change_focus_mode = true;
1628 if( mode != CAMERA_ATTR_AF_NONE && focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && !handle->on_continuous_focusing){
1629 handle->cached_focus_mode = mode;
1630 LOGD("[%s] af mode will be set actually start focusing",__func__);
1631 return __convert_camera_error_code(__func__, 0);
1633 handle->cached_focus_mode = -1;
1635 if( mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode ){
1636 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO, NULL);
1640 case CAMERA_ATTR_AF_NONE:
1641 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
1642 MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_NORMAL, NULL);
1644 case CAMERA_ATTR_AF_NORMAL:
1645 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_NORMAL, NULL);
1647 case CAMERA_ATTR_AF_MACRO:
1648 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_MACRO, NULL);
1650 case CAMERA_ATTR_AF_FULL:
1651 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_FULL, NULL);
1657 return __convert_camera_error_code(__func__, ret);
1660 int camera_attr_set_af_area(camera_h camera, int x, int y){
1661 if( camera == NULL){
1662 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1663 return CAMERA_ERROR_INVALID_PARAMETER;
1665 int ret = CAMERA_ERROR_INVALID_PARAMETER;
1666 camera_s * handle = (camera_s*)camera;
1667 camera_attr_af_mode_e mode;
1668 camera_attr_get_af_mode(camera, &mode);
1669 if( mode == CAMERA_ATTR_AF_NONE ){
1670 LOGE( "[%s] INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE",__func__,CAMERA_ERROR_INVALID_OPERATION);
1671 return CAMERA_ERROR_INVALID_OPERATION;
1673 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1674 MMCAM_CAMERA_AF_TOUCH_X, x,
1675 MMCAM_CAMERA_AF_TOUCH_Y, y,
1678 handle->focus_area_valid = true;
1679 return __convert_camera_error_code(__func__, ret);
1682 int camera_attr_clear_af_area(camera_h camera){
1683 if( camera == NULL){
1684 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__, CAMERA_ERROR_INVALID_PARAMETER);
1685 return CAMERA_ERROR_INVALID_PARAMETER;
1687 camera_s * handle = (camera_s*)camera;
1688 if( !handle->focus_area_valid ){
1689 LOGE( "[%s] INVALID_OPERATION(0x%08x) AF area was not set",__func__,CAMERA_ERROR_INVALID_OPERATION);
1690 return CAMERA_ERROR_INVALID_OPERATION;
1692 handle->focus_area_valid = false;
1696 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode){
1697 if( camera == NULL){
1698 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1699 return CAMERA_ERROR_INVALID_PARAMETER;
1701 int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, //CAMCORDER_EXPOSURE_MODE_OFF
1702 MM_CAMCORDER_AUTO_EXPOSURE_ALL, //CAMCORDER_EXPOSURE_MODE_ALL
1703 MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, //CAMCORDER_EXPOSURE_MODE_CENTER
1704 MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, //CAMCORDER_EXPOSURE_MODE_SPOT
1705 MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1,//CAMCORDER_EXPOSURE_MODE_CUSTOM
1709 camera_s * handle = (camera_s*)camera;
1710 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_MODE , maptable[abs(mode%5)], NULL);
1711 return __convert_camera_error_code(__func__, ret);
1715 int camera_attr_set_exposure(camera_h camera, int value){
1716 if( camera == NULL){
1717 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1718 return CAMERA_ERROR_INVALID_PARAMETER;
1722 camera_s * handle = (camera_s*)camera;
1723 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_VALUE , value, NULL);
1724 return __convert_camera_error_code(__func__, ret);
1728 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso){
1729 if( camera == NULL){
1730 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1731 return CAMERA_ERROR_INVALID_PARAMETER;
1734 camera_s * handle = (camera_s*)camera;
1735 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ISO , iso, NULL);
1736 return __convert_camera_error_code(__func__, ret);
1738 int camera_attr_set_brightness(camera_h camera, int level){
1739 if( camera == NULL){
1740 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1741 return CAMERA_ERROR_INVALID_PARAMETER;
1745 camera_s * handle = (camera_s*)camera;
1746 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_BRIGHTNESS , level, NULL);
1747 return __convert_camera_error_code(__func__, ret);
1751 int camera_attr_set_contrast(camera_h camera, int level){
1752 if( camera == NULL){
1753 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1754 return CAMERA_ERROR_INVALID_PARAMETER;
1758 camera_s * handle = (camera_s*)camera;
1759 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_CONTRAST , level, NULL);
1761 return __convert_camera_error_code(__func__, ret);
1764 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb){
1765 if( camera == NULL){
1766 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1767 return CAMERA_ERROR_INVALID_PARAMETER;
1770 camera_s * handle = (camera_s*)camera;
1771 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_WB , wb, NULL);
1772 return __convert_camera_error_code(__func__, ret);
1776 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect){
1777 if( camera == NULL){
1778 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1779 return CAMERA_ERROR_INVALID_PARAMETER;
1782 camera_s * handle = (camera_s*)camera;
1783 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_COLOR_TONE , effect, NULL);
1784 return __convert_camera_error_code(__func__, ret);
1786 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode){
1787 if( camera == NULL){
1788 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1789 return CAMERA_ERROR_INVALID_PARAMETER;
1792 camera_s * handle = (camera_s*)camera;
1793 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_SCENE_MODE , mode, NULL);
1794 return __convert_camera_error_code(__func__, ret);
1799 int camera_attr_enable_tag(camera_h camera, bool enable){
1800 if( camera == NULL){
1801 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1802 return CAMERA_ERROR_INVALID_PARAMETER;
1805 camera_s * handle = (camera_s*)camera;
1806 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ENABLE , enable, NULL);
1807 return __convert_camera_error_code(__func__, ret);
1811 int camera_attr_set_tag_image_description(camera_h camera, const char *description){
1812 if( camera == NULL){
1813 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1814 return CAMERA_ERROR_INVALID_PARAMETER;
1817 camera_s * handle = (camera_s*)camera;
1818 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_IMAGE_DESCRIPTION , description, strlen(description), NULL);
1819 return __convert_camera_error_code(__func__, ret);
1823 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation){
1824 if( camera == NULL){
1825 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1826 return CAMERA_ERROR_INVALID_PARAMETER;
1829 camera_s * handle = (camera_s*)camera;
1830 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ORIENTATION , orientation, NULL);
1831 return __convert_camera_error_code(__func__, ret);
1835 int camera_attr_set_tag_software(camera_h camera, const char *software){
1836 if( camera == NULL){
1837 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1838 return CAMERA_ERROR_INVALID_PARAMETER;
1841 camera_s * handle = (camera_s*)camera;
1842 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_SOFTWARE , software, strlen(software), NULL);
1843 return __convert_camera_error_code(__func__, ret);
1847 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude){
1848 if( camera == NULL){
1849 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1850 return CAMERA_ERROR_INVALID_PARAMETER;
1853 camera_s * handle = (camera_s*)camera;
1854 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_GPS_ENABLE, 1,
1855 MMCAM_TAG_LATITUDE, latitude,
1856 MMCAM_TAG_LONGITUDE, longitude,
1857 MMCAM_TAG_ALTITUDE, altitude,
1859 return __convert_camera_error_code(__func__, ret);
1862 int camera_attr_remove_geotag(camera_h camera){
1863 if( camera == NULL){
1864 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1865 return CAMERA_ERROR_INVALID_PARAMETER;
1868 camera_s * handle = (camera_s*)camera;
1869 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_GPS_ENABLE, 0, NULL);
1870 return __convert_camera_error_code(__func__, ret);
1873 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode){
1874 if( camera == NULL){
1875 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1876 return CAMERA_ERROR_INVALID_PARAMETER;
1879 camera_s * handle = (camera_s*)camera;
1880 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_STROBE_MODE , mode, NULL);
1881 return __convert_camera_error_code(__func__, ret);
1885 int camera_attr_get_zoom(camera_h camera, int *zoom){
1886 if( camera == NULL || zoom == NULL){
1887 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1888 return CAMERA_ERROR_INVALID_PARAMETER;
1892 camera_s * handle = (camera_s*)camera;
1893 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL);
1894 return __convert_camera_error_code(__func__, ret);
1898 int camera_attr_get_zoom_range(camera_h camera , int *min , int *max){
1899 if( camera == NULL || min == NULL || max == NULL ){
1900 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1901 return CAMERA_ERROR_INVALID_PARAMETER;
1905 camera_s * handle = (camera_s*)camera;
1906 MMCamAttrsInfo ainfo;
1907 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
1909 *min = ainfo.int_range.min;
1911 *max = ainfo.int_range.max;
1913 return __convert_camera_error_code(__func__, ret);
1917 int camera_attr_get_af_mode( camera_h camera, camera_attr_af_mode_e *mode){
1918 if( camera == NULL || mode == NULL){
1919 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1920 return CAMERA_ERROR_INVALID_PARAMETER;
1927 camera_s * handle = (camera_s*)camera;
1928 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , &focus_mode, MMCAM_CAMERA_AF_SCAN_RANGE , &af_range, MMCAM_DETECT_MODE , &detect_mode, NULL);
1929 if( ret == CAMERA_ERROR_NONE){
1930 switch( focus_mode ){
1931 case MM_CAMCORDER_FOCUS_MODE_NONE :
1932 case MM_CAMCORDER_FOCUS_MODE_PAN :
1933 case MM_CAMCORDER_FOCUS_MODE_MANUAL :
1934 *mode = CAMERA_ATTR_AF_NONE;
1936 case MM_CAMCORDER_FOCUS_MODE_AUTO:
1937 case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
1938 case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
1939 switch ( af_range ){
1940 case MM_CAMCORDER_AUTO_FOCUS_NONE :
1941 *mode = CAMERA_ATTR_AF_NORMAL;
1943 case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
1944 *mode = CAMERA_ATTR_AF_NORMAL;
1946 case MM_CAMCORDER_AUTO_FOCUS_MACRO:
1947 *mode = CAMERA_ATTR_AF_MACRO;
1949 case MM_CAMCORDER_AUTO_FOCUS_FULL:
1950 *mode = CAMERA_ATTR_AF_FULL;
1957 return __convert_camera_error_code(__func__, ret);
1960 int camera_attr_get_exposure_mode( camera_h camera, camera_attr_exposure_mode_e *mode){
1961 if( camera == NULL|| mode == NULL){
1962 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1963 return CAMERA_ERROR_INVALID_PARAMETER;
1967 CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
1968 CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
1969 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
1970 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
1971 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
1972 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
1973 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
1974 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
1975 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM //MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
1979 camera_s * handle = (camera_s*)camera;
1980 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_MODE , &exposure_mode, NULL);
1981 if( ret == CAMERA_ERROR_NONE ){
1982 *mode = maptable[abs(exposure_mode%9)];
1984 return __convert_camera_error_code(__func__, ret);
1988 int camera_attr_get_exposure(camera_h camera, int *value){
1989 if( camera == NULL || value == NULL){
1990 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
1991 return CAMERA_ERROR_INVALID_PARAMETER;
1995 camera_s * handle = (camera_s*)camera;
1996 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_VALUE , value, NULL);
1997 return __convert_camera_error_code(__func__, ret);
2001 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max){
2002 if( camera == NULL || min == NULL || max == NULL ){
2003 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2004 return CAMERA_ERROR_INVALID_PARAMETER;
2008 camera_s * handle = (camera_s*)camera;
2009 MMCamAttrsInfo ainfo;
2010 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
2012 *min = ainfo.int_range.min;
2014 *max = ainfo.int_range.max;
2016 return __convert_camera_error_code(__func__, ret);
2020 int camera_attr_get_iso( camera_h camera, camera_attr_iso_e *iso){
2021 if( camera == NULL || iso == NULL){
2022 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2023 return CAMERA_ERROR_INVALID_PARAMETER;
2027 camera_s * handle = (camera_s*)camera;
2028 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ISO , iso, NULL);
2029 return __convert_camera_error_code(__func__, ret);
2033 int camera_attr_get_brightness(camera_h camera, int *level){
2034 if( camera == NULL || level == NULL){
2035 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2036 return CAMERA_ERROR_INVALID_PARAMETER;
2039 camera_s * handle = (camera_s*)camera;
2040 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_BRIGHTNESS , level, NULL);
2041 return __convert_camera_error_code(__func__, ret);
2045 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max){
2046 if( camera == NULL || min == NULL || max == NULL ){
2047 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2048 return CAMERA_ERROR_INVALID_PARAMETER;
2052 camera_s * handle = (camera_s*)camera;
2053 MMCamAttrsInfo ainfo;
2054 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
2056 *min = ainfo.int_range.min;
2058 *max = ainfo.int_range.max;
2060 return __convert_camera_error_code(__func__, ret);
2064 int camera_attr_get_contrast(camera_h camera, int *level){
2065 if( camera == NULL || level == NULL){
2066 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2067 return CAMERA_ERROR_INVALID_PARAMETER;
2072 camera_s * handle = (camera_s*)camera;
2073 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_CONTRAST , level, NULL);
2074 return __convert_camera_error_code(__func__, ret);
2077 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max){
2078 if( camera == NULL || min == NULL || max == NULL ){
2079 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2080 return CAMERA_ERROR_INVALID_PARAMETER;
2084 camera_s * handle = (camera_s*)camera;
2085 MMCamAttrsInfo ainfo;
2086 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
2088 *min = ainfo.int_range.min;
2090 *max = ainfo.int_range.max;
2092 return __convert_camera_error_code(__func__, ret);
2096 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb){
2097 if( camera == NULL || wb == NULL){
2098 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2099 return CAMERA_ERROR_INVALID_PARAMETER;
2103 camera_s * handle = (camera_s*)camera;
2104 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_WB , wb, NULL);
2105 return __convert_camera_error_code(__func__, ret);
2109 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect){
2111 if( camera == NULL || effect == NULL ){
2112 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2113 return CAMERA_ERROR_INVALID_PARAMETER;
2117 camera_s * handle = (camera_s*)camera;
2119 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_COLOR_TONE , &tone, NULL);
2121 if( ret != CAMERA_ERROR_NONE )
2122 return __convert_camera_error_code(__func__, ret);
2124 *effect = (camera_attr_effect_mode_e)tone;
2126 return __convert_camera_error_code(__func__, ret);
2129 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode){
2130 if( camera == NULL || mode == NULL){
2131 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2132 return CAMERA_ERROR_INVALID_PARAMETER;
2136 camera_s * handle = (camera_s*)camera;
2137 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_SCENE_MODE , mode, NULL);
2138 return __convert_camera_error_code(__func__, ret);
2143 int camera_attr_is_enabled_tag(camera_h camera, bool *enable){
2144 if( camera == NULL || enable == NULL){
2145 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2146 return CAMERA_ERROR_INVALID_PARAMETER;
2150 camera_s * handle = (camera_s*)camera;
2152 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ENABLE , enable, NULL);
2154 return __convert_camera_error_code(__func__, ret);
2158 int camera_attr_get_tag_image_description(camera_h camera, char **description){
2159 if( camera == NULL || description == NULL){
2160 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2161 return CAMERA_ERROR_INVALID_PARAMETER;
2165 camera_s * handle = (camera_s*)camera;
2166 char *ndescription = NULL;
2168 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_IMAGE_DESCRIPTION , &ndescription, &desc_size, NULL);
2169 if( ret == CAMERA_ERROR_NONE ){
2170 if( ndescription != NULL )
2171 *description = strdup(ndescription);
2173 *description = strdup("");
2176 return __convert_camera_error_code(__func__, ret);
2180 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation){
2182 if( camera == NULL || orientation == NULL){
2183 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2184 return CAMERA_ERROR_INVALID_PARAMETER;
2188 camera_s * handle = (camera_s*)camera;
2189 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ORIENTATION , orientation, NULL);
2190 return __convert_camera_error_code(__func__, ret);
2193 int camera_attr_get_tag_software(camera_h camera, char **software){
2194 if( camera == NULL || software == NULL ){
2195 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2196 return CAMERA_ERROR_INVALID_PARAMETER;
2200 camera_s * handle = (camera_s*)camera;
2203 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_SOFTWARE , &soft, &soft_size, NULL);
2204 if( ret == CAMERA_ERROR_NONE ){
2206 *software = strdup(soft);
2208 *software = strdup("");
2210 return __convert_camera_error_code(__func__, ret);
2213 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude){
2214 if( camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL){
2215 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2216 return CAMERA_ERROR_INVALID_PARAMETER;
2219 camera_s * handle = (camera_s*)camera;
2220 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_LATITUDE , latitude,
2221 MMCAM_TAG_LONGITUDE, longitude,
2222 MMCAM_TAG_ALTITUDE, altitude,
2224 return __convert_camera_error_code(__func__, ret);
2227 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode){
2228 if( camera == NULL || mode == NULL){
2229 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2230 return CAMERA_ERROR_INVALID_PARAMETER;
2234 camera_s * handle = (camera_s*)camera;
2235 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_STROBE_MODE , mode, NULL);
2236 return __convert_camera_error_code(__func__, ret);
2239 int camera_attr_foreach_supported_af_mode( camera_h camera, camera_attr_supported_af_mode_cb foreach_cb , void *user_data){
2240 if( camera == NULL || foreach_cb == NULL){
2241 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2242 return CAMERA_ERROR_INVALID_PARAMETER;
2248 camera_s * handle = (camera_s*)camera;
2249 MMCamAttrsInfo af_range;
2250 MMCamAttrsInfo focus_mode;
2252 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE , &af_range);
2253 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE , &focus_mode);
2255 if( ret != CAMERA_ERROR_NONE )
2256 return __convert_camera_error_code(__func__, ret);
2258 for( i=0 ; i < af_range.int_array.count ; i++)
2260 if ( !foreach_cb(af_range.int_array.array[i],user_data) )
2266 return CAMERA_ERROR_NONE;
2270 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data){
2271 if( camera == NULL || foreach_cb == NULL){
2272 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2273 return CAMERA_ERROR_INVALID_PARAMETER;
2277 CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
2278 CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
2279 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
2280 -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
2281 -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
2282 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
2283 -1, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
2284 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
2285 -1//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
2288 camera_s * handle = (camera_s*)camera;
2289 MMCamAttrsInfo info;
2290 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE , &info);
2291 if( ret != CAMERA_ERROR_NONE )
2292 return __convert_camera_error_code(__func__, ret);
2295 for( i=0 ; i < info.int_array.count ; i++)
2297 if( maptable[info.int_array.array[i]] != -1){
2298 if ( !foreach_cb(maptable[info.int_array.array[i]],user_data) )
2302 return CAMERA_ERROR_NONE;
2305 int camera_attr_foreach_supported_iso( camera_h camera, camera_attr_supported_iso_cb foreach_cb , void *user_data){
2306 if( camera == NULL || foreach_cb == NULL){
2307 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2308 return CAMERA_ERROR_INVALID_PARAMETER;
2311 camera_s * handle = (camera_s*)camera;
2312 MMCamAttrsInfo info;
2313 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO , &info);
2314 if( ret != CAMERA_ERROR_NONE )
2315 return __convert_camera_error_code(__func__, ret);
2318 for( i=0 ; i < info.int_array.count ; i++)
2320 if ( !foreach_cb(info.int_array.array[i],user_data) )
2323 return CAMERA_ERROR_NONE;
2327 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data){
2328 if( camera == NULL || foreach_cb == NULL){
2329 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2330 return CAMERA_ERROR_INVALID_PARAMETER;
2333 camera_s * handle = (camera_s*)camera;
2334 MMCamAttrsInfo info;
2335 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB , &info);
2336 if( ret != CAMERA_ERROR_NONE )
2337 return __convert_camera_error_code(__func__, ret);
2340 for( i=0 ; i < info.int_array.count ; i++)
2342 if ( !foreach_cb(info.int_array.array[i],user_data) )
2345 return CAMERA_ERROR_NONE;
2348 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data){
2349 if( camera == NULL || foreach_cb == NULL){
2350 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2351 return CAMERA_ERROR_INVALID_PARAMETER;
2355 camera_s * handle = (camera_s*)camera;
2356 MMCamAttrsInfo info;
2357 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE , &info);
2358 if( ret != CAMERA_ERROR_NONE )
2359 return __convert_camera_error_code(__func__, ret);
2362 for( i=0 ; i < info.int_array.count ; i++)
2364 int effect = info.int_array.array[i];
2365 if ( !foreach_cb(effect,user_data) )
2368 return CAMERA_ERROR_NONE;
2371 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data){
2372 if( camera == NULL || foreach_cb == NULL){
2373 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2374 return CAMERA_ERROR_INVALID_PARAMETER;
2378 camera_s * handle = (camera_s*)camera;
2379 MMCamAttrsInfo info;
2380 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE , &info);
2381 if( ret != CAMERA_ERROR_NONE )
2382 return __convert_camera_error_code(__func__, ret);
2385 for( i=0 ; i < info.int_array.count ; i++)
2387 if ( !foreach_cb(info.int_array.array[i],user_data) )
2390 return CAMERA_ERROR_NONE;
2394 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data){
2395 if( camera == NULL || foreach_cb == NULL){
2396 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2397 return CAMERA_ERROR_INVALID_PARAMETER;
2400 camera_s * handle = (camera_s*)camera;
2401 MMCamAttrsInfo info;
2402 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE , &info);
2403 if( ret != CAMERA_ERROR_NONE )
2404 return __convert_camera_error_code(__func__, ret);
2407 for( i=0 ; i < info.int_array.count ; i++)
2409 if ( !foreach_cb(info.int_array.array[i],user_data) )
2412 return CAMERA_ERROR_NONE;
2415 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data){
2416 if( camera == NULL || foreach_cb == NULL){
2417 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2418 return CAMERA_ERROR_INVALID_PARAMETER;
2421 camera_s * handle = (camera_s*)camera;
2422 MMCamAttrsInfo info;
2423 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info);
2424 if( ret != CAMERA_ERROR_NONE )
2425 return __convert_camera_error_code(__func__, ret);
2428 //if (foreach_cb(CAMERA_ATTR_FPS_AUTO, user_data) < 0 )
2429 // return CAMERA_ERROR_NONE;
2430 for( i=0 ; i < info.int_array.count ; i++)
2432 if ( !foreach_cb(info.int_array.array[i],user_data) )
2435 return CAMERA_ERROR_NONE;
2439 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation){
2440 if( camera == NULL){
2441 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2442 return CAMERA_ERROR_INVALID_PARAMETER;
2445 if( rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270 )
2446 return CAMERA_ERROR_INVALID_PARAMETER;
2449 camera_s * handle = (camera_s*)camera;
2451 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ROTATION , rotation, NULL);
2452 return __convert_camera_error_code(__func__, ret);
2455 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation){
2456 if( camera == NULL || rotation == NULL ){
2457 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2458 return CAMERA_ERROR_INVALID_PARAMETER;
2462 camera_s * handle = (camera_s*)camera;
2464 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ROTATION , rotation, NULL);
2465 return __convert_camera_error_code(__func__, ret);
2468 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip){
2469 if( camera == NULL){
2470 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2471 return CAMERA_ERROR_INVALID_PARAMETER;
2474 if( flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH )
2475 return CAMERA_ERROR_INVALID_PARAMETER;
2478 camera_s * handle = (camera_s*)camera;
2479 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FLIP , flip , NULL);
2480 return __convert_camera_error_code(__func__, ret);
2483 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip){
2484 if( camera == NULL || flip == NULL ){
2485 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2486 return CAMERA_ERROR_INVALID_PARAMETER;
2489 camera_s * handle = (camera_s*)camera;
2490 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FLIP , flip , NULL);
2491 return __convert_camera_error_code(__func__, ret);
2494 int _camera_set_use(camera_h camera, bool used){
2495 camera_s * handle = (camera_s*)camera;
2496 handle->is_used_in_recorder = used;
2500 bool _camera_is_used(camera_h camera){
2501 camera_s * handle = (camera_s*)camera;
2502 return handle->is_used_in_recorder;
2506 int _camera_get_mm_handle(camera_h camera , MMHandleType *handle){
2507 if( camera == NULL || handle == NULL ){
2508 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2509 return CAMERA_ERROR_INVALID_PARAMETER;
2511 camera_s *camera_handle = (camera_s*)camera;
2512 *handle = camera_handle->mm_handle;
2513 return CAMERA_ERROR_NONE;
2516 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data){
2517 if( camera == NULL ){
2518 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2519 return CAMERA_ERROR_INVALID_PARAMETER;
2522 camera_s *handle = (camera_s*)camera;
2523 handle->relay_message_callback = callback;
2524 handle->relay_user_data = user_data;
2526 return CAMERA_ERROR_NONE;
2529 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode){
2530 if( camera == NULL){
2531 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2532 return CAMERA_ERROR_INVALID_PARAMETER;
2535 camera_s * handle = (camera_s*)camera;
2536 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , mode, NULL);
2538 if( mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL )
2539 handle->hdr_keep_mode = true;
2541 handle->hdr_keep_mode = false;
2543 return __convert_camera_error_code(__func__, ret);
2546 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode){
2547 if( camera == NULL || mode == NULL ){
2548 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2549 return CAMERA_ERROR_INVALID_PARAMETER;
2553 camera_s * handle = (camera_s*)camera;
2554 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , &result, NULL);
2558 return __convert_camera_error_code(__func__, ret);
2562 int camera_attr_enable_hdr_capture(camera_h camera, bool enable){
2563 if( camera == NULL){
2564 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2565 return CAMERA_ERROR_INVALID_PARAMETER;
2568 camera_s * handle = (camera_s*)camera;
2569 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , enable, NULL);
2570 return __convert_camera_error_code(__func__, ret);
2573 int camera_attr_is_enabled_hdr_capture(camera_h camera, bool *enabled){
2574 if( camera == NULL || enabled == NULL ){
2575 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2576 return CAMERA_ERROR_INVALID_PARAMETER;
2580 camera_s * handle = (camera_s*)camera;
2581 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_HDR_CAPTURE , &result, NULL);
2583 if( result >= MM_CAMCORDER_HDR_ON )
2588 return __convert_camera_error_code(__func__, ret);
2591 bool camera_attr_is_supported_hdr_capture(camera_h camera){
2592 if( camera == NULL){
2593 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2598 camera_s * handle = (camera_s*)camera;
2599 MMCamAttrsInfo hdr_info;
2600 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE , &hdr_info);
2601 for (i = 0; i < hdr_info.int_array.count ; i++) {
2602 if (hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON) {
2609 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void* user_data){
2610 if( camera == NULL || callback == NULL){
2611 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2612 return CAMERA_ERROR_INVALID_PARAMETER;
2615 camera_s * handle = (camera_s*)camera;
2616 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)callback;
2617 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)user_data;
2618 return CAMERA_ERROR_NONE;
2621 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera){
2622 if( camera == NULL){
2623 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2624 return CAMERA_ERROR_INVALID_PARAMETER;
2626 camera_s * handle = (camera_s*)camera;
2627 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
2628 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
2629 return CAMERA_ERROR_NONE;
2632 int camera_attr_enable_anti_shake(camera_h camera, bool enable){
2633 if( camera == NULL){
2634 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2635 return CAMERA_ERROR_INVALID_PARAMETER;
2638 int mode = MM_CAMCORDER_AHS_OFF;
2640 mode = MM_CAMCORDER_AHS_ON;
2642 camera_s * handle = (camera_s*)camera;
2643 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ANTI_HANDSHAKE , mode, NULL);
2644 return __convert_camera_error_code(__func__, ret);
2647 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled){
2648 if( camera == NULL || enabled == NULL ){
2649 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2650 return CAMERA_ERROR_INVALID_PARAMETER;
2653 int mode = MM_CAMCORDER_AHS_OFF;
2654 camera_s * handle = (camera_s*)camera;
2655 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ANTI_HANDSHAKE , &mode, NULL);
2658 return __convert_camera_error_code(__func__, ret);
2661 bool camera_attr_is_supported_anti_shake(camera_h camera){
2662 if( camera == NULL){
2663 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2667 camera_s * handle = (camera_s*)camera;
2668 MMCamAttrsInfo ash_info;
2669 mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE , &ash_info);
2671 for( i=0 ; i < ash_info.int_array.count ; i++)
2673 if ( ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON)
2679 int camera_attr_enable_video_stabilization(camera_h camera, bool enable){
2680 if( camera == NULL){
2681 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2682 return CAMERA_ERROR_INVALID_PARAMETER;
2685 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
2687 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
2689 camera_s * handle = (camera_s*)camera;
2690 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_VIDEO_STABILIZATION , mode, NULL);
2691 return __convert_camera_error_code(__func__, ret);
2694 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled){
2695 if( camera == NULL || enabled == NULL ){
2696 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2697 return CAMERA_ERROR_INVALID_PARAMETER;
2700 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
2701 camera_s * handle = (camera_s*)camera;
2702 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_VIDEO_STABILIZATION , &mode, NULL);
2704 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
2705 return __convert_camera_error_code(__func__, ret);
2708 bool camera_attr_is_supported_video_stabilization(camera_h camera){
2709 if( camera == NULL){
2710 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2714 camera_s * handle = (camera_s*)camera;
2715 MMCamAttrsInfo vs_info;
2716 mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION , &vs_info);
2718 for( i=0 ; i < vs_info.int_array.count ; i++)
2720 if ( vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON)
2728 int camera_attr_enable_auto_contrast(camera_h camera, bool enable){
2729 if( camera == NULL){
2730 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2731 return CAMERA_ERROR_INVALID_PARAMETER;
2734 int mode = MM_CAMCORDER_WDR_OFF;
2736 mode = MM_CAMCORDER_WDR_ON;
2738 camera_s * handle = (camera_s*)camera;
2739 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WDR , mode, NULL);
2740 return __convert_camera_error_code(__func__, ret);
2743 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled){
2744 if( camera == NULL || enabled == NULL ){
2745 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2746 return CAMERA_ERROR_INVALID_PARAMETER;
2749 int mode = MM_CAMCORDER_WDR_OFF;
2750 camera_s * handle = (camera_s*)camera;
2751 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WDR , &mode, NULL);
2754 return __convert_camera_error_code(__func__, ret);
2757 int camera_attr_disable_shutter_sound(camera_h camera, bool disable){
2758 if( camera == NULL){
2759 LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER);
2760 return CAMERA_ERROR_INVALID_PARAMETER;
2763 camera_s * handle = (camera_s*)camera;
2764 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "capture-sound-enable" , !disable, NULL);
2766 LOGE("[%s] CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound", __func__);
2767 return CAMERA_ERROR_INVALID_OPERATION;
2769 return CAMERA_ERROR_NONE;