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)
729 if( camera == NULL ){
730 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
731 return CAMERA_ERROR_INVALID_PARAMETER;
735 camera_s *handle = (camera_s*)camera;
736 if( handle->is_used_in_recorder ){
737 LOGE("camera is using in another recorder.");
738 return CAMERA_ERROR_INVALID_OPERATION;
741 LOGW("camera handle %p", handle);
743 ret = mm_camcorder_destroy(handle->mm_handle);
745 if( handle->pkt_fmt ){
746 media_format_unref(handle->pkt_fmt);
747 handle->pkt_fmt = NULL;
750 if( ret == MM_ERROR_NONE ){
751 _camera_remove_cb_message(handle);
752 g_mutex_clear(&handle->idle_cb_lock);
754 if (handle->wl_info) {
755 free(handle->wl_info);
756 handle->wl_info = NULL;
758 #endif /* HAVE_WAYLAND */
762 return __convert_camera_error_code(__func__, ret);
765 int camera_start_preview(camera_h camera){
767 if( camera == NULL ){
768 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
769 return CAMERA_ERROR_INVALID_PARAMETER;
773 camera_s *handle = (camera_s*)camera;
774 camera_state_e capi_state;
775 camera_get_state(camera, &capi_state);
777 if( capi_state == CAMERA_STATE_CAPTURED ){
778 ret = mm_camcorder_capture_stop(handle->mm_handle);
779 return __convert_camera_error_code(__func__, ret);
782 /*for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback*/
783 mm_camcorder_set_video_capture_callback( handle->mm_handle, (mm_camcorder_video_capture_callback)__mm_capture_callback, (void*)handle);
785 MMCamcorderStateType state;
786 mm_camcorder_get_state(handle->mm_handle, &state);
787 if( state != MM_CAMCORDER_STATE_READY ){
788 ret = mm_camcorder_realize(handle->mm_handle);
789 if( ret != MM_ERROR_NONE ){
790 return __convert_camera_error_code(__func__, ret);
794 ret = mm_camcorder_start(handle->mm_handle);
795 if( ret != MM_ERROR_NONE ){
797 mm_camcorder_unrealize(handle->mm_handle);
800 return __convert_camera_error_code(__func__, ret);
803 int camera_stop_preview(camera_h camera){
804 if( camera == NULL ){
805 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
806 return CAMERA_ERROR_INVALID_PARAMETER;
810 camera_s *handle = (camera_s*)camera;
811 MMCamcorderStateType state ;
812 mm_camcorder_get_state(handle->mm_handle, &state);
814 if( state == MM_CAMCORDER_STATE_PREPARE ){
815 ret = mm_camcorder_stop(handle->mm_handle);
816 if( ret != MM_ERROR_NONE ){
817 return __convert_camera_error_code(__func__, ret);
821 camera_stop_face_detection(camera);
823 ret = mm_camcorder_unrealize(handle->mm_handle);
825 return __convert_camera_error_code(__func__, ret);
828 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb , camera_capture_completed_cb completed_cb , void *user_data){
829 if( camera == NULL ){
830 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
831 return CAMERA_ERROR_INVALID_PARAMETER;
834 camera_s * handle = (camera_s*)camera;
836 MMCamcorderStateType state;
837 mm_camcorder_get_state(handle->mm_handle, &state);
838 if( state != MM_CAMCORDER_STATE_PREPARE &&
839 state != MM_CAMCORDER_STATE_RECORDING &&
840 state != MM_CAMCORDER_STATE_PAUSED ){
841 LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
842 return CAMERA_ERROR_INVALID_STATE;
845 if( handle->capture_resolution_modified ){
846 mm_camcorder_set_attributes(handle->mm_handle, NULL,
847 MMCAM_CAPTURE_WIDTH, handle->capture_width,
848 MMCAM_CAPTURE_HEIGHT, handle->capture_height,
850 handle->capture_resolution_modified = false;
852 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAPTURE_COUNT , 1,NULL);
854 handle->capture_count = 1;
855 handle->is_continuous_shot_break = false;
856 handle->current_capture_count = 0;
857 handle->current_capture_complete_count = 0;
858 handle->is_capture_completed = false;
860 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
861 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
862 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
863 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
864 ret = mm_camcorder_capture_start(handle->mm_handle);
866 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
867 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
868 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
869 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
872 return __convert_camera_error_code(__func__, ret);
875 bool camera_is_supported_continuous_capture(camera_h camera){
876 if( camera == NULL ){
877 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
881 int ret = MM_ERROR_NONE;
882 camera_s * handle = (camera_s*)camera;
884 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_COUNT , &info);
885 set_last_result(__convert_camera_error_code(__func__, ret));
886 if( ret != MM_ERROR_NONE ){
889 if( info.int_range.max > 1){
896 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){
897 if( camera == NULL ){
898 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
899 return CAMERA_ERROR_INVALID_PARAMETER;
902 if( camera_is_supported_continuous_capture(camera) == false ){
903 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
904 return CAMERA_ERROR_NOT_SUPPORTED;
907 if( count < 2 || interval < 0 ){
908 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
909 return CAMERA_ERROR_INVALID_PARAMETER;
912 camera_s * handle = (camera_s*)camera;
914 MMCamcorderStateType state;
915 mm_camcorder_get_state(handle->mm_handle, &state);
916 if( state != MM_CAMCORDER_STATE_PREPARE ){
917 LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
918 return CAMERA_ERROR_INVALID_STATE;
921 int supported_zsl = FALSE;
923 int ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
924 MMCAM_CAPTURE_COUNT, count,
925 MMCAM_CAPTURE_INTERVAL, interval,
928 LOGE("(%x) error set continuous shot attribute", ret);
929 return __convert_camera_error_code(__func__, ret);
932 handle->capture_count = count;
933 handle->is_continuous_shot_break = false;
934 handle->current_capture_count = 0;
935 handle->current_capture_complete_count = 0;
936 handle->is_capture_completed = false;
938 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl, NULL);
940 LOGE("(%x) error get continuous shot attribute", ret);
943 if( !supported_zsl ){
949 mm_camcorder_get_attributes(handle->mm_handle, NULL,
950 MMCAM_CAMERA_WIDTH, &preview_width,
951 MMCAM_CAMERA_HEIGHT, &preview_height,
952 MMCAM_CAPTURE_WIDTH, &capture_width,
953 MMCAM_CAPTURE_HEIGHT, &capture_height,
955 if( preview_width != capture_width || preview_height != capture_height ){
956 mm_camcorder_set_attributes(handle->mm_handle, NULL,
957 MMCAM_CAPTURE_WIDTH, preview_width,
958 MMCAM_CAPTURE_HEIGHT, preview_height,
960 handle->capture_resolution_modified = true;
964 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
965 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
966 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
967 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
969 ret = mm_camcorder_capture_start(handle->mm_handle);
971 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
972 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
973 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
974 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
977 return __convert_camera_error_code(__func__,ret);
981 int camera_stop_continuous_capture(camera_h camera){
982 if( camera == NULL ){
983 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
984 return CAMERA_ERROR_INVALID_PARAMETER;
987 if( camera_is_supported_continuous_capture(camera) == false ){
988 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
989 return CAMERA_ERROR_NOT_SUPPORTED;
992 camera_s *handle = (camera_s*)camera;
995 camera_state_e state;
996 camera_get_state(camera, &state);
998 if( state != CAMERA_STATE_CAPTURING && handle->capture_count > 1 ){
999 LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
1000 return CAMERA_ERROR_INVALID_STATE;
1003 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, "capture-break-cont-shot", 1, NULL);
1004 if( ret == MM_ERROR_NONE ){
1005 handle->is_continuous_shot_break = true;
1006 if( handle->current_capture_count > 0 ){
1007 handle->is_capture_completed = true;
1009 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
1012 return __convert_camera_error_code(__func__,ret);
1015 bool camera_is_supported_face_detection(camera_h camera){
1016 if (camera == NULL) {
1017 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1022 int ret = MM_ERROR_NONE;
1023 camera_s *handle = (camera_s *)camera;
1024 MMCamAttrsInfo info;
1026 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
1027 set_last_result(__convert_camera_error_code(__func__, ret));
1028 if( ret != MM_ERROR_NONE ){
1029 LOGE("MMCAM_DETECT_MODE get attr info failed");
1033 if( info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY ){
1034 for( i = 0 ; i < info.int_array.count ; i++ ){
1035 if( info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON ){
1036 LOGD("face detection supported");
1042 LOGD("face detection NOT supported");
1047 bool camera_is_supported_zero_shutter_lag(camera_h camera){
1048 int ret = MM_ERROR_NONE;
1049 int supported_zsl = false;
1050 camera_s *handle = (camera_s *)camera;
1052 if( camera == NULL ){
1053 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1057 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl, NULL);
1058 set_last_result(__convert_camera_error_code(__func__, ret));
1059 if( ret != MM_ERROR_NONE ){
1060 LOGE("MMCAM_SUPPORT_ZSL_CAPTURE get failed");
1064 LOGD("support zero shutter lag : %d", supported_zsl);
1066 return supported_zsl;
1069 bool camera_is_supported_media_packet_preview_cb(camera_h camera){
1070 int ret = MM_ERROR_NONE;
1071 int supported = false;
1072 camera_s *handle = (camera_s *)camera;
1074 if( camera == NULL ){
1075 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1079 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1080 MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, &supported,
1082 set_last_result(__convert_camera_error_code(__func__, ret));
1083 if( ret != MM_ERROR_NONE ){
1084 LOGE("MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB get failed");
1088 LOGD("support media packet preview callback : %d", supported);
1093 int camera_get_device_count(camera_h camera, int *device_count){
1094 int ret = MM_ERROR_NONE;
1095 camera_s *handle = (camera_s *)camera;
1097 if( camera == NULL || device_count == NULL ){
1098 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1099 return CAMERA_ERROR_INVALID_PARAMETER;
1102 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1103 MMCAM_CAMERA_DEVICE_COUNT, device_count,
1106 return __convert_camera_error_code(__func__, ret);
1109 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void * user_data){
1110 if( camera == NULL ){
1111 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1112 return CAMERA_ERROR_INVALID_PARAMETER;
1115 if( camera_is_supported_face_detection(camera) == false ){
1116 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1117 return CAMERA_ERROR_NOT_SUPPORTED;
1120 camera_s * handle = (camera_s*)camera;
1121 camera_state_e state = CAMERA_STATE_NONE;
1123 camera_get_state(camera, &state);
1124 if( state != CAMERA_STATE_PREVIEW ){
1125 LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
1126 return CAMERA_ERROR_INVALID_STATE;
1129 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1130 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON,
1132 if( ret == MM_ERROR_NONE ){
1133 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)callback;
1134 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)user_data;
1135 handle->num_of_faces = 0;
1138 return __convert_camera_error_code(__func__,ret);
1141 int camera_stop_face_detection(camera_h camera){
1142 if( camera == NULL ){
1143 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1144 return CAMERA_ERROR_INVALID_PARAMETER;
1146 camera_s * handle = (camera_s*)camera;
1149 if( camera_is_supported_face_detection(camera) == false ){
1150 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1151 return CAMERA_ERROR_NOT_SUPPORTED;
1154 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF, NULL);
1155 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1156 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1157 handle->num_of_faces = 0;
1158 return __convert_camera_error_code(__func__,ret);
1161 int camera_get_state(camera_h camera, camera_state_e * state){
1162 if( camera == NULL || state == NULL ){
1163 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1164 return CAMERA_ERROR_INVALID_PARAMETER;
1167 camera_s *handle = (camera_s*)camera;
1168 camera_state_e capi_state;
1169 MMCamcorderStateType mmstate ;
1170 mm_camcorder_get_state(handle->mm_handle, &mmstate);
1172 capi_state = __camera_state_convert(mmstate);
1174 if( (handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed) && (handle->current_capture_count > 0 || handle->is_capture_completed) && mmstate == MM_CAMCORDER_STATE_CAPTURING ){
1175 capi_state = CAMERA_STATE_CAPTURED;
1178 *state = capi_state;
1179 return CAMERA_ERROR_NONE;
1182 int camera_start_focusing( camera_h camera, bool continuous ){
1183 if( camera == NULL ){
1184 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1185 return CAMERA_ERROR_INVALID_PARAMETER;
1187 camera_s *handle = (camera_s*)camera;
1189 if( handle->cached_focus_mode != -1 ){
1190 LOGD("apply cached focus mode %d", handle->cached_focus_mode);
1191 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , handle->cached_focus_mode, NULL);
1192 handle->cached_focus_mode = -1;
1196 return __camera_start_continuous_focusing(camera);
1198 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);
1199 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s*)camera)->mm_handle));
1203 int __camera_start_continuous_focusing(camera_h camera){
1204 if( camera == NULL ){
1205 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1206 return CAMERA_ERROR_INVALID_PARAMETER;
1209 camera_s *handle = (camera_s*)camera;
1212 handle->on_continuous_focusing = true;
1213 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , &mode, NULL);
1215 if( mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS )
1216 ret = mm_camcorder_start_focusing(handle->mm_handle);
1218 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS, NULL);
1219 return __convert_camera_error_code(__func__, ret);
1222 int camera_cancel_focusing(camera_h camera){
1223 if( camera == NULL ){
1224 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1225 return CAMERA_ERROR_INVALID_PARAMETER;
1227 camera_s *handle = (camera_s*)camera;
1228 handle->on_continuous_focusing = false;
1229 return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
1232 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
1234 int ret = MM_ERROR_NONE;
1235 int set_surface = MM_DISPLAY_SURFACE_X;
1236 void *set_handle = NULL;
1237 camera_s *handle = NULL;
1239 Evas_Object *obj = NULL;
1240 const char *object_type = NULL;
1242 if( camera == NULL ){
1243 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1244 return CAMERA_ERROR_INVALID_PARAMETER;
1247 if( type != CAMERA_DISPLAY_TYPE_NONE && display == NULL ){
1248 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
1249 return CAMERA_ERROR_INVALID_PARAMETER;
1252 handle = (camera_s *)camera;
1253 handle->display_type = type;
1255 if( type == CAMERA_DISPLAY_TYPE_NONE ){
1257 set_surface = MM_DISPLAY_SURFACE_NULL;
1258 handle->display_handle = 0;
1260 LOGD("display type NONE");
1262 obj = (Evas_Object *)display;
1263 object_type = evas_object_type_get(obj);
1265 if( type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win") ){
1267 MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)malloc(sizeof(MMCamWaylandInfo));
1269 if (wl_info == NULL) {
1270 LOGE("wl_info alloc failed : %d", sizeof(MMCamWaylandInfo));
1271 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_LOW_MEMORY);
1274 memset(wl_info, 0x0, sizeof(MMCamWaylandInfo));
1276 wl_info->evas_obj = (void *)obj;
1277 wl_info->window = (void *)elm_win_wl_window_get(obj);
1278 wl_info->surface = (void *)ecore_wl_window_surface_get(wl_info->window);
1279 wl_info->display = (void *)ecore_wl_display_get();
1281 if (wl_info->window == NULL || wl_info->surface == NULL || wl_info->display == NULL) {
1282 LOGE("something is NULL %p, %p, %p", wl_info->window, wl_info->surface, wl_info->display);
1284 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_INTERNAL);
1287 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
1288 &wl_info->window_width, &wl_info->window_height);
1290 if (handle->wl_info) {
1291 free(handle->wl_info);
1292 handle->wl_info = NULL;
1295 /* set wayland info */
1296 handle->wl_info = (void *)wl_info;
1297 set_surface = MM_DISPLAY_SURFACE_X;
1298 set_handle = (void *)wl_info;
1300 LOGD("wayland obj %p, window %p, surface %p, display %p, size %d,%d,%dx%d",
1301 wl_info->evas_obj, wl_info->window, wl_info->surface, wl_info->display,
1302 wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
1303 #else /* HAVE_WAYLAND */
1304 /* x window overlay surface */
1305 handle->display_handle = (void *)elm_win_xwindow_get(obj);
1306 set_surface = MM_DISPLAY_SURFACE_X;
1307 set_handle = &(handle->display_handle);
1309 LOGD("display type OVERLAY : handle %p, %d", set_handle, (int)handle->display_handle);
1310 #endif /* HAVE_WAYLAND */
1311 } else if( type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image") ) {
1312 /* evas object surface */
1313 handle->display_handle = display;
1314 set_surface = MM_DISPLAY_SURFACE_EVAS;
1315 set_handle = display;
1317 LOGD("display type EVAS : handle %p", set_handle);
1319 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
1320 return CAMERA_ERROR_INVALID_PARAMETER;
1323 LOGE("failed to get evas object type from %p", obj);
1324 return CAMERA_ERROR_INVALID_PARAMETER;
1328 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1329 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
1330 MMCAM_DISPLAY_SURFACE, set_surface,
1333 if( ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE ){
1334 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *), NULL);
1337 return __convert_camera_error_code(__func__, ret);
1340 int camera_set_preview_resolution(camera_h camera, int width, int height){
1341 if( camera == NULL ){
1342 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1343 return CAMERA_ERROR_INVALID_PARAMETER;
1346 camera_s * handle = (camera_s*)camera;
1347 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width ,MMCAM_CAMERA_HEIGHT ,height, NULL);
1348 return __convert_camera_error_code(__func__, ret);
1351 int camera_set_capture_resolution(camera_h camera, int width, int height){
1352 if( camera == NULL ){
1353 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1354 return CAMERA_ERROR_INVALID_PARAMETER;
1358 camera_s * handle = (camera_s*)camera;
1359 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_WIDTH, width ,MMCAM_CAPTURE_HEIGHT , height, NULL);
1361 if( ret == MM_ERROR_NONE ){
1362 handle->capture_width = width;
1363 handle->capture_height = height;
1366 return __convert_camera_error_code(__func__, ret);
1369 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format){
1370 if( camera == NULL ){
1371 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1372 return CAMERA_ERROR_INVALID_PARAMETER;
1376 camera_s * handle = (camera_s*)camera;
1377 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL);
1379 return __convert_camera_error_code(__func__, ret);
1382 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format){
1383 if( camera == NULL ){
1384 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1385 return CAMERA_ERROR_INVALID_PARAMETER;
1389 camera_s * handle = (camera_s*)camera;
1391 if( format == CAMERA_PIXEL_FORMAT_UYVY ){
1392 bool supported_ITLV_UYVY = false;
1393 MMCamAttrsInfo supported_format;
1394 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1396 for( i=0 ; i < supported_format.int_array.count ; i++ ){
1397 if( supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1398 supported_ITLV_UYVY = true;
1400 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1401 MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ? MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY,
1404 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL);
1407 return __convert_camera_error_code(__func__, ret);
1410 int camera_get_preview_resolution(camera_h camera, int *width, int *height){
1411 if( camera == NULL || width == NULL || height == NULL ){
1412 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1413 return CAMERA_ERROR_INVALID_PARAMETER;
1417 camera_s * handle = (camera_s*)camera;
1418 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1419 MMCAM_CAMERA_WIDTH, width,
1420 MMCAM_CAMERA_HEIGHT, height,
1423 return __convert_camera_error_code(__func__, ret);
1426 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation){
1427 if( camera == NULL ){
1428 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1429 return CAMERA_ERROR_INVALID_PARAMETER;
1432 if( rotation > CAMERA_ROTATION_270 )
1433 return CAMERA_ERROR_INVALID_PARAMETER;
1436 camera_s * handle = (camera_s*)camera;
1438 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1439 MMCAM_DISPLAY_ROTATION, rotation,
1442 return __convert_camera_error_code(__func__, ret);
1445 int camera_get_display_rotation( camera_h camera, camera_rotation_e *rotation){
1446 if( camera == NULL || rotation == NULL ){
1447 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1448 return CAMERA_ERROR_INVALID_PARAMETER;
1452 camera_s * handle = (camera_s*)camera;
1454 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL);
1455 return __convert_camera_error_code(__func__, ret);
1458 int camera_set_display_flip(camera_h camera, camera_flip_e flip){
1459 if( camera == NULL ){
1460 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1461 return CAMERA_ERROR_INVALID_PARAMETER;
1464 if( flip > CAMERA_FLIP_BOTH )
1465 return CAMERA_ERROR_INVALID_PARAMETER;
1468 camera_s * handle = (camera_s*)camera;
1470 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1471 MMCAM_DISPLAY_FLIP, flip,
1474 return __convert_camera_error_code(__func__, ret);
1477 int camera_get_display_flip(camera_h camera, camera_flip_e *flip){
1478 if( camera == NULL || flip == NULL ){
1479 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1480 return CAMERA_ERROR_INVALID_PARAMETER;
1484 camera_s * handle = (camera_s*)camera;
1486 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1487 MMCAM_DISPLAY_FLIP, flip,
1490 return __convert_camera_error_code(__func__, ret);
1493 int camera_set_display_visible(camera_h camera, bool visible){
1494 if( camera == NULL ){
1495 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1496 return CAMERA_ERROR_INVALID_PARAMETER;
1500 camera_s * handle = (camera_s*)camera;
1502 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1503 MMCAM_DISPLAY_VISIBLE, visible,
1506 return __convert_camera_error_code(__func__, ret);
1509 int camera_is_display_visible(camera_h camera, bool* visible){
1510 if( camera == NULL || visible == NULL ){
1511 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1512 return CAMERA_ERROR_INVALID_PARAMETER;
1517 camera_s * handle = (camera_s*)camera;
1519 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1520 MMCAM_DISPLAY_VISIBLE, &result,
1523 if( ret == MM_ERROR_NONE)
1526 return __convert_camera_error_code(__func__, ret);
1529 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode){
1530 if( camera == NULL ){
1531 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1532 return CAMERA_ERROR_INVALID_PARAMETER;
1535 if( mode > CAMERA_DISPLAY_MODE_CROPPED_FULL )
1536 return CAMERA_ERROR_INVALID_PARAMETER;
1539 camera_s * handle = (camera_s*)camera;
1541 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1542 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1545 return __convert_camera_error_code(__func__, ret);
1548 int camera_get_display_mode(camera_h camera, camera_display_mode_e* mode){
1549 if( camera == NULL || mode == NULL ){
1550 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1551 return CAMERA_ERROR_INVALID_PARAMETER;
1555 camera_s * handle = (camera_s*)camera;
1557 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1558 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1561 return __convert_camera_error_code(__func__, ret);
1564 int camera_get_capture_resolution(camera_h camera, int *width, int *height){
1565 if( camera == NULL || width== NULL || height == NULL){
1566 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1567 return CAMERA_ERROR_INVALID_PARAMETER;
1570 camera_s * handle = (camera_s*)camera;
1571 *width = handle->capture_width;
1572 *height = handle->capture_height;
1574 return CAMERA_ERROR_NONE;
1577 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format){
1578 if( camera == NULL || format == NULL ){
1579 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1580 return CAMERA_ERROR_INVALID_PARAMETER;
1584 camera_s * handle = (camera_s*)camera;
1586 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1587 MMCAM_CAPTURE_FORMAT, format,
1590 return __convert_camera_error_code(__func__, ret);
1593 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format){
1594 if( camera == NULL || format == NULL ){
1595 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1596 return CAMERA_ERROR_INVALID_PARAMETER;
1600 camera_s * handle = (camera_s*)camera;
1602 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1603 MMCAM_CAMERA_FORMAT, format,
1606 if( (MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1607 *format = CAMERA_PIXEL_FORMAT_UYVY;
1609 return __convert_camera_error_code(__func__, ret);
1612 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void* user_data){
1613 if( camera == NULL || callback == NULL ){
1614 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1615 return CAMERA_ERROR_INVALID_PARAMETER;
1618 camera_s *handle = (camera_s *)camera;
1619 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)callback;
1620 handle->user_data[_CAMERA_EVENT_TYPE_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_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 camera_s *handle = (camera_s *)camera;
1637 if( handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL ){
1638 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1639 (mm_camcorder_video_stream_callback)NULL,
1643 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1644 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1646 return CAMERA_ERROR_NONE;
1649 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void* user_data){
1650 if( camera == NULL ){
1651 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
1652 return CAMERA_ERROR_INVALID_PARAMETER;
1655 if( camera_is_supported_media_packet_preview_cb(camera) == false ){
1656 LOGE("NOT SUPPORTED");
1657 return CAMERA_ERROR_NOT_SUPPORTED;
1660 if( callback == NULL ){
1661 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
1662 return CAMERA_ERROR_INVALID_PARAMETER;
1665 camera_s *handle = (camera_s *)camera;
1666 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)callback;
1667 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)user_data;
1669 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1670 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1673 return CAMERA_ERROR_NONE;
1676 int camera_unset_media_packet_preview_cb(camera_h camera){
1677 if( camera == NULL ){
1678 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1679 return CAMERA_ERROR_INVALID_PARAMETER;
1682 if( camera_is_supported_media_packet_preview_cb(camera) == false ){
1683 LOGE("NOT SUPPORTED");
1684 return CAMERA_ERROR_NOT_SUPPORTED;
1687 camera_s *handle = (camera_s *)camera;
1689 if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] == NULL ){
1690 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1691 (mm_camcorder_video_stream_callback)NULL,
1695 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void*)NULL;
1696 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void*)NULL;
1698 return CAMERA_ERROR_NONE;
1701 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data){
1702 if( camera == NULL || callback == NULL ){
1703 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1704 return CAMERA_ERROR_INVALID_PARAMETER;
1707 camera_s * handle = (camera_s*)camera;
1708 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)callback;
1709 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)user_data;
1711 return CAMERA_ERROR_NONE;
1713 int camera_unset_state_changed_cb(camera_h camera){
1714 if( camera == NULL ){
1715 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1716 return CAMERA_ERROR_INVALID_PARAMETER;
1719 camera_s * handle = (camera_s*)camera;
1720 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1721 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
1723 return CAMERA_ERROR_NONE;
1726 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data){
1727 if( camera == NULL || callback == NULL ){
1728 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1729 return CAMERA_ERROR_INVALID_PARAMETER;
1732 camera_s * handle = (camera_s*)camera;
1733 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)callback;
1734 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)user_data;
1736 return CAMERA_ERROR_NONE;
1739 int camera_unset_interrupted_cb(camera_h camera){
1740 if( camera == NULL ){
1741 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1742 return CAMERA_ERROR_INVALID_PARAMETER;
1745 camera_s * handle = (camera_s*)camera;
1746 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1747 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
1749 return CAMERA_ERROR_NONE;
1752 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data){
1753 if( camera == NULL || callback == NULL ){
1754 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1755 return CAMERA_ERROR_INVALID_PARAMETER;
1758 camera_s * handle = (camera_s*)camera;
1759 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)callback;
1760 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)user_data;
1762 return CAMERA_ERROR_NONE;
1764 int camera_unset_focus_changed_cb(camera_h camera){
1765 if( camera == NULL ){
1766 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1767 return CAMERA_ERROR_INVALID_PARAMETER;
1770 camera_s * handle = (camera_s*)camera;
1771 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1772 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
1774 return CAMERA_ERROR_NONE;
1777 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data){
1778 if( camera == NULL || callback == NULL ){
1779 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1780 return CAMERA_ERROR_INVALID_PARAMETER;
1783 camera_s * handle = (camera_s*)camera;
1784 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)callback;
1785 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)user_data;
1787 return CAMERA_ERROR_NONE;
1790 int camera_unset_error_cb(camera_h camera){
1791 if( camera == NULL ){
1792 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1793 return CAMERA_ERROR_INVALID_PARAMETER;
1796 camera_s * handle = (camera_s*)camera;
1797 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1798 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
1800 return CAMERA_ERROR_NONE;
1803 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data){
1804 if( camera == NULL || foreach_cb == NULL ){
1805 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1806 return CAMERA_ERROR_INVALID_PARAMETER;
1810 camera_s * handle = (camera_s*)camera;
1811 MMCamAttrsInfo preview_width;
1812 MMCamAttrsInfo preview_height;
1813 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH , &preview_width);
1814 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT , &preview_height);
1816 if( ret != CAMERA_ERROR_NONE )
1817 return __convert_camera_error_code(__func__, ret);
1820 for( i=0 ; i < preview_width.int_array.count ; i++ ){
1821 if( !foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i],user_data) )
1825 return CAMERA_ERROR_NONE;
1828 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data){
1829 if( camera == NULL || foreach_cb == NULL){
1830 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1831 return CAMERA_ERROR_INVALID_PARAMETER;
1834 camera_s * handle = (camera_s*)camera;
1835 MMCamAttrsInfo capture_width;
1836 MMCamAttrsInfo capture_height;
1837 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH , &capture_width);
1838 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT , &capture_height);
1840 if( ret != CAMERA_ERROR_NONE )
1841 return __convert_camera_error_code(__func__, ret);
1844 for( i=0 ; i < capture_width.int_array.count ; i++)
1846 if ( !foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i],user_data) )
1849 return CAMERA_ERROR_NONE;
1852 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data){
1853 if( camera == NULL || foreach_cb == NULL){
1854 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1855 return CAMERA_ERROR_INVALID_PARAMETER;
1859 camera_s * handle = (camera_s*)camera;
1860 MMCamAttrsInfo format;
1861 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT , &format);
1863 if( ret != CAMERA_ERROR_NONE )
1864 return __convert_camera_error_code(__func__, ret);
1867 for( i=0 ; i < format.int_array.count ; i++ ){
1868 if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
1869 if ( !foreach_cb(format.int_array.array[i], user_data) )
1873 return CAMERA_ERROR_NONE;
1876 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data){
1877 if( camera == NULL || foreach_cb == NULL ){
1878 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1879 return CAMERA_ERROR_INVALID_PARAMETER;
1883 camera_s * handle = (camera_s*)camera;
1884 MMCamAttrsInfo format;
1885 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &format);
1887 if( ret != CAMERA_ERROR_NONE )
1888 return __convert_camera_error_code(__func__, ret);
1891 for( i=0 ; i < format.int_array.count ; i++ ){
1892 if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY /* || format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_NV12 */)
1893 if ( !foreach_cb(format.int_array.array[i], user_data) )
1897 return CAMERA_ERROR_NONE;
1900 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height){
1901 if( camera == NULL || width == NULL || height == NULL ){
1902 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1903 return CAMERA_ERROR_INVALID_PARAMETER;
1906 enum MMCamcorderPreviewType wide;
1907 int capture_w, capture_h;
1910 camera_s * handle = (camera_s*)camera;
1912 camera_get_capture_resolution(camera, &capture_w, &capture_h);
1913 ratio = (double)capture_w/(double)capture_h;
1915 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
1916 } else if( ratio == 1.0 ){
1917 wide = MM_CAMCORDER_PREVIEW_TYPE_SQUARE;
1919 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
1922 MMCamAttrsInfo width_info, height_info;
1923 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH , &width_info);
1924 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
1927 return __convert_camera_error_code(__func__, ret);
1929 if( width && (unsigned int)width_info.int_array.count > wide ){
1930 *width = width_info.int_array.array[wide];
1932 LOGE("there is no width value for resolution %dx%d type %d", capture_w, capture_h, wide);
1933 return CAMERA_ERROR_INVALID_OPERATION;
1936 if( height && (unsigned int)height_info.int_array.count > wide ){
1937 *height = height_info.int_array.array[wide];
1939 LOGE("there is no height value for resolution %dx%d type %d", capture_w, capture_h, wide);
1940 return CAMERA_ERROR_INVALID_OPERATION;
1943 LOGI("recommend resolution %dx%d, type %d", *width, *height, wide);
1945 return CAMERA_ERROR_NONE;
1948 int camera_attr_get_lens_orientation(camera_h camera, int *angle){
1949 if( camera == NULL || angle == NULL ){
1950 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1951 return CAMERA_ERROR_INVALID_PARAMETER;
1955 camera_s * handle = (camera_s*)camera;
1957 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation , NULL);
1960 case MM_DISPLAY_ROTATION_NONE:
1963 case MM_DISPLAY_ROTATION_90:
1966 case MM_DISPLAY_ROTATION_180:
1969 case MM_DISPLAY_ROTATION_270:
1977 return __convert_camera_error_code(__func__, ret);
1980 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode){
1981 if( camera == NULL ){
1982 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1983 return CAMERA_ERROR_INVALID_PARAMETER;
1987 camera_s * handle = (camera_s*)camera;
1988 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE, mode, NULL);
1990 return __convert_camera_error_code(__func__, ret);
1993 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode){
1994 if( camera == NULL || mode == NULL ){
1995 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
1996 return CAMERA_ERROR_INVALID_PARAMETER;
2000 camera_s * handle = (camera_s*)camera;
2001 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE , mode, NULL);
2003 return __convert_camera_error_code(__func__, ret);
2006 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data){
2007 if( camera == NULL || foreach_cb == NULL ){
2008 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2009 return CAMERA_ERROR_INVALID_PARAMETER;
2013 camera_s * handle = (camera_s*)camera;
2014 MMCamAttrsInfo info;
2015 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DISPLAY_MODE , &info);
2017 if( ret != CAMERA_ERROR_NONE )
2018 return __convert_camera_error_code(__func__, ret);
2021 for (i=0 ; i < info.int_array.count ; i++ ){
2022 if ( !foreach_cb(info.int_array.array[i],user_data) )
2026 return CAMERA_ERROR_NONE;
2029 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps){
2030 if( camera == NULL ){
2031 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2032 return CAMERA_ERROR_INVALID_PARAMETER;
2036 camera_s * handle = (camera_s*)camera;
2038 if( fps == CAMERA_ATTR_FPS_AUTO ){
2039 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2040 MMCAM_CAMERA_FPS_AUTO, 1,
2043 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2044 MMCAM_CAMERA_FPS_AUTO, 0,
2045 MMCAM_CAMERA_FPS, fps,
2049 return __convert_camera_error_code(__func__, ret);
2052 int camera_attr_set_image_quality(camera_h camera, int quality){
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_IMAGE_ENCODER_QUALITY , quality, NULL);
2062 return __convert_camera_error_code(__func__, ret);
2065 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps){
2066 if( camera == NULL || fps == NULL ){
2067 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2068 return CAMERA_ERROR_INVALID_PARAMETER;
2074 camera_s * handle = (camera_s*)camera;
2076 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS , &mm_fps, MMCAM_CAMERA_FPS_AUTO , &is_auto, NULL);
2079 *fps = CAMERA_ATTR_FPS_AUTO;
2083 return __convert_camera_error_code(__func__, ret);
2086 int camera_attr_get_image_quality(camera_h camera, int *quality){
2087 if( camera == NULL || quality == NULL ){
2088 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2089 return CAMERA_ERROR_INVALID_PARAMETER;
2093 camera_s * handle = (camera_s*)camera;
2094 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
2096 return __convert_camera_error_code(__func__, ret);
2099 int camera_attr_set_zoom(camera_h camera, int zoom){
2100 if( camera == NULL ){
2101 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2102 return CAMERA_ERROR_INVALID_PARAMETER;
2106 camera_s * handle = (camera_s*)camera;
2107 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL);
2109 return __convert_camera_error_code(__func__, ret);
2112 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode){
2113 if( camera == NULL ){
2114 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2115 return CAMERA_ERROR_INVALID_PARAMETER;
2118 int ret = CAMERA_ERROR_INVALID_PARAMETER;
2119 camera_s * handle = (camera_s*)camera;
2122 bool should_change_focus_mode = false;
2123 mm_camcorder_get_attributes(handle->mm_handle, NULL,
2124 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2127 if( focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO && focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO )
2128 should_change_focus_mode = true;
2130 if( mode != CAMERA_ATTR_AF_NONE && focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && !handle->on_continuous_focusing ){
2131 handle->cached_focus_mode = mode;
2132 LOGD("af mode will be set actually start focusing");
2133 return __convert_camera_error_code(__func__, 0);
2135 handle->cached_focus_mode = -1;
2138 if( mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode ){
2139 mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO, NULL);
2143 case CAMERA_ATTR_AF_NONE:
2144 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2145 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
2146 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NONE,
2149 case CAMERA_ATTR_AF_NORMAL:
2150 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2151 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NORMAL,
2154 case CAMERA_ATTR_AF_MACRO:
2155 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2156 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_MACRO,
2159 case CAMERA_ATTR_AF_FULL:
2160 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2161 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_FULL,
2168 return __convert_camera_error_code(__func__, ret);
2171 int camera_attr_set_af_area(camera_h camera, int x, int y){
2172 if( camera == NULL ){
2173 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2174 return CAMERA_ERROR_INVALID_PARAMETER;
2177 int ret = CAMERA_ERROR_INVALID_PARAMETER;
2178 camera_s * handle = (camera_s*)camera;
2179 camera_attr_af_mode_e mode;
2180 camera_attr_get_af_mode(camera, &mode);
2182 if( mode == CAMERA_ATTR_AF_NONE ){
2183 LOGE("INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE",CAMERA_ERROR_INVALID_OPERATION);
2184 return CAMERA_ERROR_INVALID_OPERATION;
2187 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2188 MMCAM_CAMERA_AF_TOUCH_X, x,
2189 MMCAM_CAMERA_AF_TOUCH_Y, y,
2192 if( ret == MM_ERROR_NONE )
2193 handle->focus_area_valid = true;
2195 return __convert_camera_error_code(__func__, ret);
2198 int camera_attr_clear_af_area(camera_h camera){
2199 if( camera == NULL ){
2200 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2201 return CAMERA_ERROR_INVALID_PARAMETER;
2204 camera_s * handle = (camera_s*)camera;
2205 handle->focus_area_valid = false;
2207 return CAMERA_ERROR_NONE;
2210 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode){
2211 if( camera == NULL ){
2212 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2213 return CAMERA_ERROR_INVALID_PARAMETER;
2216 int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, //CAMCORDER_EXPOSURE_MODE_OFF
2217 MM_CAMCORDER_AUTO_EXPOSURE_ALL, //CAMCORDER_EXPOSURE_MODE_ALL
2218 MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, //CAMCORDER_EXPOSURE_MODE_CENTER
2219 MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, //CAMCORDER_EXPOSURE_MODE_SPOT
2220 MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1,//CAMCORDER_EXPOSURE_MODE_CUSTOM
2224 camera_s * handle = (camera_s*)camera;
2225 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2226 MMCAM_CAMERA_EXPOSURE_MODE, maptable[abs(mode%5)],
2229 return __convert_camera_error_code(__func__, ret);
2232 int camera_attr_set_exposure(camera_h camera, int value){
2233 if( camera == NULL ){
2234 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2235 return CAMERA_ERROR_INVALID_PARAMETER;
2239 camera_s * handle = (camera_s*)camera;
2240 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2241 MMCAM_CAMERA_EXPOSURE_VALUE, value,
2244 return __convert_camera_error_code(__func__, ret);
2247 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso){
2248 if( camera == NULL ){
2249 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2250 return CAMERA_ERROR_INVALID_PARAMETER;
2254 camera_s * handle = (camera_s*)camera;
2255 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2256 MMCAM_CAMERA_ISO, iso,
2259 return __convert_camera_error_code(__func__, ret);
2262 int camera_attr_set_brightness(camera_h camera, int level){
2263 if( camera == NULL ){
2264 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2265 return CAMERA_ERROR_INVALID_PARAMETER;
2269 camera_s * handle = (camera_s*)camera;
2270 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2271 MMCAM_FILTER_BRIGHTNESS, level,
2274 return __convert_camera_error_code(__func__, ret);
2277 int camera_attr_set_contrast(camera_h camera, int level){
2278 if( camera == NULL ){
2279 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2280 return CAMERA_ERROR_INVALID_PARAMETER;
2284 camera_s * handle = (camera_s*)camera;
2285 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2286 MMCAM_FILTER_CONTRAST, level,
2289 return __convert_camera_error_code(__func__, ret);
2292 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb){
2293 if( camera == NULL ){
2294 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2295 return CAMERA_ERROR_INVALID_PARAMETER;
2299 camera_s * handle = (camera_s*)camera;
2300 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2301 MMCAM_FILTER_WB, wb,
2304 return __convert_camera_error_code(__func__, ret);
2307 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect){
2308 if( camera == NULL ){
2309 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2310 return CAMERA_ERROR_INVALID_PARAMETER;
2314 camera_s * handle = (camera_s*)camera;
2315 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2316 MMCAM_FILTER_COLOR_TONE, effect,
2319 return __convert_camera_error_code(__func__, ret);
2322 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode){
2323 if( camera == NULL ){
2324 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2325 return CAMERA_ERROR_INVALID_PARAMETER;
2329 camera_s * handle = (camera_s*)camera;
2330 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2331 MMCAM_FILTER_SCENE_MODE, mode,
2334 return __convert_camera_error_code(__func__, ret);
2337 int camera_attr_enable_tag(camera_h camera, bool enable){
2338 if( camera == NULL ){
2339 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2340 return CAMERA_ERROR_INVALID_PARAMETER;
2344 camera_s * handle = (camera_s*)camera;
2345 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2346 MMCAM_TAG_ENABLE, enable,
2349 return __convert_camera_error_code(__func__, ret);
2352 int camera_attr_set_tag_image_description(camera_h camera, const char *description){
2353 if( camera == NULL ){
2354 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2355 return CAMERA_ERROR_INVALID_PARAMETER;
2359 camera_s * handle = (camera_s*)camera;
2360 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2361 MMCAM_TAG_IMAGE_DESCRIPTION, description, strlen(description),
2364 return __convert_camera_error_code(__func__, ret);
2367 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation){
2368 if( camera == NULL ){
2369 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2370 return CAMERA_ERROR_INVALID_PARAMETER;
2374 camera_s * handle = (camera_s*)camera;
2375 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2376 MMCAM_TAG_ORIENTATION, orientation,
2379 return __convert_camera_error_code(__func__, ret);
2382 int camera_attr_set_tag_software(camera_h camera, const char *software){
2383 if( camera == NULL ){
2384 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2385 return CAMERA_ERROR_INVALID_PARAMETER;
2389 camera_s * handle = (camera_s*)camera;
2390 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2391 MMCAM_TAG_SOFTWARE, software, strlen(software),
2394 return __convert_camera_error_code(__func__, ret);
2397 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude){
2398 if( camera == NULL ){
2399 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2400 return CAMERA_ERROR_INVALID_PARAMETER;
2404 camera_s * handle = (camera_s*)camera;
2405 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2406 MMCAM_TAG_GPS_ENABLE, 1,
2407 MMCAM_TAG_LATITUDE, latitude,
2408 MMCAM_TAG_LONGITUDE, longitude,
2409 MMCAM_TAG_ALTITUDE, altitude,
2412 return __convert_camera_error_code(__func__, ret);
2415 int camera_attr_remove_geotag(camera_h camera){
2416 if( camera == NULL ){
2417 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2418 return CAMERA_ERROR_INVALID_PARAMETER;
2422 camera_s * handle = (camera_s*)camera;
2423 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2424 MMCAM_TAG_GPS_ENABLE, 0,
2427 return __convert_camera_error_code(__func__, ret);
2430 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode){
2431 if( camera == NULL ){
2432 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2433 return CAMERA_ERROR_INVALID_PARAMETER;
2437 camera_s * handle = (camera_s*)camera;
2438 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2439 MMCAM_STROBE_MODE, mode,
2442 return __convert_camera_error_code(__func__, ret);
2446 int camera_attr_get_zoom(camera_h camera, int *zoom){
2447 if( camera == NULL || zoom == NULL ){
2448 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2449 return CAMERA_ERROR_INVALID_PARAMETER;
2453 camera_s * handle = (camera_s*)camera;
2454 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2455 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2458 return __convert_camera_error_code(__func__, ret);
2461 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max){
2462 if( camera == NULL || min == NULL || max == NULL ){
2463 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2464 return CAMERA_ERROR_INVALID_PARAMETER;
2468 camera_s * handle = (camera_s*)camera;
2469 MMCamAttrsInfo ainfo;
2470 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
2473 *min = ainfo.int_range.min;
2475 *max = ainfo.int_range.max;
2477 return __convert_camera_error_code(__func__, ret);
2480 int camera_attr_get_af_mode( camera_h camera, camera_attr_af_mode_e *mode){
2481 if( camera == NULL || mode == NULL ){
2482 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2483 return CAMERA_ERROR_INVALID_PARAMETER;
2490 camera_s * handle = (camera_s*)camera;
2491 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2492 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2493 MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
2494 MMCAM_DETECT_MODE, &detect_mode,
2497 if( ret == CAMERA_ERROR_NONE ){
2498 switch( focus_mode ){
2499 case MM_CAMCORDER_FOCUS_MODE_NONE :
2500 case MM_CAMCORDER_FOCUS_MODE_PAN :
2501 case MM_CAMCORDER_FOCUS_MODE_MANUAL :
2502 *mode = CAMERA_ATTR_AF_NONE;
2504 case MM_CAMCORDER_FOCUS_MODE_AUTO:
2505 case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
2506 case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
2507 switch ( af_range ){
2508 case MM_CAMCORDER_AUTO_FOCUS_NONE :
2509 *mode = CAMERA_ATTR_AF_NORMAL;
2511 case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
2512 *mode = CAMERA_ATTR_AF_NORMAL;
2514 case MM_CAMCORDER_AUTO_FOCUS_MACRO:
2515 *mode = CAMERA_ATTR_AF_MACRO;
2517 case MM_CAMCORDER_AUTO_FOCUS_FULL:
2518 *mode = CAMERA_ATTR_AF_FULL;
2521 *mode = CAMERA_ATTR_AF_NORMAL;
2526 *mode = CAMERA_ATTR_AF_NONE;
2531 return __convert_camera_error_code(__func__, ret);
2534 int camera_attr_get_exposure_mode( camera_h camera, camera_attr_exposure_mode_e *mode){
2535 if( camera == NULL|| mode == NULL){
2536 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2537 return CAMERA_ERROR_INVALID_PARAMETER;
2541 CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
2542 CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
2543 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
2544 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
2545 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
2546 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
2547 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
2548 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
2549 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM //MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
2553 camera_s * handle = (camera_s*)camera;
2554 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_EXPOSURE_MODE, &exposure_mode, NULL);
2555 if( ret == CAMERA_ERROR_NONE ){
2556 *mode = maptable[abs(exposure_mode%9)];
2559 return __convert_camera_error_code(__func__, ret);
2562 int camera_attr_get_exposure(camera_h camera, int *value){
2563 if( camera == NULL || value == 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, MMCAM_CAMERA_EXPOSURE_VALUE, value, NULL);
2572 return __convert_camera_error_code(__func__, ret);
2575 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max){
2576 if( camera == NULL || min == NULL || max == NULL ){
2577 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2578 return CAMERA_ERROR_INVALID_PARAMETER;
2582 camera_s * handle = (camera_s*)camera;
2583 MMCamAttrsInfo ainfo;
2584 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
2587 *min = ainfo.int_range.min;
2589 *max = ainfo.int_range.max;
2591 return __convert_camera_error_code(__func__, ret);
2594 int camera_attr_get_iso( camera_h camera, camera_attr_iso_e *iso){
2595 if( camera == NULL || iso == NULL ){
2596 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2597 return CAMERA_ERROR_INVALID_PARAMETER;
2601 camera_s * handle = (camera_s*)camera;
2602 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2603 MMCAM_CAMERA_ISO, iso,
2606 return __convert_camera_error_code(__func__, ret);
2609 int camera_attr_get_brightness(camera_h camera, int *level){
2610 if( camera == NULL || level == NULL ){
2611 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2612 return CAMERA_ERROR_INVALID_PARAMETER;
2616 camera_s * handle = (camera_s*)camera;
2617 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2618 MMCAM_FILTER_BRIGHTNESS, level,
2621 return __convert_camera_error_code(__func__, ret);
2624 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max){
2625 if( camera == NULL || min == NULL || max == NULL ){
2626 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2627 return CAMERA_ERROR_INVALID_PARAMETER;
2631 camera_s * handle = (camera_s*)camera;
2632 MMCamAttrsInfo ainfo;
2633 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
2636 *min = ainfo.int_range.min;
2638 *max = ainfo.int_range.max;
2640 return __convert_camera_error_code(__func__, ret);
2643 int camera_attr_get_contrast(camera_h camera, int *level){
2644 if( camera == NULL || level == NULL ){
2645 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2646 return CAMERA_ERROR_INVALID_PARAMETER;
2650 camera_s * handle = (camera_s*)camera;
2651 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2652 MMCAM_FILTER_CONTRAST, level,
2655 return __convert_camera_error_code(__func__, ret);
2658 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max){
2659 if( camera == NULL || min == NULL || max == NULL ){
2660 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2661 return CAMERA_ERROR_INVALID_PARAMETER;
2665 camera_s * handle = (camera_s*)camera;
2666 MMCamAttrsInfo ainfo;
2667 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
2670 *min = ainfo.int_range.min;
2672 *max = ainfo.int_range.max;
2674 return __convert_camera_error_code(__func__, ret);
2677 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb){
2678 if( camera == NULL || wb == NULL ){
2679 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2680 return CAMERA_ERROR_INVALID_PARAMETER;
2684 camera_s * handle = (camera_s*)camera;
2685 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2686 MMCAM_FILTER_WB, wb,
2689 return __convert_camera_error_code(__func__, ret);
2692 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect){
2693 if( camera == NULL || effect == NULL ){
2694 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2695 return CAMERA_ERROR_INVALID_PARAMETER;
2699 camera_s * handle = (camera_s*)camera;
2701 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2702 MMCAM_FILTER_COLOR_TONE, &tone,
2705 if( ret != CAMERA_ERROR_NONE )
2706 return __convert_camera_error_code(__func__, ret);
2708 *effect = (camera_attr_effect_mode_e)tone;
2710 return __convert_camera_error_code(__func__, ret);
2713 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode){
2714 if( camera == NULL || mode == NULL ){
2715 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2716 return CAMERA_ERROR_INVALID_PARAMETER;
2720 camera_s * handle = (camera_s*)camera;
2721 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2722 MMCAM_FILTER_SCENE_MODE, mode,
2725 return __convert_camera_error_code(__func__, ret);
2728 int camera_attr_is_enabled_tag(camera_h camera, bool *enable){
2729 if( camera == NULL || enable == NULL ){
2730 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2731 return CAMERA_ERROR_INVALID_PARAMETER;
2735 camera_s * handle = (camera_s*)camera;
2737 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2738 MMCAM_TAG_ENABLE, enable,
2741 return __convert_camera_error_code(__func__, ret);
2744 int camera_attr_get_tag_image_description(camera_h camera, char **description){
2745 if( camera == NULL || description == NULL ){
2746 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2747 return CAMERA_ERROR_INVALID_PARAMETER;
2751 camera_s * handle = (camera_s*)camera;
2752 char *ndescription = NULL;
2754 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_TAG_IMAGE_DESCRIPTION, &ndescription, &desc_size, NULL);
2756 if( ret == CAMERA_ERROR_NONE ){
2757 if( ndescription != NULL )
2758 *description = strdup(ndescription);
2760 *description = strdup("");
2763 return __convert_camera_error_code(__func__, ret);
2766 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation){
2767 if( camera == NULL || orientation == NULL ){
2768 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2769 return CAMERA_ERROR_INVALID_PARAMETER;
2773 camera_s * handle = (camera_s*)camera;
2774 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2775 MMCAM_TAG_ORIENTATION, orientation,
2778 return __convert_camera_error_code(__func__, ret);
2781 int camera_attr_get_tag_software(camera_h camera, char **software){
2782 if( camera == NULL || software == NULL ){
2783 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2784 return CAMERA_ERROR_INVALID_PARAMETER;
2788 camera_s * handle = (camera_s*)camera;
2792 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_TAG_SOFTWARE, &soft, &soft_size, NULL);
2794 if( ret == CAMERA_ERROR_NONE ){
2796 *software = strdup(soft);
2798 *software = strdup("");
2801 return __convert_camera_error_code(__func__, ret);
2804 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude){
2805 if( camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL ){
2806 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2807 return CAMERA_ERROR_INVALID_PARAMETER;
2811 camera_s * handle = (camera_s*)camera;
2812 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2813 MMCAM_TAG_LATITUDE, latitude,
2814 MMCAM_TAG_LONGITUDE, longitude,
2815 MMCAM_TAG_ALTITUDE, altitude,
2818 return __convert_camera_error_code(__func__, ret);
2821 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode){
2822 if( camera == NULL || mode == NULL ){
2823 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2824 return CAMERA_ERROR_INVALID_PARAMETER;
2828 camera_s * handle = (camera_s*)camera;
2829 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2830 MMCAM_STROBE_MODE, mode,
2833 return __convert_camera_error_code(__func__, ret);
2836 int camera_attr_foreach_supported_af_mode( camera_h camera, camera_attr_supported_af_mode_cb foreach_cb , void *user_data){
2837 if( camera == NULL || foreach_cb == NULL ){
2838 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2839 return CAMERA_ERROR_INVALID_PARAMETER;
2844 camera_s * handle = (camera_s*)camera;
2845 MMCamAttrsInfo af_range;
2846 MMCamAttrsInfo focus_mode;
2848 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE, &af_range);
2849 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE, &focus_mode);
2851 if( ret != CAMERA_ERROR_NONE )
2852 return __convert_camera_error_code(__func__, ret);
2854 for( i=0 ; i < af_range.int_array.count ; i++ ) {
2855 if( !foreach_cb(af_range.int_array.array[i],user_data) )
2861 return CAMERA_ERROR_NONE;
2864 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data){
2865 if( camera == NULL || foreach_cb == NULL ){
2866 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2867 return CAMERA_ERROR_INVALID_PARAMETER;
2871 CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
2872 CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
2873 CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
2874 -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
2875 -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
2876 CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
2877 -1, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
2878 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
2879 -1//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
2882 camera_s * handle = (camera_s*)camera;
2883 MMCamAttrsInfo info;
2884 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE , &info);
2886 if( ret != CAMERA_ERROR_NONE )
2887 return __convert_camera_error_code(__func__, ret);
2890 for( i=0 ; i < info.int_array.count ; i++ ){
2891 if( maptable[info.int_array.array[i]] != -1 ){
2892 if ( !foreach_cb(maptable[info.int_array.array[i]],user_data) )
2897 return CAMERA_ERROR_NONE;
2900 int camera_attr_foreach_supported_iso( camera_h camera, camera_attr_supported_iso_cb foreach_cb , void *user_data){
2901 if( camera == NULL || foreach_cb == NULL ){
2902 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2903 return CAMERA_ERROR_INVALID_PARAMETER;
2907 camera_s * handle = (camera_s*)camera;
2908 MMCamAttrsInfo info;
2909 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO , &info);
2911 if( ret != CAMERA_ERROR_NONE )
2912 return __convert_camera_error_code(__func__, ret);
2915 for( i=0 ; i < info.int_array.count ; i++ ){
2916 if( !foreach_cb(info.int_array.array[i],user_data) )
2920 return CAMERA_ERROR_NONE;
2923 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_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_WB, &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_effect(camera_h camera, camera_attr_supported_effect_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_FILTER_COLOR_TONE , &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 int effect = info.int_array.array[i];
2963 if( !foreach_cb(effect,user_data) )
2967 return CAMERA_ERROR_NONE;
2970 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data){
2971 if( camera == NULL || foreach_cb == NULL ){
2972 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2973 return CAMERA_ERROR_INVALID_PARAMETER;
2977 camera_s * handle = (camera_s*)camera;
2978 MMCamAttrsInfo info;
2979 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE , &info);
2981 if( ret != CAMERA_ERROR_NONE )
2982 return __convert_camera_error_code(__func__, ret);
2985 for( i=0 ; i < info.int_array.count ; i++){
2986 if ( !foreach_cb(info.int_array.array[i],user_data) )
2990 return CAMERA_ERROR_NONE;
2993 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data){
2994 if( camera == NULL || foreach_cb == NULL){
2995 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
2996 return CAMERA_ERROR_INVALID_PARAMETER;
3000 camera_s * handle = (camera_s*)camera;
3001 MMCamAttrsInfo info;
3002 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE , &info);
3004 if( ret != CAMERA_ERROR_NONE )
3005 return __convert_camera_error_code(__func__, ret);
3008 for( i=0 ; i < info.int_array.count ; i++){
3009 if( !foreach_cb(info.int_array.array[i],user_data) )
3013 return CAMERA_ERROR_NONE;
3016 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data){
3017 if( camera == NULL || foreach_cb == NULL ){
3018 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3019 return CAMERA_ERROR_INVALID_PARAMETER;
3023 camera_s * handle = (camera_s*)camera;
3024 MMCamAttrsInfo info;
3025 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info);
3027 if( ret != CAMERA_ERROR_NONE )
3028 return __convert_camera_error_code(__func__, ret);
3031 for( i=0 ; i < info.int_array.count ; i++){
3032 if( !foreach_cb(info.int_array.array[i],user_data) )
3036 return CAMERA_ERROR_NONE;
3039 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data){
3040 if( camera == NULL || foreach_cb == NULL ){
3041 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3042 return CAMERA_ERROR_INVALID_PARAMETER;
3046 camera_s * handle = (camera_s*)camera;
3047 MMCamAttrsInfo info;
3048 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FLIP , &info);
3050 if( ret != CAMERA_ERROR_NONE )
3051 return __convert_camera_error_code(__func__, ret);
3054 for( i=0 ; i < info.int_array.count ; i++){
3055 if( !foreach_cb(info.int_array.array[i], user_data) )
3059 return CAMERA_ERROR_NONE;
3062 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data){
3063 if( camera == NULL || foreach_cb == NULL ){
3064 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3065 return CAMERA_ERROR_INVALID_PARAMETER;
3069 camera_s * handle = (camera_s*)camera;
3070 MMCamAttrsInfo info;
3071 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ROTATION , &info);
3073 if( ret != CAMERA_ERROR_NONE )
3074 return __convert_camera_error_code(__func__, ret);
3077 for( i=0 ; i < info.int_array.count ; i++ ){
3078 if( !foreach_cb(info.int_array.array[i], user_data) )
3082 return CAMERA_ERROR_NONE;
3085 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation){
3086 if( camera == NULL){
3087 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3088 return CAMERA_ERROR_INVALID_PARAMETER;
3091 if( rotation > CAMERA_ROTATION_270 )
3092 return CAMERA_ERROR_INVALID_PARAMETER;
3095 camera_s * handle = (camera_s*)camera;
3097 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ROTATION, rotation, NULL);
3099 return __convert_camera_error_code(__func__, ret);
3102 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation){
3103 if( camera == NULL || rotation == NULL ){
3104 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3105 return CAMERA_ERROR_INVALID_PARAMETER;
3109 camera_s * handle = (camera_s*)camera;
3111 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ROTATION, rotation, NULL);
3113 return __convert_camera_error_code(__func__, ret);
3116 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip){
3117 if( camera == NULL ){
3118 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3119 return CAMERA_ERROR_INVALID_PARAMETER;
3122 if( flip > CAMERA_FLIP_BOTH )
3123 return CAMERA_ERROR_INVALID_PARAMETER;
3126 camera_s * handle = (camera_s*)camera;
3127 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3128 MMCAM_CAMERA_FLIP, flip,
3131 return __convert_camera_error_code(__func__, ret);
3134 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip){
3135 if( camera == NULL || flip == NULL ){
3136 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3137 return CAMERA_ERROR_INVALID_PARAMETER;
3140 camera_s * handle = (camera_s*)camera;
3141 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FLIP, flip, NULL);
3143 return __convert_camera_error_code(__func__, ret);
3146 int _camera_set_use(camera_h camera, bool used){
3147 camera_s * handle = (camera_s*)camera;
3148 handle->is_used_in_recorder = used;
3149 return CAMERA_ERROR_NONE;
3152 bool _camera_is_used(camera_h camera){
3153 camera_s * handle = (camera_s*)camera;
3154 return handle->is_used_in_recorder;
3157 int _camera_get_mm_handle(camera_h camera , MMHandleType *handle){
3158 if( camera == NULL || handle == NULL ){
3159 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3160 return CAMERA_ERROR_INVALID_PARAMETER;
3162 camera_s *camera_handle = (camera_s*)camera;
3163 *handle = camera_handle->mm_handle;
3165 return CAMERA_ERROR_NONE;
3168 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data){
3169 if( camera == NULL ){
3170 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3171 return CAMERA_ERROR_INVALID_PARAMETER;
3174 camera_s *handle = (camera_s*)camera;
3175 handle->relay_message_callback = callback;
3176 handle->relay_user_data = user_data;
3178 return CAMERA_ERROR_NONE;
3181 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format){
3182 if( in_format <= MM_PIXEL_FORMAT_INVALID ||
3183 in_format >= MM_PIXEL_FORMAT_NUM ||
3184 out_format == NULL ){
3185 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
3186 return CAMERA_ERROR_INVALID_PARAMETER;
3189 switch( in_format ){
3190 case MM_PIXEL_FORMAT_NV12:
3191 case MM_PIXEL_FORMAT_NV12T:
3192 *out_format = TBM_FORMAT_NV12;
3194 case MM_PIXEL_FORMAT_NV16:
3195 *out_format = TBM_FORMAT_NV16;
3197 case MM_PIXEL_FORMAT_NV21:
3198 *out_format = TBM_FORMAT_NV21;
3200 case MM_PIXEL_FORMAT_YUYV:
3201 *out_format = TBM_FORMAT_YUYV;
3203 case MM_PIXEL_FORMAT_UYVY:
3204 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3205 *out_format = TBM_FORMAT_UYVY;
3207 case MM_PIXEL_FORMAT_422P:
3208 *out_format = TBM_FORMAT_YUV422;
3210 case MM_PIXEL_FORMAT_I420:
3211 *out_format = TBM_FORMAT_YUV420;
3213 case MM_PIXEL_FORMAT_YV12:
3214 *out_format = TBM_FORMAT_YVU420;
3216 case MM_PIXEL_FORMAT_RGB565:
3217 *out_format = TBM_FORMAT_RGB565;
3219 case MM_PIXEL_FORMAT_RGB888:
3220 *out_format = TBM_FORMAT_RGB888;
3222 case MM_PIXEL_FORMAT_RGBA:
3223 *out_format = TBM_FORMAT_RGBA8888;
3225 case MM_PIXEL_FORMAT_ARGB:
3226 *out_format = TBM_FORMAT_ARGB8888;
3229 LOGE("invalid in_format %d", in_format);
3230 return CAMERA_ERROR_INVALID_PARAMETER;
3233 return CAMERA_ERROR_NONE;
3236 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype){
3237 if( in_format <= MM_PIXEL_FORMAT_INVALID ||
3238 in_format >= MM_PIXEL_FORMAT_NUM ||
3240 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
3241 return CAMERA_ERROR_INVALID_PARAMETER;
3244 switch (in_format) {
3245 case MM_PIXEL_FORMAT_NV12:
3246 case MM_PIXEL_FORMAT_NV12T:
3247 *mimetype = MEDIA_FORMAT_NV12;
3249 case MM_PIXEL_FORMAT_NV16:
3250 *mimetype = MEDIA_FORMAT_NV16;
3252 case MM_PIXEL_FORMAT_NV21:
3253 *mimetype = MEDIA_FORMAT_NV21;
3255 case MM_PIXEL_FORMAT_YUYV:
3256 *mimetype = MEDIA_FORMAT_YUYV;
3258 case MM_PIXEL_FORMAT_UYVY:
3259 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3260 *mimetype = MEDIA_FORMAT_UYVY;
3262 case MM_PIXEL_FORMAT_422P:
3263 *mimetype = MEDIA_FORMAT_422P;
3265 case MM_PIXEL_FORMAT_I420:
3266 *mimetype = MEDIA_FORMAT_I420;
3268 case MM_PIXEL_FORMAT_YV12:
3269 *mimetype = MEDIA_FORMAT_YV12;
3271 case MM_PIXEL_FORMAT_RGB565:
3272 *mimetype = MEDIA_FORMAT_RGB565;
3274 case MM_PIXEL_FORMAT_RGB888:
3275 *mimetype = MEDIA_FORMAT_RGB888;
3277 case MM_PIXEL_FORMAT_RGBA:
3278 *mimetype = MEDIA_FORMAT_RGBA;
3280 case MM_PIXEL_FORMAT_ARGB:
3281 *mimetype = MEDIA_FORMAT_ARGB;
3284 LOGE("invalid in_format %d", in_format);
3285 return CAMERA_ERROR_INVALID_PARAMETER;
3288 return CAMERA_ERROR_NONE;
3291 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data){
3293 void *internal_buffer = NULL;
3294 tbm_surface_h tsurf = NULL;
3296 if( pkt == NULL || user_data == NULL ){
3297 LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
3298 return MEDIA_PACKET_FINALIZE;
3301 ret = media_packet_get_extra(pkt, &internal_buffer);
3303 if( ret != MEDIA_PACKET_ERROR_NONE ){
3304 LOGE("media_packet_get_extra failed 0x%x", ret);
3305 return MEDIA_PACKET_FINALIZE;
3308 /*LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret);*/
3310 if( internal_buffer ){
3311 gst_buffer_unref((GstBuffer *)internal_buffer);
3312 internal_buffer = NULL;
3315 ret = media_packet_get_tbm_surface(pkt, &tsurf);
3316 if( ret != MEDIA_PACKET_ERROR_NONE ){
3317 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
3318 return MEDIA_PACKET_FINALIZE;
3322 tbm_surface_destroy(tsurf);
3326 return MEDIA_PACKET_FINALIZE;
3329 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode){
3330 if( camera == NULL ){
3331 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3332 return CAMERA_ERROR_INVALID_PARAMETER;
3335 if( camera_attr_is_supported_hdr_capture(camera) == false ){
3336 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3337 return CAMERA_ERROR_NOT_SUPPORTED;
3341 camera_s * handle = (camera_s*)camera;
3342 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_HDR_CAPTURE, mode, NULL);
3344 if( ret == MM_ERROR_NONE ){
3345 if( mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL )
3346 handle->hdr_keep_mode = true;
3348 handle->hdr_keep_mode = false;
3351 return __convert_camera_error_code(__func__, ret);
3354 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode){
3355 if( camera == NULL ){
3356 LOGE("INVALID_PARAMETER(0x%08x) - handle",CAMERA_ERROR_INVALID_PARAMETER);
3357 return CAMERA_ERROR_INVALID_PARAMETER;
3360 if( camera_attr_is_supported_hdr_capture(camera) == false ){
3361 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3362 return CAMERA_ERROR_NOT_SUPPORTED;
3366 LOGE("INVALID_PARAMETER(0x%08x) - mode",CAMERA_ERROR_INVALID_PARAMETER);
3367 return CAMERA_ERROR_INVALID_PARAMETER;
3372 camera_s * handle = (camera_s*)camera;
3373 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_HDR_CAPTURE, &result, NULL);
3375 if( ret == MM_ERROR_NONE ){
3379 return __convert_camera_error_code(__func__, ret);
3382 bool camera_attr_is_supported_hdr_capture(camera_h camera){
3383 if( camera == NULL ){
3384 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3389 camera_s * handle = (camera_s*)camera;
3390 MMCamAttrsInfo hdr_info;
3392 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE, &hdr_info);
3393 set_last_result(__convert_camera_error_code(__func__, ret));
3394 if( ret != MM_ERROR_NONE ){
3395 LOGE("MMCAM_CAMERA_HDR_CAPTURE get attr info failed");
3399 for( i = 0; i < hdr_info.int_array.count ; i++ ){
3400 if( hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON ){
3401 LOGD("HDR capture supported");
3406 LOGD("HDR capture NOT supported");
3411 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void* user_data){
3412 if( camera == NULL ){
3413 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3414 return CAMERA_ERROR_INVALID_PARAMETER;
3417 if( camera_attr_is_supported_hdr_capture(camera) == false ){
3418 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3419 return CAMERA_ERROR_NOT_SUPPORTED;
3422 if( callback == NULL ){
3423 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
3424 return CAMERA_ERROR_INVALID_PARAMETER;
3427 camera_s * handle = (camera_s*)camera;
3428 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)callback;
3429 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)user_data;
3430 return CAMERA_ERROR_NONE;
3433 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera){
3434 if( camera == NULL ){
3435 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3436 return CAMERA_ERROR_INVALID_PARAMETER;
3439 if( camera_attr_is_supported_hdr_capture(camera) == false ){
3440 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3441 return CAMERA_ERROR_NOT_SUPPORTED;
3444 camera_s * handle = (camera_s*)camera;
3445 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
3446 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
3448 return CAMERA_ERROR_NONE;
3451 int camera_attr_enable_anti_shake(camera_h camera, bool enable){
3452 if( camera == NULL ){
3453 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3454 return CAMERA_ERROR_INVALID_PARAMETER;
3457 if( camera_attr_is_supported_anti_shake(camera) == false ){
3458 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3459 return CAMERA_ERROR_NOT_SUPPORTED;
3463 int mode = MM_CAMCORDER_AHS_OFF;
3466 mode = MM_CAMCORDER_AHS_ON;
3468 camera_s * handle = (camera_s*)camera;
3469 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ANTI_HANDSHAKE, mode, NULL);
3471 return __convert_camera_error_code(__func__, ret);
3474 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled){
3475 if( camera == NULL ){
3476 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3477 return CAMERA_ERROR_INVALID_PARAMETER;
3480 if( camera_attr_is_supported_anti_shake(camera) == false ){
3481 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3482 return CAMERA_ERROR_NOT_SUPPORTED;
3485 if( enabled == NULL ){
3486 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
3487 return CAMERA_ERROR_INVALID_PARAMETER;
3491 int mode = MM_CAMCORDER_AHS_OFF;
3492 camera_s * handle = (camera_s*)camera;
3493 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ANTI_HANDSHAKE, &mode, NULL);
3495 if( ret == MM_ERROR_NONE )
3498 return __convert_camera_error_code(__func__, ret);
3501 bool camera_attr_is_supported_anti_shake(camera_h camera){
3502 if( camera == NULL ){
3503 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3508 camera_s * handle = (camera_s*)camera;
3509 MMCamAttrsInfo ash_info;
3510 int ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE , &ash_info);
3511 set_last_result(__convert_camera_error_code(__func__, ret));
3513 for( i=0 ; i < ash_info.int_array.count ; i++ ){
3514 if( ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON )
3521 int camera_attr_enable_video_stabilization(camera_h camera, bool enable){
3522 if( camera == NULL ){
3523 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3524 return CAMERA_ERROR_INVALID_PARAMETER;
3527 if( camera_attr_is_supported_video_stabilization(camera) == false ){
3528 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3529 return CAMERA_ERROR_NOT_SUPPORTED;
3533 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
3536 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
3538 camera_s * handle = (camera_s*)camera;
3539 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_VIDEO_STABILIZATION, mode, NULL);
3541 return __convert_camera_error_code(__func__, ret);
3544 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled){
3545 if( camera == NULL ){
3546 LOGE("INVALID_PARAMETER(0x%08x) - handle",CAMERA_ERROR_INVALID_PARAMETER);
3547 return CAMERA_ERROR_INVALID_PARAMETER;
3550 if( camera_attr_is_supported_video_stabilization(camera) == false ){
3551 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3552 return CAMERA_ERROR_NOT_SUPPORTED;
3555 if( enabled == NULL ){
3556 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
3557 return CAMERA_ERROR_INVALID_PARAMETER;
3561 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
3562 camera_s * handle = (camera_s*)camera;
3563 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_VIDEO_STABILIZATION, &mode, NULL);
3565 if( ret == MM_ERROR_NONE )
3566 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
3568 return __convert_camera_error_code(__func__, ret);
3571 bool camera_attr_is_supported_video_stabilization(camera_h camera){
3572 if( camera == NULL ){
3573 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3578 camera_s * handle = (camera_s*)camera;
3579 MMCamAttrsInfo vs_info;
3580 int ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION , &vs_info);
3581 set_last_result(__convert_camera_error_code(__func__, ret));
3583 for( i=0 ; i < vs_info.int_array.count ; i++ ){
3584 if( vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON )
3591 int camera_attr_enable_auto_contrast(camera_h camera, bool enable){
3592 if( camera == NULL ){
3593 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3594 return CAMERA_ERROR_INVALID_PARAMETER;
3597 if( camera_attr_is_supported_auto_contrast(camera) == false ){
3598 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3599 return CAMERA_ERROR_NOT_SUPPORTED;
3603 int mode = MM_CAMCORDER_WDR_OFF;
3606 mode = MM_CAMCORDER_WDR_ON;
3608 camera_s * handle = (camera_s*)camera;
3609 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_WDR, mode, NULL);
3611 return __convert_camera_error_code(__func__, ret);
3614 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled){
3615 if( camera == NULL ){
3616 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3617 return CAMERA_ERROR_INVALID_PARAMETER;
3620 if( camera_attr_is_supported_auto_contrast(camera) == false ){
3621 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3622 return CAMERA_ERROR_NOT_SUPPORTED;
3625 if( enabled == NULL ){
3626 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
3627 return CAMERA_ERROR_INVALID_PARAMETER;
3631 int mode = MM_CAMCORDER_WDR_OFF;
3632 camera_s * handle = (camera_s*)camera;
3633 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WDR , &mode, NULL);
3635 if( ret == MM_ERROR_NONE )
3638 return __convert_camera_error_code(__func__, ret);
3641 bool camera_attr_is_supported_auto_contrast(camera_h camera) {
3642 if( camera == NULL ){
3643 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3648 camera_s * handle = (camera_s*)camera;
3649 MMCamAttrsInfo info;
3650 int ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WDR, &info);
3651 set_last_result(__convert_camera_error_code(__func__, ret));
3653 for( i=0 ; i < info.int_array.count ; i++ ) {
3654 if( info.int_array.array[i] == MM_CAMCORDER_WDR_ON )
3661 int camera_attr_disable_shutter_sound(camera_h camera, bool disable){
3662 if (camera == NULL ){
3663 LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
3664 return CAMERA_ERROR_INVALID_PARAMETER;
3668 camera_s * handle = (camera_s*)camera;
3669 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, "capture-sound-enable", !disable, NULL);
3672 LOGE("CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound");
3673 return CAMERA_ERROR_INVALID_OPERATION;
3676 return CAMERA_ERROR_NONE;