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>
31 #include <tbm_bufmgr.h>
32 #include <tbm_surface_internal.h>
35 #include <Elementary.h>
40 #define LOG_TAG "TIZEN_N_CAMERA"
42 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data);
43 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data);
45 void _camera_remove_cb_message(camera_s *handle){
48 camera_cb_data *cb_data = NULL;
51 LOGE("handle is NULL");
57 g_mutex_lock(&handle->idle_cb_lock);
59 if( handle->cb_data_list ){
60 list = handle->cb_data_list;
64 list = g_list_next(list);
67 LOGW("cb_data is NULL");
69 ret = g_idle_remove_by_data (cb_data);
70 LOGW("Remove cb_data[%p]. ret[%d]", cb_data, ret);
72 handle->cb_data_list = g_list_remove(handle->cb_data_list, cb_data);
78 g_list_free(handle->cb_data_list);
79 handle->cb_data_list = NULL;
81 LOGW("There is no remained callback");
84 g_mutex_unlock(&handle->idle_cb_lock);
92 int __convert_camera_error_code(const char* func, int code){
93 int ret = CAMERA_ERROR_NONE;
94 const char *errorstr = NULL;
98 ret = CAMERA_ERROR_NONE;
99 errorstr = "ERROR_NONE";
101 case MM_ERROR_CAMCORDER_INVALID_ARGUMENT:
102 case MM_ERROR_COMMON_INVALID_ATTRTYPE:
103 ret = CAMERA_ERROR_INVALID_PARAMETER;
104 errorstr = "INVALID_PARAMETER";
106 case MM_ERROR_CAMCORDER_NOT_INITIALIZED:
107 case MM_ERROR_CAMCORDER_INVALID_STATE:
108 ret = CAMERA_ERROR_INVALID_STATE;
109 errorstr = "INVALID_STATE";
111 case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND:
112 ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
113 errorstr = "DEVICE_NOT_FOUND";
115 case MM_ERROR_CAMCORDER_DEVICE_BUSY:
116 case MM_ERROR_CAMCORDER_DEVICE_OPEN:
117 case MM_ERROR_CAMCORDER_CMD_IS_RUNNING:
118 ret = CAMERA_ERROR_DEVICE_BUSY;
119 errorstr = "DEVICE_BUSY";
121 case MM_ERROR_CAMCORDER_DEVICE:
122 case MM_ERROR_CAMCORDER_DEVICE_IO:
123 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
124 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
125 case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER:
126 ret = CAMERA_ERROR_DEVICE;
127 errorstr = "ERROR_DEVICE";
130 case MM_ERROR_CAMCORDER_GST_CORE:
131 case MM_ERROR_CAMCORDER_GST_LIBRARY:
132 case MM_ERROR_CAMCORDER_GST_RESOURCE:
133 case MM_ERROR_CAMCORDER_GST_STREAM:
134 case MM_ERROR_CAMCORDER_GST_STATECHANGE:
135 case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
136 case MM_ERROR_CAMCORDER_GST_LINK:
137 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
138 case MM_ERROR_CAMCORDER_ENCODER:
139 case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
140 case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE:
141 case MM_ERROR_CAMCORDER_ENCODER_WORKING:
142 case MM_ERROR_CAMCORDER_INTERNAL:
143 case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT:
144 case MM_ERROR_CAMCORDER_DSP_FAIL:
145 case MM_ERROR_CAMCORDER_AUDIO_EMPTY:
146 case MM_ERROR_CAMCORDER_CREATE_CONFIGURE:
147 case MM_ERROR_CAMCORDER_FILE_SIZE_OVER:
148 case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF:
149 case MM_ERROR_CAMCORDER_INVALID_CONDITION:
150 ret = CAMERA_ERROR_INVALID_OPERATION;
151 errorstr = "INVALID_OPERATION";
154 case MM_ERROR_CAMCORDER_RESOURCE_CREATION:
155 case MM_ERROR_COMMON_OUT_OF_MEMORY:
156 ret = CAMERA_ERROR_OUT_OF_MEMORY;
157 errorstr = "OUT_OF_MEMORY";
160 case MM_ERROR_POLICY_BLOCKED:
161 ret = CAMERA_ERROR_SOUND_POLICY;
162 errorstr = "ERROR_SOUND_POLICY";
164 case MM_ERROR_POLICY_BLOCKED_BY_CALL:
165 ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
166 errorstr = "ERROR_SOUND_POLICY_BY_CALL";
168 case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
169 ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
170 errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
172 case MM_ERROR_POLICY_RESTRICTED:
173 ret = CAMERA_ERROR_SECURITY_RESTRICTED;
174 errorstr = "ERROR_RESTRICTED";
176 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
177 ret = CAMERA_ERROR_ESD;
178 errorstr = "ERROR_ESD";
180 case MM_ERROR_COMMON_INVALID_PERMISSION:
181 ret = CAMERA_ERROR_PERMISSION_DENIED;
182 errorstr = "ERROR_PERMISSION_DENIED";
184 case MM_ERROR_COMMON_OUT_OF_ARRAY:
185 case MM_ERROR_COMMON_OUT_OF_RANGE:
186 case MM_ERROR_COMMON_ATTR_NOT_EXIST:
187 case MM_ERROR_CAMCORDER_NOT_SUPPORTED:
188 ret = CAMERA_ERROR_NOT_SUPPORTED;
189 errorstr = "ERROR_NOT_SUPPORTED";
192 ret = CAMERA_ERROR_INVALID_OPERATION;
193 errorstr = "INVALID_OPERATION";
196 if( code != MM_ERROR_NONE ){
197 LOGE("%s(0x%08x) : core frameworks error code(0x%08x)", errorstr, ret, code);
204 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data){
205 if( user_data == NULL || stream == NULL)
208 camera_s * handle = (camera_s*)user_data;
209 if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] ){
210 camera_preview_data_s frame;
211 frame.format = stream->format;
212 if( frame.format == (camera_pixel_format_e)MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
213 frame.format = MM_PIXEL_FORMAT_UYVY;
214 frame.width = stream->width;
215 frame.height = stream->height;
216 frame.timestamp = stream->timestamp;
217 frame.num_of_planes = stream->num_planes;
218 switch( stream->data_type ){
219 case MM_CAM_STREAM_DATA_YUV420 :
220 frame.data.single_plane.yuv = stream->data.yuv420.yuv;
221 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
223 case MM_CAM_STREAM_DATA_YUV422:
224 frame.data.single_plane.yuv = stream->data.yuv422.yuv;
225 frame.data.single_plane.size = stream->data.yuv422.length_yuv;
227 case MM_CAM_STREAM_DATA_YUV420SP:
228 frame.data.double_plane.y = stream->data.yuv420sp.y;
229 frame.data.double_plane.uv = stream->data.yuv420sp.uv;
230 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
231 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
233 case MM_CAM_STREAM_DATA_YUV420P:
234 frame.data.triple_plane.y = stream->data.yuv420p.y;
235 frame.data.triple_plane.u = stream->data.yuv420p.u;
236 frame.data.triple_plane.v = stream->data.yuv420p.v;
237 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
238 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
239 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
241 case MM_CAM_STREAM_DATA_YUV422P:
242 frame.data.triple_plane.y = stream->data.yuv422p.y;
243 frame.data.triple_plane.u = stream->data.yuv422p.u;
244 frame.data.triple_plane.v = stream->data.yuv422p.v;
245 frame.data.triple_plane.y_size = stream->data.yuv422p.length_y;
246 frame.data.triple_plane.u_size = stream->data.yuv422p.length_u;
247 frame.data.triple_plane.v_size = stream->data.yuv422p.length_v;
252 ((camera_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW])(&frame, handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW]);
255 if( handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ){
256 media_packet_h pkt = NULL;
257 tbm_surface_h tsurf = NULL;
258 uint32_t bo_format = 0;
262 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
263 bool make_pkt_fmt = false;
265 /* create tbm surface */
266 for( i = 0, bo_num = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++ ){
272 /* get tbm surface format */
273 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
274 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
276 if( bo_num > 0 && ret == CAMERA_ERROR_NONE ){
277 tsurf = tbm_surface_internal_create_with_bos(stream->width, stream->height, bo_format, (tbm_bo *)stream->bo, bo_num);
278 /*LOGD("tbm surface %p", tsurf);*/
282 /* check media packet format */
283 if( handle->pkt_fmt ){
284 int pkt_fmt_width = 0;
285 int pkt_fmt_height = 0;
286 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
288 media_format_get_video_info(handle->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
289 if( pkt_fmt_mimetype != mimetype ||
290 pkt_fmt_width != stream->width ||
291 pkt_fmt_height != stream->height ){
292 LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
293 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
294 media_format_unref(handle->pkt_fmt);
295 handle->pkt_fmt = NULL;
302 /* create packet format */
304 LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
305 ret = media_format_create(&handle->pkt_fmt);
306 if (ret == MEDIA_FORMAT_ERROR_NONE) {
307 ret = media_format_set_video_mime(handle->pkt_fmt, mimetype);
308 ret |= media_format_set_video_width(handle->pkt_fmt, stream->width);
309 ret |= media_format_set_video_height(handle->pkt_fmt, stream->height);
310 LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
312 LOGW("media_format_create failed");
316 /* create media packet */
317 ret = media_packet_create_from_tbm_surface(handle->pkt_fmt, tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize, (void *)handle, &pkt);
318 if( ret != MEDIA_PACKET_ERROR_NONE ){
319 LOGE("media_packet_create_from_tbm_surface failed");
321 tbm_surface_destroy(tsurf);
325 LOGE("failed to create tbm surface %dx%d, format %d, bo_num %d", stream->width, stream->height, stream->format, bo_num);
329 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
331 /* set internal buffer */
332 ret = media_packet_set_extra(pkt, stream->internal_buffer);
333 if( ret != MEDIA_PACKET_ERROR_NONE ){
334 LOGE("media_packet_set_extra failed");
336 media_packet_destroy(pkt);
339 /* set timestamp : msec -> nsec */
340 if( media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE ){
341 LOGW("media_packet_set_pts failed");
344 /* increase ref count of gst buffer */
345 gst_buffer_ref((GstBuffer *)stream->internal_buffer);
347 /* call media packet callback */
348 ((camera_media_packet_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt, handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
356 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data){
357 if( user_data == NULL || frame == NULL)
360 camera_s * handle = (camera_s*)user_data;
361 handle->current_capture_count++;
362 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] ){
363 MMCamcorderCaptureDataType *scrnl = NULL;
365 camera_image_data_s image = { NULL, 0, 0, 0, 0, NULL, 0 };
366 camera_image_data_s thumb = { NULL, 0, 0, 0, 0, NULL, 0 };
367 camera_image_data_s postview = { NULL, 0, 0, 0, 0, NULL, 0 };
372 image.data = frame->data;
373 image.size = frame->length;
374 image.width = frame->width;
375 image.height = frame->height;
376 image.format = frame->format;
377 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, "captured-exif-raw-data", &exif, &exif_size, NULL);
378 if( ret == MM_ERROR_NONE ){
380 image.exif_size = exif_size;
385 thumb.data = thumbnail->data;
386 thumb.size = thumbnail->length;
387 thumb.width = thumbnail->width;
388 thumb.height = thumbnail->height;
389 thumb.format = thumbnail->format;
391 mm_camcorder_get_attributes( handle->mm_handle, NULL, "captured-screennail", &scrnl, &size,NULL );
393 postview.data = scrnl->data;
394 postview.size = scrnl->length;
395 postview.width = scrnl->width;
396 postview.height = scrnl->height;
397 postview.format = scrnl->format;
400 ((camera_capturing_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE])(&image, scrnl ? &postview : NULL, thumbnail ? &thumb : NULL, handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE]);
402 // update captured state
403 if( handle->capture_count == 1 && handle->hdr_keep_mode ){
404 if( handle->current_capture_count == 2 ){
405 handle->is_capture_completed = true;
407 } else if( handle->capture_count == handle->current_capture_count || handle->is_continuous_shot_break){
408 handle->is_capture_completed = true;
414 static camera_state_e __camera_state_convert(MMCamcorderStateType mm_state){
415 camera_state_e state = CAMERA_STATE_NONE;
418 case MM_CAMCORDER_STATE_NONE:
419 state = CAMERA_STATE_NONE;
421 case MM_CAMCORDER_STATE_NULL:
422 state = CAMERA_STATE_CREATED;
424 case MM_CAMCORDER_STATE_READY:
425 state = CAMERA_STATE_CREATED;
427 case MM_CAMCORDER_STATE_PREPARE:
428 state = CAMERA_STATE_PREVIEW;
430 case MM_CAMCORDER_STATE_CAPTURING:
431 state = CAMERA_STATE_CAPTURING;
433 case MM_CAMCORDER_STATE_RECORDING:
434 state = CAMERA_STATE_PREVIEW;
436 case MM_CAMCORDER_STATE_PAUSED:
437 state = CAMERA_STATE_PREVIEW;
440 state = CAMERA_STATE_NONE;
448 static int __mm_camera_message_callback(int message, void *param, void *user_data){
449 if( user_data == NULL || param == NULL )
452 camera_s * handle = (camera_s*)user_data;
454 if( handle->relay_message_callback )
455 handle->relay_message_callback(message, param, handle->relay_user_data);
457 MMMessageParamType *m = (MMMessageParamType*)param;
458 camera_state_e previous_state;
462 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
463 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
464 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
465 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) ){
466 LOGI( "Invalid state changed message");
470 previous_state = handle->state;
471 handle->state = __camera_state_convert(m->state.current );
472 camera_policy_e policy = CAMERA_POLICY_NONE;
473 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
474 switch (m->state.code) {
475 case ASM_EVENT_SOURCE_CALL_START:
476 policy = CAMERA_POLICY_SOUND_BY_CALL;
477 LOGW("CAMERA_POLICY_SOUND_BY_CALL");
479 case ASM_EVENT_SOURCE_ALARM_START:
480 case ASM_EVENT_SOURCE_ALARM_END:
481 policy = CAMERA_POLICY_SOUND_BY_ALARM;
482 LOGW("CAMERA_POLICY_SOUND_BY_ALARM");
485 policy = CAMERA_POLICY_SOUND;
486 LOGW("CAMERA_POLICY_SOUND");
489 } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
490 policy = CAMERA_POLICY_SECURITY;
491 LOGW("CAMERA_POLICY_SECURITY");
494 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
495 ((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]);
498 // should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state
499 if( policy != CAMERA_POLICY_NONE &&
500 m->state.current == MM_CAMCORDER_STATE_NULL ){
501 if( handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED]){
502 ((camera_interrupted_cb)handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED])(policy, previous_state, handle->state, handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED]);
504 LOGW("_CAMERA_EVENT_TYPE_INTERRUPTED cb is NULL");
509 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED :
510 if( handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] ){
511 ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])( m->code, handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
514 case MM_MESSAGE_CAMCORDER_CAPTURED:
516 handle->current_capture_complete_count = m->code;
517 if( handle->capture_count == 1 || m->code == handle->capture_count ||(handle->is_continuous_shot_break && handle->state == CAMERA_STATE_CAPTURING) ){
518 //pseudo state change
519 previous_state = handle->state ;
520 handle->state = CAMERA_STATE_CAPTURED;
521 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
522 ((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]);
524 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
525 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
530 case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
531 case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
533 MMCamRecordingReport *report = (MMCamRecordingReport *)m ->data;
534 if( report != NULL && report->recording_filename ){
535 free(report->recording_filename );
536 report->recording_filename = NULL;
544 case MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED:
546 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
547 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
551 case MM_MESSAGE_CAMCORDER_ERROR:
553 int errorcode = m->code;
554 int camera_error = 0;
556 case MM_ERROR_CAMCORDER_DEVICE :
557 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
558 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
559 camera_error = CAMERA_ERROR_DEVICE;
561 case MM_ERROR_CAMCORDER_GST_CORE:
562 case MM_ERROR_CAMCORDER_GST_LIBRARY:
563 case MM_ERROR_CAMCORDER_GST_RESOURCE:
564 case MM_ERROR_CAMCORDER_GST_STREAM:
565 case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
566 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
567 case MM_ERROR_CAMCORDER_ENCODER:
568 case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
569 case MM_ERROR_CAMCORDER_ENCODER_WORKING:
570 case MM_ERROR_CAMCORDER_MNOTE_CREATION:
571 case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY:
572 case MM_ERROR_CAMCORDER_INTERNAL:
573 case MM_ERROR_FILE_NOT_FOUND:
574 case MM_ERROR_FILE_READ:
575 camera_error = CAMERA_ERROR_INVALID_OPERATION;
577 case MM_ERROR_CAMCORDER_LOW_MEMORY:
578 case MM_ERROR_CAMCORDER_MNOTE_MALLOC:
579 camera_error = CAMERA_ERROR_OUT_OF_MEMORY;
581 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
582 camera_error = CAMERA_ERROR_ESD;
585 camera_error = CAMERA_ERROR_INVALID_OPERATION;
589 /* set capture completed flag as true to release camera handle */
590 handle->is_capture_completed = true;
592 if( camera_error != 0 && handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] )
593 ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(camera_error, handle->state , handle->user_data[_CAMERA_EVENT_TYPE_ERROR]);
597 case MM_MESSAGE_CAMCORDER_HDR_PROGRESS:
599 int percent = m->code;
600 if( handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] )
601 ((camera_attr_hdr_progress_cb)handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS])(percent, handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
604 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
606 MMCamFaceDetectInfo *cam_fd_info = (MMCamFaceDetectInfo *)(m->data);
608 camera_detected_face_s faces[cam_fd_info->num_of_faces];
609 handle->num_of_faces = cam_fd_info->num_of_faces > MAX_DETECTED_FACE ? MAX_DETECTED_FACE : cam_fd_info->num_of_faces;
611 for(i=0; i < handle->num_of_faces ; i++){
612 faces[i].id = cam_fd_info->face_info[i].id;
613 faces[i].score = cam_fd_info->face_info[i].score;
614 faces[i].x = cam_fd_info->face_info[i].rect.x;
615 faces[i].y = cam_fd_info->face_info[i].rect.y;
616 faces[i].width = cam_fd_info->face_info[i].rect.width;
617 faces[i].height = cam_fd_info->face_info[i].rect.height;
618 handle->faceinfo[i] = faces[i]; //cache face coordinate
620 if( handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] )
621 ((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]);
623 handle->num_of_faces = 0;
634 static int __capture_completed_event_cb(void *data){
635 camera_s *handle = (camera_s*)data;
636 if( handle->current_capture_count > 0 && handle->current_capture_count == handle->current_capture_complete_count && handle->state == CAMERA_STATE_CAPTURING ){
637 //pseudo state change
638 camera_state_e previous_state = handle->state;
639 handle->state = CAMERA_STATE_CAPTURED;
640 if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
641 ((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]);
643 if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
644 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
650 int camera_create(camera_device_e device, camera_h* camera){
652 if( camera == NULL ){
653 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
654 return CAMERA_ERROR_INVALID_PARAMETER;
662 LOGW("device name = [%d]",device);
664 info.videodev_type = device;
666 camera_s* handle = (camera_s*)malloc( sizeof(camera_s) );
669 return CAMERA_ERROR_OUT_OF_MEMORY;
671 memset(handle, 0 , sizeof(camera_s));
673 ret = mm_camcorder_create(&handle->mm_handle, &info);
674 if( ret != MM_ERROR_NONE ){
676 return __convert_camera_error_code(__func__,ret);
679 preview_format = MM_PIXEL_FORMAT_YUYV;
680 rotation = MM_DISPLAY_ROTATION_NONE;
681 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
682 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
683 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
684 MMCAM_CAPTURE_WIDTH, &handle->capture_width,
685 MMCAM_CAPTURE_HEIGHT, &handle->capture_height,
689 ret = mm_camcorder_set_attributes(handle->mm_handle, &error,
690 MMCAM_MODE , MM_CAMCORDER_MODE_VIDEO_CAPTURE,
691 MMCAM_CAMERA_FORMAT, preview_format,
692 MMCAM_IMAGE_ENCODER , MM_IMAGE_CODEC_JPEG,
693 MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
694 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL,
695 MMCAM_DISPLAY_ROTATION, rotation,
696 MMCAM_CAPTURE_COUNT, 1,
699 handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
701 if( ret != MM_ERROR_NONE ){
702 LOGE("mm_camcorder_set_attributes fail(%x, %s)", ret, error);
703 mm_camcorder_destroy(handle->mm_handle);
706 return __convert_camera_error_code(__func__, ret);
709 handle->state = CAMERA_STATE_CREATED;
710 handle->relay_message_callback = NULL;
711 handle->relay_user_data = NULL;
712 handle->capture_resolution_modified = false;
713 handle->hdr_keep_mode = false;
714 handle->focus_area_valid = false;
715 handle->is_used_in_recorder = false;
716 handle->on_continuous_focusing = false;
717 handle->cached_focus_mode = -1;
718 g_mutex_init(&handle->idle_cb_lock);
719 mm_camcorder_set_message_callback(handle->mm_handle, __mm_camera_message_callback, (void*)handle);
721 LOGW("camera handle %p", handle);
723 *camera = (camera_h)handle;
724 return __convert_camera_error_code(__func__, ret);
727 int camera_destroy(camera_h camera){
728 if( camera == NULL ){
729 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
730 return CAMERA_ERROR_INVALID_PARAMETER;
734 camera_s *handle = (camera_s*)camera;
735 if( handle->is_used_in_recorder ){
736 LOGE("camera is using in another recorder.");
737 return CAMERA_ERROR_INVALID_OPERATION;
740 LOGW("camera handle %p", handle);
742 ret = mm_camcorder_destroy(handle->mm_handle);
744 if( handle->pkt_fmt ){
745 media_format_unref(handle->pkt_fmt);
746 handle->pkt_fmt = NULL;
749 if( ret == MM_ERROR_NONE ){
750 _camera_remove_cb_message(handle);
751 g_mutex_clear(&handle->idle_cb_lock);
755 return __convert_camera_error_code(__func__, ret);
759 int camera_start_preview(camera_h camera){
761 if( camera == NULL ){
762 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
763 return CAMERA_ERROR_INVALID_PARAMETER;
767 camera_s *handle = (camera_s*)camera;
768 camera_state_e capi_state;
769 camera_get_state(camera, &capi_state);
771 if( capi_state == CAMERA_STATE_CAPTURED ){
772 ret = mm_camcorder_capture_stop(handle->mm_handle);
773 return __convert_camera_error_code(__func__, ret);
776 /*for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback*/
777 mm_camcorder_set_video_capture_callback( handle->mm_handle, (mm_camcorder_video_capture_callback)__mm_capture_callback, (void*)handle);
779 MMCamcorderStateType state;
780 mm_camcorder_get_state(handle->mm_handle, &state);
781 if( state != MM_CAMCORDER_STATE_READY ){
782 ret = mm_camcorder_realize(handle->mm_handle);
783 if( ret != MM_ERROR_NONE ){
784 return __convert_camera_error_code(__func__, ret);
788 ret = mm_camcorder_start(handle->mm_handle);
789 if( ret != MM_ERROR_NONE ){
791 mm_camcorder_unrealize(handle->mm_handle);
794 return __convert_camera_error_code(__func__, ret);
797 int camera_stop_preview(camera_h camera){
798 if( camera == NULL ){
799 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
800 return CAMERA_ERROR_INVALID_PARAMETER;
804 camera_s *handle = (camera_s*)camera;
805 MMCamcorderStateType state ;
806 mm_camcorder_get_state(handle->mm_handle, &state);
808 if( state == MM_CAMCORDER_STATE_PREPARE ){
809 ret = mm_camcorder_stop(handle->mm_handle);
810 if( ret != MM_ERROR_NONE ){
811 return __convert_camera_error_code(__func__, ret);
815 camera_stop_face_detection(camera);
817 ret = mm_camcorder_unrealize(handle->mm_handle);
819 return __convert_camera_error_code(__func__, ret);
822 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb , camera_capture_completed_cb completed_cb , void *user_data){
823 if( camera == NULL ){
824 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
825 return CAMERA_ERROR_INVALID_PARAMETER;
828 camera_s * handle = (camera_s*)camera;
830 MMCamcorderStateType state;
831 mm_camcorder_get_state(handle->mm_handle, &state);
832 if( state != MM_CAMCORDER_STATE_PREPARE &&
833 state != MM_CAMCORDER_STATE_RECORDING &&
834 state != MM_CAMCORDER_STATE_PAUSED ){
835 LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
836 return CAMERA_ERROR_INVALID_STATE;
839 if( handle->capture_resolution_modified ){
840 mm_camcorder_set_attributes(handle->mm_handle, NULL,
841 MMCAM_CAPTURE_WIDTH, handle->capture_width,
842 MMCAM_CAPTURE_HEIGHT, handle->capture_height,
844 handle->capture_resolution_modified = false;
846 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAPTURE_COUNT , 1,NULL);
848 handle->capture_count = 1;
849 handle->is_continuous_shot_break = false;
850 handle->current_capture_count = 0;
851 handle->current_capture_complete_count = 0;
852 handle->is_capture_completed = false;
854 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
855 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
856 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
857 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
858 ret = mm_camcorder_capture_start(handle->mm_handle);
860 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
861 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
862 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
863 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
866 return __convert_camera_error_code(__func__, ret);
869 bool camera_is_supported_continuous_capture(camera_h camera){
870 if( camera == NULL ){
871 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
875 int ret = MM_ERROR_NONE;
876 camera_s * handle = (camera_s*)camera;
878 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_COUNT , &info);
879 set_last_result(__convert_camera_error_code(__func__, ret));
880 if( ret != MM_ERROR_NONE ){
883 if( info.int_range.max > 1){
890 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){
891 if( camera == NULL ){
892 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
893 return CAMERA_ERROR_INVALID_PARAMETER;
896 if( camera_is_supported_continuous_capture(camera) == false ){
897 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
898 return CAMERA_ERROR_NOT_SUPPORTED;
901 if( count < 2 || interval < 0 ){
902 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
903 return CAMERA_ERROR_INVALID_PARAMETER;
906 camera_s * handle = (camera_s*)camera;
908 MMCamcorderStateType state;
909 mm_camcorder_get_state(handle->mm_handle, &state);
910 if( state != MM_CAMCORDER_STATE_PREPARE ){
911 LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
912 return CAMERA_ERROR_INVALID_STATE;
915 int supported_zsl = FALSE;
917 int ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
918 MMCAM_CAPTURE_COUNT, count,
919 MMCAM_CAPTURE_INTERVAL, interval,
922 LOGE("(%x) error set continuous shot attribute", ret);
923 return __convert_camera_error_code(__func__, ret);
926 handle->capture_count = count;
927 handle->is_continuous_shot_break = false;
928 handle->current_capture_count = 0;
929 handle->current_capture_complete_count = 0;
930 handle->is_capture_completed = false;
932 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl, NULL);
934 LOGE("(%x) error get continuous shot attribute", ret);
937 if( !supported_zsl ){
943 mm_camcorder_get_attributes(handle->mm_handle, NULL,
944 MMCAM_CAMERA_WIDTH, &preview_width,
945 MMCAM_CAMERA_HEIGHT, &preview_height,
946 MMCAM_CAPTURE_WIDTH, &capture_width,
947 MMCAM_CAPTURE_HEIGHT, &capture_height,
949 if( preview_width != capture_width || preview_height != capture_height ){
950 mm_camcorder_set_attributes(handle->mm_handle, NULL,
951 MMCAM_CAPTURE_WIDTH, preview_width,
952 MMCAM_CAPTURE_HEIGHT, preview_height,
954 handle->capture_resolution_modified = true;
958 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
959 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
960 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
961 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
963 ret = mm_camcorder_capture_start(handle->mm_handle);
965 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
966 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
967 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
968 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
971 return __convert_camera_error_code(__func__,ret);
975 int camera_stop_continuous_capture(camera_h camera){
976 if( camera == NULL ){
977 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
978 return CAMERA_ERROR_INVALID_PARAMETER;
981 if( camera_is_supported_continuous_capture(camera) == false ){
982 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
983 return CAMERA_ERROR_NOT_SUPPORTED;
986 camera_s *handle = (camera_s*)camera;
989 camera_state_e state;
990 camera_get_state(camera, &state);
992 if( state != CAMERA_STATE_CAPTURING && handle->capture_count > 1 ){
993 LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
994 return CAMERA_ERROR_INVALID_STATE;
997 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, "capture-break-cont-shot", 1, NULL);
998 if( ret == MM_ERROR_NONE ){
999 handle->is_continuous_shot_break = true;
1000 if( handle->current_capture_count > 0 ){
1001 handle->is_capture_completed = true;
1003 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
1006 return __convert_camera_error_code(__func__,ret);
1009 bool camera_is_supported_face_detection(camera_h camera){
1010 if (camera == NULL) {
1011 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1016 int ret = MM_ERROR_NONE;
1017 camera_s *handle = (camera_s *)camera;
1018 MMCamAttrsInfo info;
1020 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
1021 set_last_result(__convert_camera_error_code(__func__, ret));
1022 if( ret != MM_ERROR_NONE ){
1023 LOGE("MMCAM_DETECT_MODE get attr info failed");
1027 if( info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY ){
1028 for( i = 0 ; i < info.int_array.count ; i++ ){
1029 if( info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON ){
1030 LOGD("face detection supported");
1036 LOGD("face detection NOT supported");
1041 bool camera_is_supported_zero_shutter_lag(camera_h camera){
1042 int ret = MM_ERROR_NONE;
1043 int supported_zsl = false;
1044 camera_s *handle = (camera_s *)camera;
1046 if( camera == NULL ){
1047 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1051 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl, NULL);
1052 set_last_result(__convert_camera_error_code(__func__, ret));
1053 if( ret != MM_ERROR_NONE ){
1054 LOGE("MMCAM_SUPPORT_ZSL_CAPTURE get failed");
1058 LOGD("support zero shutter lag : %d", supported_zsl);
1060 return supported_zsl;
1063 bool camera_is_supported_media_packet_preview_cb(camera_h camera){
1064 int ret = MM_ERROR_NONE;
1065 int supported = false;
1066 camera_s *handle = (camera_s *)camera;
1068 if( camera == NULL ){
1069 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1073 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1074 MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, &supported,
1076 set_last_result(__convert_camera_error_code(__func__, ret));
1077 if( ret != MM_ERROR_NONE ){
1078 LOGE("MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB get failed");
1082 LOGD("support media packet preview callback : %d", supported);
1087 int camera_get_device_count(camera_h camera, int *device_count){
1088 int ret = MM_ERROR_NONE;
1089 camera_s *handle = (camera_s *)camera;
1091 if( camera == NULL || device_count == NULL ){
1092 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1093 return CAMERA_ERROR_INVALID_PARAMETER;
1096 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1097 MMCAM_CAMERA_DEVICE_COUNT, device_count,
1100 return __convert_camera_error_code(__func__, ret);
1103 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void * user_data){
1104 if( camera == NULL ){
1105 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1106 return CAMERA_ERROR_INVALID_PARAMETER;
1109 if( camera_is_supported_face_detection(camera) == false ){
1110 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1111 return CAMERA_ERROR_NOT_SUPPORTED;
1114 camera_s * handle = (camera_s*)camera;
1115 camera_state_e state = CAMERA_STATE_NONE;
1117 camera_get_state(camera, &state);
1118 if( state != CAMERA_STATE_PREVIEW ){
1119 LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
1120 return CAMERA_ERROR_INVALID_STATE;
1123 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1124 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON,
1126 if( ret == MM_ERROR_NONE ){
1127 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)callback;
1128 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)user_data;
1129 handle->num_of_faces = 0;
1132 return __convert_camera_error_code(__func__,ret);
1135 int camera_stop_face_detection(camera_h camera){
1136 if( camera == NULL ){
1137 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1138 return CAMERA_ERROR_INVALID_PARAMETER;
1140 camera_s * handle = (camera_s*)camera;
1143 if( camera_is_supported_face_detection(camera) == false ){
1144 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1145 return CAMERA_ERROR_NOT_SUPPORTED;
1148 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF, NULL);
1149 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1150 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1151 handle->num_of_faces = 0;
1152 return __convert_camera_error_code(__func__,ret);
1155 int camera_get_state(camera_h camera, camera_state_e * state){
1156 if( camera == NULL || state == NULL ){
1157 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1158 return CAMERA_ERROR_INVALID_PARAMETER;
1161 camera_s *handle = (camera_s*)camera;
1162 camera_state_e capi_state;
1163 MMCamcorderStateType mmstate ;
1164 mm_camcorder_get_state(handle->mm_handle, &mmstate);
1166 capi_state = __camera_state_convert(mmstate);
1168 if( (handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed) && (handle->current_capture_count > 0 || handle->is_capture_completed) && mmstate == MM_CAMCORDER_STATE_CAPTURING ){
1169 capi_state = CAMERA_STATE_CAPTURED;
1172 *state = capi_state;
1173 return CAMERA_ERROR_NONE;
1176 int camera_start_focusing( camera_h camera, bool continuous ){
1177 if( camera == NULL ){
1178 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1179 return CAMERA_ERROR_INVALID_PARAMETER;
1181 camera_s *handle = (camera_s*)camera;
1183 if( handle->cached_focus_mode != -1 ){
1184 LOGD("apply cached focus mode %d", handle->cached_focus_mode);
1185 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , handle->cached_focus_mode, NULL);
1186 handle->cached_focus_mode = -1;
1190 return __camera_start_continuous_focusing(camera);
1192 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);
1193 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s*)camera)->mm_handle));
1197 int __camera_start_continuous_focusing(camera_h camera){
1198 if( camera == NULL ){
1199 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1200 return CAMERA_ERROR_INVALID_PARAMETER;
1203 camera_s *handle = (camera_s*)camera;
1206 handle->on_continuous_focusing = true;
1207 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , &mode, NULL);
1209 if( mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS )
1210 ret = mm_camcorder_start_focusing(handle->mm_handle);
1212 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS, NULL);
1213 return __convert_camera_error_code(__func__, ret);
1216 int camera_cancel_focusing(camera_h camera){
1217 if( camera == NULL ){
1218 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1219 return CAMERA_ERROR_INVALID_PARAMETER;
1221 camera_s *handle = (camera_s*)camera;
1222 handle->on_continuous_focusing = false;
1223 return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
1225 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display){
1226 int ret = MM_ERROR_NONE;
1227 int set_surface = MM_DISPLAY_SURFACE_X;
1228 void *set_handle = NULL;
1229 camera_s *handle = NULL;
1231 Evas_Object *obj = NULL;
1232 const char *object_type = NULL;
1234 if( camera == NULL ){
1235 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1236 return CAMERA_ERROR_INVALID_PARAMETER;
1239 if( type != CAMERA_DISPLAY_TYPE_NONE && display == NULL ){
1240 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
1241 return CAMERA_ERROR_INVALID_PARAMETER;
1244 handle = (camera_s *)camera;
1245 handle->display_type = type;
1247 if( type == CAMERA_DISPLAY_TYPE_NONE ){
1249 set_surface = MM_DISPLAY_SURFACE_NULL;
1250 handle->display_handle = 0;
1252 LOGD("display type NONE");
1254 obj = (Evas_Object *)display;
1255 object_type = evas_object_type_get(obj);
1257 if( type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win") ){
1258 /* x window overlay surface */
1259 handle->display_handle = (void *)elm_win_xwindow_get(obj);
1260 set_surface = MM_DISPLAY_SURFACE_X;
1261 set_handle = &(handle->display_handle);
1263 LOGD("display type OVERLAY : handle %p, %d", set_handle, (int)handle->display_handle);
1264 } else if( type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image") ) {
1265 /* evas object surface */
1266 handle->display_handle = display;
1267 set_surface = MM_DISPLAY_SURFACE_EVAS;
1268 set_handle = display;
1270 LOGD("display type EVAS : handle %p", set_handle);
1272 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
1273 return CAMERA_ERROR_INVALID_PARAMETER;
1276 LOGE("failed to get evas object type from %p", obj);
1277 return CAMERA_ERROR_INVALID_PARAMETER;
1281 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1282 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
1283 MMCAM_DISPLAY_SURFACE, set_surface,
1286 if( ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE ){
1287 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *), NULL);
1290 return __convert_camera_error_code(__func__, ret);
1293 int camera_set_preview_resolution(camera_h camera, int width, int height){
1294 if( camera == NULL ){
1295 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1296 return CAMERA_ERROR_INVALID_PARAMETER;
1299 camera_s * handle = (camera_s*)camera;
1300 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width ,MMCAM_CAMERA_HEIGHT ,height, NULL);
1301 return __convert_camera_error_code(__func__, ret);
1304 int camera_set_capture_resolution(camera_h camera, int width, int height){
1305 if( camera == NULL ){
1306 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1307 return CAMERA_ERROR_INVALID_PARAMETER;
1311 camera_s * handle = (camera_s*)camera;
1312 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_WIDTH, width ,MMCAM_CAPTURE_HEIGHT , height, NULL);
1314 if( ret == MM_ERROR_NONE ){
1315 handle->capture_width = width;
1316 handle->capture_height = height;
1319 return __convert_camera_error_code(__func__, ret);
1322 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format){
1323 if( camera == NULL ){
1324 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1325 return CAMERA_ERROR_INVALID_PARAMETER;
1329 camera_s * handle = (camera_s*)camera;
1330 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL);
1332 return __convert_camera_error_code(__func__, ret);
1335 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format){
1336 if( camera == NULL ){
1337 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1338 return CAMERA_ERROR_INVALID_PARAMETER;
1342 camera_s * handle = (camera_s*)camera;
1344 if( format == CAMERA_PIXEL_FORMAT_UYVY ){
1345 bool supported_ITLV_UYVY = false;
1346 MMCamAttrsInfo supported_format;
1347 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1349 for( i=0 ; i < supported_format.int_array.count ; i++ ){
1350 if( supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1351 supported_ITLV_UYVY = true;
1353 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1354 MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ? MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY,
1357 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL);
1360 return __convert_camera_error_code(__func__, ret);
1363 int camera_get_preview_resolution(camera_h camera, int *width, int *height){
1364 if( camera == NULL || width == NULL || height == NULL ){
1365 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1366 return CAMERA_ERROR_INVALID_PARAMETER;
1370 camera_s * handle = (camera_s*)camera;
1371 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1372 MMCAM_CAMERA_WIDTH, width,
1373 MMCAM_CAMERA_HEIGHT, height,
1376 return __convert_camera_error_code(__func__, ret);
1379 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation){
1380 if( camera == NULL ){
1381 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1382 return CAMERA_ERROR_INVALID_PARAMETER;
1385 if( rotation > CAMERA_ROTATION_270 )
1386 return CAMERA_ERROR_INVALID_PARAMETER;
1389 camera_s * handle = (camera_s*)camera;
1391 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1392 MMCAM_DISPLAY_ROTATION, rotation,
1395 return __convert_camera_error_code(__func__, ret);
1398 int camera_get_display_rotation( camera_h camera, camera_rotation_e *rotation){
1399 if( camera == NULL || rotation == NULL ){
1400 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1401 return CAMERA_ERROR_INVALID_PARAMETER;
1405 camera_s * handle = (camera_s*)camera;
1407 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL);
1408 return __convert_camera_error_code(__func__, ret);
1411 int camera_set_display_flip(camera_h camera, camera_flip_e flip){
1412 if( camera == NULL ){
1413 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1414 return CAMERA_ERROR_INVALID_PARAMETER;
1417 if( flip > CAMERA_FLIP_BOTH )
1418 return CAMERA_ERROR_INVALID_PARAMETER;
1421 camera_s * handle = (camera_s*)camera;
1423 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1424 MMCAM_DISPLAY_FLIP, flip,
1427 return __convert_camera_error_code(__func__, ret);
1430 int camera_get_display_flip(camera_h camera, camera_flip_e *flip){
1431 if( camera == NULL || flip == NULL ){
1432 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1433 return CAMERA_ERROR_INVALID_PARAMETER;
1437 camera_s * handle = (camera_s*)camera;
1439 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1440 MMCAM_DISPLAY_FLIP, flip,
1443 return __convert_camera_error_code(__func__, ret);
1446 int camera_set_display_visible(camera_h camera, bool visible){
1447 if( camera == NULL ){
1448 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1449 return CAMERA_ERROR_INVALID_PARAMETER;
1453 camera_s * handle = (camera_s*)camera;
1455 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1456 MMCAM_DISPLAY_VISIBLE, visible,
1459 return __convert_camera_error_code(__func__, ret);
1462 int camera_is_display_visible(camera_h camera, bool* visible){
1463 if( camera == NULL || visible == NULL ){
1464 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1465 return CAMERA_ERROR_INVALID_PARAMETER;
1470 camera_s * handle = (camera_s*)camera;
1472 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1473 MMCAM_DISPLAY_VISIBLE, &result,
1476 if( ret == MM_ERROR_NONE)
1479 return __convert_camera_error_code(__func__, ret);
1482 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode){
1483 if( camera == NULL ){
1484 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1485 return CAMERA_ERROR_INVALID_PARAMETER;
1488 if( mode > CAMERA_DISPLAY_MODE_CROPPED_FULL )
1489 return CAMERA_ERROR_INVALID_PARAMETER;
1492 camera_s * handle = (camera_s*)camera;
1494 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1495 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1498 return __convert_camera_error_code(__func__, ret);
1501 int camera_get_display_mode(camera_h camera, camera_display_mode_e* mode){
1502 if( camera == NULL || mode == NULL ){
1503 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1504 return CAMERA_ERROR_INVALID_PARAMETER;
1508 camera_s * handle = (camera_s*)camera;
1510 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1511 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1514 return __convert_camera_error_code(__func__, ret);
1517 int camera_get_capture_resolution(camera_h camera, int *width, int *height){
1518 if( camera == NULL || width== NULL || height == NULL){
1519 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1520 return CAMERA_ERROR_INVALID_PARAMETER;
1523 camera_s * handle = (camera_s*)camera;
1524 *width = handle->capture_width;
1525 *height = handle->capture_height;
1527 return CAMERA_ERROR_NONE;
1530 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format){
1531 if( camera == NULL || format == NULL ){
1532 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1533 return CAMERA_ERROR_INVALID_PARAMETER;
1537 camera_s * handle = (camera_s*)camera;
1539 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1540 MMCAM_CAPTURE_FORMAT, format,
1543 return __convert_camera_error_code(__func__, ret);
1546 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format){
1547 if( camera == NULL || format == NULL ){
1548 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1549 return CAMERA_ERROR_INVALID_PARAMETER;
1553 camera_s * handle = (camera_s*)camera;
1555 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1556 MMCAM_CAMERA_FORMAT, format,
1559 if( (MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1560 *format = CAMERA_PIXEL_FORMAT_UYVY;
1562 return __convert_camera_error_code(__func__, ret);
1565 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void* user_data){
1566 if( camera == NULL || callback == NULL ){
1567 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1568 return CAMERA_ERROR_INVALID_PARAMETER;
1571 camera_s *handle = (camera_s *)camera;
1572 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)callback;
1573 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)user_data;
1575 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1576 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1579 return CAMERA_ERROR_NONE;
1582 int camera_unset_preview_cb( camera_h camera){
1583 if( camera == NULL ){
1584 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1585 return CAMERA_ERROR_INVALID_PARAMETER;
1588 camera_s *handle = (camera_s *)camera;
1590 if( handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL ){
1591 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1592 (mm_camcorder_video_stream_callback)NULL,
1596 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1597 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1599 return CAMERA_ERROR_NONE;
1602 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void* user_data){
1603 if( camera == NULL ){
1604 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
1605 return CAMERA_ERROR_INVALID_PARAMETER;
1608 if( camera_is_supported_media_packet_preview_cb(camera) == false ){
1609 LOGE("NOT SUPPORTED");
1610 return CAMERA_ERROR_NOT_SUPPORTED;
1613 if( callback == NULL ){
1614 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
1615 return CAMERA_ERROR_INVALID_PARAMETER;
1618 camera_s *handle = (camera_s *)camera;
1619 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)callback;
1620 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)user_data;
1622 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1623 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1626 return CAMERA_ERROR_NONE;
1629 int camera_unset_media_packet_preview_cb(camera_h camera){
1630 if( camera == NULL ){
1631 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1632 return CAMERA_ERROR_INVALID_PARAMETER;
1635 if( camera_is_supported_media_packet_preview_cb(camera) == false ){
1636 LOGE("NOT SUPPORTED");
1637 return CAMERA_ERROR_NOT_SUPPORTED;
1640 camera_s *handle = (camera_s *)camera;
1642 if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] == NULL ){
1643 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1644 (mm_camcorder_video_stream_callback)NULL,
1648 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void*)NULL;
1649 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void*)NULL;
1651 return CAMERA_ERROR_NONE;
1654 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data){
1655 if( camera == NULL || callback == NULL ){
1656 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1657 return CAMERA_ERROR_INVALID_PARAMETER;
1660 camera_s * handle = (camera_s*)camera;
1661 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)callback;
1662 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)user_data;
1664 return CAMERA_ERROR_NONE;
1666 int camera_unset_state_changed_cb(camera_h camera){
1667 if( camera == NULL ){
1668 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1669 return CAMERA_ERROR_INVALID_PARAMETER;
1672 camera_s * handle = (camera_s*)camera;
1673 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1674 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1676 return CAMERA_ERROR_NONE;
1679 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data){
1680 if( camera == NULL || callback == NULL ){
1681 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1682 return CAMERA_ERROR_INVALID_PARAMETER;
1685 camera_s * handle = (camera_s*)camera;
1686 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)callback;
1687 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)user_data;
1689 return CAMERA_ERROR_NONE;
1692 int camera_unset_interrupted_cb(camera_h camera){
1693 if( camera == NULL ){
1694 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1695 return CAMERA_ERROR_INVALID_PARAMETER;
1698 camera_s * handle = (camera_s*)camera;
1699 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1700 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1702 return CAMERA_ERROR_NONE;
1705 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data){
1706 if( camera == NULL || callback == NULL ){
1707 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1708 return CAMERA_ERROR_INVALID_PARAMETER;
1711 camera_s * handle = (camera_s*)camera;
1712 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)callback;
1713 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)user_data;
1715 return CAMERA_ERROR_NONE;
1717 int camera_unset_focus_changed_cb(camera_h camera){
1718 if( camera == NULL ){
1719 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1720 return CAMERA_ERROR_INVALID_PARAMETER;
1723 camera_s * handle = (camera_s*)camera;
1724 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1725 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1727 return CAMERA_ERROR_NONE;
1730 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data){
1731 if( camera == NULL || callback == NULL ){
1732 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1733 return CAMERA_ERROR_INVALID_PARAMETER;
1736 camera_s * handle = (camera_s*)camera;
1737 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)callback;
1738 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)user_data;
1740 return CAMERA_ERROR_NONE;
1743 int camera_unset_error_cb(camera_h camera){
1744 if( camera == NULL ){
1745 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1746 return CAMERA_ERROR_INVALID_PARAMETER;
1749 camera_s * handle = (camera_s*)camera;
1750 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1751 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1753 return CAMERA_ERROR_NONE;
1756 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data){
1757 if( camera == NULL || foreach_cb == NULL ){
1758 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1759 return CAMERA_ERROR_INVALID_PARAMETER;
1763 camera_s * handle = (camera_s*)camera;
1764 MMCamAttrsInfo preview_width;
1765 MMCamAttrsInfo preview_height;
1766 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH , &preview_width);
1767 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT , &preview_height);
1769 if( ret != CAMERA_ERROR_NONE )
1770 return __convert_camera_error_code(__func__, ret);
1773 for( i=0 ; i < preview_width.int_array.count ; i++ ){
1774 if( !foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i],user_data) )
1778 return CAMERA_ERROR_NONE;
1781 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data){
1782 if( camera == NULL || foreach_cb == NULL){
1783 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1784 return CAMERA_ERROR_INVALID_PARAMETER;
1787 camera_s * handle = (camera_s*)camera;
1788 MMCamAttrsInfo capture_width;
1789 MMCamAttrsInfo capture_height;
1790 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH , &capture_width);
1791 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT , &capture_height);
1793 if( ret != CAMERA_ERROR_NONE )
1794 return __convert_camera_error_code(__func__, ret);
1797 for( i=0 ; i < capture_width.int_array.count ; i++)
1799 if ( !foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i],user_data) )
1802 return CAMERA_ERROR_NONE;
1805 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data){
1806 if( camera == NULL || foreach_cb == NULL){
1807 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1808 return CAMERA_ERROR_INVALID_PARAMETER;
1812 camera_s * handle = (camera_s*)camera;
1813 MMCamAttrsInfo format;
1814 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT , &format);
1816 if( ret != CAMERA_ERROR_NONE )
1817 return __convert_camera_error_code(__func__, ret);
1820 for( i=0 ; i < format.int_array.count ; i++ ){
1821 if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1822 if ( !foreach_cb(format.int_array.array[i], user_data) )
1826 return CAMERA_ERROR_NONE;
1829 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data){
1830 if( camera == NULL || foreach_cb == NULL ){
1831 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1832 return CAMERA_ERROR_INVALID_PARAMETER;
1836 camera_s * handle = (camera_s*)camera;
1837 MMCamAttrsInfo format;
1838 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &format);
1840 if( ret != CAMERA_ERROR_NONE )
1841 return __convert_camera_error_code(__func__, ret);
1844 for( i=0 ; i < format.int_array.count ; i++ ){
1845 if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY /* || format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_NV12 */)
1846 if ( !foreach_cb(format.int_array.array[i], user_data) )
1850 return CAMERA_ERROR_NONE;
1853 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height){
1854 if( camera == NULL || width == NULL || height == NULL ){
1855 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1856 return CAMERA_ERROR_INVALID_PARAMETER;
1859 enum MMCamcorderPreviewType wide;
1860 int capture_w, capture_h;
1863 camera_s * handle = (camera_s*)camera;
1865 camera_get_capture_resolution(camera, &capture_w, &capture_h);
1866 ratio = (double)capture_w/(double)capture_h;
1868 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
1869 } else if( ratio == 1.0 ){
1870 wide = MM_CAMCORDER_PREVIEW_TYPE_SQUARE;
1872 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
1875 MMCamAttrsInfo width_info, height_info;
1876 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH , &width_info);
1877 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
1880 return __convert_camera_error_code(__func__, ret);
1882 if( width && (unsigned int)width_info.int_array.count > wide ){
1883 *width = width_info.int_array.array[wide];
1885 LOGE("there is no width value for resolution %dx%d type %d", capture_w, capture_h, wide);
1886 return CAMERA_ERROR_INVALID_OPERATION;
1889 if( height && (unsigned int)height_info.int_array.count > wide ){
1890 *height = height_info.int_array.array[wide];
1892 LOGE("there is no height value for resolution %dx%d type %d", capture_w, capture_h, wide);
1893 return CAMERA_ERROR_INVALID_OPERATION;
1896 LOGI("recommend resolution %dx%d, type %d", *width, *height, wide);
1898 return CAMERA_ERROR_NONE;
1901 int camera_attr_get_lens_orientation(camera_h camera, int *angle){
1902 if( camera == NULL || angle == NULL ){
1903 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1904 return CAMERA_ERROR_INVALID_PARAMETER;
1908 camera_s * handle = (camera_s*)camera;
1910 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation , NULL);
1913 case MM_DISPLAY_ROTATION_NONE:
1916 case MM_DISPLAY_ROTATION_90:
1919 case MM_DISPLAY_ROTATION_180:
1922 case MM_DISPLAY_ROTATION_270:
1930 return __convert_camera_error_code(__func__, ret);
1933 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode){
1934 if( camera == NULL ){
1935 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1936 return CAMERA_ERROR_INVALID_PARAMETER;
1940 camera_s * handle = (camera_s*)camera;
1941 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE, mode, NULL);
1943 return __convert_camera_error_code(__func__, ret);
1946 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode){
1947 if( camera == NULL || mode == NULL ){
1948 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1949 return CAMERA_ERROR_INVALID_PARAMETER;
1953 camera_s * handle = (camera_s*)camera;
1954 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE , mode, NULL);
1956 return __convert_camera_error_code(__func__, ret);
1959 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data){
1960 if( camera == NULL || foreach_cb == NULL ){
1961 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1962 return CAMERA_ERROR_INVALID_PARAMETER;
1966 camera_s * handle = (camera_s*)camera;
1967 MMCamAttrsInfo info;
1968 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DISPLAY_MODE , &info);
1970 if( ret != CAMERA_ERROR_NONE )
1971 return __convert_camera_error_code(__func__, ret);
1974 for (i=0 ; i < info.int_array.count ; i++ ){
1975 if ( !foreach_cb(info.int_array.array[i],user_data) )
1979 return CAMERA_ERROR_NONE;
1982 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps){
1983 if( camera == NULL ){
1984 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1985 return CAMERA_ERROR_INVALID_PARAMETER;
1989 camera_s * handle = (camera_s*)camera;
1991 if( fps == CAMERA_ATTR_FPS_AUTO ){
1992 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1993 MMCAM_CAMERA_FPS_AUTO, 1,
1996 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1997 MMCAM_CAMERA_FPS_AUTO, 0,
1998 MMCAM_CAMERA_FPS, fps,
2002 return __convert_camera_error_code(__func__, ret);
2005 int camera_attr_set_image_quality(camera_h camera, int quality){
2006 if( camera == NULL ){
2007 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2008 return CAMERA_ERROR_INVALID_PARAMETER;
2012 camera_s * handle = (camera_s*)camera;
2013 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
2015 return __convert_camera_error_code(__func__, ret);
2018 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps){
2019 if( camera == NULL || fps == NULL ){
2020 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2021 return CAMERA_ERROR_INVALID_PARAMETER;
2027 camera_s * handle = (camera_s*)camera;
2029 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS , &mm_fps, MMCAM_CAMERA_FPS_AUTO , &is_auto, NULL);
2032 *fps = CAMERA_ATTR_FPS_AUTO;
2036 return __convert_camera_error_code(__func__, ret);
2039 int camera_attr_get_image_quality(camera_h camera, int *quality){
2040 if( camera == NULL || quality == NULL ){
2041 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2042 return CAMERA_ERROR_INVALID_PARAMETER;
2046 camera_s * handle = (camera_s*)camera;
2047 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
2049 return __convert_camera_error_code(__func__, ret);
2052 int camera_attr_set_zoom(camera_h camera, int zoom){
2053 if( camera == NULL ){
2054 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2055 return CAMERA_ERROR_INVALID_PARAMETER;
2059 camera_s * handle = (camera_s*)camera;
2060 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL);
2062 return __convert_camera_error_code(__func__, ret);
2065 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode){
2066 if( camera == NULL ){
2067 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2068 return CAMERA_ERROR_INVALID_PARAMETER;
2071 int ret = CAMERA_ERROR_INVALID_PARAMETER;
2072 camera_s * handle = (camera_s*)camera;
2075 bool should_change_focus_mode = false;
2076 mm_camcorder_get_attributes(handle->mm_handle, NULL,
2077 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2080 if( focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO && focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO )
2081 should_change_focus_mode = true;
2083 if( mode != CAMERA_ATTR_AF_NONE && focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && !handle->on_continuous_focusing ){
2084 handle->cached_focus_mode = mode;
2085 LOGD("af mode will be set actually start focusing");
2086 return __convert_camera_error_code(__func__, 0);
2088 handle->cached_focus_mode = -1;
2091 if( mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode ){
2092 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO, NULL);
2096 case CAMERA_ATTR_AF_NONE:
2097 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2098 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
2099 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NONE,
2102 case CAMERA_ATTR_AF_NORMAL:
2103 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2104 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NORMAL,
2107 case CAMERA_ATTR_AF_MACRO:
2108 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2109 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_MACRO,
2112 case CAMERA_ATTR_AF_FULL:
2113 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2114 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_FULL,
2121 return __convert_camera_error_code(__func__, ret);
2124 int camera_attr_set_af_area(camera_h camera, int x, int y){
2125 if( camera == NULL ){
2126 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2127 return CAMERA_ERROR_INVALID_PARAMETER;
2130 int ret = CAMERA_ERROR_INVALID_PARAMETER;
2131 camera_s * handle = (camera_s*)camera;
2132 camera_attr_af_mode_e mode;
2133 camera_attr_get_af_mode(camera, &mode);
2135 if( mode == CAMERA_ATTR_AF_NONE ){
2136 LOGE("INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE",CAMERA_ERROR_INVALID_OPERATION);
2137 return CAMERA_ERROR_INVALID_OPERATION;
2140 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2141 MMCAM_CAMERA_AF_TOUCH_X, x,
2142 MMCAM_CAMERA_AF_TOUCH_Y, y,
2145 if( ret == MM_ERROR_NONE )
2146 handle->focus_area_valid = true;
2148 return __convert_camera_error_code(__func__, ret);
2151 int camera_attr_clear_af_area(camera_h camera){
2152 if( camera == NULL ){
2153 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2154 return CAMERA_ERROR_INVALID_PARAMETER;
2157 camera_s * handle = (camera_s*)camera;
2158 handle->focus_area_valid = false;
2160 return CAMERA_ERROR_NONE;
2163 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode){
2164 if( camera == NULL ){
2165 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2166 return CAMERA_ERROR_INVALID_PARAMETER;
2169 int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, //CAMCORDER_EXPOSURE_MODE_OFF
2170 MM_CAMCORDER_AUTO_EXPOSURE_ALL, //CAMCORDER_EXPOSURE_MODE_ALL
2171 MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, //CAMCORDER_EXPOSURE_MODE_CENTER
2172 MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, //CAMCORDER_EXPOSURE_MODE_SPOT
2173 MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1,//CAMCORDER_EXPOSURE_MODE_CUSTOM
2177 camera_s * handle = (camera_s*)camera;
2178 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2179 MMCAM_CAMERA_EXPOSURE_MODE, maptable[abs(mode%5)],
2182 return __convert_camera_error_code(__func__, ret);
2185 int camera_attr_set_exposure(camera_h camera, int value){
2186 if( camera == NULL ){
2187 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2188 return CAMERA_ERROR_INVALID_PARAMETER;
2192 camera_s * handle = (camera_s*)camera;
2193 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2194 MMCAM_CAMERA_EXPOSURE_VALUE, value,
2197 return __convert_camera_error_code(__func__, ret);
2200 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso){
2201 if( camera == NULL ){
2202 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2203 return CAMERA_ERROR_INVALID_PARAMETER;
2207 camera_s * handle = (camera_s*)camera;
2208 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2209 MMCAM_CAMERA_ISO, iso,
2212 return __convert_camera_error_code(__func__, ret);
2215 int camera_attr_set_brightness(camera_h camera, int level){
2216 if( camera == NULL ){
2217 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2218 return CAMERA_ERROR_INVALID_PARAMETER;
2222 camera_s * handle = (camera_s*)camera;
2223 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2224 MMCAM_FILTER_BRIGHTNESS, level,
2227 return __convert_camera_error_code(__func__, ret);
2230 int camera_attr_set_contrast(camera_h camera, int level){
2231 if( camera == NULL ){
2232 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2233 return CAMERA_ERROR_INVALID_PARAMETER;
2237 camera_s * handle = (camera_s*)camera;
2238 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2239 MMCAM_FILTER_CONTRAST, level,
2242 return __convert_camera_error_code(__func__, ret);
2245 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb){
2246 if( camera == NULL ){
2247 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2248 return CAMERA_ERROR_INVALID_PARAMETER;
2252 camera_s * handle = (camera_s*)camera;
2253 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2254 MMCAM_FILTER_WB, wb,
2257 return __convert_camera_error_code(__func__, ret);
2260 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect){
2261 if( camera == NULL ){
2262 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2263 return CAMERA_ERROR_INVALID_PARAMETER;
2267 camera_s * handle = (camera_s*)camera;
2268 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2269 MMCAM_FILTER_COLOR_TONE, effect,
2272 return __convert_camera_error_code(__func__, ret);
2275 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode){
2276 if( camera == NULL ){
2277 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2278 return CAMERA_ERROR_INVALID_PARAMETER;
2282 camera_s * handle = (camera_s*)camera;
2283 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2284 MMCAM_FILTER_SCENE_MODE, mode,
2287 return __convert_camera_error_code(__func__, ret);
2290 int camera_attr_enable_tag(camera_h camera, bool enable){
2291 if( camera == NULL ){
2292 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2293 return CAMERA_ERROR_INVALID_PARAMETER;
2297 camera_s * handle = (camera_s*)camera;
2298 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2299 MMCAM_TAG_ENABLE, enable,
2302 return __convert_camera_error_code(__func__, ret);
2305 int camera_attr_set_tag_image_description(camera_h camera, const char *description){
2306 if( camera == NULL ){
2307 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2308 return CAMERA_ERROR_INVALID_PARAMETER;
2312 camera_s * handle = (camera_s*)camera;
2313 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2314 MMCAM_TAG_IMAGE_DESCRIPTION, description, strlen(description),
2317 return __convert_camera_error_code(__func__, ret);
2320 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation){
2321 if( camera == NULL ){
2322 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2323 return CAMERA_ERROR_INVALID_PARAMETER;
2327 camera_s * handle = (camera_s*)camera;
2328 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2329 MMCAM_TAG_ORIENTATION, orientation,
2332 return __convert_camera_error_code(__func__, ret);
2335 int camera_attr_set_tag_software(camera_h camera, const char *software){
2336 if( camera == NULL ){
2337 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2338 return CAMERA_ERROR_INVALID_PARAMETER;
2342 camera_s * handle = (camera_s*)camera;
2343 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2344 MMCAM_TAG_SOFTWARE, software, strlen(software),
2347 return __convert_camera_error_code(__func__, ret);
2350 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude){
2351 if( camera == NULL ){
2352 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2353 return CAMERA_ERROR_INVALID_PARAMETER;
2357 camera_s * handle = (camera_s*)camera;
2358 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2359 MMCAM_TAG_GPS_ENABLE, 1,
2360 MMCAM_TAG_LATITUDE, latitude,
2361 MMCAM_TAG_LONGITUDE, longitude,
2362 MMCAM_TAG_ALTITUDE, altitude,
2365 return __convert_camera_error_code(__func__, ret);
2368 int camera_attr_remove_geotag(camera_h camera){
2369 if( camera == NULL ){
2370 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2371 return CAMERA_ERROR_INVALID_PARAMETER;
2375 camera_s * handle = (camera_s*)camera;
2376 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2377 MMCAM_TAG_GPS_ENABLE, 0,
2380 return __convert_camera_error_code(__func__, ret);
2383 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode){
2384 if( camera == NULL ){
2385 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2386 return CAMERA_ERROR_INVALID_PARAMETER;
2390 camera_s * handle = (camera_s*)camera;
2391 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2392 MMCAM_STROBE_MODE, mode,
2395 return __convert_camera_error_code(__func__, ret);
2399 int camera_attr_get_zoom(camera_h camera, int *zoom){
2400 if( camera == NULL || zoom == NULL ){
2401 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2402 return CAMERA_ERROR_INVALID_PARAMETER;
2406 camera_s * handle = (camera_s*)camera;
2407 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2408 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2411 return __convert_camera_error_code(__func__, ret);
2414 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max){
2415 if( camera == NULL || min == NULL || max == NULL ){
2416 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2417 return CAMERA_ERROR_INVALID_PARAMETER;
2421 camera_s * handle = (camera_s*)camera;
2422 MMCamAttrsInfo ainfo;
2423 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
2426 *min = ainfo.int_range.min;
2428 *max = ainfo.int_range.max;
2430 return __convert_camera_error_code(__func__, ret);
2433 int camera_attr_get_af_mode( camera_h camera, camera_attr_af_mode_e *mode){
2434 if( camera == NULL || mode == NULL ){
2435 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2436 return CAMERA_ERROR_INVALID_PARAMETER;
2443 camera_s * handle = (camera_s*)camera;
2444 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2445 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2446 MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
2447 MMCAM_DETECT_MODE, &detect_mode,
2450 if( ret == CAMERA_ERROR_NONE ){
2451 switch( focus_mode ){
2452 case MM_CAMCORDER_FOCUS_MODE_NONE :
2453 case MM_CAMCORDER_FOCUS_MODE_PAN :
2454 case MM_CAMCORDER_FOCUS_MODE_MANUAL :
2455 *mode = CAMERA_ATTR_AF_NONE;
2457 case MM_CAMCORDER_FOCUS_MODE_AUTO:
2458 case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
2459 case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
2460 switch ( af_range ){
2461 case MM_CAMCORDER_AUTO_FOCUS_NONE :
2462 *mode = CAMERA_ATTR_AF_NORMAL;
2464 case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
2465 *mode = CAMERA_ATTR_AF_NORMAL;
2467 case MM_CAMCORDER_AUTO_FOCUS_MACRO:
2468 *mode = CAMERA_ATTR_AF_MACRO;
2470 case MM_CAMCORDER_AUTO_FOCUS_FULL:
2471 *mode = CAMERA_ATTR_AF_FULL;
2474 *mode = CAMERA_ATTR_AF_NORMAL;
2479 *mode = CAMERA_ATTR_AF_NONE;
2484 return __convert_camera_error_code(__func__, ret);
2487 int camera_attr_get_exposure_mode( camera_h camera, camera_attr_exposure_mode_e *mode){
2488 if( camera == NULL|| mode == NULL){
2489 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2490 return CAMERA_ERROR_INVALID_PARAMETER;
2494 CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
2495 CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
2496 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
2497 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
2498 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
2499 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
2500 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
2501 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
2502 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM //MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
2506 camera_s * handle = (camera_s*)camera;
2507 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_EXPOSURE_MODE, &exposure_mode, NULL);
2508 if( ret == CAMERA_ERROR_NONE ){
2509 *mode = maptable[abs(exposure_mode%9)];
2512 return __convert_camera_error_code(__func__, ret);
2515 int camera_attr_get_exposure(camera_h camera, int *value){
2516 if( camera == NULL || value == NULL ){
2517 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2518 return CAMERA_ERROR_INVALID_PARAMETER;
2522 camera_s * handle = (camera_s*)camera;
2523 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_EXPOSURE_VALUE, value, NULL);
2525 return __convert_camera_error_code(__func__, ret);
2528 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max){
2529 if( camera == NULL || min == NULL || max == NULL ){
2530 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2531 return CAMERA_ERROR_INVALID_PARAMETER;
2535 camera_s * handle = (camera_s*)camera;
2536 MMCamAttrsInfo ainfo;
2537 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
2540 *min = ainfo.int_range.min;
2542 *max = ainfo.int_range.max;
2544 return __convert_camera_error_code(__func__, ret);
2547 int camera_attr_get_iso( camera_h camera, camera_attr_iso_e *iso){
2548 if( camera == NULL || iso == NULL ){
2549 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2550 return CAMERA_ERROR_INVALID_PARAMETER;
2554 camera_s * handle = (camera_s*)camera;
2555 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2556 MMCAM_CAMERA_ISO, iso,
2559 return __convert_camera_error_code(__func__, ret);
2562 int camera_attr_get_brightness(camera_h camera, int *level){
2563 if( camera == NULL || level == NULL ){
2564 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2565 return CAMERA_ERROR_INVALID_PARAMETER;
2569 camera_s * handle = (camera_s*)camera;
2570 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2571 MMCAM_FILTER_BRIGHTNESS, level,
2574 return __convert_camera_error_code(__func__, ret);
2577 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max){
2578 if( camera == NULL || min == NULL || max == NULL ){
2579 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2580 return CAMERA_ERROR_INVALID_PARAMETER;
2584 camera_s * handle = (camera_s*)camera;
2585 MMCamAttrsInfo ainfo;
2586 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
2589 *min = ainfo.int_range.min;
2591 *max = ainfo.int_range.max;
2593 return __convert_camera_error_code(__func__, ret);
2596 int camera_attr_get_contrast(camera_h camera, int *level){
2597 if( camera == NULL || level == NULL ){
2598 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2599 return CAMERA_ERROR_INVALID_PARAMETER;
2603 camera_s * handle = (camera_s*)camera;
2604 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2605 MMCAM_FILTER_CONTRAST, level,
2608 return __convert_camera_error_code(__func__, ret);
2611 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max){
2612 if( camera == NULL || min == NULL || max == NULL ){
2613 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2614 return CAMERA_ERROR_INVALID_PARAMETER;
2618 camera_s * handle = (camera_s*)camera;
2619 MMCamAttrsInfo ainfo;
2620 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
2623 *min = ainfo.int_range.min;
2625 *max = ainfo.int_range.max;
2627 return __convert_camera_error_code(__func__, ret);
2630 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb){
2631 if( camera == NULL || wb == NULL ){
2632 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2633 return CAMERA_ERROR_INVALID_PARAMETER;
2637 camera_s * handle = (camera_s*)camera;
2638 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2639 MMCAM_FILTER_WB, wb,
2642 return __convert_camera_error_code(__func__, ret);
2645 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect){
2646 if( camera == NULL || effect == NULL ){
2647 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2648 return CAMERA_ERROR_INVALID_PARAMETER;
2652 camera_s * handle = (camera_s*)camera;
2654 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2655 MMCAM_FILTER_COLOR_TONE, &tone,
2658 if( ret != CAMERA_ERROR_NONE )
2659 return __convert_camera_error_code(__func__, ret);
2661 *effect = (camera_attr_effect_mode_e)tone;
2663 return __convert_camera_error_code(__func__, ret);
2666 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode){
2667 if( camera == NULL || mode == NULL ){
2668 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2669 return CAMERA_ERROR_INVALID_PARAMETER;
2673 camera_s * handle = (camera_s*)camera;
2674 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2675 MMCAM_FILTER_SCENE_MODE, mode,
2678 return __convert_camera_error_code(__func__, ret);
2681 int camera_attr_is_enabled_tag(camera_h camera, bool *enable){
2682 if( camera == NULL || enable == NULL ){
2683 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2684 return CAMERA_ERROR_INVALID_PARAMETER;
2688 camera_s * handle = (camera_s*)camera;
2690 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2691 MMCAM_TAG_ENABLE, enable,
2694 return __convert_camera_error_code(__func__, ret);
2697 int camera_attr_get_tag_image_description(camera_h camera, char **description){
2698 if( camera == NULL || description == NULL ){
2699 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2700 return CAMERA_ERROR_INVALID_PARAMETER;
2704 camera_s * handle = (camera_s*)camera;
2705 char *ndescription = NULL;
2707 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_TAG_IMAGE_DESCRIPTION, &ndescription, &desc_size, NULL);
2709 if( ret == CAMERA_ERROR_NONE ){
2710 if( ndescription != NULL )
2711 *description = strdup(ndescription);
2713 *description = strdup("");
2716 return __convert_camera_error_code(__func__, ret);
2719 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation){
2720 if( camera == NULL || orientation == NULL ){
2721 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2722 return CAMERA_ERROR_INVALID_PARAMETER;
2726 camera_s * handle = (camera_s*)camera;
2727 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2728 MMCAM_TAG_ORIENTATION, orientation,
2731 return __convert_camera_error_code(__func__, ret);
2734 int camera_attr_get_tag_software(camera_h camera, char **software){
2735 if( camera == NULL || software == NULL ){
2736 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2737 return CAMERA_ERROR_INVALID_PARAMETER;
2741 camera_s * handle = (camera_s*)camera;
2745 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_TAG_SOFTWARE, &soft, &soft_size, NULL);
2747 if( ret == CAMERA_ERROR_NONE ){
2749 *software = strdup(soft);
2751 *software = strdup("");
2754 return __convert_camera_error_code(__func__, ret);
2757 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude){
2758 if( camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL ){
2759 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2760 return CAMERA_ERROR_INVALID_PARAMETER;
2764 camera_s * handle = (camera_s*)camera;
2765 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2766 MMCAM_TAG_LATITUDE, latitude,
2767 MMCAM_TAG_LONGITUDE, longitude,
2768 MMCAM_TAG_ALTITUDE, altitude,
2771 return __convert_camera_error_code(__func__, ret);
2774 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode){
2775 if( camera == NULL || mode == NULL ){
2776 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2777 return CAMERA_ERROR_INVALID_PARAMETER;
2781 camera_s * handle = (camera_s*)camera;
2782 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2783 MMCAM_STROBE_MODE, mode,
2786 return __convert_camera_error_code(__func__, ret);
2789 int camera_attr_foreach_supported_af_mode( camera_h camera, camera_attr_supported_af_mode_cb foreach_cb , void *user_data){
2790 if( camera == NULL || foreach_cb == NULL ){
2791 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2792 return CAMERA_ERROR_INVALID_PARAMETER;
2797 camera_s * handle = (camera_s*)camera;
2798 MMCamAttrsInfo af_range;
2799 MMCamAttrsInfo focus_mode;
2801 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE, &af_range);
2802 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE, &focus_mode);
2804 if( ret != CAMERA_ERROR_NONE )
2805 return __convert_camera_error_code(__func__, ret);
2807 for( i=0 ; i < af_range.int_array.count ; i++ ) {
2808 if( !foreach_cb(af_range.int_array.array[i],user_data) )
2814 return CAMERA_ERROR_NONE;
2817 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data){
2818 if( camera == NULL || foreach_cb == NULL ){
2819 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2820 return CAMERA_ERROR_INVALID_PARAMETER;
2824 CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
2825 CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
2826 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
2827 -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
2828 -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
2829 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
2830 -1, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
2831 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
2832 -1//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
2835 camera_s * handle = (camera_s*)camera;
2836 MMCamAttrsInfo info;
2837 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE , &info);
2839 if( ret != CAMERA_ERROR_NONE )
2840 return __convert_camera_error_code(__func__, ret);
2843 for( i=0 ; i < info.int_array.count ; i++ ){
2844 if( maptable[info.int_array.array[i]] != -1 ){
2845 if ( !foreach_cb(maptable[info.int_array.array[i]],user_data) )
2850 return CAMERA_ERROR_NONE;
2853 int camera_attr_foreach_supported_iso( camera_h camera, camera_attr_supported_iso_cb foreach_cb , void *user_data){
2854 if( camera == NULL || foreach_cb == NULL ){
2855 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2856 return CAMERA_ERROR_INVALID_PARAMETER;
2860 camera_s * handle = (camera_s*)camera;
2861 MMCamAttrsInfo info;
2862 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO , &info);
2864 if( ret != CAMERA_ERROR_NONE )
2865 return __convert_camera_error_code(__func__, ret);
2868 for( i=0 ; i < info.int_array.count ; i++ ){
2869 if( !foreach_cb(info.int_array.array[i],user_data) )
2873 return CAMERA_ERROR_NONE;
2876 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data){
2877 if( camera == NULL || foreach_cb == NULL ){
2878 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2879 return CAMERA_ERROR_INVALID_PARAMETER;
2883 camera_s * handle = (camera_s*)camera;
2884 MMCamAttrsInfo info;
2885 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB, &info);
2887 if( ret != CAMERA_ERROR_NONE )
2888 return __convert_camera_error_code(__func__, ret);
2891 for( i=0 ; i < info.int_array.count ; i++ ){
2892 if ( !foreach_cb(info.int_array.array[i],user_data) )
2896 return CAMERA_ERROR_NONE;
2899 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data){
2900 if( camera == NULL || foreach_cb == NULL ){
2901 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2902 return CAMERA_ERROR_INVALID_PARAMETER;
2906 camera_s * handle = (camera_s*)camera;
2907 MMCamAttrsInfo info;
2908 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE , &info);
2910 if( ret != CAMERA_ERROR_NONE )
2911 return __convert_camera_error_code(__func__, ret);
2914 for( i=0 ; i < info.int_array.count ; i++){
2915 int effect = info.int_array.array[i];
2916 if( !foreach_cb(effect,user_data) )
2920 return CAMERA_ERROR_NONE;
2923 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data){
2924 if( camera == NULL || foreach_cb == NULL ){
2925 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2926 return CAMERA_ERROR_INVALID_PARAMETER;
2930 camera_s * handle = (camera_s*)camera;
2931 MMCamAttrsInfo info;
2932 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE , &info);
2934 if( ret != CAMERA_ERROR_NONE )
2935 return __convert_camera_error_code(__func__, ret);
2938 for( i=0 ; i < info.int_array.count ; i++){
2939 if ( !foreach_cb(info.int_array.array[i],user_data) )
2943 return CAMERA_ERROR_NONE;
2946 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data){
2947 if( camera == NULL || foreach_cb == NULL){
2948 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2949 return CAMERA_ERROR_INVALID_PARAMETER;
2953 camera_s * handle = (camera_s*)camera;
2954 MMCamAttrsInfo info;
2955 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE , &info);
2957 if( ret != CAMERA_ERROR_NONE )
2958 return __convert_camera_error_code(__func__, ret);
2961 for( i=0 ; i < info.int_array.count ; i++){
2962 if( !foreach_cb(info.int_array.array[i],user_data) )
2966 return CAMERA_ERROR_NONE;
2969 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data){
2970 if( camera == NULL || foreach_cb == NULL ){
2971 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2972 return CAMERA_ERROR_INVALID_PARAMETER;
2976 camera_s * handle = (camera_s*)camera;
2977 MMCamAttrsInfo info;
2978 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info);
2980 if( ret != CAMERA_ERROR_NONE )
2981 return __convert_camera_error_code(__func__, ret);
2984 for( i=0 ; i < info.int_array.count ; i++){
2985 if( !foreach_cb(info.int_array.array[i],user_data) )
2989 return CAMERA_ERROR_NONE;
2992 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data){
2993 if( camera == NULL || foreach_cb == NULL ){
2994 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2995 return CAMERA_ERROR_INVALID_PARAMETER;
2999 camera_s * handle = (camera_s*)camera;
3000 MMCamAttrsInfo info;
3001 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FLIP , &info);
3003 if( ret != CAMERA_ERROR_NONE )
3004 return __convert_camera_error_code(__func__, ret);
3007 for( i=0 ; i < info.int_array.count ; i++){
3008 if( !foreach_cb(info.int_array.array[i], user_data) )
3012 return CAMERA_ERROR_NONE;
3015 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data){
3016 if( camera == NULL || foreach_cb == NULL ){
3017 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3018 return CAMERA_ERROR_INVALID_PARAMETER;
3022 camera_s * handle = (camera_s*)camera;
3023 MMCamAttrsInfo info;
3024 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ROTATION , &info);
3026 if( ret != CAMERA_ERROR_NONE )
3027 return __convert_camera_error_code(__func__, ret);
3030 for( i=0 ; i < info.int_array.count ; i++ ){
3031 if( !foreach_cb(info.int_array.array[i], user_data) )
3035 return CAMERA_ERROR_NONE;
3038 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation){
3039 if( camera == NULL){
3040 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3041 return CAMERA_ERROR_INVALID_PARAMETER;
3044 if( rotation > CAMERA_ROTATION_270 )
3045 return CAMERA_ERROR_INVALID_PARAMETER;
3048 camera_s * handle = (camera_s*)camera;
3050 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ROTATION, rotation, NULL);
3052 return __convert_camera_error_code(__func__, ret);
3055 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation){
3056 if( camera == NULL || rotation == NULL ){
3057 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3058 return CAMERA_ERROR_INVALID_PARAMETER;
3062 camera_s * handle = (camera_s*)camera;
3064 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ROTATION, rotation, NULL);
3066 return __convert_camera_error_code(__func__, ret);
3069 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip){
3070 if( camera == NULL ){
3071 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3072 return CAMERA_ERROR_INVALID_PARAMETER;
3075 if( flip > CAMERA_FLIP_BOTH )
3076 return CAMERA_ERROR_INVALID_PARAMETER;
3079 camera_s * handle = (camera_s*)camera;
3080 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3081 MMCAM_CAMERA_FLIP, flip,
3084 return __convert_camera_error_code(__func__, ret);
3087 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip){
3088 if( camera == NULL || flip == NULL ){
3089 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3090 return CAMERA_ERROR_INVALID_PARAMETER;
3093 camera_s * handle = (camera_s*)camera;
3094 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FLIP, flip, NULL);
3096 return __convert_camera_error_code(__func__, ret);
3099 int _camera_set_use(camera_h camera, bool used){
3100 camera_s * handle = (camera_s*)camera;
3101 handle->is_used_in_recorder = used;
3102 return CAMERA_ERROR_NONE;
3105 bool _camera_is_used(camera_h camera){
3106 camera_s * handle = (camera_s*)camera;
3107 return handle->is_used_in_recorder;
3110 int _camera_get_mm_handle(camera_h camera , MMHandleType *handle){
3111 if( camera == NULL || handle == NULL ){
3112 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3113 return CAMERA_ERROR_INVALID_PARAMETER;
3115 camera_s *camera_handle = (camera_s*)camera;
3116 *handle = camera_handle->mm_handle;
3118 return CAMERA_ERROR_NONE;
3121 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data){
3122 if( camera == NULL ){
3123 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3124 return CAMERA_ERROR_INVALID_PARAMETER;
3127 camera_s *handle = (camera_s*)camera;
3128 handle->relay_message_callback = callback;
3129 handle->relay_user_data = user_data;
3131 return CAMERA_ERROR_NONE;
3134 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format){
3135 if( in_format <= MM_PIXEL_FORMAT_INVALID ||
3136 in_format >= MM_PIXEL_FORMAT_NUM ||
3137 out_format == NULL ){
3138 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
3139 return CAMERA_ERROR_INVALID_PARAMETER;
3142 switch( in_format ){
3143 case MM_PIXEL_FORMAT_NV12:
3144 case MM_PIXEL_FORMAT_NV12T:
3145 *out_format = TBM_FORMAT_NV12;
3147 case MM_PIXEL_FORMAT_NV16:
3148 *out_format = TBM_FORMAT_NV16;
3150 case MM_PIXEL_FORMAT_NV21:
3151 *out_format = TBM_FORMAT_NV21;
3153 case MM_PIXEL_FORMAT_YUYV:
3154 *out_format = TBM_FORMAT_YUYV;
3156 case MM_PIXEL_FORMAT_UYVY:
3157 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3158 *out_format = TBM_FORMAT_UYVY;
3160 case MM_PIXEL_FORMAT_422P:
3161 *out_format = TBM_FORMAT_YUV422;
3163 case MM_PIXEL_FORMAT_I420:
3164 *out_format = TBM_FORMAT_YUV420;
3166 case MM_PIXEL_FORMAT_YV12:
3167 *out_format = TBM_FORMAT_YVU420;
3169 case MM_PIXEL_FORMAT_RGB565:
3170 *out_format = TBM_FORMAT_RGB565;
3172 case MM_PIXEL_FORMAT_RGB888:
3173 *out_format = TBM_FORMAT_RGB888;
3175 case MM_PIXEL_FORMAT_RGBA:
3176 *out_format = TBM_FORMAT_RGBA8888;
3178 case MM_PIXEL_FORMAT_ARGB:
3179 *out_format = TBM_FORMAT_ARGB8888;
3182 LOGE("invalid in_format %d", in_format);
3183 return CAMERA_ERROR_INVALID_PARAMETER;
3186 return CAMERA_ERROR_NONE;
3189 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype){
3190 if( in_format <= MM_PIXEL_FORMAT_INVALID ||
3191 in_format >= MM_PIXEL_FORMAT_NUM ||
3193 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
3194 return CAMERA_ERROR_INVALID_PARAMETER;
3197 switch (in_format) {
3198 case MM_PIXEL_FORMAT_NV12:
3199 case MM_PIXEL_FORMAT_NV12T:
3200 *mimetype = MEDIA_FORMAT_NV12;
3202 case MM_PIXEL_FORMAT_NV16:
3203 *mimetype = MEDIA_FORMAT_NV16;
3205 case MM_PIXEL_FORMAT_NV21:
3206 *mimetype = MEDIA_FORMAT_NV21;
3208 case MM_PIXEL_FORMAT_YUYV:
3209 *mimetype = MEDIA_FORMAT_YUYV;
3211 case MM_PIXEL_FORMAT_UYVY:
3212 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3213 *mimetype = MEDIA_FORMAT_UYVY;
3215 case MM_PIXEL_FORMAT_422P:
3216 *mimetype = MEDIA_FORMAT_422P;
3218 case MM_PIXEL_FORMAT_I420:
3219 *mimetype = MEDIA_FORMAT_I420;
3221 case MM_PIXEL_FORMAT_YV12:
3222 *mimetype = MEDIA_FORMAT_YV12;
3224 case MM_PIXEL_FORMAT_RGB565:
3225 *mimetype = MEDIA_FORMAT_RGB565;
3227 case MM_PIXEL_FORMAT_RGB888:
3228 *mimetype = MEDIA_FORMAT_RGB888;
3230 case MM_PIXEL_FORMAT_RGBA:
3231 *mimetype = MEDIA_FORMAT_RGBA;
3233 case MM_PIXEL_FORMAT_ARGB:
3234 *mimetype = MEDIA_FORMAT_ARGB;
3237 LOGE("invalid in_format %d", in_format);
3238 return CAMERA_ERROR_INVALID_PARAMETER;
3241 return CAMERA_ERROR_NONE;
3244 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data){
3246 void *internal_buffer = NULL;
3247 tbm_surface_h tsurf = NULL;
3249 if( pkt == NULL || user_data == NULL ){
3250 LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
3251 return MEDIA_PACKET_FINALIZE;
3254 ret = media_packet_get_extra(pkt, &internal_buffer);
3256 if( ret != MEDIA_PACKET_ERROR_NONE ){
3257 LOGE("media_packet_get_extra failed 0x%x", ret);
3258 return MEDIA_PACKET_FINALIZE;
3261 /*LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret);*/
3263 if( internal_buffer ){
3264 gst_buffer_unref((GstBuffer *)internal_buffer);
3265 internal_buffer = NULL;
3268 ret = media_packet_get_tbm_surface(pkt, &tsurf);
3269 if( ret != MEDIA_PACKET_ERROR_NONE ){
3270 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
3271 return MEDIA_PACKET_FINALIZE;
3275 tbm_surface_destroy(tsurf);
3279 return MEDIA_PACKET_FINALIZE;
3282 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode){
3283 if( camera == NULL ){
3284 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3285 return CAMERA_ERROR_INVALID_PARAMETER;
3288 if( camera_attr_is_supported_hdr_capture(camera) == false ){
3289 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3290 return CAMERA_ERROR_NOT_SUPPORTED;
3294 camera_s * handle = (camera_s*)camera;
3295 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_HDR_CAPTURE, mode, NULL);
3297 if( ret == MM_ERROR_NONE ){
3298 if( mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL )
3299 handle->hdr_keep_mode = true;
3301 handle->hdr_keep_mode = false;
3304 return __convert_camera_error_code(__func__, ret);
3307 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode){
3308 if( camera == NULL ){
3309 LOGE("INVALID_PARAMETER(0x%08x) - handle",CAMERA_ERROR_INVALID_PARAMETER);
3310 return CAMERA_ERROR_INVALID_PARAMETER;
3313 if( camera_attr_is_supported_hdr_capture(camera) == false ){
3314 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3315 return CAMERA_ERROR_NOT_SUPPORTED;
3319 LOGE("INVALID_PARAMETER(0x%08x) - mode",CAMERA_ERROR_INVALID_PARAMETER);
3320 return CAMERA_ERROR_INVALID_PARAMETER;
3325 camera_s * handle = (camera_s*)camera;
3326 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_HDR_CAPTURE, &result, NULL);
3328 if( ret == MM_ERROR_NONE ){
3332 return __convert_camera_error_code(__func__, ret);
3335 bool camera_attr_is_supported_hdr_capture(camera_h camera){
3336 if( camera == NULL ){
3337 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3342 camera_s * handle = (camera_s*)camera;
3343 MMCamAttrsInfo hdr_info;
3345 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE, &hdr_info);
3346 set_last_result(__convert_camera_error_code(__func__, ret));
3347 if( ret != MM_ERROR_NONE ){
3348 LOGE("MMCAM_CAMERA_HDR_CAPTURE get attr info failed");
3352 for( i = 0; i < hdr_info.int_array.count ; i++ ){
3353 if( hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON ){
3354 LOGD("HDR capture supported");
3359 LOGD("HDR capture NOT supported");
3364 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void* user_data){
3365 if( camera == NULL ){
3366 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3367 return CAMERA_ERROR_INVALID_PARAMETER;
3370 if( camera_attr_is_supported_hdr_capture(camera) == false ){
3371 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3372 return CAMERA_ERROR_NOT_SUPPORTED;
3375 if( callback == NULL ){
3376 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
3377 return CAMERA_ERROR_INVALID_PARAMETER;
3380 camera_s * handle = (camera_s*)camera;
3381 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)callback;
3382 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)user_data;
3383 return CAMERA_ERROR_NONE;
3386 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera){
3387 if( camera == NULL ){
3388 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3389 return CAMERA_ERROR_INVALID_PARAMETER;
3392 if( camera_attr_is_supported_hdr_capture(camera) == false ){
3393 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3394 return CAMERA_ERROR_NOT_SUPPORTED;
3397 camera_s * handle = (camera_s*)camera;
3398 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
3399 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
3401 return CAMERA_ERROR_NONE;
3404 int camera_attr_enable_anti_shake(camera_h camera, bool enable){
3405 if( camera == NULL ){
3406 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3407 return CAMERA_ERROR_INVALID_PARAMETER;
3410 if( camera_attr_is_supported_anti_shake(camera) == false ){
3411 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3412 return CAMERA_ERROR_NOT_SUPPORTED;
3416 int mode = MM_CAMCORDER_AHS_OFF;
3419 mode = MM_CAMCORDER_AHS_ON;
3421 camera_s * handle = (camera_s*)camera;
3422 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ANTI_HANDSHAKE, mode, NULL);
3424 return __convert_camera_error_code(__func__, ret);
3427 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled){
3428 if( camera == NULL ){
3429 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3430 return CAMERA_ERROR_INVALID_PARAMETER;
3433 if( camera_attr_is_supported_anti_shake(camera) == false ){
3434 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3435 return CAMERA_ERROR_NOT_SUPPORTED;
3438 if( enabled == NULL ){
3439 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
3440 return CAMERA_ERROR_INVALID_PARAMETER;
3444 int mode = MM_CAMCORDER_AHS_OFF;
3445 camera_s * handle = (camera_s*)camera;
3446 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ANTI_HANDSHAKE, &mode, NULL);
3448 if( ret == MM_ERROR_NONE )
3451 return __convert_camera_error_code(__func__, ret);
3454 bool camera_attr_is_supported_anti_shake(camera_h camera){
3455 if( camera == NULL ){
3456 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3461 camera_s * handle = (camera_s*)camera;
3462 MMCamAttrsInfo ash_info;
3463 int ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE , &ash_info);
3464 set_last_result(__convert_camera_error_code(__func__, ret));
3466 for( i=0 ; i < ash_info.int_array.count ; i++ ){
3467 if( ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON )
3474 int camera_attr_enable_video_stabilization(camera_h camera, bool enable){
3475 if( camera == NULL ){
3476 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3477 return CAMERA_ERROR_INVALID_PARAMETER;
3480 if( camera_attr_is_supported_video_stabilization(camera) == false ){
3481 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3482 return CAMERA_ERROR_NOT_SUPPORTED;
3486 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
3489 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
3491 camera_s * handle = (camera_s*)camera;
3492 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_VIDEO_STABILIZATION, mode, NULL);
3494 return __convert_camera_error_code(__func__, ret);
3497 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled){
3498 if( camera == NULL ){
3499 LOGE("INVALID_PARAMETER(0x%08x) - handle",CAMERA_ERROR_INVALID_PARAMETER);
3500 return CAMERA_ERROR_INVALID_PARAMETER;
3503 if( camera_attr_is_supported_video_stabilization(camera) == false ){
3504 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3505 return CAMERA_ERROR_NOT_SUPPORTED;
3508 if( enabled == NULL ){
3509 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
3510 return CAMERA_ERROR_INVALID_PARAMETER;
3514 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
3515 camera_s * handle = (camera_s*)camera;
3516 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_VIDEO_STABILIZATION, &mode, NULL);
3518 if( ret == MM_ERROR_NONE )
3519 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
3521 return __convert_camera_error_code(__func__, ret);
3524 bool camera_attr_is_supported_video_stabilization(camera_h camera){
3525 if( camera == NULL ){
3526 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3531 camera_s * handle = (camera_s*)camera;
3532 MMCamAttrsInfo vs_info;
3533 int ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION , &vs_info);
3534 set_last_result(__convert_camera_error_code(__func__, ret));
3536 for( i=0 ; i < vs_info.int_array.count ; i++ ){
3537 if( vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON )
3544 int camera_attr_enable_auto_contrast(camera_h camera, bool enable){
3545 if( camera == NULL ){
3546 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3547 return CAMERA_ERROR_INVALID_PARAMETER;
3550 if( camera_attr_is_supported_auto_contrast(camera) == false ){
3551 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3552 return CAMERA_ERROR_NOT_SUPPORTED;
3556 int mode = MM_CAMCORDER_WDR_OFF;
3559 mode = MM_CAMCORDER_WDR_ON;
3561 camera_s * handle = (camera_s*)camera;
3562 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_WDR, mode, NULL);
3564 return __convert_camera_error_code(__func__, ret);
3567 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled){
3568 if( camera == NULL ){
3569 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3570 return CAMERA_ERROR_INVALID_PARAMETER;
3573 if( camera_attr_is_supported_auto_contrast(camera) == false ){
3574 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3575 return CAMERA_ERROR_NOT_SUPPORTED;
3578 if( enabled == NULL ){
3579 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
3580 return CAMERA_ERROR_INVALID_PARAMETER;
3584 int mode = MM_CAMCORDER_WDR_OFF;
3585 camera_s * handle = (camera_s*)camera;
3586 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WDR , &mode, NULL);
3588 if( ret == MM_ERROR_NONE )
3591 return __convert_camera_error_code(__func__, ret);
3594 bool camera_attr_is_supported_auto_contrast(camera_h camera) {
3595 if( camera == NULL ){
3596 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3601 camera_s * handle = (camera_s*)camera;
3602 MMCamAttrsInfo info;
3603 int ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WDR, &info);
3604 set_last_result(__convert_camera_error_code(__func__, ret));
3606 for( i=0 ; i < info.int_array.count ; i++ ) {
3607 if( info.int_array.array[i] == MM_CAMCORDER_WDR_ON )
3614 int camera_attr_disable_shutter_sound(camera_h camera, bool disable){
3615 if (camera == NULL ){
3616 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3617 return CAMERA_ERROR_INVALID_PARAMETER;
3621 camera_s * handle = (camera_s*)camera;
3622 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, "capture-sound-enable", !disable, NULL);
3625 LOGE("CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound");
3626 return CAMERA_ERROR_INVALID_OPERATION;
3629 return CAMERA_ERROR_NONE;