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>
36 #include <Ecore_Wayland.h>
37 #endif /* HAVE_WAYLAND */
38 #include <Elementary.h>
43 #define LOG_TAG "TIZEN_N_CAMERA"
45 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType *stream, void *user_data);
46 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data);
49 void _camera_remove_cb_message(camera_s *handle)
53 camera_cb_data *cb_data = NULL;
56 LOGE("handle is NULL");
62 g_mutex_lock(&handle->idle_cb_lock);
64 if (handle->cb_data_list) {
65 list = handle->cb_data_list;
69 list = g_list_next(list);
72 LOGW("cb_data is NULL");
74 ret = g_idle_remove_by_data (cb_data);
75 LOGW("Remove cb_data[%p]. ret[%d]", cb_data, ret);
77 handle->cb_data_list = g_list_remove(handle->cb_data_list, cb_data);
83 g_list_free(handle->cb_data_list);
84 handle->cb_data_list = NULL;
86 LOGW("There is no remained callback");
89 g_mutex_unlock(&handle->idle_cb_lock);
97 int __convert_camera_error_code(const char *func, int code)
99 int ret = CAMERA_ERROR_NONE;
100 const char *errorstr = NULL;
104 ret = CAMERA_ERROR_NONE;
105 errorstr = "ERROR_NONE";
107 case MM_ERROR_CAMCORDER_INVALID_ARGUMENT:
108 case MM_ERROR_COMMON_INVALID_ATTRTYPE:
109 ret = CAMERA_ERROR_INVALID_PARAMETER;
110 errorstr = "INVALID_PARAMETER";
112 case MM_ERROR_CAMCORDER_NOT_INITIALIZED:
113 case MM_ERROR_CAMCORDER_INVALID_STATE:
114 ret = CAMERA_ERROR_INVALID_STATE;
115 errorstr = "INVALID_STATE";
117 case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND:
118 ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
119 errorstr = "DEVICE_NOT_FOUND";
121 case MM_ERROR_CAMCORDER_DEVICE_BUSY:
122 case MM_ERROR_CAMCORDER_DEVICE_OPEN:
123 case MM_ERROR_CAMCORDER_CMD_IS_RUNNING:
124 ret = CAMERA_ERROR_DEVICE_BUSY;
125 errorstr = "DEVICE_BUSY";
127 case MM_ERROR_CAMCORDER_DEVICE:
128 case MM_ERROR_CAMCORDER_DEVICE_IO:
129 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
130 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
131 case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER:
132 ret = CAMERA_ERROR_DEVICE;
133 errorstr = "ERROR_DEVICE";
135 case MM_ERROR_CAMCORDER_GST_CORE:
136 case MM_ERROR_CAMCORDER_GST_LIBRARY:
137 case MM_ERROR_CAMCORDER_GST_RESOURCE:
138 case MM_ERROR_CAMCORDER_GST_STREAM:
139 case MM_ERROR_CAMCORDER_GST_STATECHANGE:
140 case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
141 case MM_ERROR_CAMCORDER_GST_LINK:
142 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
143 case MM_ERROR_CAMCORDER_ENCODER:
144 case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
145 case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE:
146 case MM_ERROR_CAMCORDER_ENCODER_WORKING:
147 case MM_ERROR_CAMCORDER_INTERNAL:
148 case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT:
149 case MM_ERROR_CAMCORDER_DSP_FAIL:
150 case MM_ERROR_CAMCORDER_AUDIO_EMPTY:
151 case MM_ERROR_CAMCORDER_CREATE_CONFIGURE:
152 case MM_ERROR_CAMCORDER_FILE_SIZE_OVER:
153 case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF:
154 case MM_ERROR_CAMCORDER_INVALID_CONDITION:
155 ret = CAMERA_ERROR_INVALID_OPERATION;
156 errorstr = "INVALID_OPERATION";
158 case MM_ERROR_CAMCORDER_RESOURCE_CREATION:
159 case MM_ERROR_COMMON_OUT_OF_MEMORY:
160 ret = CAMERA_ERROR_OUT_OF_MEMORY;
161 errorstr = "OUT_OF_MEMORY";
163 case MM_ERROR_POLICY_BLOCKED:
164 ret = CAMERA_ERROR_SOUND_POLICY;
165 errorstr = "ERROR_SOUND_POLICY";
167 case MM_ERROR_POLICY_BLOCKED_BY_CALL:
168 ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
169 errorstr = "ERROR_SOUND_POLICY_BY_CALL";
171 case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
172 ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
173 errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
175 case MM_ERROR_POLICY_RESTRICTED:
176 ret = CAMERA_ERROR_SECURITY_RESTRICTED;
177 errorstr = "ERROR_RESTRICTED";
179 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
180 ret = CAMERA_ERROR_ESD;
181 errorstr = "ERROR_ESD";
183 case MM_ERROR_COMMON_INVALID_PERMISSION:
184 ret = CAMERA_ERROR_PERMISSION_DENIED;
185 errorstr = "ERROR_PERMISSION_DENIED";
187 case MM_ERROR_COMMON_OUT_OF_ARRAY:
188 case MM_ERROR_COMMON_OUT_OF_RANGE:
189 case MM_ERROR_COMMON_ATTR_NOT_EXIST:
190 case MM_ERROR_CAMCORDER_NOT_SUPPORTED:
191 ret = CAMERA_ERROR_NOT_SUPPORTED;
192 errorstr = "ERROR_NOT_SUPPORTED";
195 ret = CAMERA_ERROR_INVALID_OPERATION;
196 errorstr = "INVALID_OPERATION";
199 if (code != MM_ERROR_NONE) {
200 LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func ? func : "NULL_FUNC", errorstr, ret, code);
207 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType *stream, void *user_data)
209 if (user_data == NULL || stream == NULL) {
213 camera_s *handle = (camera_s *)user_data;
215 if (handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW]) {
216 camera_preview_data_s frame;
218 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
219 frame.format = MM_PIXEL_FORMAT_UYVY;
221 frame.format = stream->format;
223 frame.width = stream->width;
224 frame.height = stream->height;
225 frame.timestamp = stream->timestamp;
226 frame.num_of_planes = stream->num_planes;
228 switch (stream->data_type) {
229 case MM_CAM_STREAM_DATA_YUV420:
230 frame.data.single_plane.yuv = stream->data.yuv420.yuv;
231 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
233 case MM_CAM_STREAM_DATA_YUV422:
234 frame.data.single_plane.yuv = stream->data.yuv422.yuv;
235 frame.data.single_plane.size = stream->data.yuv422.length_yuv;
237 case MM_CAM_STREAM_DATA_YUV420SP:
238 frame.data.double_plane.y = stream->data.yuv420sp.y;
239 frame.data.double_plane.uv = stream->data.yuv420sp.uv;
240 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
241 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
243 case MM_CAM_STREAM_DATA_YUV420P:
244 frame.data.triple_plane.y = stream->data.yuv420p.y;
245 frame.data.triple_plane.u = stream->data.yuv420p.u;
246 frame.data.triple_plane.v = stream->data.yuv420p.v;
247 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
248 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
249 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
251 case MM_CAM_STREAM_DATA_YUV422P:
252 frame.data.triple_plane.y = stream->data.yuv422p.y;
253 frame.data.triple_plane.u = stream->data.yuv422p.u;
254 frame.data.triple_plane.v = stream->data.yuv422p.v;
255 frame.data.triple_plane.y_size = stream->data.yuv422p.length_y;
256 frame.data.triple_plane.u_size = stream->data.yuv422p.length_u;
257 frame.data.triple_plane.v_size = stream->data.yuv422p.length_v;
263 ((camera_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW])(&frame, handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW]);
266 if (handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
267 media_packet_h pkt = NULL;
268 tbm_surface_h tsurf = NULL;
269 uint32_t bo_format = 0;
273 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
274 bool make_pkt_fmt = false;
275 tbm_surface_info_s tsurf_info;
277 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
279 /* create tbm surface */
280 for (i = 0, bo_num = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++) {
284 tsurf_info.planes[i].stride = stream->stride[i];
287 /* get tbm surface format */
288 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
289 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
291 if (bo_num > 0 && ret == CAMERA_ERROR_NONE) {
292 tsurf_info.width = stream->width;
293 tsurf_info.height = stream->height;
294 tsurf_info.format = bo_format;
295 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
296 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
299 case TBM_FORMAT_NV12:
300 case TBM_FORMAT_NV21:
301 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
302 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
303 tsurf_info.planes[0].offset = 0;
305 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
307 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
309 case TBM_FORMAT_YUV420:
310 case TBM_FORMAT_YVU420:
311 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
312 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
313 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
314 tsurf_info.planes[0].offset = 0;
316 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
317 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
319 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
321 case TBM_FORMAT_UYVY:
322 case TBM_FORMAT_YUYV:
323 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
324 tsurf_info.planes[0].offset = 0;
325 tsurf_info.size = tsurf_info.planes[0].size;
331 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, (tbm_bo *)stream->bo, bo_num);
332 /*LOGD("tbm surface %p", tsurf);*/
336 /* check media packet format */
337 if (handle->pkt_fmt) {
338 int pkt_fmt_width = 0;
339 int pkt_fmt_height = 0;
340 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
342 media_format_get_video_info(handle->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
343 if (pkt_fmt_mimetype != mimetype ||
344 pkt_fmt_width != stream->width ||
345 pkt_fmt_height != stream->height) {
346 LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
347 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
348 media_format_unref(handle->pkt_fmt);
349 handle->pkt_fmt = NULL;
356 /* create packet format */
358 LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
359 ret = media_format_create(&handle->pkt_fmt);
360 if (ret == MEDIA_FORMAT_ERROR_NONE) {
361 ret = media_format_set_video_mime(handle->pkt_fmt, mimetype);
362 ret |= media_format_set_video_width(handle->pkt_fmt, stream->width);
363 ret |= media_format_set_video_height(handle->pkt_fmt, stream->height);
364 LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
366 LOGW("media_format_create failed");
370 /* create media packet */
371 ret = media_packet_create_from_tbm_surface(handle->pkt_fmt, tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize, (void *)handle, &pkt);
372 if (ret != MEDIA_PACKET_ERROR_NONE) {
373 LOGE("media_packet_create_from_tbm_surface failed");
375 tbm_surface_destroy(tsurf);
379 LOGE("failed to create tbm surface %dx%d, format %d, bo_num %d", stream->width, stream->height, stream->format, bo_num);
383 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
385 /* set internal buffer */
386 ret = media_packet_set_extra(pkt, stream->internal_buffer);
387 if (ret != MEDIA_PACKET_ERROR_NONE) {
388 LOGE("media_packet_set_extra failed");
390 media_packet_destroy(pkt);
393 /* set timestamp : msec -> nsec */
394 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE) {
395 LOGW("media_packet_set_pts failed");
398 /* increase ref count of gst buffer */
399 gst_buffer_ref((GstBuffer *)stream->internal_buffer);
401 /* call media packet callback */
402 ((camera_media_packet_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt, handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
411 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data)
413 if (user_data == NULL || frame == NULL) {
417 camera_s *handle = (camera_s *)user_data;
418 int ret = MM_ERROR_NONE;
419 unsigned char *exif = NULL;
421 MMCamcorderCaptureDataType *scrnl = NULL;
424 handle->current_capture_count++;
426 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE]) {
427 camera_image_data_s image = { NULL, 0, 0, 0, 0, NULL, 0 };
428 camera_image_data_s thumb = { NULL, 0, 0, 0, 0, NULL, 0 };
429 camera_image_data_s postview = { NULL, 0, 0, 0, 0, NULL, 0 };
432 image.data = frame->data;
433 image.size = frame->length;
434 image.width = frame->width;
435 image.height = frame->height;
436 image.format = frame->format;
438 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
439 "captured-exif-raw-data", &exif, &exif_size,
441 if (ret == MM_ERROR_NONE) {
443 image.exif_size = exif_size;
448 thumb.data = thumbnail->data;
449 thumb.size = thumbnail->length;
450 thumb.width = thumbnail->width;
451 thumb.height = thumbnail->height;
452 thumb.format = thumbnail->format;
455 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
456 "captured-screennail", &scrnl, &scrnl_size,
458 if (ret == MM_ERROR_NONE && scrnl) {
459 postview.data = scrnl->data;
460 postview.size = scrnl->length;
461 postview.width = scrnl->width;
462 postview.height = scrnl->height;
463 postview.format = scrnl->format;
466 ((camera_capturing_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE])(&image,
467 scrnl ? &postview : NULL,
468 thumbnail ? &thumb : NULL,
469 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE]);
472 /* update captured state */
473 if (handle->capture_count == 1 && handle->hdr_keep_mode) {
474 if (handle->current_capture_count == 2) {
475 handle->is_capture_completed = true;
477 } else if (handle->capture_count == handle->current_capture_count ||
478 handle->is_continuous_shot_break) {
479 handle->is_capture_completed = true;
486 static camera_state_e __camera_state_convert(MMCamcorderStateType mm_state)
488 camera_state_e state = CAMERA_STATE_NONE;
491 case MM_CAMCORDER_STATE_NONE:
492 state = CAMERA_STATE_NONE;
494 case MM_CAMCORDER_STATE_NULL:
495 state = CAMERA_STATE_CREATED;
497 case MM_CAMCORDER_STATE_READY:
498 state = CAMERA_STATE_CREATED;
500 case MM_CAMCORDER_STATE_PREPARE:
501 state = CAMERA_STATE_PREVIEW;
503 case MM_CAMCORDER_STATE_CAPTURING:
504 state = CAMERA_STATE_CAPTURING;
506 case MM_CAMCORDER_STATE_RECORDING:
507 state = CAMERA_STATE_PREVIEW;
509 case MM_CAMCORDER_STATE_PAUSED:
510 state = CAMERA_STATE_PREVIEW;
513 state = CAMERA_STATE_NONE;
521 static int __mm_camera_message_callback(int message, void *param, void *user_data)
523 if (user_data == NULL || param == NULL) {
528 int camera_error = 0;
529 camera_s *handle = (camera_s *)user_data;
530 MMMessageParamType *m = (MMMessageParamType *)param;
531 camera_state_e previous_state;
532 camera_policy_e policy = CAMERA_POLICY_NONE;
533 MMCamFaceDetectInfo *cam_fd_info = NULL;
535 if (handle->relay_message_callback) {
536 handle->relay_message_callback(message, param, handle->relay_user_data);
540 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
541 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
542 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
543 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED &&
544 (m->state.previous < MM_CAMCORDER_STATE_NONE ||
545 m->state.previous > MM_CAMCORDER_STATE_PAUSED ||
546 m->state.code != 0)) {
547 LOGI( "Invalid state changed message");
551 previous_state = handle->state;
552 handle->state = __camera_state_convert(m->state.current );
554 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
555 switch (m->state.code) {
556 case ASM_EVENT_SOURCE_CALL_START:
557 case ASM_EVENT_SOURCE_CALL_END:
558 policy = CAMERA_POLICY_SOUND_BY_CALL;
559 LOGW("CAMERA_POLICY_SOUND_BY_CALL");
561 case ASM_EVENT_SOURCE_ALARM_START:
562 case ASM_EVENT_SOURCE_ALARM_END:
563 policy = CAMERA_POLICY_SOUND_BY_ALARM;
564 LOGW("CAMERA_POLICY_SOUND_BY_ALARM");
567 policy = CAMERA_POLICY_SOUND;
568 LOGW("CAMERA_POLICY_SOUND");
571 } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
572 policy = CAMERA_POLICY_SECURITY;
573 LOGW("CAMERA_POLICY_SECURITY");
576 if (previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
577 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
580 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
583 /* should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state */
584 if (policy != CAMERA_POLICY_NONE &&
585 m->state.current == MM_CAMCORDER_STATE_NULL) {
586 if (handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED]) {
587 ((camera_interrupted_cb)handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED])(policy,
590 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED]);
592 LOGW("_CAMERA_EVENT_TYPE_INTERRUPTED cb is NULL");
596 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED :
597 if (handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]) {
598 ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])(m->code,
599 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
602 case MM_MESSAGE_CAMCORDER_CAPTURED:
603 handle->current_capture_complete_count = m->code;
604 if (handle->capture_count == 1 ||
605 m->code == handle->capture_count ||
606 (handle->is_continuous_shot_break &&
607 handle->state == CAMERA_STATE_CAPTURING)) {
608 /* pseudo state change */
609 previous_state = handle->state ;
610 handle->state = CAMERA_STATE_CAPTURED;
611 if (previous_state != handle->state &&
612 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
613 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
616 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
618 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
619 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
623 case MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED:
624 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
625 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
628 case MM_MESSAGE_CAMCORDER_ERROR:
630 case MM_ERROR_CAMCORDER_DEVICE :
631 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
632 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
633 camera_error = CAMERA_ERROR_DEVICE;
635 case MM_ERROR_CAMCORDER_GST_CORE:
636 case MM_ERROR_CAMCORDER_GST_LIBRARY:
637 case MM_ERROR_CAMCORDER_GST_RESOURCE:
638 case MM_ERROR_CAMCORDER_GST_STREAM:
639 case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
640 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
641 case MM_ERROR_CAMCORDER_ENCODER:
642 case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
643 case MM_ERROR_CAMCORDER_ENCODER_WORKING:
644 case MM_ERROR_CAMCORDER_MNOTE_CREATION:
645 case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY:
646 case MM_ERROR_CAMCORDER_INTERNAL:
647 case MM_ERROR_FILE_NOT_FOUND:
648 case MM_ERROR_FILE_READ:
649 camera_error = CAMERA_ERROR_INVALID_OPERATION;
651 case MM_ERROR_CAMCORDER_LOW_MEMORY:
652 case MM_ERROR_CAMCORDER_MNOTE_MALLOC:
653 camera_error = CAMERA_ERROR_OUT_OF_MEMORY;
655 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
656 camera_error = CAMERA_ERROR_ESD;
659 camera_error = CAMERA_ERROR_INVALID_OPERATION;
663 /* set capture completed flag as true to release camera handle */
664 handle->is_capture_completed = true;
666 if (camera_error != 0 && handle->user_cb[_CAMERA_EVENT_TYPE_ERROR]) {
667 ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(camera_error,
669 handle->user_data[_CAMERA_EVENT_TYPE_ERROR]);
673 case MM_MESSAGE_CAMCORDER_HDR_PROGRESS:
674 if (handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS]) {
675 ((camera_attr_hdr_progress_cb)handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS])(m->code,
676 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
679 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
680 cam_fd_info = (MMCamFaceDetectInfo *)(m->data);
682 camera_detected_face_s faces[cam_fd_info->num_of_faces];
683 handle->num_of_faces = cam_fd_info->num_of_faces > MAX_DETECTED_FACE ? MAX_DETECTED_FACE : cam_fd_info->num_of_faces;
685 for (i = 0 ; i < handle->num_of_faces ; i++) {
686 faces[i].id = cam_fd_info->face_info[i].id;
687 faces[i].score = cam_fd_info->face_info[i].score;
688 faces[i].x = cam_fd_info->face_info[i].rect.x;
689 faces[i].y = cam_fd_info->face_info[i].rect.y;
690 faces[i].width = cam_fd_info->face_info[i].rect.width;
691 faces[i].height = cam_fd_info->face_info[i].rect.height;
692 handle->faceinfo[i] = faces[i]; //cache face coordinate
695 if (handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
696 ((camera_face_detected_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
697 handle->num_of_faces,
698 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION]);
701 handle->num_of_faces = 0;
712 static int __capture_completed_event_cb(void *data)
714 camera_s *handle = (camera_s *)data;
715 camera_state_e previous_state = CAMERA_STATE_NONE;
717 if (handle == NULL) {
718 LOGE("handle is NULL");
722 if (handle->current_capture_count > 0 &&
723 handle->current_capture_count == handle->current_capture_complete_count &&
724 handle->state == CAMERA_STATE_CAPTURING) {
725 /* pseudo state change */
726 previous_state = handle->state;
727 handle->state = CAMERA_STATE_CAPTURED;
729 if (previous_state != handle->state &&
730 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
731 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
734 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
737 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
738 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
745 int camera_create(camera_device_e device, camera_h* camera)
748 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
749 return CAMERA_ERROR_INVALID_PARAMETER;
752 int ret = MM_ERROR_NONE;;
756 camera_s *handle = NULL;
759 LOGW("device name = [%d]",device);
761 info.videodev_type = device;
763 handle = (camera_s*)malloc( sizeof(camera_s) );
764 if (handle == NULL) {
766 return CAMERA_ERROR_OUT_OF_MEMORY;
769 memset(handle, 0x0, sizeof(camera_s));
771 ret = mm_camcorder_create(&handle->mm_handle, &info);
772 if (ret != MM_ERROR_NONE) {
774 return __convert_camera_error_code(__func__,ret);
777 preview_format = MM_PIXEL_FORMAT_YUYV;
778 rotation = MM_DISPLAY_ROTATION_NONE;
779 ret = mm_camcorder_get_attributes(handle->mm_handle, &error,
780 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
781 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
782 MMCAM_CAPTURE_WIDTH, &handle->capture_width,
783 MMCAM_CAPTURE_HEIGHT, &handle->capture_height,
785 if (ret != MM_ERROR_NONE) {
786 LOGE("mm_camcorder_get_attributes fail(%x)", ret);
788 LOGE("failed attribute name %s", error);
792 mm_camcorder_destroy(handle->mm_handle);
795 return __convert_camera_error_code(__func__, ret);
798 ret = mm_camcorder_set_attributes(handle->mm_handle, &error,
799 MMCAM_MODE, MM_CAMCORDER_MODE_VIDEO_CAPTURE,
800 MMCAM_CAMERA_FORMAT, preview_format,
801 MMCAM_IMAGE_ENCODER, MM_IMAGE_CODEC_JPEG,
802 MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
803 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL,
804 MMCAM_DISPLAY_ROTATION, rotation,
805 MMCAM_CAPTURE_COUNT, 1,
806 MMCAM_PID_FOR_SOUND_FOCUS, getpid(),
809 handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
811 if (ret != MM_ERROR_NONE) {
812 LOGE("mm_camcorder_set_attributes fail(%x)", ret);
814 LOGE("failed attribute name %s", error);
818 mm_camcorder_destroy(handle->mm_handle);
821 return __convert_camera_error_code(__func__, ret);
824 handle->state = CAMERA_STATE_CREATED;
825 handle->relay_message_callback = NULL;
826 handle->relay_user_data = NULL;
827 handle->capture_resolution_modified = false;
828 handle->hdr_keep_mode = false;
829 handle->focus_area_valid = false;
830 handle->is_used_in_recorder = false;
831 handle->on_continuous_focusing = false;
832 handle->cached_focus_mode = -1;
834 g_mutex_init(&handle->idle_cb_lock);
836 mm_camcorder_set_message_callback(handle->mm_handle,
837 __mm_camera_message_callback,
840 *camera = (camera_h)handle;
842 LOGW("camera handle %p", handle);
844 return __convert_camera_error_code(__func__, ret);
848 int camera_destroy(camera_h camera)
850 if (camera == NULL) {
851 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
852 return CAMERA_ERROR_INVALID_PARAMETER;
855 int ret = MM_ERROR_NONE;
856 camera_s *handle = (camera_s *)camera;
858 if (handle->is_used_in_recorder) {
859 LOGE("camera is using in another recorder.");
860 return CAMERA_ERROR_INVALID_OPERATION;
863 LOGW("camera handle %p", handle);
865 if (handle->pkt_fmt) {
866 media_format_unref(handle->pkt_fmt);
867 handle->pkt_fmt = NULL;
870 ret = mm_camcorder_destroy(handle->mm_handle);
871 if (ret == MM_ERROR_NONE) {
872 _camera_remove_cb_message(handle);
873 g_mutex_clear(&handle->idle_cb_lock);
875 if (handle->wl_info) {
876 free(handle->wl_info);
877 handle->wl_info = NULL;
879 #endif /* HAVE_WAYLAND */
883 return __convert_camera_error_code(__func__, ret);
887 int camera_start_preview(camera_h camera)
889 if (camera == NULL) {
890 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
891 return CAMERA_ERROR_INVALID_PARAMETER;
894 int ret = MM_ERROR_NONE;
895 camera_s *handle = (camera_s *)camera;
896 camera_state_e capi_state = CAMERA_STATE_NONE;
897 MMCamcorderStateType mm_state = MM_CAMCORDER_STATE_NONE;
899 camera_get_state(camera, &capi_state);
900 if (capi_state == CAMERA_STATE_CAPTURED) {
901 ret = mm_camcorder_capture_stop(handle->mm_handle);
902 return __convert_camera_error_code(__func__, ret);
905 /* for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback */
906 mm_camcorder_set_video_capture_callback(handle->mm_handle,
907 (mm_camcorder_video_capture_callback)__mm_capture_callback,
910 mm_camcorder_get_state(handle->mm_handle, &mm_state);
911 if (mm_state != MM_CAMCORDER_STATE_READY) {
912 ret = mm_camcorder_realize(handle->mm_handle);
913 if (ret != MM_ERROR_NONE) {
914 LOGE("mm_camcorder_realize failed 0x%x", ret);
915 return __convert_camera_error_code(__func__, ret);
919 ret = mm_camcorder_start(handle->mm_handle);
920 if (ret != MM_ERROR_NONE) {
921 LOGE("mm_camcorder_start failed 0x%x, call mm_camcorder_unrealize", ret);
922 mm_camcorder_unrealize(handle->mm_handle);
925 return __convert_camera_error_code(__func__, ret);
929 int camera_stop_preview(camera_h camera)
931 if (camera == NULL) {
932 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
933 return CAMERA_ERROR_INVALID_PARAMETER;
936 int ret = MM_ERROR_NONE;;
937 camera_s *handle = (camera_s *)camera;
938 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
940 mm_camcorder_get_state(handle->mm_handle, &state);
941 if (state == MM_CAMCORDER_STATE_PREPARE) {
942 ret = mm_camcorder_stop(handle->mm_handle);
943 if (ret != MM_ERROR_NONE) {
944 LOGE("mm_camcorder_stop failed 0x%x", ret);
945 return __convert_camera_error_code(__func__, ret);
949 camera_stop_face_detection(camera);
951 ret = mm_camcorder_unrealize(handle->mm_handle);
953 return __convert_camera_error_code(__func__, ret);
957 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
959 if (camera == NULL) {
960 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
961 return CAMERA_ERROR_INVALID_PARAMETER;
964 camera_s *handle = (camera_s *)camera;
965 int ret = MM_ERROR_NONE;
966 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
968 mm_camcorder_get_state(handle->mm_handle, &state);
969 if (state != MM_CAMCORDER_STATE_PREPARE &&
970 state != MM_CAMCORDER_STATE_RECORDING &&
971 state != MM_CAMCORDER_STATE_PAUSED) {
972 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
973 return CAMERA_ERROR_INVALID_STATE;
976 if (handle->capture_resolution_modified) {
977 mm_camcorder_set_attributes(handle->mm_handle, NULL,
978 MMCAM_CAPTURE_WIDTH, handle->capture_width,
979 MMCAM_CAPTURE_HEIGHT, handle->capture_height,
982 handle->capture_resolution_modified = false;
985 mm_camcorder_set_attributes(handle->mm_handle, NULL,
986 MMCAM_CAPTURE_COUNT, 1,
989 handle->capture_count = 1;
990 handle->is_continuous_shot_break = false;
991 handle->current_capture_count = 0;
992 handle->current_capture_complete_count = 0;
993 handle->is_capture_completed = false;
995 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
996 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
997 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
998 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
1000 ret = mm_camcorder_capture_start(handle->mm_handle);
1001 if (ret != MM_ERROR_NONE) {
1002 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1003 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1004 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1005 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1008 return __convert_camera_error_code(__func__, ret);
1012 bool camera_is_supported_continuous_capture(camera_h camera)
1014 if (camera == NULL) {
1015 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1019 int ret = MM_ERROR_NONE;
1020 camera_s *handle = (camera_s *)camera;
1021 MMCamAttrsInfo info;
1023 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_COUNT, &info);
1024 set_last_result(__convert_camera_error_code(__func__, ret));
1025 if (ret != MM_ERROR_NONE) {
1026 LOGE("MMCAM_CAPTURE_COUNT info get failed 0x%x", ret);
1030 if (info.int_range.max > 1) {
1038 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)
1040 if (camera == NULL) {
1041 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1042 return CAMERA_ERROR_INVALID_PARAMETER;
1045 if (camera_is_supported_continuous_capture(camera) == false) {
1046 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1047 return CAMERA_ERROR_NOT_SUPPORTED;
1050 if (count < 2 || interval < 0) {
1051 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1052 return CAMERA_ERROR_INVALID_PARAMETER;
1055 camera_s *handle = (camera_s *)camera;
1056 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
1057 int supported_zsl = FALSE;
1058 int ret = MM_ERROR_NONE;
1060 mm_camcorder_get_state(handle->mm_handle, &state);
1061 if (state != MM_CAMCORDER_STATE_PREPARE) {
1062 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1063 return CAMERA_ERROR_INVALID_STATE;
1066 supported_zsl = FALSE;
1068 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1069 MMCAM_CAPTURE_COUNT, count,
1070 MMCAM_CAPTURE_INTERVAL, interval,
1072 if (ret != MM_ERROR_NONE) {
1073 LOGE("error set continuous shot attribute 0x%x", ret);
1074 return __convert_camera_error_code(__func__, ret);
1077 handle->capture_count = count;
1078 handle->is_continuous_shot_break = false;
1079 handle->current_capture_count = 0;
1080 handle->current_capture_complete_count = 0;
1081 handle->is_capture_completed = false;
1083 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1084 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1086 if (ret != MM_ERROR_NONE) {
1087 LOGE("(%x) error get continuous shot attribute", ret);
1090 if (!supported_zsl) {
1096 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1097 MMCAM_CAMERA_WIDTH, &preview_width,
1098 MMCAM_CAMERA_HEIGHT, &preview_height,
1099 MMCAM_CAPTURE_WIDTH, &capture_width,
1100 MMCAM_CAPTURE_HEIGHT, &capture_height,
1103 if (preview_width != capture_width || preview_height != capture_height) {
1104 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1105 MMCAM_CAPTURE_WIDTH, preview_width,
1106 MMCAM_CAPTURE_HEIGHT, preview_height,
1109 handle->capture_resolution_modified = true;
1113 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
1114 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
1115 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
1116 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
1118 ret = mm_camcorder_capture_start(handle->mm_handle);
1119 if(ret != MM_ERROR_NONE ){
1120 LOGE("mm_camcorder_capture_start failed 0x%x", ret);
1121 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1122 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1123 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1124 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1127 return __convert_camera_error_code(__func__, ret);
1132 int camera_stop_continuous_capture(camera_h camera)
1134 if (camera == NULL) {
1135 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1136 return CAMERA_ERROR_INVALID_PARAMETER;
1139 if (camera_is_supported_continuous_capture(camera) == false) {
1140 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1141 return CAMERA_ERROR_NOT_SUPPORTED;
1144 camera_s *handle = (camera_s *)camera;
1145 int ret = MM_ERROR_NONE;
1146 camera_state_e state = CAMERA_STATE_NONE;
1148 camera_get_state(camera, &state);
1149 if (state != CAMERA_STATE_CAPTURING && handle->capture_count > 1) {
1150 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1151 return CAMERA_ERROR_INVALID_STATE;
1154 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1155 "capture-break-cont-shot", 1,
1157 if (ret == MM_ERROR_NONE) {
1158 handle->is_continuous_shot_break = true;
1160 if (handle->current_capture_count > 0) {
1161 handle->is_capture_completed = true;
1164 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
1167 return __convert_camera_error_code(__func__, ret);
1171 bool camera_is_supported_face_detection(camera_h camera)
1173 if (camera == NULL) {
1174 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1179 int ret = MM_ERROR_NONE;
1180 camera_s *handle = (camera_s *)camera;
1181 MMCamAttrsInfo info;
1183 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
1184 set_last_result(__convert_camera_error_code(__func__, ret));
1185 if (ret != MM_ERROR_NONE) {
1186 LOGE("MMCAM_DETECT_MODE get attr info failed");
1190 if (info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY) {
1191 for (i = 0 ; i < info.int_array.count ; i++) {
1192 if (info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON) {
1193 LOGD("face detection supported");
1199 LOGD("face detection NOT supported");
1205 bool camera_is_supported_zero_shutter_lag(camera_h camera)
1207 int ret = MM_ERROR_NONE;
1208 int supported_zsl = false;
1209 camera_s *handle = (camera_s *)camera;
1211 if (camera == NULL) {
1212 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1216 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1217 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1219 set_last_result(__convert_camera_error_code(__func__, ret));
1220 if (ret != MM_ERROR_NONE) {
1221 LOGE("MMCAM_SUPPORT_ZSL_CAPTURE get failed");
1225 LOGD("support zero shutter lag : %d", supported_zsl);
1227 return supported_zsl;
1231 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
1233 int ret = MM_ERROR_NONE;
1234 int supported = false;
1235 camera_s *handle = (camera_s *)camera;
1237 if (camera == NULL) {
1238 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1242 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1243 MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, &supported,
1245 set_last_result(__convert_camera_error_code(__func__, ret));
1246 if (ret != MM_ERROR_NONE) {
1247 LOGE("MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB get failed");
1251 LOGD("support media packet preview callback : %d", supported);
1257 int camera_get_device_count(camera_h camera, int *device_count)
1259 int ret = MM_ERROR_NONE;
1260 camera_s *handle = (camera_s *)camera;
1262 if (camera == NULL || device_count == NULL) {
1263 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1264 return CAMERA_ERROR_INVALID_PARAMETER;
1267 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1268 MMCAM_CAMERA_DEVICE_COUNT, device_count,
1271 return __convert_camera_error_code(__func__, ret);
1275 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
1277 if (camera == NULL) {
1278 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1279 return CAMERA_ERROR_INVALID_PARAMETER;
1282 if (camera_is_supported_face_detection(camera) == false) {
1283 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1284 return CAMERA_ERROR_NOT_SUPPORTED;
1287 camera_s *handle = (camera_s *)camera;
1288 camera_state_e state = CAMERA_STATE_NONE;
1289 int ret = MM_ERROR_NONE;
1291 camera_get_state(camera, &state);
1292 if (state != CAMERA_STATE_PREVIEW) {
1293 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1294 return CAMERA_ERROR_INVALID_STATE;
1297 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1298 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON,
1300 if (ret == MM_ERROR_NONE) {
1301 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)callback;
1302 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)user_data;
1303 handle->num_of_faces = 0;
1306 return __convert_camera_error_code(__func__,ret);
1310 int camera_stop_face_detection(camera_h camera)
1312 if (camera == NULL) {
1313 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1314 return CAMERA_ERROR_INVALID_PARAMETER;
1317 camera_s *handle = (camera_s *)camera;
1318 int ret = MM_ERROR_NONE;
1320 if (camera_is_supported_face_detection(camera) == false) {
1321 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1322 return CAMERA_ERROR_NOT_SUPPORTED;
1325 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1326 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF,
1328 if (ret == MM_ERROR_NONE) {
1329 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1330 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1331 handle->num_of_faces = 0;
1334 return __convert_camera_error_code(__func__,ret);
1338 int camera_get_state(camera_h camera, camera_state_e *state)
1340 if (camera == NULL || state == NULL) {
1341 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1342 return CAMERA_ERROR_INVALID_PARAMETER;
1345 camera_s *handle = (camera_s *)camera;
1346 camera_state_e capi_state = CAMERA_STATE_NONE;
1347 MMCamcorderStateType mmstate = MM_CAMCORDER_STATE_NONE;
1349 mm_camcorder_get_state(handle->mm_handle, &mmstate);
1350 capi_state = __camera_state_convert(mmstate);
1352 if ((handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed) &&
1353 (handle->current_capture_count > 0 || handle->is_capture_completed) &&
1354 mmstate == MM_CAMCORDER_STATE_CAPTURING) {
1355 capi_state = CAMERA_STATE_CAPTURED;
1358 *state = capi_state;
1360 return CAMERA_ERROR_NONE;
1364 int camera_start_focusing(camera_h camera, bool continuous)
1366 if (camera == NULL) {
1367 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1368 return CAMERA_ERROR_INVALID_PARAMETER;
1371 camera_s *handle = (camera_s *)camera;
1373 if (handle->cached_focus_mode != -1) {
1374 LOGD("apply cached focus mode %d", handle->cached_focus_mode);
1376 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1377 MMCAM_CAMERA_AF_SCAN_RANGE, handle->cached_focus_mode,
1380 handle->cached_focus_mode = -1;
1384 return __camera_start_continuous_focusing(camera);
1386 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1387 MMCAM_CAMERA_FOCUS_MODE, handle->focus_area_valid ? \
1388 MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO : MM_CAMCORDER_FOCUS_MODE_AUTO,
1391 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s *)camera)->mm_handle));
1396 int __camera_start_continuous_focusing(camera_h camera)
1398 if (camera == NULL) {
1399 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1400 return CAMERA_ERROR_INVALID_PARAMETER;
1403 camera_s *handle = (camera_s *)camera;
1404 int ret = MM_ERROR_NONE;
1405 int mode = MM_CAMCORDER_FOCUS_MODE_NONE;
1407 handle->on_continuous_focusing = true;
1408 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1409 MMCAM_CAMERA_FOCUS_MODE, &mode,
1412 if (mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS) {
1413 ret = mm_camcorder_start_focusing(handle->mm_handle);
1415 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1416 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS,
1420 return __convert_camera_error_code(__func__, ret);
1424 int camera_cancel_focusing(camera_h camera)
1426 if (camera == NULL) {
1427 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1428 return CAMERA_ERROR_INVALID_PARAMETER;
1431 camera_s *handle = (camera_s *)camera;
1433 handle->on_continuous_focusing = false;
1435 return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
1439 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
1441 int ret = MM_ERROR_NONE;
1442 int set_surface = MM_DISPLAY_SURFACE_X;
1443 void *set_handle = NULL;
1444 camera_s *handle = NULL;
1446 Evas_Object *obj = NULL;
1447 const char *object_type = NULL;
1449 if (camera == NULL) {
1450 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1451 return CAMERA_ERROR_INVALID_PARAMETER;
1454 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
1455 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
1456 return CAMERA_ERROR_INVALID_PARAMETER;
1459 handle = (camera_s *)camera;
1460 handle->display_type = type;
1462 if (type == CAMERA_DISPLAY_TYPE_NONE) {
1464 set_surface = MM_DISPLAY_SURFACE_NULL;
1465 handle->display_handle = 0;
1467 LOGD("display type NONE");
1469 obj = (Evas_Object *)display;
1470 object_type = evas_object_type_get(obj);
1472 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
1474 MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)malloc(sizeof(MMCamWaylandInfo));
1476 if (wl_info == NULL) {
1477 LOGE("wl_info alloc failed : %d", sizeof(MMCamWaylandInfo));
1478 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_LOW_MEMORY);
1481 memset(wl_info, 0x0, sizeof(MMCamWaylandInfo));
1483 wl_info->evas_obj = (void *)obj;
1484 wl_info->window = (void *)elm_win_wl_window_get(obj);
1485 wl_info->surface = (void *)ecore_wl_window_surface_get(wl_info->window);
1486 wl_info->display = (void *)ecore_wl_display_get();
1488 if (wl_info->window == NULL || wl_info->surface == NULL || wl_info->display == NULL) {
1489 LOGE("something is NULL %p, %p, %p", wl_info->window, wl_info->surface, wl_info->display);
1491 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_INTERNAL);
1494 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
1495 &wl_info->window_width, &wl_info->window_height);
1497 if (handle->wl_info) {
1498 free(handle->wl_info);
1499 handle->wl_info = NULL;
1502 /* set wayland info */
1503 handle->wl_info = (void *)wl_info;
1504 set_surface = MM_DISPLAY_SURFACE_X;
1505 set_handle = (void *)wl_info;
1507 LOGD("wayland obj %p, window %p, surface %p, display %p, size %d,%d,%dx%d",
1508 wl_info->evas_obj, wl_info->window, wl_info->surface, wl_info->display,
1509 wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
1510 #else /* HAVE_WAYLAND */
1511 /* x window overlay surface */
1512 handle->display_handle = (void *)elm_win_xwindow_get(obj);
1513 set_surface = MM_DISPLAY_SURFACE_X;
1514 set_handle = &(handle->display_handle);
1516 LOGD("display type OVERLAY : handle %p, %d", set_handle, (int)handle->display_handle);
1517 #endif /* HAVE_WAYLAND */
1518 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
1519 /* evas object surface */
1520 handle->display_handle = display;
1521 set_surface = MM_DISPLAY_SURFACE_EVAS;
1522 set_handle = display;
1524 LOGD("display type EVAS : handle %p", set_handle);
1526 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
1527 return CAMERA_ERROR_INVALID_PARAMETER;
1530 LOGE("failed to get evas object type from %p", obj);
1531 return CAMERA_ERROR_INVALID_PARAMETER;
1535 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1536 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
1537 MMCAM_DISPLAY_SURFACE, set_surface,
1540 if (ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE) {
1541 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1542 MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *),
1546 return __convert_camera_error_code(__func__, ret);
1550 int camera_set_preview_resolution(camera_h camera, int width, int height)
1552 if( camera == NULL){
1553 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1554 return CAMERA_ERROR_INVALID_PARAMETER;
1557 int ret = MM_ERROR_NONE;
1558 camera_s *handle = (camera_s *)camera;
1559 MMCamAttrsInfo info;
1563 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1564 MMCAM_CAMERA_FPS, &mm_fps,
1567 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
1568 if (ret != MM_ERROR_NONE) {
1569 return __convert_camera_error_code(__func__, ret);
1572 for (i = 0 ; i < info.int_array.count ; i++) {
1573 if (info.int_array.array[i] == mm_fps) {
1576 if (i == info.int_array.count - 1) {
1577 LOGE("Not supported resolution: Current set Resolution's FPS is not supported in wanted resolution.");
1578 return CAMERA_ERROR_NOT_SUPPORTED;
1582 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1583 MMCAM_CAMERA_WIDTH, width,
1584 MMCAM_CAMERA_HEIGHT, height,
1587 return __convert_camera_error_code(__func__, ret);
1591 int camera_set_capture_resolution(camera_h camera, int width, int height)
1593 if (camera == NULL) {
1594 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1595 return CAMERA_ERROR_INVALID_PARAMETER;
1598 int ret = MM_ERROR_NONE;
1599 camera_s *handle = (camera_s *)camera;
1601 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1602 MMCAM_CAPTURE_WIDTH, width,
1603 MMCAM_CAPTURE_HEIGHT, height,
1605 if (ret == MM_ERROR_NONE) {
1606 handle->capture_width = width;
1607 handle->capture_height = height;
1610 return __convert_camera_error_code(__func__, ret);
1614 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
1616 if (camera == NULL) {
1617 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1618 return CAMERA_ERROR_INVALID_PARAMETER;
1621 int ret = MM_ERROR_NONE;
1622 camera_s *handle = (camera_s *)camera;
1624 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1625 MMCAM_CAPTURE_FORMAT, format,
1628 return __convert_camera_error_code(__func__, ret);
1632 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
1634 if (camera == NULL) {
1635 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1636 return CAMERA_ERROR_INVALID_PARAMETER;
1640 int ret = MM_ERROR_NONE;
1641 camera_s *handle = (camera_s *)camera;
1643 if (format == CAMERA_PIXEL_FORMAT_UYVY) {
1644 bool supported_ITLV_UYVY = false;
1645 MMCamAttrsInfo supported_format;
1646 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1647 for (i = 0 ; i < supported_format.int_array.count ; i++) {
1648 if (supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1649 supported_ITLV_UYVY = true;
1652 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1653 MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ? MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY,
1656 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1657 MMCAM_CAMERA_FORMAT, format,
1661 return __convert_camera_error_code(__func__, ret);
1665 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
1667 if (camera == NULL || width == NULL || height == NULL) {
1668 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1669 return CAMERA_ERROR_INVALID_PARAMETER;
1672 int ret = MM_ERROR_NONE;
1673 camera_s *handle = (camera_s *)camera;
1675 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1676 MMCAM_CAMERA_WIDTH, width,
1677 MMCAM_CAMERA_HEIGHT, height,
1680 return __convert_camera_error_code(__func__, ret);
1684 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
1686 if (camera == NULL) {
1687 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1688 return CAMERA_ERROR_INVALID_PARAMETER;
1691 if (rotation > CAMERA_ROTATION_270) {
1692 return CAMERA_ERROR_INVALID_PARAMETER;
1695 int ret = MM_ERROR_NONE;
1696 camera_s *handle = (camera_s *)camera;
1698 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1699 MMCAM_DISPLAY_ROTATION, rotation,
1702 return __convert_camera_error_code(__func__, ret);
1706 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
1708 if (camera == NULL || rotation == NULL) {
1709 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1710 return CAMERA_ERROR_INVALID_PARAMETER;
1713 int ret = MM_ERROR_NONE;
1714 camera_s *handle = (camera_s *)camera;
1716 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1717 MMCAM_DISPLAY_ROTATION, rotation,
1720 return __convert_camera_error_code(__func__, ret);
1724 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
1726 if (camera == NULL) {
1727 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1728 return CAMERA_ERROR_INVALID_PARAMETER;
1731 if (flip > CAMERA_FLIP_BOTH) {
1732 return CAMERA_ERROR_INVALID_PARAMETER;
1735 int ret = MM_ERROR_NONE;
1736 camera_s *handle = (camera_s *)camera;
1738 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1739 MMCAM_DISPLAY_FLIP, flip,
1742 return __convert_camera_error_code(__func__, ret);
1746 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
1748 if (camera == NULL || flip == NULL) {
1749 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1750 return CAMERA_ERROR_INVALID_PARAMETER;
1753 int ret = MM_ERROR_NONE;
1754 camera_s *handle = (camera_s *)camera;
1756 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1757 MMCAM_DISPLAY_FLIP, flip,
1760 return __convert_camera_error_code(__func__, ret);
1764 int camera_set_display_visible(camera_h camera, bool visible)
1766 if (camera == NULL) {
1767 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1768 return CAMERA_ERROR_INVALID_PARAMETER;
1771 int ret = MM_ERROR_NONE;
1772 camera_s *handle = (camera_s *)camera;
1774 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1775 MMCAM_DISPLAY_VISIBLE, visible,
1778 return __convert_camera_error_code(__func__, ret);
1782 int camera_is_display_visible(camera_h camera, bool* visible)
1784 if (camera == NULL || visible == NULL) {
1785 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1786 return CAMERA_ERROR_INVALID_PARAMETER;
1789 int ret = MM_ERROR_NONE;
1791 camera_s *handle = (camera_s *)camera;
1793 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1794 MMCAM_DISPLAY_VISIBLE, &result,
1797 if (ret == MM_ERROR_NONE) {
1801 return __convert_camera_error_code(__func__, ret);
1805 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
1807 if (camera == NULL) {
1808 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1809 return CAMERA_ERROR_INVALID_PARAMETER;
1812 if (mode > CAMERA_DISPLAY_MODE_CROPPED_FULL) {
1813 return CAMERA_ERROR_INVALID_PARAMETER;
1816 int ret = MM_ERROR_NONE;
1817 camera_s *handle = (camera_s *)camera;
1819 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1820 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1823 return __convert_camera_error_code(__func__, ret);
1827 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
1829 if (camera == NULL || mode == NULL) {
1830 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1831 return CAMERA_ERROR_INVALID_PARAMETER;
1834 int ret = MM_ERROR_NONE;
1835 camera_s *handle = (camera_s *)camera;
1837 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1838 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1841 return __convert_camera_error_code(__func__, ret);
1845 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
1847 if (camera == NULL || width == NULL || height == NULL) {
1848 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1849 return CAMERA_ERROR_INVALID_PARAMETER;
1852 camera_s *handle = (camera_s *)camera;
1854 *width = handle->capture_width;
1855 *height = handle->capture_height;
1857 return CAMERA_ERROR_NONE;
1861 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
1863 if (camera == NULL || format == NULL) {
1864 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1865 return CAMERA_ERROR_INVALID_PARAMETER;
1868 int ret = MM_ERROR_NONE;
1869 camera_s *handle = (camera_s *)camera;
1871 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1872 MMCAM_CAPTURE_FORMAT, format,
1875 return __convert_camera_error_code(__func__, ret);
1879 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
1881 if (camera == NULL || format == NULL) {
1882 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1883 return CAMERA_ERROR_INVALID_PARAMETER;
1886 int ret = MM_ERROR_NONE;
1887 camera_s *handle = (camera_s *)camera;
1889 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1890 MMCAM_CAMERA_FORMAT, format,
1893 if ((MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1894 *format = CAMERA_PIXEL_FORMAT_UYVY;
1897 return __convert_camera_error_code(__func__, ret);
1901 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
1903 if (camera == NULL || callback == NULL) {
1904 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1905 return CAMERA_ERROR_INVALID_PARAMETER;
1908 camera_s *handle = (camera_s *)camera;
1909 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)callback;
1910 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)user_data;
1912 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1913 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1916 return CAMERA_ERROR_NONE;
1920 int camera_unset_preview_cb(camera_h camera)
1922 if (camera == NULL) {
1923 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1924 return CAMERA_ERROR_INVALID_PARAMETER;
1927 camera_s *handle = (camera_s *)camera;
1929 if (handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1930 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1931 (mm_camcorder_video_stream_callback)NULL,
1935 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1936 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1938 return CAMERA_ERROR_NONE;
1942 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
1944 if (camera == NULL) {
1945 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
1946 return CAMERA_ERROR_INVALID_PARAMETER;
1949 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1950 LOGE("NOT SUPPORTED");
1951 return CAMERA_ERROR_NOT_SUPPORTED;
1954 if (callback == NULL) {
1955 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
1956 return CAMERA_ERROR_INVALID_PARAMETER;
1959 camera_s *handle = (camera_s *)camera;
1960 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)callback;
1961 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)user_data;
1963 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1964 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1967 return CAMERA_ERROR_NONE;
1971 int camera_unset_media_packet_preview_cb(camera_h camera)
1973 if (camera == NULL) {
1974 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1975 return CAMERA_ERROR_INVALID_PARAMETER;
1978 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1979 LOGE("NOT SUPPORTED");
1980 return CAMERA_ERROR_NOT_SUPPORTED;
1983 camera_s *handle = (camera_s *)camera;
1985 if (handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] == NULL) {
1986 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1987 (mm_camcorder_video_stream_callback)NULL,
1991 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
1992 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
1994 return CAMERA_ERROR_NONE;
1998 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
2000 if (camera == NULL || callback == NULL) {
2001 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2002 return CAMERA_ERROR_INVALID_PARAMETER;
2005 camera_s *handle = (camera_s *)camera;
2006 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)callback;
2007 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)user_data;
2009 return CAMERA_ERROR_NONE;
2013 int camera_unset_state_changed_cb(camera_h camera)
2015 if (camera == NULL) {
2016 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2017 return CAMERA_ERROR_INVALID_PARAMETER;
2020 camera_s *handle = (camera_s *)camera;
2021 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2022 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2024 return CAMERA_ERROR_NONE;
2028 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
2030 if (camera == NULL || callback == NULL) {
2031 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2032 return CAMERA_ERROR_INVALID_PARAMETER;
2035 camera_s *handle = (camera_s *)camera;
2036 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)callback;
2037 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)user_data;
2039 return CAMERA_ERROR_NONE;
2043 int camera_unset_interrupted_cb(camera_h camera)
2045 if (camera == NULL) {
2046 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2047 return CAMERA_ERROR_INVALID_PARAMETER;
2050 camera_s *handle = (camera_s *)camera;
2052 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2053 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2055 return CAMERA_ERROR_NONE;
2059 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
2061 if (camera == NULL || callback == NULL) {
2062 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2063 return CAMERA_ERROR_INVALID_PARAMETER;
2066 camera_s *handle = (camera_s *)camera;
2068 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)callback;
2069 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)user_data;
2071 return CAMERA_ERROR_NONE;
2075 int camera_unset_focus_changed_cb(camera_h camera)
2077 if (camera == NULL) {
2078 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2079 return CAMERA_ERROR_INVALID_PARAMETER;
2082 camera_s *handle = (camera_s *)camera;
2084 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2085 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2087 return CAMERA_ERROR_NONE;
2091 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
2093 if (camera == NULL || callback == NULL) {
2094 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2095 return CAMERA_ERROR_INVALID_PARAMETER;
2098 camera_s *handle = (camera_s *)camera;
2100 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)callback;
2101 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)user_data;
2103 return CAMERA_ERROR_NONE;
2107 int camera_unset_error_cb(camera_h camera)
2109 if (camera == NULL) {
2110 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2111 return CAMERA_ERROR_INVALID_PARAMETER;
2114 camera_s *handle = (camera_s *)camera;
2116 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2117 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2119 return CAMERA_ERROR_NONE;
2123 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
2125 if (camera == NULL || foreach_cb == NULL) {
2126 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2127 return CAMERA_ERROR_INVALID_PARAMETER;
2131 int ret = MM_ERROR_NONE;
2132 camera_s *handle = (camera_s *)camera;
2133 MMCamAttrsInfo preview_width;
2134 MMCamAttrsInfo preview_height;
2136 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH, &preview_width);
2137 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT, &preview_height);
2138 if (ret != CAMERA_ERROR_NONE) {
2139 return __convert_camera_error_code(__func__, ret);
2142 for (i = 0 ; i < preview_width.int_array.count ; i++) {
2143 if (!foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i], user_data)) {
2148 return CAMERA_ERROR_NONE;
2152 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
2154 if (camera == NULL || foreach_cb == NULL) {
2155 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2156 return CAMERA_ERROR_INVALID_PARAMETER;
2160 int ret = MM_ERROR_NONE;
2161 camera_s *handle = (camera_s *)camera;
2162 MMCamAttrsInfo capture_width;
2163 MMCamAttrsInfo capture_height;
2165 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH, &capture_width);
2166 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT, &capture_height);
2167 if (ret != CAMERA_ERROR_NONE) {
2168 return __convert_camera_error_code(__func__, ret);
2171 for (i = 0 ; i < capture_width.int_array.count ; i++) {
2172 if (!foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i], user_data)) {
2177 return CAMERA_ERROR_NONE;
2181 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
2183 if (camera == NULL || foreach_cb == NULL) {
2184 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2185 return CAMERA_ERROR_INVALID_PARAMETER;
2189 int ret = MM_ERROR_NONE;
2190 camera_s *handle = (camera_s *)camera;
2191 MMCamAttrsInfo format;
2193 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT, &format);
2194 if (ret != CAMERA_ERROR_NONE) {
2195 return __convert_camera_error_code(__func__, ret);
2198 for (i = 0 ; i < format.int_array.count ; i++) {
2199 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2200 if (!foreach_cb(format.int_array.array[i], user_data)) {
2206 return CAMERA_ERROR_NONE;
2210 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
2212 if (camera == NULL || foreach_cb == NULL) {
2213 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2214 return CAMERA_ERROR_INVALID_PARAMETER;
2218 int ret = MM_ERROR_NONE;
2219 camera_s *handle = (camera_s *)camera;
2220 MMCamAttrsInfo format;
2222 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT, &format);
2223 if (ret != CAMERA_ERROR_NONE) {
2224 return __convert_camera_error_code(__func__, ret);
2227 for (i = 0 ; i < format.int_array.count ; i++) {
2228 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2229 if (!foreach_cb(format.int_array.array[i], user_data)) {
2235 return CAMERA_ERROR_NONE;
2239 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
2241 if (camera == NULL || width == NULL || height == NULL) {
2242 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2243 return CAMERA_ERROR_INVALID_PARAMETER;
2246 enum MMCamcorderPreviewType wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2250 int ret = MM_ERROR_NONE;
2251 camera_s *handle = (camera_s *)camera;
2252 MMCamAttrsInfo width_info;
2253 MMCamAttrsInfo height_info;
2255 camera_get_capture_resolution(camera, &capture_w, &capture_h);
2256 ratio = (double)capture_w / (double)capture_h;
2258 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
2259 } else if (ratio == 1.0) {
2260 wide = MM_CAMCORDER_PREVIEW_TYPE_SQUARE;
2262 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2265 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH, &width_info);
2266 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
2267 if (ret != MM_ERROR_NONE) {
2268 return __convert_camera_error_code(__func__, ret);
2271 if (width && (unsigned int)width_info.int_array.count > wide) {
2272 *width = width_info.int_array.array[wide];
2274 LOGE("there is no width value for resolution %dx%d type %d", capture_w, capture_h, wide);
2275 return CAMERA_ERROR_INVALID_OPERATION;
2278 if (height && (unsigned int)height_info.int_array.count > wide) {
2279 *height = height_info.int_array.array[wide];
2281 LOGE("there is no height value for resolution %dx%d type %d", capture_w, capture_h, wide);
2282 return CAMERA_ERROR_INVALID_OPERATION;
2285 LOGI("recommend resolution %dx%d, type %d", *width, *height, wide);
2287 return CAMERA_ERROR_NONE;
2291 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
2293 if (camera == NULL || angle == NULL) {
2294 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2295 return CAMERA_ERROR_INVALID_PARAMETER;
2298 int ret = MM_ERROR_NONE;
2299 camera_s *handle = (camera_s *)camera;
2300 int rotation = MM_DISPLAY_ROTATION_NONE;
2302 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2303 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
2306 if (ret == MM_ERROR_NONE) {
2308 case MM_DISPLAY_ROTATION_NONE:
2311 case MM_DISPLAY_ROTATION_90:
2314 case MM_DISPLAY_ROTATION_180:
2317 case MM_DISPLAY_ROTATION_270:
2326 return __convert_camera_error_code(__func__, ret);
2330 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
2332 if (camera == NULL) {
2333 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2334 return CAMERA_ERROR_INVALID_PARAMETER;
2337 int ret = MM_ERROR_NONE;
2338 camera_s *handle = (camera_s *)camera;
2340 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2341 MMCAM_DISPLAY_MODE, mode,
2344 return __convert_camera_error_code(__func__, ret);
2348 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
2350 if (camera == NULL || mode == NULL) {
2351 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2352 return CAMERA_ERROR_INVALID_PARAMETER;
2355 int ret = MM_ERROR_NONE;
2356 camera_s *handle = (camera_s *)camera;
2358 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2359 MMCAM_DISPLAY_MODE, mode,
2362 return __convert_camera_error_code(__func__, ret);
2366 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
2368 if (camera == NULL || foreach_cb == NULL) {
2369 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2370 return CAMERA_ERROR_INVALID_PARAMETER;
2374 int ret = MM_ERROR_NONE;
2375 camera_s *handle = (camera_s *)camera;
2376 MMCamAttrsInfo info;
2378 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DISPLAY_MODE, &info);
2379 if (ret != CAMERA_ERROR_NONE) {
2380 return __convert_camera_error_code(__func__, ret);
2383 for (i = 0 ; i < info.int_array.count ; i++) {
2384 if (!foreach_cb(info.int_array.array[i], user_data)) {
2389 return CAMERA_ERROR_NONE;
2393 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
2395 if (camera == NULL) {
2396 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2397 return CAMERA_ERROR_INVALID_PARAMETER;
2400 int ret = MM_ERROR_NONE;
2401 camera_s *handle = (camera_s *)camera;
2403 if (fps == CAMERA_ATTR_FPS_AUTO) {
2404 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2405 MMCAM_CAMERA_FPS_AUTO, true,
2408 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2409 MMCAM_CAMERA_FPS_AUTO, false,
2410 MMCAM_CAMERA_FPS, fps,
2414 return __convert_camera_error_code(__func__, ret);
2418 int camera_attr_set_image_quality(camera_h camera, int quality)
2420 if (camera == NULL) {
2421 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2422 return CAMERA_ERROR_INVALID_PARAMETER;
2425 int ret = MM_ERROR_NONE;
2426 camera_s *handle = (camera_s *)camera;
2428 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2429 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2432 return __convert_camera_error_code(__func__, ret);
2436 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
2438 if (camera == NULL || fps == NULL) {
2439 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2440 return CAMERA_ERROR_INVALID_PARAMETER;
2443 int ret = MM_ERROR_NONE;
2445 int is_auto = false;
2446 camera_s *handle = (camera_s *)camera;
2448 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2449 MMCAM_CAMERA_FPS, &mm_fps,
2450 MMCAM_CAMERA_FPS_AUTO, &is_auto,
2452 if (ret == MM_ERROR_NONE) {
2454 *fps = CAMERA_ATTR_FPS_AUTO;
2460 return __convert_camera_error_code(__func__, ret);
2464 int camera_attr_get_image_quality(camera_h camera, int *quality)
2466 if (camera == NULL || quality == NULL) {
2467 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2468 return CAMERA_ERROR_INVALID_PARAMETER;
2471 int ret = MM_ERROR_NONE;
2472 camera_s *handle = (camera_s *)camera;
2474 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2475 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2478 return __convert_camera_error_code(__func__, ret);
2482 int camera_attr_set_zoom(camera_h camera, int zoom)
2484 if (camera == NULL) {
2485 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2486 return CAMERA_ERROR_INVALID_PARAMETER;
2489 int ret = MM_ERROR_NONE;
2490 camera_s *handle = (camera_s *)camera;
2492 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2493 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2496 return __convert_camera_error_code(__func__, ret);
2500 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
2502 if (camera == NULL) {
2503 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2504 return CAMERA_ERROR_INVALID_PARAMETER;
2507 int ret = MM_ERROR_NONE;
2508 camera_s *handle = (camera_s *)camera;
2510 bool should_change_focus_mode = false;
2512 mm_camcorder_get_attributes(handle->mm_handle, NULL,
2513 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2516 if (focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO &&
2517 focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2518 focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO) {
2519 should_change_focus_mode = true;
2522 if (mode != CAMERA_ATTR_AF_NONE &&
2523 focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2524 !handle->on_continuous_focusing) {
2525 handle->cached_focus_mode = mode;
2526 LOGD("af mode will be set actually start focusing");
2527 return __convert_camera_error_code(__func__, MM_ERROR_NONE);
2529 handle->cached_focus_mode = -1;
2532 if (mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode) {
2533 mm_camcorder_set_attributes(handle->mm_handle, NULL,
2534 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO,
2539 case CAMERA_ATTR_AF_NONE:
2540 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2541 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
2542 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NONE,
2545 case CAMERA_ATTR_AF_NORMAL:
2546 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2547 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NORMAL,
2550 case CAMERA_ATTR_AF_MACRO:
2551 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2552 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_MACRO,
2555 case CAMERA_ATTR_AF_FULL:
2556 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2557 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_FULL,
2561 LOGE("invalid mode %d", mode);
2562 return CAMERA_ERROR_INVALID_PARAMETER;
2565 return __convert_camera_error_code(__func__, ret);
2569 int camera_attr_set_af_area(camera_h camera, int x, int y)
2571 if (camera == NULL) {
2572 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2573 return CAMERA_ERROR_INVALID_PARAMETER;
2576 int ret = MM_ERROR_NONE;
2577 camera_s *handle = (camera_s *)camera;
2578 camera_attr_af_mode_e mode;
2580 camera_attr_get_af_mode(camera, &mode);
2581 if (mode == CAMERA_ATTR_AF_NONE) {
2582 LOGE("INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE", CAMERA_ERROR_INVALID_OPERATION);
2583 return CAMERA_ERROR_INVALID_OPERATION;
2586 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2587 MMCAM_CAMERA_AF_TOUCH_X, x,
2588 MMCAM_CAMERA_AF_TOUCH_Y, y,
2590 if (ret == MM_ERROR_NONE) {
2591 handle->focus_area_valid = true;
2594 return __convert_camera_error_code(__func__, ret);
2598 int camera_attr_clear_af_area(camera_h camera)
2600 if (camera == NULL) {
2601 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2602 return CAMERA_ERROR_INVALID_PARAMETER;
2605 camera_s *handle = (camera_s *)camera;
2607 handle->focus_area_valid = false;
2613 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
2615 if (camera == NULL) {
2616 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2617 return CAMERA_ERROR_INVALID_PARAMETER;
2620 int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, /* CAMERA_ATTR_EXPOSURE_MODE_OFF */
2621 MM_CAMCORDER_AUTO_EXPOSURE_ALL, /* CAMERA_ATTR_EXPOSURE_MODE_ALL */
2622 MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, /* CAMERA_ATTR_EXPOSURE_MODE_CENTER */
2623 MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, /* CAMERA_ATTR_EXPOSURE_MODE_SPOT */
2624 MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1, /* CAMERA_ATTR_EXPOSURE_MODE_CUSTOM */
2627 int ret = MM_ERROR_NONE;
2628 camera_s *handle = (camera_s *)camera;
2630 if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
2631 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2632 return CAMERA_ERROR_INVALID_PARAMETER;
2635 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2636 MMCAM_CAMERA_EXPOSURE_MODE, maptable[mode],
2639 return __convert_camera_error_code(__func__, ret);
2643 int camera_attr_set_exposure(camera_h camera, int value)
2645 if (camera == NULL) {
2646 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2647 return CAMERA_ERROR_INVALID_PARAMETER;
2650 int ret = MM_ERROR_NONE;
2651 camera_s *handle = (camera_s *)camera;
2653 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2654 MMCAM_CAMERA_EXPOSURE_VALUE, value,
2657 return __convert_camera_error_code(__func__, ret);
2661 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
2663 if (camera == NULL) {
2664 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2665 return CAMERA_ERROR_INVALID_PARAMETER;
2668 int ret = MM_ERROR_NONE;
2669 camera_s *handle = (camera_s*)camera;
2671 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2672 MMCAM_CAMERA_ISO, iso,
2675 return __convert_camera_error_code(__func__, ret);
2679 int camera_attr_set_brightness(camera_h camera, int level)
2681 if (camera == NULL) {
2682 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2683 return CAMERA_ERROR_INVALID_PARAMETER;
2686 int ret = MM_ERROR_NONE;
2687 camera_s *handle = (camera_s *)camera;
2689 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2690 MMCAM_FILTER_BRIGHTNESS, level,
2693 return __convert_camera_error_code(__func__, ret);
2697 int camera_attr_set_contrast(camera_h camera, int level)
2699 if (camera == NULL) {
2700 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2701 return CAMERA_ERROR_INVALID_PARAMETER;
2704 int ret = MM_ERROR_NONE;
2705 camera_s *handle = (camera_s *)camera;
2707 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2708 MMCAM_FILTER_CONTRAST, level,
2711 return __convert_camera_error_code(__func__, ret);
2715 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
2717 if (camera == NULL) {
2718 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2719 return CAMERA_ERROR_INVALID_PARAMETER;
2722 int ret = MM_ERROR_NONE;
2723 camera_s *handle = (camera_s *)camera;
2725 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2726 MMCAM_FILTER_WB, wb,
2729 return __convert_camera_error_code(__func__, ret);
2733 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
2735 if (camera == NULL) {
2736 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2737 return CAMERA_ERROR_INVALID_PARAMETER;
2740 int ret = MM_ERROR_NONE;
2741 camera_s *handle = (camera_s *)camera;
2743 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2744 MMCAM_FILTER_COLOR_TONE, effect,
2747 return __convert_camera_error_code(__func__, ret);
2751 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
2753 if (camera == NULL) {
2754 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2755 return CAMERA_ERROR_INVALID_PARAMETER;
2758 int ret = MM_ERROR_NONE;
2759 camera_s *handle = (camera_s *)camera;
2761 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2762 MMCAM_FILTER_SCENE_MODE, mode,
2765 return __convert_camera_error_code(__func__, ret);
2769 int camera_attr_enable_tag(camera_h camera, bool enable)
2771 if (camera == NULL) {
2772 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2773 return CAMERA_ERROR_INVALID_PARAMETER;
2776 int ret = MM_ERROR_NONE;
2777 camera_s *handle = (camera_s *)camera;
2779 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2780 MMCAM_TAG_ENABLE, enable,
2783 return __convert_camera_error_code(__func__, ret);
2787 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
2789 if (camera == NULL) {
2790 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2791 return CAMERA_ERROR_INVALID_PARAMETER;
2794 int ret = MM_ERROR_NONE;
2795 camera_s *handle = (camera_s *)camera;
2797 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2798 MMCAM_TAG_IMAGE_DESCRIPTION, description, strlen(description),
2801 return __convert_camera_error_code(__func__, ret);
2805 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
2807 if (camera == NULL) {
2808 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2809 return CAMERA_ERROR_INVALID_PARAMETER;
2812 int ret = MM_ERROR_NONE;
2813 camera_s *handle = (camera_s *)camera;
2815 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2816 MMCAM_TAG_ORIENTATION, orientation,
2819 return __convert_camera_error_code(__func__, ret);
2823 int camera_attr_set_tag_software(camera_h camera, const char *software)
2825 if (camera == NULL) {
2826 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2827 return CAMERA_ERROR_INVALID_PARAMETER;
2830 int ret = MM_ERROR_NONE;
2831 camera_s *handle = (camera_s *)camera;
2833 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2834 MMCAM_TAG_SOFTWARE, software, strlen(software),
2837 return __convert_camera_error_code(__func__, ret);
2841 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
2843 if (camera == NULL) {
2844 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2845 return CAMERA_ERROR_INVALID_PARAMETER;
2848 int ret = MM_ERROR_NONE;
2849 camera_s *handle = (camera_s *)camera;
2851 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2852 MMCAM_TAG_GPS_ENABLE, true,
2853 MMCAM_TAG_LATITUDE, latitude,
2854 MMCAM_TAG_LONGITUDE, longitude,
2855 MMCAM_TAG_ALTITUDE, altitude,
2858 return __convert_camera_error_code(__func__, ret);
2862 int camera_attr_remove_geotag(camera_h camera)
2864 if (camera == NULL) {
2865 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2866 return CAMERA_ERROR_INVALID_PARAMETER;
2869 int ret = MM_ERROR_NONE;
2870 camera_s *handle = (camera_s *)camera;
2872 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2873 MMCAM_TAG_GPS_ENABLE, false,
2876 return __convert_camera_error_code(__func__, ret);
2880 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
2882 if (camera == NULL) {
2883 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2884 return CAMERA_ERROR_INVALID_PARAMETER;
2887 int ret = MM_ERROR_NONE;
2888 camera_s *handle = (camera_s *)camera;
2890 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2891 MMCAM_STROBE_MODE, mode,
2894 return __convert_camera_error_code(__func__, ret);
2898 int camera_attr_get_zoom(camera_h camera, int *zoom)
2900 if (camera == NULL || zoom == NULL) {
2901 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2902 return CAMERA_ERROR_INVALID_PARAMETER;
2905 int ret = MM_ERROR_NONE;
2906 camera_s *handle = (camera_s *)camera;
2908 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2909 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2912 return __convert_camera_error_code(__func__, ret);
2916 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
2918 if (camera == NULL || min == NULL || max == NULL) {
2919 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2920 return CAMERA_ERROR_INVALID_PARAMETER;
2923 int ret = MM_ERROR_NONE;
2924 camera_s *handle = (camera_s *)camera;
2925 MMCamAttrsInfo ainfo;
2927 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
2928 if (ret == MM_ERROR_NONE) {
2929 *min = ainfo.int_range.min;
2930 *max = ainfo.int_range.max;
2933 return __convert_camera_error_code(__func__, ret);
2937 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
2939 if (camera == NULL || mode == NULL) {
2940 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2941 return CAMERA_ERROR_INVALID_PARAMETER;
2944 int ret = MM_ERROR_NONE;
2948 camera_s *handle = (camera_s *)camera;
2950 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2951 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2952 MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
2953 MMCAM_DETECT_MODE, &detect_mode,
2955 if (ret == MM_ERROR_NONE) {
2956 switch (focus_mode) {
2957 case MM_CAMCORDER_FOCUS_MODE_NONE:
2958 case MM_CAMCORDER_FOCUS_MODE_PAN:
2959 case MM_CAMCORDER_FOCUS_MODE_MANUAL:
2960 *mode = CAMERA_ATTR_AF_NONE;
2962 case MM_CAMCORDER_FOCUS_MODE_AUTO:
2963 case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
2964 case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
2966 case MM_CAMCORDER_AUTO_FOCUS_NONE:
2967 *mode = CAMERA_ATTR_AF_NORMAL;
2969 case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
2970 *mode = CAMERA_ATTR_AF_NORMAL;
2972 case MM_CAMCORDER_AUTO_FOCUS_MACRO:
2973 *mode = CAMERA_ATTR_AF_MACRO;
2975 case MM_CAMCORDER_AUTO_FOCUS_FULL:
2976 *mode = CAMERA_ATTR_AF_FULL;
2979 *mode = CAMERA_ATTR_AF_NORMAL;
2984 *mode = CAMERA_ATTR_AF_NONE;
2989 return __convert_camera_error_code(__func__, ret);
2993 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
2995 if (camera == NULL || mode == NULL) {
2996 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2997 return CAMERA_ERROR_INVALID_PARAMETER;
3000 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3001 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3002 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3003 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3004 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3005 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3006 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3007 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3008 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3010 int ret = MM_ERROR_NONE;
3012 camera_s *handle = (camera_s *)camera;
3014 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3015 MMCAM_CAMERA_EXPOSURE_MODE, &exposure_mode,
3018 if (ret == CAMERA_ERROR_NONE) {
3019 *mode = maptable[abs(exposure_mode%9)];
3022 return __convert_camera_error_code(__func__, ret);
3026 int camera_attr_get_exposure(camera_h camera, int *value)
3028 if (camera == NULL || value == NULL) {
3029 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3030 return CAMERA_ERROR_INVALID_PARAMETER;
3033 int ret = MM_ERROR_NONE;
3034 camera_s *handle = (camera_s *)camera;
3036 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3037 MMCAM_CAMERA_EXPOSURE_VALUE, value,
3040 return __convert_camera_error_code(__func__, ret);
3044 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
3046 if (camera == NULL || min == NULL || max == NULL) {
3047 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3048 return CAMERA_ERROR_INVALID_PARAMETER;
3051 int ret = MM_ERROR_NONE;
3052 camera_s *handle = (camera_s *)camera;
3053 MMCamAttrsInfo ainfo;
3055 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
3056 if (ret == MM_ERROR_NONE) {
3057 *min = ainfo.int_range.min;
3058 *max = ainfo.int_range.max;
3061 return __convert_camera_error_code(__func__, ret);
3065 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
3067 if (camera == NULL || iso == NULL) {
3068 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3069 return CAMERA_ERROR_INVALID_PARAMETER;
3072 int ret = MM_ERROR_NONE;
3073 camera_s *handle = (camera_s *)camera;
3075 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3076 MMCAM_CAMERA_ISO, iso,
3079 return __convert_camera_error_code(__func__, ret);
3083 int camera_attr_get_brightness(camera_h camera, int *level)
3085 if (camera == NULL || level == NULL) {
3086 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3087 return CAMERA_ERROR_INVALID_PARAMETER;
3090 int ret = MM_ERROR_NONE;
3091 camera_s *handle = (camera_s *)camera;
3093 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3094 MMCAM_FILTER_BRIGHTNESS, level,
3097 return __convert_camera_error_code(__func__, ret);
3101 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
3103 if (camera == NULL || min == NULL || max == NULL) {
3104 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3105 return CAMERA_ERROR_INVALID_PARAMETER;
3108 int ret = MM_ERROR_NONE;
3109 camera_s *handle = (camera_s *)camera;
3110 MMCamAttrsInfo ainfo;
3112 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
3113 if (ret == MM_ERROR_NONE) {
3114 *min = ainfo.int_range.min;
3115 *max = ainfo.int_range.max;
3118 return __convert_camera_error_code(__func__, ret);
3122 int camera_attr_get_contrast(camera_h camera, int *level)
3124 if (camera == NULL || level == NULL) {
3125 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3126 return CAMERA_ERROR_INVALID_PARAMETER;
3129 int ret = MM_ERROR_NONE;
3130 camera_s *handle = (camera_s *)camera;
3132 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3133 MMCAM_FILTER_CONTRAST, level,
3136 return __convert_camera_error_code(__func__, ret);
3140 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
3142 if (camera == NULL || min == NULL || max == NULL) {
3143 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3144 return CAMERA_ERROR_INVALID_PARAMETER;
3147 int ret = MM_ERROR_NONE;
3148 camera_s *handle = (camera_s *)camera;
3149 MMCamAttrsInfo ainfo;
3151 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
3152 if (ret == MM_ERROR_NONE) {
3153 *min = ainfo.int_range.min;
3154 *max = ainfo.int_range.max;
3157 return __convert_camera_error_code(__func__, ret);
3161 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
3163 if (camera == NULL || wb == NULL) {
3164 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3165 return CAMERA_ERROR_INVALID_PARAMETER;
3168 int ret = MM_ERROR_NONE;
3169 camera_s *handle = (camera_s *)camera;
3171 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3172 MMCAM_FILTER_WB, wb,
3175 return __convert_camera_error_code(__func__, ret);
3179 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
3181 if (camera == NULL || effect == NULL) {
3182 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3183 return CAMERA_ERROR_INVALID_PARAMETER;
3186 int ret = MM_ERROR_NONE;
3187 camera_s *handle = (camera_s *)camera;
3189 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3190 MMCAM_FILTER_COLOR_TONE, effect,
3193 return __convert_camera_error_code(__func__, ret);
3197 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
3199 if (camera == NULL || mode == NULL) {
3200 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3201 return CAMERA_ERROR_INVALID_PARAMETER;
3204 int ret = MM_ERROR_NONE;
3205 camera_s *handle = (camera_s *)camera;
3207 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3208 MMCAM_FILTER_SCENE_MODE, mode,
3211 return __convert_camera_error_code(__func__, ret);
3215 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
3217 if (camera == NULL || enable == NULL) {
3218 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3219 return CAMERA_ERROR_INVALID_PARAMETER;
3222 int ret = MM_ERROR_NONE;
3223 camera_s *handle = (camera_s *)camera;
3225 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3226 MMCAM_TAG_ENABLE, enable,
3229 return __convert_camera_error_code(__func__, ret);
3233 int camera_attr_get_tag_image_description(camera_h camera, char **description)
3235 if (camera == NULL || description == NULL) {
3236 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3237 return CAMERA_ERROR_INVALID_PARAMETER;
3240 int ret = MM_ERROR_NONE;
3241 camera_s *handle = (camera_s *)camera;
3242 char *ndescription = NULL;
3245 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3246 MMCAM_TAG_IMAGE_DESCRIPTION, &ndescription, &desc_size,
3248 if (ret == MM_ERROR_NONE) {
3249 if (ndescription != NULL) {
3250 *description = strdup(ndescription);
3252 *description = strdup("");
3256 return __convert_camera_error_code(__func__, ret);
3260 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
3262 if (camera == NULL || orientation == NULL) {
3263 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3264 return CAMERA_ERROR_INVALID_PARAMETER;
3267 int ret = MM_ERROR_NONE;
3268 camera_s *handle = (camera_s *)camera;
3270 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3271 MMCAM_TAG_ORIENTATION, orientation,
3274 return __convert_camera_error_code(__func__, ret);
3278 int camera_attr_get_tag_software(camera_h camera, char **software)
3280 if (camera == NULL || software == NULL) {
3281 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3282 return CAMERA_ERROR_INVALID_PARAMETER;
3285 int ret = MM_ERROR_NONE;
3286 camera_s *handle = (camera_s *)camera;
3290 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3291 MMCAM_TAG_SOFTWARE, &soft, &soft_size,
3293 if (ret == MM_ERROR_NONE) {
3295 *software = strdup(soft);
3297 *software = strdup("");
3301 return __convert_camera_error_code(__func__, ret);
3305 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
3307 if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
3308 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3309 return CAMERA_ERROR_INVALID_PARAMETER;
3312 int ret = MM_ERROR_NONE;
3313 camera_s *handle = (camera_s *)camera;
3315 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3316 MMCAM_TAG_LATITUDE, latitude,
3317 MMCAM_TAG_LONGITUDE, longitude,
3318 MMCAM_TAG_ALTITUDE, altitude,
3321 return __convert_camera_error_code(__func__, ret);
3325 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
3327 if (camera == NULL || mode == NULL) {
3328 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3329 return CAMERA_ERROR_INVALID_PARAMETER;
3332 int ret = MM_ERROR_NONE;
3333 camera_s *handle = (camera_s *)camera;
3335 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3336 MMCAM_STROBE_MODE, mode,
3339 return __convert_camera_error_code(__func__, ret);
3343 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
3345 if (camera == NULL || foreach_cb == NULL) {
3346 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3347 return CAMERA_ERROR_INVALID_PARAMETER;
3350 int ret = MM_ERROR_NONE;
3352 camera_s *handle = (camera_s *)camera;
3353 MMCamAttrsInfo af_range;
3354 MMCamAttrsInfo focus_mode;
3356 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE, &af_range);
3357 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE, &focus_mode);
3358 if (ret != MM_ERROR_NONE) {
3359 return __convert_camera_error_code(__func__, ret);
3362 for (i = 0 ; i < af_range.int_array.count ; i++) {
3363 if (!foreach_cb(af_range.int_array.array[i], user_data)) {
3368 return CAMERA_ERROR_NONE;
3372 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
3374 if (camera == NULL || foreach_cb == NULL) {
3375 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3376 return CAMERA_ERROR_INVALID_PARAMETER;
3379 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3380 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3381 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3382 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3383 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3384 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3385 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3386 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3387 -1 /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3390 int ret = MM_ERROR_NONE;
3391 camera_s *handle = (camera_s *)camera;
3392 MMCamAttrsInfo info;
3394 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE, &info);
3395 if (ret != MM_ERROR_NONE) {
3396 return __convert_camera_error_code(__func__, ret);
3399 for (i = 0 ; i < info.int_array.count ; i++) {
3400 if (info.int_array.array[i] >= MM_CAMCORDER_AUTO_EXPOSURE_OFF &&
3401 info.int_array.array[i] <= MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2) {
3402 if (maptable[info.int_array.array[i]] != -1) {
3403 if (!foreach_cb(maptable[info.int_array.array[i]], user_data)) {
3408 LOGW("unknown value %d", info.int_array.array[i]);
3412 return CAMERA_ERROR_NONE;
3416 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
3418 if (camera == NULL || foreach_cb == NULL) {
3419 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3420 return CAMERA_ERROR_INVALID_PARAMETER;
3424 int ret = MM_ERROR_NONE;
3425 camera_s *handle = (camera_s *)camera;
3426 MMCamAttrsInfo info;
3428 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO, &info);
3429 if (ret != MM_ERROR_NONE) {
3430 return __convert_camera_error_code(__func__, ret);
3433 for (i = 0 ; i < info.int_array.count ; i++) {
3434 if (!foreach_cb(info.int_array.array[i], user_data)) {
3439 return CAMERA_ERROR_NONE;
3443 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
3445 if (camera == NULL || foreach_cb == NULL) {
3446 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3447 return CAMERA_ERROR_INVALID_PARAMETER;
3451 int ret = MM_ERROR_NONE;
3452 camera_s *handle = (camera_s *)camera;
3453 MMCamAttrsInfo info;
3455 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB, &info);
3456 if (ret != MM_ERROR_NONE) {
3457 return __convert_camera_error_code(__func__, ret);
3460 for (i = 0 ; i < info.int_array.count ; i++) {
3461 if (!foreach_cb(info.int_array.array[i], user_data)) {
3466 return CAMERA_ERROR_NONE;
3470 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
3472 if (camera == NULL || foreach_cb == NULL) {
3473 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3474 return CAMERA_ERROR_INVALID_PARAMETER;
3478 int ret = MM_ERROR_NONE;
3479 camera_s *handle = (camera_s *)camera;
3480 MMCamAttrsInfo info;
3482 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE, &info);
3483 if (ret != MM_ERROR_NONE) {
3484 return __convert_camera_error_code(__func__, ret);
3487 for (i = 0 ; i < info.int_array.count ; i++) {
3488 if (!foreach_cb(info.int_array.array[i], user_data)) {
3493 return CAMERA_ERROR_NONE;
3497 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
3499 if (camera == NULL || foreach_cb == NULL) {
3500 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3501 return CAMERA_ERROR_INVALID_PARAMETER;
3505 int ret = MM_ERROR_NONE;
3506 camera_s *handle = (camera_s *)camera;
3507 MMCamAttrsInfo info;
3509 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE, &info);
3510 if (ret != MM_ERROR_NONE) {
3511 return __convert_camera_error_code(__func__, ret);
3514 for (i = 0 ; i < info.int_array.count ; i++) {
3515 if (!foreach_cb(info.int_array.array[i], user_data)) {
3520 return CAMERA_ERROR_NONE;
3524 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
3526 if (camera == NULL || foreach_cb == NULL) {
3527 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3528 return CAMERA_ERROR_INVALID_PARAMETER;
3532 int ret = MM_ERROR_NONE;
3533 camera_s *handle = (camera_s *)camera;
3534 MMCamAttrsInfo info;
3536 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE, &info);
3537 if (ret != MM_ERROR_NONE) {
3538 return __convert_camera_error_code(__func__, ret);
3541 for (i = 0 ; i < info.int_array.count ; i++) {
3542 if (!foreach_cb(info.int_array.array[i], user_data)) {
3547 return CAMERA_ERROR_NONE;
3551 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
3553 if (camera == NULL || foreach_cb == NULL) {
3554 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3555 return CAMERA_ERROR_INVALID_PARAMETER;
3558 int ret = MM_ERROR_NONE;
3559 camera_s *handle = (camera_s *)camera;
3560 MMCamAttrsInfo info;
3565 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3566 MMCAM_CAMERA_WIDTH, &width,
3567 MMCAM_CAMERA_HEIGHT, &height,
3569 if (ret != MM_ERROR_NONE) {
3570 return __convert_camera_error_code(__func__, ret);
3573 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3574 if (ret != MM_ERROR_NONE) {
3575 return __convert_camera_error_code(__func__, ret);
3578 for (i = 0 ; i < info.int_array.count ; i++) {
3579 if (!foreach_cb(info.int_array.array[i], user_data)) {
3584 return CAMERA_ERROR_NONE;
3588 int camera_attr_foreach_supported_fps_by_resolution(camera_h camera, int width, int height, camera_attr_supported_fps_cb foreach_cb, void *user_data)
3590 if (camera == NULL || foreach_cb == NULL) {
3591 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3592 return CAMERA_ERROR_INVALID_PARAMETER;
3595 int ret = MM_ERROR_NONE;
3596 camera_s *handle = (camera_s *)camera;
3597 MMCamAttrsInfo info;
3600 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3601 if (ret != MM_ERROR_NONE) {
3602 return __convert_camera_error_code(__func__, ret);
3605 for (i = 0 ; i < info.int_array.count ; i++) {
3606 if (!foreach_cb(info.int_array.array[i], user_data)) {
3611 return CAMERA_ERROR_NONE;
3615 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
3617 if (camera == NULL || foreach_cb == NULL) {
3618 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3619 return CAMERA_ERROR_INVALID_PARAMETER;
3623 int ret = MM_ERROR_NONE;
3624 camera_s *handle = (camera_s *)camera;
3625 MMCamAttrsInfo info;
3627 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FLIP, &info);
3628 if (ret != MM_ERROR_NONE) {
3629 return __convert_camera_error_code(__func__, ret);
3632 for (i = 0 ; i < info.int_array.count ; i++) {
3633 if (!foreach_cb(info.int_array.array[i], user_data)) {
3638 return CAMERA_ERROR_NONE;
3642 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
3644 if (camera == NULL || foreach_cb == NULL) {
3645 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3646 return CAMERA_ERROR_INVALID_PARAMETER;
3650 int ret = MM_ERROR_NONE;
3651 camera_s *handle = (camera_s *)camera;
3652 MMCamAttrsInfo info;
3654 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ROTATION, &info);
3655 if (ret != MM_ERROR_NONE) {
3656 return __convert_camera_error_code(__func__, ret);
3659 for (i = 0 ; i < info.int_array.count ; i++) {
3660 if (!foreach_cb(info.int_array.array[i], user_data)) {
3665 return CAMERA_ERROR_NONE;
3669 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
3671 if (camera == NULL) {
3672 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3673 return CAMERA_ERROR_INVALID_PARAMETER;
3676 if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
3677 LOGE("INVALID_PARAMETER - %d", rotation);
3678 return CAMERA_ERROR_INVALID_PARAMETER;
3681 int ret = MM_ERROR_NONE;
3682 camera_s *handle = (camera_s *)camera;
3684 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3685 MMCAM_CAMERA_ROTATION, rotation,
3688 return __convert_camera_error_code(__func__, ret);
3692 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
3694 if (camera == NULL || rotation == NULL) {
3695 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3696 return CAMERA_ERROR_INVALID_PARAMETER;
3699 int ret = MM_ERROR_NONE;
3700 camera_s *handle = (camera_s *)camera;
3702 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3703 MMCAM_CAMERA_ROTATION, rotation,
3706 return __convert_camera_error_code(__func__, ret);
3710 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
3712 if (camera == NULL) {
3713 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3714 return CAMERA_ERROR_INVALID_PARAMETER;
3717 if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
3718 LOGE("INVALID_PARAMETER - %d", flip);
3719 return CAMERA_ERROR_INVALID_PARAMETER;
3722 int ret = MM_ERROR_NONE;
3723 camera_s *handle = (camera_s *)camera;
3725 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3726 MMCAM_CAMERA_FLIP, flip,
3729 return __convert_camera_error_code(__func__, ret);
3733 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
3735 if (camera == NULL || flip == NULL) {
3736 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3737 return CAMERA_ERROR_INVALID_PARAMETER;
3740 int ret = MM_ERROR_NONE;
3741 camera_s *handle = (camera_s *)camera;
3743 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3744 MMCAM_CAMERA_FLIP, flip,
3747 return __convert_camera_error_code(__func__, ret);
3751 int _camera_set_use(camera_h camera, bool used)
3753 camera_s *handle = (camera_s *)camera;
3755 if (handle == NULL) {
3756 LOGE("handle is NULL");
3757 return CAMERA_ERROR_INVALID_PARAMETER;
3760 handle->is_used_in_recorder = used;
3762 return CAMERA_ERROR_NONE;
3766 bool _camera_is_used(camera_h camera)
3768 camera_s *handle = (camera_s *)camera;
3770 if (handle == NULL) {
3771 LOGE("handle is NULL");
3775 return handle->is_used_in_recorder;
3779 int _camera_get_mm_handle(camera_h camera, MMHandleType *handle)
3781 if (camera == NULL || handle == NULL) {
3782 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3783 return CAMERA_ERROR_INVALID_PARAMETER;
3786 camera_s *camera_handle = (camera_s*)camera;
3788 *handle = camera_handle->mm_handle;
3790 return CAMERA_ERROR_NONE;
3794 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data)
3796 if( camera == NULL ){
3797 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3798 return CAMERA_ERROR_INVALID_PARAMETER;
3801 camera_s *handle = (camera_s *)camera;
3802 handle->relay_message_callback = callback;
3803 handle->relay_user_data = user_data;
3805 return CAMERA_ERROR_NONE;
3809 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
3811 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3812 in_format >= MM_PIXEL_FORMAT_NUM ||
3813 out_format == NULL) {
3814 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
3815 return CAMERA_ERROR_INVALID_PARAMETER;
3818 switch (in_format) {
3819 case MM_PIXEL_FORMAT_NV12:
3820 case MM_PIXEL_FORMAT_NV12T:
3821 *out_format = TBM_FORMAT_NV12;
3823 case MM_PIXEL_FORMAT_NV16:
3824 *out_format = TBM_FORMAT_NV16;
3826 case MM_PIXEL_FORMAT_NV21:
3827 *out_format = TBM_FORMAT_NV21;
3829 case MM_PIXEL_FORMAT_YUYV:
3830 *out_format = TBM_FORMAT_YUYV;
3832 case MM_PIXEL_FORMAT_UYVY:
3833 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3834 *out_format = TBM_FORMAT_UYVY;
3836 case MM_PIXEL_FORMAT_422P:
3837 *out_format = TBM_FORMAT_YUV422;
3839 case MM_PIXEL_FORMAT_I420:
3840 *out_format = TBM_FORMAT_YUV420;
3842 case MM_PIXEL_FORMAT_YV12:
3843 *out_format = TBM_FORMAT_YVU420;
3845 case MM_PIXEL_FORMAT_RGB565:
3846 *out_format = TBM_FORMAT_RGB565;
3848 case MM_PIXEL_FORMAT_RGB888:
3849 *out_format = TBM_FORMAT_RGB888;
3851 case MM_PIXEL_FORMAT_RGBA:
3852 *out_format = TBM_FORMAT_RGBA8888;
3854 case MM_PIXEL_FORMAT_ARGB:
3855 *out_format = TBM_FORMAT_ARGB8888;
3858 LOGE("invalid in_format %d", in_format);
3859 return CAMERA_ERROR_INVALID_PARAMETER;
3862 return CAMERA_ERROR_NONE;
3866 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
3868 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3869 in_format >= MM_PIXEL_FORMAT_NUM ||
3871 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
3872 return CAMERA_ERROR_INVALID_PARAMETER;
3875 switch (in_format) {
3876 case MM_PIXEL_FORMAT_NV12:
3877 case MM_PIXEL_FORMAT_NV12T:
3878 *mimetype = MEDIA_FORMAT_NV12;
3880 case MM_PIXEL_FORMAT_NV16:
3881 *mimetype = MEDIA_FORMAT_NV16;
3883 case MM_PIXEL_FORMAT_NV21:
3884 *mimetype = MEDIA_FORMAT_NV21;
3886 case MM_PIXEL_FORMAT_YUYV:
3887 *mimetype = MEDIA_FORMAT_YUYV;
3889 case MM_PIXEL_FORMAT_UYVY:
3890 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3891 *mimetype = MEDIA_FORMAT_UYVY;
3893 case MM_PIXEL_FORMAT_422P:
3894 *mimetype = MEDIA_FORMAT_422P;
3896 case MM_PIXEL_FORMAT_I420:
3897 *mimetype = MEDIA_FORMAT_I420;
3899 case MM_PIXEL_FORMAT_YV12:
3900 *mimetype = MEDIA_FORMAT_YV12;
3902 case MM_PIXEL_FORMAT_RGB565:
3903 *mimetype = MEDIA_FORMAT_RGB565;
3905 case MM_PIXEL_FORMAT_RGB888:
3906 *mimetype = MEDIA_FORMAT_RGB888;
3908 case MM_PIXEL_FORMAT_RGBA:
3909 *mimetype = MEDIA_FORMAT_RGBA;
3911 case MM_PIXEL_FORMAT_ARGB:
3912 *mimetype = MEDIA_FORMAT_ARGB;
3915 LOGE("invalid in_format %d", in_format);
3916 return CAMERA_ERROR_INVALID_PARAMETER;
3919 return CAMERA_ERROR_NONE;
3923 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
3926 void *internal_buffer = NULL;
3927 tbm_surface_h tsurf = NULL;
3929 if (pkt == NULL || user_data == NULL) {
3930 LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
3931 return MEDIA_PACKET_FINALIZE;
3934 ret = media_packet_get_extra(pkt, &internal_buffer);
3935 if (ret != MEDIA_PACKET_ERROR_NONE) {
3936 LOGE("media_packet_get_extra failed 0x%x", ret);
3937 return MEDIA_PACKET_FINALIZE;
3940 /*LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret);*/
3942 if (internal_buffer) {
3943 gst_buffer_unref((GstBuffer *)internal_buffer);
3944 internal_buffer = NULL;
3947 ret = media_packet_get_tbm_surface(pkt, &tsurf);
3948 if (ret != MEDIA_PACKET_ERROR_NONE) {
3949 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
3950 return MEDIA_PACKET_FINALIZE;
3954 tbm_surface_destroy(tsurf);
3958 return MEDIA_PACKET_FINALIZE;
3962 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
3964 if (camera == NULL) {
3965 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3966 return CAMERA_ERROR_INVALID_PARAMETER;
3969 if (camera_attr_is_supported_hdr_capture(camera) == false) {
3970 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3971 return CAMERA_ERROR_NOT_SUPPORTED;
3974 int ret = MM_ERROR_NONE;
3975 camera_s *handle = (camera_s *)camera;
3977 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3978 MMCAM_CAMERA_HDR_CAPTURE, mode,
3981 if (ret == MM_ERROR_NONE) {
3982 if (mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL) {
3983 handle->hdr_keep_mode = true;
3985 handle->hdr_keep_mode = false;
3989 return __convert_camera_error_code(__func__, ret);
3993 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
3995 if (camera == NULL) {
3996 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3997 return CAMERA_ERROR_INVALID_PARAMETER;
4000 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4001 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4002 return CAMERA_ERROR_NOT_SUPPORTED;
4006 LOGE("INVALID_PARAMETER(0x%08x) - mode", CAMERA_ERROR_INVALID_PARAMETER);
4007 return CAMERA_ERROR_INVALID_PARAMETER;
4010 int ret = MM_ERROR_NONE;
4011 camera_s *handle = (camera_s *)camera;
4013 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4014 MMCAM_CAMERA_HDR_CAPTURE, mode,
4017 return __convert_camera_error_code(__func__, ret);
4021 bool camera_attr_is_supported_hdr_capture(camera_h camera)
4023 if (camera == NULL) {
4024 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4028 int ret = MM_ERROR_NONE;
4030 camera_s *handle = (camera_s *)camera;
4031 MMCamAttrsInfo hdr_info;
4033 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE, &hdr_info);
4034 set_last_result(__convert_camera_error_code(__func__, ret));
4035 if (ret != MM_ERROR_NONE) {
4036 LOGE("MMCAM_CAMERA_HDR_CAPTURE get attr info failed");
4040 for (i = 0; i < hdr_info.int_array.count ; i++) {
4041 if (hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON) {
4042 LOGD("HDR capture supported");
4047 LOGD("HDR capture NOT supported");
4053 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
4055 if (camera == NULL) {
4056 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4057 return CAMERA_ERROR_INVALID_PARAMETER;
4060 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4061 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4062 return CAMERA_ERROR_NOT_SUPPORTED;
4065 if (callback == NULL) {
4066 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
4067 return CAMERA_ERROR_INVALID_PARAMETER;
4070 camera_s *handle = (camera_s *)camera;
4072 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)callback;
4073 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)user_data;
4075 return CAMERA_ERROR_NONE;
4079 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
4081 if (camera == NULL) {
4082 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4083 return CAMERA_ERROR_INVALID_PARAMETER;
4086 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4087 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4088 return CAMERA_ERROR_NOT_SUPPORTED;
4091 camera_s *handle = (camera_s *)camera;
4093 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4094 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4096 return CAMERA_ERROR_NONE;
4100 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
4102 if (camera == NULL) {
4103 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4104 return CAMERA_ERROR_INVALID_PARAMETER;
4107 if (camera_attr_is_supported_anti_shake(camera) == false) {
4108 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4109 return CAMERA_ERROR_NOT_SUPPORTED;
4112 int ret = MM_ERROR_NONE;
4113 int mode = MM_CAMCORDER_AHS_OFF;
4114 camera_s *handle = (camera_s *)camera;
4117 mode = MM_CAMCORDER_AHS_ON;
4120 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4121 MMCAM_CAMERA_ANTI_HANDSHAKE, mode,
4124 return __convert_camera_error_code(__func__, ret);
4128 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
4130 if (camera == NULL) {
4131 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4132 return CAMERA_ERROR_INVALID_PARAMETER;
4135 if (camera_attr_is_supported_anti_shake(camera) == false) {
4136 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4137 return CAMERA_ERROR_NOT_SUPPORTED;
4140 if (enabled == NULL) {
4141 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4142 return CAMERA_ERROR_INVALID_PARAMETER;
4145 int ret = MM_ERROR_NONE;
4146 camera_s *handle = (camera_s *)camera;
4148 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4149 MMCAM_CAMERA_ANTI_HANDSHAKE, enabled,
4152 return __convert_camera_error_code(__func__, ret);
4156 bool camera_attr_is_supported_anti_shake(camera_h camera)
4158 if (camera == NULL) {
4159 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4164 int ret = MM_ERROR_NONE;
4165 camera_s *handle = (camera_s *)camera;
4166 MMCamAttrsInfo ash_info;
4168 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE, &ash_info);
4169 set_last_result(__convert_camera_error_code(__func__, ret));
4170 if (ret != MM_ERROR_NONE) {
4171 LOGE("MMCAM_CAMERA_ANTI_HANDSHAKE get attr info failed");
4175 for (i = 0 ; i < ash_info.int_array.count ; i++) {
4176 if (ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON) {
4185 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
4187 if (camera == NULL) {
4188 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4189 return CAMERA_ERROR_INVALID_PARAMETER;
4192 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4193 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4194 return CAMERA_ERROR_NOT_SUPPORTED;
4197 int ret = MM_ERROR_NONE;
4198 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4199 camera_s *handle = (camera_s*)camera;
4202 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
4205 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4206 MMCAM_CAMERA_VIDEO_STABILIZATION, mode,
4209 return __convert_camera_error_code(__func__, ret);
4213 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
4215 if (camera == NULL) {
4216 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4217 return CAMERA_ERROR_INVALID_PARAMETER;
4220 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4221 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4222 return CAMERA_ERROR_NOT_SUPPORTED;
4225 if (enabled == NULL) {
4226 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4227 return CAMERA_ERROR_INVALID_PARAMETER;
4230 int ret = MM_ERROR_NONE;
4231 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4232 camera_s *handle = (camera_s *)camera;
4234 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4235 MMCAM_CAMERA_VIDEO_STABILIZATION, &mode,
4237 if (ret == MM_ERROR_NONE) {
4238 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
4241 return __convert_camera_error_code(__func__, ret);
4245 bool camera_attr_is_supported_video_stabilization(camera_h camera)
4247 if (camera == NULL) {
4248 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4253 int ret = MM_ERROR_NONE;
4254 camera_s *handle = (camera_s *)camera;
4255 MMCamAttrsInfo vs_info;
4257 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION, &vs_info);
4258 set_last_result(__convert_camera_error_code(__func__, ret));
4259 if (ret != MM_ERROR_NONE) {
4260 LOGE("MMCAM_CAMERA_VIDEO_STABILIZATION get attr info failed");
4264 for (i = 0 ; i < vs_info.int_array.count ; i++) {
4265 if (vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
4274 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
4276 if (camera == NULL) {
4277 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4278 return CAMERA_ERROR_INVALID_PARAMETER;
4281 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4282 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4283 return CAMERA_ERROR_NOT_SUPPORTED;
4286 int ret = MM_ERROR_NONE;
4287 int mode = MM_CAMCORDER_WDR_OFF;
4288 camera_s *handle = (camera_s *)camera;
4291 mode = MM_CAMCORDER_WDR_ON;
4294 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4295 MMCAM_CAMERA_WDR, mode,
4298 return __convert_camera_error_code(__func__, ret);
4302 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
4304 if (camera == NULL) {
4305 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4306 return CAMERA_ERROR_INVALID_PARAMETER;
4309 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4310 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4311 return CAMERA_ERROR_NOT_SUPPORTED;
4314 if (enabled == NULL) {
4315 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4316 return CAMERA_ERROR_INVALID_PARAMETER;
4319 int ret = MM_ERROR_NONE;
4320 int mode = MM_CAMCORDER_WDR_OFF;
4321 camera_s *handle = (camera_s *)camera;
4323 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4324 MMCAM_CAMERA_WDR, &mode,
4327 if (ret == MM_ERROR_NONE) {
4331 return __convert_camera_error_code(__func__, ret);
4335 bool camera_attr_is_supported_auto_contrast(camera_h camera)
4337 if (camera == NULL) {
4338 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4343 int ret = MM_ERROR_NONE;
4344 camera_s *handle = (camera_s *)camera;
4345 MMCamAttrsInfo info;
4347 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WDR, &info);
4348 set_last_result(__convert_camera_error_code(__func__, ret));
4349 if (ret != MM_ERROR_NONE) {
4350 LOGE("MMCAM_CAMERA_WDR get attr info failed");
4354 for (i = 0 ; i < info.int_array.count ; i++) {
4355 if (info.int_array.array[i] == MM_CAMCORDER_WDR_ON) {
4364 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
4366 if (camera == NULL) {
4367 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4368 return CAMERA_ERROR_INVALID_PARAMETER;
4371 int ret = MM_ERROR_NONE;
4372 camera_s *handle = (camera_s *)camera;
4374 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4375 "capture-sound-enable", !disable,
4377 if (ret != MM_ERROR_NONE) {
4378 LOGE("CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound");
4379 return CAMERA_ERROR_INVALID_OPERATION;
4382 return CAMERA_ERROR_NONE;