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,
808 handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
810 if (ret != MM_ERROR_NONE) {
811 LOGE("mm_camcorder_set_attributes fail(%x)", ret);
813 LOGE("failed attribute name %s", error);
817 mm_camcorder_destroy(handle->mm_handle);
820 return __convert_camera_error_code(__func__, ret);
823 handle->state = CAMERA_STATE_CREATED;
824 handle->relay_message_callback = NULL;
825 handle->relay_user_data = NULL;
826 handle->capture_resolution_modified = false;
827 handle->hdr_keep_mode = false;
828 handle->focus_area_valid = false;
829 handle->is_used_in_recorder = false;
830 handle->on_continuous_focusing = false;
831 handle->cached_focus_mode = -1;
833 g_mutex_init(&handle->idle_cb_lock);
835 mm_camcorder_set_message_callback(handle->mm_handle,
836 __mm_camera_message_callback,
839 *camera = (camera_h)handle;
841 LOGW("camera handle %p", handle);
843 return __convert_camera_error_code(__func__, ret);
847 int camera_destroy(camera_h camera)
849 if (camera == NULL) {
850 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
851 return CAMERA_ERROR_INVALID_PARAMETER;
854 int ret = MM_ERROR_NONE;
855 camera_s *handle = (camera_s *)camera;
857 if (handle->is_used_in_recorder) {
858 LOGE("camera is using in another recorder.");
859 return CAMERA_ERROR_INVALID_OPERATION;
862 LOGW("camera handle %p", handle);
864 if (handle->pkt_fmt) {
865 media_format_unref(handle->pkt_fmt);
866 handle->pkt_fmt = NULL;
869 ret = mm_camcorder_destroy(handle->mm_handle);
870 if (ret == MM_ERROR_NONE) {
871 _camera_remove_cb_message(handle);
872 g_mutex_clear(&handle->idle_cb_lock);
874 if (handle->wl_info) {
875 free(handle->wl_info);
876 handle->wl_info = NULL;
878 #endif /* HAVE_WAYLAND */
882 return __convert_camera_error_code(__func__, ret);
886 int camera_start_preview(camera_h camera)
888 if (camera == NULL) {
889 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
890 return CAMERA_ERROR_INVALID_PARAMETER;
893 int ret = MM_ERROR_NONE;
894 camera_s *handle = (camera_s *)camera;
895 camera_state_e capi_state = CAMERA_STATE_NONE;
896 MMCamcorderStateType mm_state = MM_CAMCORDER_STATE_NONE;
898 camera_get_state(camera, &capi_state);
899 if (capi_state == CAMERA_STATE_CAPTURED) {
900 ret = mm_camcorder_capture_stop(handle->mm_handle);
901 return __convert_camera_error_code(__func__, ret);
904 /* for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback */
905 mm_camcorder_set_video_capture_callback(handle->mm_handle,
906 (mm_camcorder_video_capture_callback)__mm_capture_callback,
909 mm_camcorder_get_state(handle->mm_handle, &mm_state);
910 if (mm_state != MM_CAMCORDER_STATE_READY) {
911 ret = mm_camcorder_realize(handle->mm_handle);
912 if (ret != MM_ERROR_NONE) {
913 LOGE("mm_camcorder_realize failed 0x%x", ret);
914 return __convert_camera_error_code(__func__, ret);
918 ret = mm_camcorder_start(handle->mm_handle);
919 if (ret != MM_ERROR_NONE) {
920 LOGE("mm_camcorder_start failed 0x%x, call mm_camcorder_unrealize", ret);
921 mm_camcorder_unrealize(handle->mm_handle);
924 return __convert_camera_error_code(__func__, ret);
928 int camera_stop_preview(camera_h camera)
930 if (camera == NULL) {
931 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
932 return CAMERA_ERROR_INVALID_PARAMETER;
935 int ret = MM_ERROR_NONE;;
936 camera_s *handle = (camera_s *)camera;
937 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
939 mm_camcorder_get_state(handle->mm_handle, &state);
940 if (state == MM_CAMCORDER_STATE_PREPARE) {
941 ret = mm_camcorder_stop(handle->mm_handle);
942 if (ret != MM_ERROR_NONE) {
943 LOGE("mm_camcorder_stop failed 0x%x", ret);
944 return __convert_camera_error_code(__func__, ret);
948 camera_stop_face_detection(camera);
950 ret = mm_camcorder_unrealize(handle->mm_handle);
952 return __convert_camera_error_code(__func__, ret);
956 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
958 if (camera == NULL) {
959 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
960 return CAMERA_ERROR_INVALID_PARAMETER;
963 camera_s *handle = (camera_s *)camera;
964 int ret = MM_ERROR_NONE;
965 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
967 mm_camcorder_get_state(handle->mm_handle, &state);
968 if (state != MM_CAMCORDER_STATE_PREPARE &&
969 state != MM_CAMCORDER_STATE_RECORDING &&
970 state != MM_CAMCORDER_STATE_PAUSED) {
971 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
972 return CAMERA_ERROR_INVALID_STATE;
975 if (handle->capture_resolution_modified) {
976 mm_camcorder_set_attributes(handle->mm_handle, NULL,
977 MMCAM_CAPTURE_WIDTH, handle->capture_width,
978 MMCAM_CAPTURE_HEIGHT, handle->capture_height,
981 handle->capture_resolution_modified = false;
984 mm_camcorder_set_attributes(handle->mm_handle, NULL,
985 MMCAM_CAPTURE_COUNT, 1,
988 handle->capture_count = 1;
989 handle->is_continuous_shot_break = false;
990 handle->current_capture_count = 0;
991 handle->current_capture_complete_count = 0;
992 handle->is_capture_completed = false;
994 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
995 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
996 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
997 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
999 ret = mm_camcorder_capture_start(handle->mm_handle);
1000 if (ret != MM_ERROR_NONE) {
1001 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1002 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1003 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1004 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1007 return __convert_camera_error_code(__func__, ret);
1011 bool camera_is_supported_continuous_capture(camera_h camera)
1013 if (camera == NULL) {
1014 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1018 int ret = MM_ERROR_NONE;
1019 camera_s *handle = (camera_s *)camera;
1020 MMCamAttrsInfo info;
1022 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_COUNT, &info);
1023 set_last_result(__convert_camera_error_code(__func__, ret));
1024 if (ret != MM_ERROR_NONE) {
1025 LOGE("MMCAM_CAPTURE_COUNT info get failed 0x%x", ret);
1029 if (info.int_range.max > 1) {
1037 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)
1039 if (camera == NULL) {
1040 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1041 return CAMERA_ERROR_INVALID_PARAMETER;
1044 if (camera_is_supported_continuous_capture(camera) == false) {
1045 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1046 return CAMERA_ERROR_NOT_SUPPORTED;
1049 if (count < 2 || interval < 0) {
1050 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1051 return CAMERA_ERROR_INVALID_PARAMETER;
1054 camera_s *handle = (camera_s *)camera;
1055 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
1056 int supported_zsl = FALSE;
1057 int ret = MM_ERROR_NONE;
1059 mm_camcorder_get_state(handle->mm_handle, &state);
1060 if (state != MM_CAMCORDER_STATE_PREPARE) {
1061 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1062 return CAMERA_ERROR_INVALID_STATE;
1065 supported_zsl = FALSE;
1067 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1068 MMCAM_CAPTURE_COUNT, count,
1069 MMCAM_CAPTURE_INTERVAL, interval,
1071 if (ret != MM_ERROR_NONE) {
1072 LOGE("error set continuous shot attribute 0x%x", ret);
1073 return __convert_camera_error_code(__func__, ret);
1076 handle->capture_count = count;
1077 handle->is_continuous_shot_break = false;
1078 handle->current_capture_count = 0;
1079 handle->current_capture_complete_count = 0;
1080 handle->is_capture_completed = false;
1082 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1083 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1085 if (ret != MM_ERROR_NONE) {
1086 LOGE("(%x) error get continuous shot attribute", ret);
1089 if (!supported_zsl) {
1095 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1096 MMCAM_CAMERA_WIDTH, &preview_width,
1097 MMCAM_CAMERA_HEIGHT, &preview_height,
1098 MMCAM_CAPTURE_WIDTH, &capture_width,
1099 MMCAM_CAPTURE_HEIGHT, &capture_height,
1102 if (preview_width != capture_width || preview_height != capture_height) {
1103 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1104 MMCAM_CAPTURE_WIDTH, preview_width,
1105 MMCAM_CAPTURE_HEIGHT, preview_height,
1108 handle->capture_resolution_modified = true;
1112 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
1113 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
1114 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
1115 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
1117 ret = mm_camcorder_capture_start(handle->mm_handle);
1118 if(ret != MM_ERROR_NONE ){
1119 LOGE("mm_camcorder_capture_start failed 0x%x", ret);
1120 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1121 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1122 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1123 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1126 return __convert_camera_error_code(__func__, ret);
1131 int camera_stop_continuous_capture(camera_h camera)
1133 if (camera == NULL) {
1134 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1135 return CAMERA_ERROR_INVALID_PARAMETER;
1138 if (camera_is_supported_continuous_capture(camera) == false) {
1139 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1140 return CAMERA_ERROR_NOT_SUPPORTED;
1143 camera_s *handle = (camera_s *)camera;
1144 int ret = MM_ERROR_NONE;
1145 camera_state_e state = CAMERA_STATE_NONE;
1147 camera_get_state(camera, &state);
1148 if (state != CAMERA_STATE_CAPTURING && handle->capture_count > 1) {
1149 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1150 return CAMERA_ERROR_INVALID_STATE;
1153 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1154 "capture-break-cont-shot", 1,
1156 if (ret == MM_ERROR_NONE) {
1157 handle->is_continuous_shot_break = true;
1159 if (handle->current_capture_count > 0) {
1160 handle->is_capture_completed = true;
1163 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
1166 return __convert_camera_error_code(__func__, ret);
1170 bool camera_is_supported_face_detection(camera_h camera)
1172 if (camera == NULL) {
1173 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1178 int ret = MM_ERROR_NONE;
1179 camera_s *handle = (camera_s *)camera;
1180 MMCamAttrsInfo info;
1182 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
1183 set_last_result(__convert_camera_error_code(__func__, ret));
1184 if (ret != MM_ERROR_NONE) {
1185 LOGE("MMCAM_DETECT_MODE get attr info failed");
1189 if (info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY) {
1190 for (i = 0 ; i < info.int_array.count ; i++) {
1191 if (info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON) {
1192 LOGD("face detection supported");
1198 LOGD("face detection NOT supported");
1204 bool camera_is_supported_zero_shutter_lag(camera_h camera)
1206 int ret = MM_ERROR_NONE;
1207 int supported_zsl = false;
1208 camera_s *handle = (camera_s *)camera;
1210 if (camera == NULL) {
1211 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1215 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1216 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1218 set_last_result(__convert_camera_error_code(__func__, ret));
1219 if (ret != MM_ERROR_NONE) {
1220 LOGE("MMCAM_SUPPORT_ZSL_CAPTURE get failed");
1224 LOGD("support zero shutter lag : %d", supported_zsl);
1226 return supported_zsl;
1230 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
1232 int ret = MM_ERROR_NONE;
1233 int supported = false;
1234 camera_s *handle = (camera_s *)camera;
1236 if (camera == NULL) {
1237 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1241 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1242 MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, &supported,
1244 set_last_result(__convert_camera_error_code(__func__, ret));
1245 if (ret != MM_ERROR_NONE) {
1246 LOGE("MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB get failed");
1250 LOGD("support media packet preview callback : %d", supported);
1256 int camera_get_device_count(camera_h camera, int *device_count)
1258 int ret = MM_ERROR_NONE;
1259 camera_s *handle = (camera_s *)camera;
1261 if (camera == NULL || device_count == NULL) {
1262 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1263 return CAMERA_ERROR_INVALID_PARAMETER;
1266 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1267 MMCAM_CAMERA_DEVICE_COUNT, device_count,
1270 return __convert_camera_error_code(__func__, ret);
1274 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
1276 if (camera == NULL) {
1277 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1278 return CAMERA_ERROR_INVALID_PARAMETER;
1281 if (camera_is_supported_face_detection(camera) == false) {
1282 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1283 return CAMERA_ERROR_NOT_SUPPORTED;
1286 camera_s *handle = (camera_s *)camera;
1287 camera_state_e state = CAMERA_STATE_NONE;
1288 int ret = MM_ERROR_NONE;
1290 camera_get_state(camera, &state);
1291 if (state != CAMERA_STATE_PREVIEW) {
1292 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1293 return CAMERA_ERROR_INVALID_STATE;
1296 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1297 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON,
1299 if (ret == MM_ERROR_NONE) {
1300 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)callback;
1301 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)user_data;
1302 handle->num_of_faces = 0;
1305 return __convert_camera_error_code(__func__,ret);
1309 int camera_stop_face_detection(camera_h camera)
1311 if (camera == NULL) {
1312 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1313 return CAMERA_ERROR_INVALID_PARAMETER;
1316 camera_s *handle = (camera_s *)camera;
1317 int ret = MM_ERROR_NONE;
1319 if (camera_is_supported_face_detection(camera) == false) {
1320 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1321 return CAMERA_ERROR_NOT_SUPPORTED;
1324 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1325 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF,
1327 if (ret == MM_ERROR_NONE) {
1328 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1329 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1330 handle->num_of_faces = 0;
1333 return __convert_camera_error_code(__func__,ret);
1337 int camera_get_state(camera_h camera, camera_state_e *state)
1339 if (camera == NULL || state == NULL) {
1340 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1341 return CAMERA_ERROR_INVALID_PARAMETER;
1344 camera_s *handle = (camera_s *)camera;
1345 camera_state_e capi_state = CAMERA_STATE_NONE;
1346 MMCamcorderStateType mmstate = MM_CAMCORDER_STATE_NONE;
1348 mm_camcorder_get_state(handle->mm_handle, &mmstate);
1349 capi_state = __camera_state_convert(mmstate);
1351 if ((handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed) &&
1352 (handle->current_capture_count > 0 || handle->is_capture_completed) &&
1353 mmstate == MM_CAMCORDER_STATE_CAPTURING) {
1354 capi_state = CAMERA_STATE_CAPTURED;
1357 *state = capi_state;
1359 return CAMERA_ERROR_NONE;
1363 int camera_start_focusing(camera_h camera, bool continuous)
1365 if (camera == NULL) {
1366 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1367 return CAMERA_ERROR_INVALID_PARAMETER;
1370 camera_s *handle = (camera_s *)camera;
1372 if (handle->cached_focus_mode != -1) {
1373 LOGD("apply cached focus mode %d", handle->cached_focus_mode);
1375 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1376 MMCAM_CAMERA_AF_SCAN_RANGE, handle->cached_focus_mode,
1379 handle->cached_focus_mode = -1;
1383 return __camera_start_continuous_focusing(camera);
1385 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1386 MMCAM_CAMERA_FOCUS_MODE, handle->focus_area_valid ? \
1387 MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO : MM_CAMCORDER_FOCUS_MODE_AUTO,
1390 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s *)camera)->mm_handle));
1395 int __camera_start_continuous_focusing(camera_h camera)
1397 if (camera == NULL) {
1398 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1399 return CAMERA_ERROR_INVALID_PARAMETER;
1402 camera_s *handle = (camera_s *)camera;
1403 int ret = MM_ERROR_NONE;
1404 int mode = MM_CAMCORDER_FOCUS_MODE_NONE;
1406 handle->on_continuous_focusing = true;
1407 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1408 MMCAM_CAMERA_FOCUS_MODE, &mode,
1411 if (mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS) {
1412 ret = mm_camcorder_start_focusing(handle->mm_handle);
1414 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1415 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS,
1419 return __convert_camera_error_code(__func__, ret);
1423 int camera_cancel_focusing(camera_h camera)
1425 if (camera == NULL) {
1426 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1427 return CAMERA_ERROR_INVALID_PARAMETER;
1430 camera_s *handle = (camera_s *)camera;
1432 handle->on_continuous_focusing = false;
1434 return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
1438 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
1440 int ret = MM_ERROR_NONE;
1441 int set_surface = MM_DISPLAY_SURFACE_X;
1442 void *set_handle = NULL;
1443 camera_s *handle = NULL;
1445 Evas_Object *obj = NULL;
1446 const char *object_type = NULL;
1448 if (camera == NULL) {
1449 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1450 return CAMERA_ERROR_INVALID_PARAMETER;
1453 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
1454 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
1455 return CAMERA_ERROR_INVALID_PARAMETER;
1458 handle = (camera_s *)camera;
1459 handle->display_type = type;
1461 if (type == CAMERA_DISPLAY_TYPE_NONE) {
1463 set_surface = MM_DISPLAY_SURFACE_NULL;
1464 handle->display_handle = 0;
1466 LOGD("display type NONE");
1468 obj = (Evas_Object *)display;
1469 object_type = evas_object_type_get(obj);
1471 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
1473 MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)malloc(sizeof(MMCamWaylandInfo));
1475 if (wl_info == NULL) {
1476 LOGE("wl_info alloc failed : %d", sizeof(MMCamWaylandInfo));
1477 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_LOW_MEMORY);
1480 memset(wl_info, 0x0, sizeof(MMCamWaylandInfo));
1482 wl_info->evas_obj = (void *)obj;
1483 wl_info->window = (void *)elm_win_wl_window_get(obj);
1484 wl_info->surface = (void *)ecore_wl_window_surface_get(wl_info->window);
1485 wl_info->display = (void *)ecore_wl_display_get();
1487 if (wl_info->window == NULL || wl_info->surface == NULL || wl_info->display == NULL) {
1488 LOGE("something is NULL %p, %p, %p", wl_info->window, wl_info->surface, wl_info->display);
1490 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_INTERNAL);
1493 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
1494 &wl_info->window_width, &wl_info->window_height);
1496 if (handle->wl_info) {
1497 free(handle->wl_info);
1498 handle->wl_info = NULL;
1501 /* set wayland info */
1502 handle->wl_info = (void *)wl_info;
1503 set_surface = MM_DISPLAY_SURFACE_X;
1504 set_handle = (void *)wl_info;
1506 LOGD("wayland obj %p, window %p, surface %p, display %p, size %d,%d,%dx%d",
1507 wl_info->evas_obj, wl_info->window, wl_info->surface, wl_info->display,
1508 wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
1509 #else /* HAVE_WAYLAND */
1510 /* x window overlay surface */
1511 handle->display_handle = (void *)elm_win_xwindow_get(obj);
1512 set_surface = MM_DISPLAY_SURFACE_X;
1513 set_handle = &(handle->display_handle);
1515 LOGD("display type OVERLAY : handle %p, %d", set_handle, (int)handle->display_handle);
1516 #endif /* HAVE_WAYLAND */
1517 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
1518 /* evas object surface */
1519 handle->display_handle = display;
1520 set_surface = MM_DISPLAY_SURFACE_EVAS;
1521 set_handle = display;
1523 LOGD("display type EVAS : handle %p", set_handle);
1525 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
1526 return CAMERA_ERROR_INVALID_PARAMETER;
1529 LOGE("failed to get evas object type from %p", obj);
1530 return CAMERA_ERROR_INVALID_PARAMETER;
1534 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1535 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
1536 MMCAM_DISPLAY_SURFACE, set_surface,
1539 if (ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE) {
1540 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1541 MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *),
1545 return __convert_camera_error_code(__func__, ret);
1549 int camera_set_preview_resolution(camera_h camera, int width, int height)
1551 if( camera == NULL){
1552 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1553 return CAMERA_ERROR_INVALID_PARAMETER;
1556 int ret = MM_ERROR_NONE;
1557 camera_s *handle = (camera_s *)camera;
1558 MMCamAttrsInfo info;
1562 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1563 MMCAM_CAMERA_FPS, &mm_fps,
1566 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
1567 if (ret != MM_ERROR_NONE) {
1568 return __convert_camera_error_code(__func__, ret);
1571 for (i = 0 ; i < info.int_array.count ; i++) {
1572 if (info.int_array.array[i] == mm_fps) {
1575 if (i == info.int_array.count - 1) {
1576 LOGE("Not supported resolution: Current set Resolution's FPS is not supported in wanted resolution.");
1577 return CAMERA_ERROR_NOT_SUPPORTED;
1581 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1582 MMCAM_CAMERA_WIDTH, width,
1583 MMCAM_CAMERA_HEIGHT, height,
1586 return __convert_camera_error_code(__func__, ret);
1590 int camera_set_capture_resolution(camera_h camera, int width, int height)
1592 if (camera == NULL) {
1593 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1594 return CAMERA_ERROR_INVALID_PARAMETER;
1597 int ret = MM_ERROR_NONE;
1598 camera_s *handle = (camera_s *)camera;
1600 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1601 MMCAM_CAPTURE_WIDTH, width,
1602 MMCAM_CAPTURE_HEIGHT, height,
1604 if (ret == MM_ERROR_NONE) {
1605 handle->capture_width = width;
1606 handle->capture_height = height;
1609 return __convert_camera_error_code(__func__, ret);
1613 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
1615 if (camera == NULL) {
1616 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1617 return CAMERA_ERROR_INVALID_PARAMETER;
1620 int ret = MM_ERROR_NONE;
1621 camera_s *handle = (camera_s *)camera;
1623 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1624 MMCAM_CAPTURE_FORMAT, format,
1627 return __convert_camera_error_code(__func__, ret);
1631 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
1633 if (camera == NULL) {
1634 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1635 return CAMERA_ERROR_INVALID_PARAMETER;
1639 int ret = MM_ERROR_NONE;
1640 camera_s *handle = (camera_s *)camera;
1642 if (format == CAMERA_PIXEL_FORMAT_UYVY) {
1643 bool supported_ITLV_UYVY = false;
1644 MMCamAttrsInfo supported_format;
1645 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1646 for (i = 0 ; i < supported_format.int_array.count ; i++) {
1647 if (supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1648 supported_ITLV_UYVY = true;
1651 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1652 MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ? MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY,
1655 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1656 MMCAM_CAMERA_FORMAT, format,
1660 return __convert_camera_error_code(__func__, ret);
1664 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
1666 if (camera == NULL || width == NULL || height == NULL) {
1667 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1668 return CAMERA_ERROR_INVALID_PARAMETER;
1671 int ret = MM_ERROR_NONE;
1672 camera_s *handle = (camera_s *)camera;
1674 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1675 MMCAM_CAMERA_WIDTH, width,
1676 MMCAM_CAMERA_HEIGHT, height,
1679 return __convert_camera_error_code(__func__, ret);
1683 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
1685 if (camera == NULL) {
1686 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1687 return CAMERA_ERROR_INVALID_PARAMETER;
1690 if (rotation > CAMERA_ROTATION_270) {
1691 return CAMERA_ERROR_INVALID_PARAMETER;
1694 int ret = MM_ERROR_NONE;
1695 camera_s *handle = (camera_s *)camera;
1697 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1698 MMCAM_DISPLAY_ROTATION, rotation,
1701 return __convert_camera_error_code(__func__, ret);
1705 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
1707 if (camera == NULL || rotation == NULL) {
1708 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1709 return CAMERA_ERROR_INVALID_PARAMETER;
1712 int ret = MM_ERROR_NONE;
1713 camera_s *handle = (camera_s *)camera;
1715 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1716 MMCAM_DISPLAY_ROTATION, rotation,
1719 return __convert_camera_error_code(__func__, ret);
1723 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
1725 if (camera == NULL) {
1726 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1727 return CAMERA_ERROR_INVALID_PARAMETER;
1730 if (flip > CAMERA_FLIP_BOTH) {
1731 return CAMERA_ERROR_INVALID_PARAMETER;
1734 int ret = MM_ERROR_NONE;
1735 camera_s *handle = (camera_s *)camera;
1737 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1738 MMCAM_DISPLAY_FLIP, flip,
1741 return __convert_camera_error_code(__func__, ret);
1745 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
1747 if (camera == NULL || flip == NULL) {
1748 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1749 return CAMERA_ERROR_INVALID_PARAMETER;
1752 int ret = MM_ERROR_NONE;
1753 camera_s *handle = (camera_s *)camera;
1755 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1756 MMCAM_DISPLAY_FLIP, flip,
1759 return __convert_camera_error_code(__func__, ret);
1763 int camera_set_display_visible(camera_h camera, bool visible)
1765 if (camera == NULL) {
1766 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1767 return CAMERA_ERROR_INVALID_PARAMETER;
1770 int ret = MM_ERROR_NONE;
1771 camera_s *handle = (camera_s *)camera;
1773 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1774 MMCAM_DISPLAY_VISIBLE, visible,
1777 return __convert_camera_error_code(__func__, ret);
1781 int camera_is_display_visible(camera_h camera, bool* visible)
1783 if (camera == NULL || visible == NULL) {
1784 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1785 return CAMERA_ERROR_INVALID_PARAMETER;
1788 int ret = MM_ERROR_NONE;
1790 camera_s *handle = (camera_s *)camera;
1792 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1793 MMCAM_DISPLAY_VISIBLE, &result,
1796 if (ret == MM_ERROR_NONE) {
1800 return __convert_camera_error_code(__func__, ret);
1804 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
1806 if (camera == NULL) {
1807 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1808 return CAMERA_ERROR_INVALID_PARAMETER;
1811 if (mode > CAMERA_DISPLAY_MODE_CROPPED_FULL) {
1812 return CAMERA_ERROR_INVALID_PARAMETER;
1815 int ret = MM_ERROR_NONE;
1816 camera_s *handle = (camera_s *)camera;
1818 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1819 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1822 return __convert_camera_error_code(__func__, ret);
1826 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
1828 if (camera == NULL || mode == NULL) {
1829 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1830 return CAMERA_ERROR_INVALID_PARAMETER;
1833 int ret = MM_ERROR_NONE;
1834 camera_s *handle = (camera_s *)camera;
1836 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1837 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1840 return __convert_camera_error_code(__func__, ret);
1844 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
1846 if (camera == NULL || width == NULL || height == NULL) {
1847 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1848 return CAMERA_ERROR_INVALID_PARAMETER;
1851 camera_s *handle = (camera_s *)camera;
1853 *width = handle->capture_width;
1854 *height = handle->capture_height;
1856 return CAMERA_ERROR_NONE;
1860 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
1862 if (camera == NULL || format == NULL) {
1863 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1864 return CAMERA_ERROR_INVALID_PARAMETER;
1867 int ret = MM_ERROR_NONE;
1868 camera_s *handle = (camera_s *)camera;
1870 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1871 MMCAM_CAPTURE_FORMAT, format,
1874 return __convert_camera_error_code(__func__, ret);
1878 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
1880 if (camera == NULL || format == NULL) {
1881 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1882 return CAMERA_ERROR_INVALID_PARAMETER;
1885 int ret = MM_ERROR_NONE;
1886 camera_s *handle = (camera_s *)camera;
1888 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1889 MMCAM_CAMERA_FORMAT, format,
1892 if ((MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1893 *format = CAMERA_PIXEL_FORMAT_UYVY;
1896 return __convert_camera_error_code(__func__, ret);
1900 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
1902 if (camera == NULL || callback == NULL) {
1903 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1904 return CAMERA_ERROR_INVALID_PARAMETER;
1907 camera_s *handle = (camera_s *)camera;
1908 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)callback;
1909 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)user_data;
1911 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1912 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1915 return CAMERA_ERROR_NONE;
1919 int camera_unset_preview_cb(camera_h camera)
1921 if (camera == NULL) {
1922 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1923 return CAMERA_ERROR_INVALID_PARAMETER;
1926 camera_s *handle = (camera_s *)camera;
1928 if (handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1929 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1930 (mm_camcorder_video_stream_callback)NULL,
1934 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1935 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1937 return CAMERA_ERROR_NONE;
1941 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
1943 if (camera == NULL) {
1944 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
1945 return CAMERA_ERROR_INVALID_PARAMETER;
1948 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1949 LOGE("NOT SUPPORTED");
1950 return CAMERA_ERROR_NOT_SUPPORTED;
1953 if (callback == NULL) {
1954 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
1955 return CAMERA_ERROR_INVALID_PARAMETER;
1958 camera_s *handle = (camera_s *)camera;
1959 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)callback;
1960 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)user_data;
1962 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1963 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1966 return CAMERA_ERROR_NONE;
1970 int camera_unset_media_packet_preview_cb(camera_h camera)
1972 if (camera == NULL) {
1973 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1974 return CAMERA_ERROR_INVALID_PARAMETER;
1977 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1978 LOGE("NOT SUPPORTED");
1979 return CAMERA_ERROR_NOT_SUPPORTED;
1982 camera_s *handle = (camera_s *)camera;
1984 if (handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] == NULL) {
1985 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1986 (mm_camcorder_video_stream_callback)NULL,
1990 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
1991 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
1993 return CAMERA_ERROR_NONE;
1997 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
1999 if (camera == NULL || callback == NULL) {
2000 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2001 return CAMERA_ERROR_INVALID_PARAMETER;
2004 camera_s *handle = (camera_s *)camera;
2005 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)callback;
2006 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)user_data;
2008 return CAMERA_ERROR_NONE;
2012 int camera_unset_state_changed_cb(camera_h camera)
2014 if (camera == NULL) {
2015 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2016 return CAMERA_ERROR_INVALID_PARAMETER;
2019 camera_s *handle = (camera_s *)camera;
2020 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2021 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2023 return CAMERA_ERROR_NONE;
2027 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
2029 if (camera == NULL || callback == NULL) {
2030 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2031 return CAMERA_ERROR_INVALID_PARAMETER;
2034 camera_s *handle = (camera_s *)camera;
2035 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)callback;
2036 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)user_data;
2038 return CAMERA_ERROR_NONE;
2042 int camera_unset_interrupted_cb(camera_h camera)
2044 if (camera == NULL) {
2045 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2046 return CAMERA_ERROR_INVALID_PARAMETER;
2049 camera_s *handle = (camera_s *)camera;
2051 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2052 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2054 return CAMERA_ERROR_NONE;
2058 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
2060 if (camera == NULL || callback == NULL) {
2061 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2062 return CAMERA_ERROR_INVALID_PARAMETER;
2065 camera_s *handle = (camera_s *)camera;
2067 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)callback;
2068 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)user_data;
2070 return CAMERA_ERROR_NONE;
2074 int camera_unset_focus_changed_cb(camera_h camera)
2076 if (camera == NULL) {
2077 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2078 return CAMERA_ERROR_INVALID_PARAMETER;
2081 camera_s *handle = (camera_s *)camera;
2083 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2084 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2086 return CAMERA_ERROR_NONE;
2090 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
2092 if (camera == NULL || callback == NULL) {
2093 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2094 return CAMERA_ERROR_INVALID_PARAMETER;
2097 camera_s *handle = (camera_s *)camera;
2099 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)callback;
2100 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)user_data;
2102 return CAMERA_ERROR_NONE;
2106 int camera_unset_error_cb(camera_h camera)
2108 if (camera == NULL) {
2109 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2110 return CAMERA_ERROR_INVALID_PARAMETER;
2113 camera_s *handle = (camera_s *)camera;
2115 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2116 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2118 return CAMERA_ERROR_NONE;
2122 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
2124 if (camera == NULL || foreach_cb == NULL) {
2125 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2126 return CAMERA_ERROR_INVALID_PARAMETER;
2130 int ret = MM_ERROR_NONE;
2131 camera_s *handle = (camera_s *)camera;
2132 MMCamAttrsInfo preview_width;
2133 MMCamAttrsInfo preview_height;
2135 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH, &preview_width);
2136 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT, &preview_height);
2137 if (ret != CAMERA_ERROR_NONE) {
2138 return __convert_camera_error_code(__func__, ret);
2141 for (i = 0 ; i < preview_width.int_array.count ; i++) {
2142 if (!foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i], user_data)) {
2147 return CAMERA_ERROR_NONE;
2151 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
2153 if (camera == NULL || foreach_cb == NULL) {
2154 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2155 return CAMERA_ERROR_INVALID_PARAMETER;
2159 int ret = MM_ERROR_NONE;
2160 camera_s *handle = (camera_s *)camera;
2161 MMCamAttrsInfo capture_width;
2162 MMCamAttrsInfo capture_height;
2164 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH, &capture_width);
2165 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT, &capture_height);
2166 if (ret != CAMERA_ERROR_NONE) {
2167 return __convert_camera_error_code(__func__, ret);
2170 for (i = 0 ; i < capture_width.int_array.count ; i++) {
2171 if (!foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i], user_data)) {
2176 return CAMERA_ERROR_NONE;
2180 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
2182 if (camera == NULL || foreach_cb == NULL) {
2183 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2184 return CAMERA_ERROR_INVALID_PARAMETER;
2188 int ret = MM_ERROR_NONE;
2189 camera_s *handle = (camera_s *)camera;
2190 MMCamAttrsInfo format;
2192 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT, &format);
2193 if (ret != CAMERA_ERROR_NONE) {
2194 return __convert_camera_error_code(__func__, ret);
2197 for (i = 0 ; i < format.int_array.count ; i++) {
2198 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2199 if (!foreach_cb(format.int_array.array[i], user_data)) {
2205 return CAMERA_ERROR_NONE;
2209 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
2211 if (camera == NULL || foreach_cb == NULL) {
2212 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2213 return CAMERA_ERROR_INVALID_PARAMETER;
2217 int ret = MM_ERROR_NONE;
2218 camera_s *handle = (camera_s *)camera;
2219 MMCamAttrsInfo format;
2221 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT, &format);
2222 if (ret != CAMERA_ERROR_NONE) {
2223 return __convert_camera_error_code(__func__, ret);
2226 for (i = 0 ; i < format.int_array.count ; i++) {
2227 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2228 if (!foreach_cb(format.int_array.array[i], user_data)) {
2234 return CAMERA_ERROR_NONE;
2238 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
2240 if (camera == NULL || width == NULL || height == NULL) {
2241 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2242 return CAMERA_ERROR_INVALID_PARAMETER;
2245 enum MMCamcorderPreviewType wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2249 int ret = MM_ERROR_NONE;
2250 camera_s *handle = (camera_s *)camera;
2251 MMCamAttrsInfo width_info;
2252 MMCamAttrsInfo height_info;
2254 camera_get_capture_resolution(camera, &capture_w, &capture_h);
2255 ratio = (double)capture_w / (double)capture_h;
2257 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
2258 } else if (ratio == 1.0) {
2259 wide = MM_CAMCORDER_PREVIEW_TYPE_SQUARE;
2261 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2264 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH, &width_info);
2265 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
2266 if (ret != MM_ERROR_NONE) {
2267 return __convert_camera_error_code(__func__, ret);
2270 if (width && (unsigned int)width_info.int_array.count > wide) {
2271 *width = width_info.int_array.array[wide];
2273 LOGE("there is no width value for resolution %dx%d type %d", capture_w, capture_h, wide);
2274 return CAMERA_ERROR_INVALID_OPERATION;
2277 if (height && (unsigned int)height_info.int_array.count > wide) {
2278 *height = height_info.int_array.array[wide];
2280 LOGE("there is no height value for resolution %dx%d type %d", capture_w, capture_h, wide);
2281 return CAMERA_ERROR_INVALID_OPERATION;
2284 LOGI("recommend resolution %dx%d, type %d", *width, *height, wide);
2286 return CAMERA_ERROR_NONE;
2290 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
2292 if (camera == NULL || angle == NULL) {
2293 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2294 return CAMERA_ERROR_INVALID_PARAMETER;
2297 int ret = MM_ERROR_NONE;
2298 camera_s *handle = (camera_s *)camera;
2299 int rotation = MM_DISPLAY_ROTATION_NONE;
2301 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2302 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
2305 if (ret == MM_ERROR_NONE) {
2307 case MM_DISPLAY_ROTATION_NONE:
2310 case MM_DISPLAY_ROTATION_90:
2313 case MM_DISPLAY_ROTATION_180:
2316 case MM_DISPLAY_ROTATION_270:
2325 return __convert_camera_error_code(__func__, ret);
2329 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
2331 if (camera == NULL) {
2332 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2333 return CAMERA_ERROR_INVALID_PARAMETER;
2336 int ret = MM_ERROR_NONE;
2337 camera_s *handle = (camera_s *)camera;
2339 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2340 MMCAM_DISPLAY_MODE, mode,
2343 return __convert_camera_error_code(__func__, ret);
2347 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
2349 if (camera == NULL || mode == NULL) {
2350 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2351 return CAMERA_ERROR_INVALID_PARAMETER;
2354 int ret = MM_ERROR_NONE;
2355 camera_s *handle = (camera_s *)camera;
2357 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2358 MMCAM_DISPLAY_MODE, mode,
2361 return __convert_camera_error_code(__func__, ret);
2365 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
2367 if (camera == NULL || foreach_cb == NULL) {
2368 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2369 return CAMERA_ERROR_INVALID_PARAMETER;
2373 int ret = MM_ERROR_NONE;
2374 camera_s *handle = (camera_s *)camera;
2375 MMCamAttrsInfo info;
2377 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DISPLAY_MODE, &info);
2378 if (ret != CAMERA_ERROR_NONE) {
2379 return __convert_camera_error_code(__func__, ret);
2382 for (i = 0 ; i < info.int_array.count ; i++) {
2383 if (!foreach_cb(info.int_array.array[i], user_data)) {
2388 return CAMERA_ERROR_NONE;
2392 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
2394 if (camera == NULL) {
2395 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2396 return CAMERA_ERROR_INVALID_PARAMETER;
2399 int ret = MM_ERROR_NONE;
2400 camera_s *handle = (camera_s *)camera;
2402 if (fps == CAMERA_ATTR_FPS_AUTO) {
2403 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2404 MMCAM_CAMERA_FPS_AUTO, true,
2407 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2408 MMCAM_CAMERA_FPS_AUTO, false,
2409 MMCAM_CAMERA_FPS, fps,
2413 return __convert_camera_error_code(__func__, ret);
2417 int camera_attr_set_image_quality(camera_h camera, int quality)
2419 if (camera == NULL) {
2420 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2421 return CAMERA_ERROR_INVALID_PARAMETER;
2424 int ret = MM_ERROR_NONE;
2425 camera_s *handle = (camera_s *)camera;
2427 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2428 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2431 return __convert_camera_error_code(__func__, ret);
2435 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
2437 if (camera == NULL || fps == NULL) {
2438 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2439 return CAMERA_ERROR_INVALID_PARAMETER;
2442 int ret = MM_ERROR_NONE;
2444 int is_auto = false;
2445 camera_s *handle = (camera_s *)camera;
2447 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2448 MMCAM_CAMERA_FPS, &mm_fps,
2449 MMCAM_CAMERA_FPS_AUTO, &is_auto,
2451 if (ret == MM_ERROR_NONE) {
2453 *fps = CAMERA_ATTR_FPS_AUTO;
2459 return __convert_camera_error_code(__func__, ret);
2463 int camera_attr_get_image_quality(camera_h camera, int *quality)
2465 if (camera == NULL || quality == NULL) {
2466 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2467 return CAMERA_ERROR_INVALID_PARAMETER;
2470 int ret = MM_ERROR_NONE;
2471 camera_s *handle = (camera_s *)camera;
2473 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2474 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2477 return __convert_camera_error_code(__func__, ret);
2481 int camera_attr_set_zoom(camera_h camera, int zoom)
2483 if (camera == NULL) {
2484 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2485 return CAMERA_ERROR_INVALID_PARAMETER;
2488 int ret = MM_ERROR_NONE;
2489 camera_s *handle = (camera_s *)camera;
2491 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2492 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2495 return __convert_camera_error_code(__func__, ret);
2499 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
2501 if (camera == NULL) {
2502 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2503 return CAMERA_ERROR_INVALID_PARAMETER;
2506 int ret = MM_ERROR_NONE;
2507 camera_s *handle = (camera_s *)camera;
2509 bool should_change_focus_mode = false;
2511 mm_camcorder_get_attributes(handle->mm_handle, NULL,
2512 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2515 if (focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO &&
2516 focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2517 focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO) {
2518 should_change_focus_mode = true;
2521 if (mode != CAMERA_ATTR_AF_NONE &&
2522 focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2523 !handle->on_continuous_focusing) {
2524 handle->cached_focus_mode = mode;
2525 LOGD("af mode will be set actually start focusing");
2526 return __convert_camera_error_code(__func__, MM_ERROR_NONE);
2528 handle->cached_focus_mode = -1;
2531 if (mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode) {
2532 mm_camcorder_set_attributes(handle->mm_handle, NULL,
2533 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO,
2538 case CAMERA_ATTR_AF_NONE:
2539 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2540 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
2541 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NONE,
2544 case CAMERA_ATTR_AF_NORMAL:
2545 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2546 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NORMAL,
2549 case CAMERA_ATTR_AF_MACRO:
2550 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2551 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_MACRO,
2554 case CAMERA_ATTR_AF_FULL:
2555 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2556 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_FULL,
2560 LOGE("invalid mode %d", mode);
2561 return CAMERA_ERROR_INVALID_PARAMETER;
2564 return __convert_camera_error_code(__func__, ret);
2568 int camera_attr_set_af_area(camera_h camera, int x, int y)
2570 if (camera == NULL) {
2571 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2572 return CAMERA_ERROR_INVALID_PARAMETER;
2575 int ret = MM_ERROR_NONE;
2576 camera_s *handle = (camera_s *)camera;
2577 camera_attr_af_mode_e mode;
2579 camera_attr_get_af_mode(camera, &mode);
2580 if (mode == CAMERA_ATTR_AF_NONE) {
2581 LOGE("INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE", CAMERA_ERROR_INVALID_OPERATION);
2582 return CAMERA_ERROR_INVALID_OPERATION;
2585 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2586 MMCAM_CAMERA_AF_TOUCH_X, x,
2587 MMCAM_CAMERA_AF_TOUCH_Y, y,
2589 if (ret == MM_ERROR_NONE) {
2590 handle->focus_area_valid = true;
2593 return __convert_camera_error_code(__func__, ret);
2597 int camera_attr_clear_af_area(camera_h camera)
2599 if (camera == NULL) {
2600 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2601 return CAMERA_ERROR_INVALID_PARAMETER;
2604 camera_s *handle = (camera_s *)camera;
2606 handle->focus_area_valid = false;
2612 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
2614 if (camera == NULL) {
2615 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2616 return CAMERA_ERROR_INVALID_PARAMETER;
2619 int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, /* CAMERA_ATTR_EXPOSURE_MODE_OFF */
2620 MM_CAMCORDER_AUTO_EXPOSURE_ALL, /* CAMERA_ATTR_EXPOSURE_MODE_ALL */
2621 MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, /* CAMERA_ATTR_EXPOSURE_MODE_CENTER */
2622 MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, /* CAMERA_ATTR_EXPOSURE_MODE_SPOT */
2623 MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1, /* CAMERA_ATTR_EXPOSURE_MODE_CUSTOM */
2626 int ret = MM_ERROR_NONE;
2627 camera_s *handle = (camera_s *)camera;
2629 if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
2630 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2631 return CAMERA_ERROR_INVALID_PARAMETER;
2634 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2635 MMCAM_CAMERA_EXPOSURE_MODE, maptable[mode],
2638 return __convert_camera_error_code(__func__, ret);
2642 int camera_attr_set_exposure(camera_h camera, int value)
2644 if (camera == NULL) {
2645 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2646 return CAMERA_ERROR_INVALID_PARAMETER;
2649 int ret = MM_ERROR_NONE;
2650 camera_s *handle = (camera_s *)camera;
2652 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2653 MMCAM_CAMERA_EXPOSURE_VALUE, value,
2656 return __convert_camera_error_code(__func__, ret);
2660 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
2662 if (camera == NULL) {
2663 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2664 return CAMERA_ERROR_INVALID_PARAMETER;
2667 int ret = MM_ERROR_NONE;
2668 camera_s *handle = (camera_s*)camera;
2670 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2671 MMCAM_CAMERA_ISO, iso,
2674 return __convert_camera_error_code(__func__, ret);
2678 int camera_attr_set_brightness(camera_h camera, int level)
2680 if (camera == NULL) {
2681 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2682 return CAMERA_ERROR_INVALID_PARAMETER;
2685 int ret = MM_ERROR_NONE;
2686 camera_s *handle = (camera_s *)camera;
2688 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2689 MMCAM_FILTER_BRIGHTNESS, level,
2692 return __convert_camera_error_code(__func__, ret);
2696 int camera_attr_set_contrast(camera_h camera, int level)
2698 if (camera == NULL) {
2699 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2700 return CAMERA_ERROR_INVALID_PARAMETER;
2703 int ret = MM_ERROR_NONE;
2704 camera_s *handle = (camera_s *)camera;
2706 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2707 MMCAM_FILTER_CONTRAST, level,
2710 return __convert_camera_error_code(__func__, ret);
2714 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
2716 if (camera == NULL) {
2717 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2718 return CAMERA_ERROR_INVALID_PARAMETER;
2721 int ret = MM_ERROR_NONE;
2722 camera_s *handle = (camera_s *)camera;
2724 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2725 MMCAM_FILTER_WB, wb,
2728 return __convert_camera_error_code(__func__, ret);
2732 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
2734 if (camera == NULL) {
2735 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2736 return CAMERA_ERROR_INVALID_PARAMETER;
2739 int ret = MM_ERROR_NONE;
2740 camera_s *handle = (camera_s *)camera;
2742 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2743 MMCAM_FILTER_COLOR_TONE, effect,
2746 return __convert_camera_error_code(__func__, ret);
2750 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
2752 if (camera == NULL) {
2753 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2754 return CAMERA_ERROR_INVALID_PARAMETER;
2757 int ret = MM_ERROR_NONE;
2758 camera_s *handle = (camera_s *)camera;
2760 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2761 MMCAM_FILTER_SCENE_MODE, mode,
2764 return __convert_camera_error_code(__func__, ret);
2768 int camera_attr_enable_tag(camera_h camera, bool enable)
2770 if (camera == NULL) {
2771 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2772 return CAMERA_ERROR_INVALID_PARAMETER;
2775 int ret = MM_ERROR_NONE;
2776 camera_s *handle = (camera_s *)camera;
2778 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2779 MMCAM_TAG_ENABLE, enable,
2782 return __convert_camera_error_code(__func__, ret);
2786 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
2788 if (camera == NULL) {
2789 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2790 return CAMERA_ERROR_INVALID_PARAMETER;
2793 int ret = MM_ERROR_NONE;
2794 camera_s *handle = (camera_s *)camera;
2796 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2797 MMCAM_TAG_IMAGE_DESCRIPTION, description, strlen(description),
2800 return __convert_camera_error_code(__func__, ret);
2804 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
2806 if (camera == NULL) {
2807 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2808 return CAMERA_ERROR_INVALID_PARAMETER;
2811 int ret = MM_ERROR_NONE;
2812 camera_s *handle = (camera_s *)camera;
2814 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2815 MMCAM_TAG_ORIENTATION, orientation,
2818 return __convert_camera_error_code(__func__, ret);
2822 int camera_attr_set_tag_software(camera_h camera, const char *software)
2824 if (camera == NULL) {
2825 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2826 return CAMERA_ERROR_INVALID_PARAMETER;
2829 int ret = MM_ERROR_NONE;
2830 camera_s *handle = (camera_s *)camera;
2832 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2833 MMCAM_TAG_SOFTWARE, software, strlen(software),
2836 return __convert_camera_error_code(__func__, ret);
2840 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
2842 if (camera == NULL) {
2843 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2844 return CAMERA_ERROR_INVALID_PARAMETER;
2847 int ret = MM_ERROR_NONE;
2848 camera_s *handle = (camera_s *)camera;
2850 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2851 MMCAM_TAG_GPS_ENABLE, true,
2852 MMCAM_TAG_LATITUDE, latitude,
2853 MMCAM_TAG_LONGITUDE, longitude,
2854 MMCAM_TAG_ALTITUDE, altitude,
2857 return __convert_camera_error_code(__func__, ret);
2861 int camera_attr_remove_geotag(camera_h camera)
2863 if (camera == NULL) {
2864 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2865 return CAMERA_ERROR_INVALID_PARAMETER;
2868 int ret = MM_ERROR_NONE;
2869 camera_s *handle = (camera_s *)camera;
2871 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2872 MMCAM_TAG_GPS_ENABLE, false,
2875 return __convert_camera_error_code(__func__, ret);
2879 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
2881 if (camera == NULL) {
2882 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2883 return CAMERA_ERROR_INVALID_PARAMETER;
2886 int ret = MM_ERROR_NONE;
2887 camera_s *handle = (camera_s *)camera;
2889 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2890 MMCAM_STROBE_MODE, mode,
2893 return __convert_camera_error_code(__func__, ret);
2897 int camera_attr_get_zoom(camera_h camera, int *zoom)
2899 if (camera == NULL || zoom == NULL) {
2900 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2901 return CAMERA_ERROR_INVALID_PARAMETER;
2904 int ret = MM_ERROR_NONE;
2905 camera_s *handle = (camera_s *)camera;
2907 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2908 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2911 return __convert_camera_error_code(__func__, ret);
2915 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
2917 if (camera == NULL || min == NULL || max == NULL) {
2918 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2919 return CAMERA_ERROR_INVALID_PARAMETER;
2922 int ret = MM_ERROR_NONE;
2923 camera_s *handle = (camera_s *)camera;
2924 MMCamAttrsInfo ainfo;
2926 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
2927 if (ret == MM_ERROR_NONE) {
2928 *min = ainfo.int_range.min;
2929 *max = ainfo.int_range.max;
2932 return __convert_camera_error_code(__func__, ret);
2936 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
2938 if (camera == NULL || mode == NULL) {
2939 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2940 return CAMERA_ERROR_INVALID_PARAMETER;
2943 int ret = MM_ERROR_NONE;
2947 camera_s *handle = (camera_s *)camera;
2949 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2950 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2951 MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
2952 MMCAM_DETECT_MODE, &detect_mode,
2954 if (ret == MM_ERROR_NONE) {
2955 switch (focus_mode) {
2956 case MM_CAMCORDER_FOCUS_MODE_NONE:
2957 case MM_CAMCORDER_FOCUS_MODE_PAN:
2958 case MM_CAMCORDER_FOCUS_MODE_MANUAL:
2959 *mode = CAMERA_ATTR_AF_NONE;
2961 case MM_CAMCORDER_FOCUS_MODE_AUTO:
2962 case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
2963 case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
2965 case MM_CAMCORDER_AUTO_FOCUS_NONE:
2966 *mode = CAMERA_ATTR_AF_NORMAL;
2968 case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
2969 *mode = CAMERA_ATTR_AF_NORMAL;
2971 case MM_CAMCORDER_AUTO_FOCUS_MACRO:
2972 *mode = CAMERA_ATTR_AF_MACRO;
2974 case MM_CAMCORDER_AUTO_FOCUS_FULL:
2975 *mode = CAMERA_ATTR_AF_FULL;
2978 *mode = CAMERA_ATTR_AF_NORMAL;
2983 *mode = CAMERA_ATTR_AF_NONE;
2988 return __convert_camera_error_code(__func__, ret);
2992 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
2994 if (camera == NULL || mode == NULL) {
2995 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2996 return CAMERA_ERROR_INVALID_PARAMETER;
2999 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3000 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3001 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3002 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3003 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3004 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3005 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3006 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3007 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3009 int ret = MM_ERROR_NONE;
3011 camera_s *handle = (camera_s *)camera;
3013 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3014 MMCAM_CAMERA_EXPOSURE_MODE, &exposure_mode,
3017 if (ret == CAMERA_ERROR_NONE) {
3018 *mode = maptable[abs(exposure_mode%9)];
3021 return __convert_camera_error_code(__func__, ret);
3025 int camera_attr_get_exposure(camera_h camera, int *value)
3027 if (camera == NULL || value == NULL) {
3028 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3029 return CAMERA_ERROR_INVALID_PARAMETER;
3032 int ret = MM_ERROR_NONE;
3033 camera_s *handle = (camera_s *)camera;
3035 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3036 MMCAM_CAMERA_EXPOSURE_VALUE, value,
3039 return __convert_camera_error_code(__func__, ret);
3043 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
3045 if (camera == NULL || min == NULL || max == NULL) {
3046 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3047 return CAMERA_ERROR_INVALID_PARAMETER;
3050 int ret = MM_ERROR_NONE;
3051 camera_s *handle = (camera_s *)camera;
3052 MMCamAttrsInfo ainfo;
3054 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
3055 if (ret == MM_ERROR_NONE) {
3056 *min = ainfo.int_range.min;
3057 *max = ainfo.int_range.max;
3060 return __convert_camera_error_code(__func__, ret);
3064 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
3066 if (camera == NULL || iso == NULL) {
3067 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3068 return CAMERA_ERROR_INVALID_PARAMETER;
3071 int ret = MM_ERROR_NONE;
3072 camera_s *handle = (camera_s *)camera;
3074 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3075 MMCAM_CAMERA_ISO, iso,
3078 return __convert_camera_error_code(__func__, ret);
3082 int camera_attr_get_brightness(camera_h camera, int *level)
3084 if (camera == NULL || level == NULL) {
3085 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3086 return CAMERA_ERROR_INVALID_PARAMETER;
3089 int ret = MM_ERROR_NONE;
3090 camera_s *handle = (camera_s *)camera;
3092 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3093 MMCAM_FILTER_BRIGHTNESS, level,
3096 return __convert_camera_error_code(__func__, ret);
3100 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
3102 if (camera == NULL || min == NULL || max == NULL) {
3103 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3104 return CAMERA_ERROR_INVALID_PARAMETER;
3107 int ret = MM_ERROR_NONE;
3108 camera_s *handle = (camera_s *)camera;
3109 MMCamAttrsInfo ainfo;
3111 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
3112 if (ret == MM_ERROR_NONE) {
3113 *min = ainfo.int_range.min;
3114 *max = ainfo.int_range.max;
3117 return __convert_camera_error_code(__func__, ret);
3121 int camera_attr_get_contrast(camera_h camera, int *level)
3123 if (camera == NULL || level == NULL) {
3124 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3125 return CAMERA_ERROR_INVALID_PARAMETER;
3128 int ret = MM_ERROR_NONE;
3129 camera_s *handle = (camera_s *)camera;
3131 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3132 MMCAM_FILTER_CONTRAST, level,
3135 return __convert_camera_error_code(__func__, ret);
3139 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
3141 if (camera == NULL || min == NULL || max == NULL) {
3142 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3143 return CAMERA_ERROR_INVALID_PARAMETER;
3146 int ret = MM_ERROR_NONE;
3147 camera_s *handle = (camera_s *)camera;
3148 MMCamAttrsInfo ainfo;
3150 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
3151 if (ret == MM_ERROR_NONE) {
3152 *min = ainfo.int_range.min;
3153 *max = ainfo.int_range.max;
3156 return __convert_camera_error_code(__func__, ret);
3160 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
3162 if (camera == NULL || wb == NULL) {
3163 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3164 return CAMERA_ERROR_INVALID_PARAMETER;
3167 int ret = MM_ERROR_NONE;
3168 camera_s *handle = (camera_s *)camera;
3170 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3171 MMCAM_FILTER_WB, wb,
3174 return __convert_camera_error_code(__func__, ret);
3178 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
3180 if (camera == NULL || effect == NULL) {
3181 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3182 return CAMERA_ERROR_INVALID_PARAMETER;
3185 int ret = MM_ERROR_NONE;
3186 camera_s *handle = (camera_s *)camera;
3188 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3189 MMCAM_FILTER_COLOR_TONE, effect,
3192 return __convert_camera_error_code(__func__, ret);
3196 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
3198 if (camera == NULL || mode == NULL) {
3199 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3200 return CAMERA_ERROR_INVALID_PARAMETER;
3203 int ret = MM_ERROR_NONE;
3204 camera_s *handle = (camera_s *)camera;
3206 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3207 MMCAM_FILTER_SCENE_MODE, mode,
3210 return __convert_camera_error_code(__func__, ret);
3214 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
3216 if (camera == NULL || enable == NULL) {
3217 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3218 return CAMERA_ERROR_INVALID_PARAMETER;
3221 int ret = MM_ERROR_NONE;
3222 camera_s *handle = (camera_s *)camera;
3224 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3225 MMCAM_TAG_ENABLE, enable,
3228 return __convert_camera_error_code(__func__, ret);
3232 int camera_attr_get_tag_image_description(camera_h camera, char **description)
3234 if (camera == NULL || description == NULL) {
3235 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3236 return CAMERA_ERROR_INVALID_PARAMETER;
3239 int ret = MM_ERROR_NONE;
3240 camera_s *handle = (camera_s *)camera;
3241 char *ndescription = NULL;
3244 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3245 MMCAM_TAG_IMAGE_DESCRIPTION, &ndescription, &desc_size,
3247 if (ret == MM_ERROR_NONE) {
3248 if (ndescription != NULL) {
3249 *description = strdup(ndescription);
3251 *description = strdup("");
3255 return __convert_camera_error_code(__func__, ret);
3259 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
3261 if (camera == NULL || orientation == NULL) {
3262 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3263 return CAMERA_ERROR_INVALID_PARAMETER;
3266 int ret = MM_ERROR_NONE;
3267 camera_s *handle = (camera_s *)camera;
3269 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3270 MMCAM_TAG_ORIENTATION, orientation,
3273 return __convert_camera_error_code(__func__, ret);
3277 int camera_attr_get_tag_software(camera_h camera, char **software)
3279 if (camera == NULL || software == NULL) {
3280 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3281 return CAMERA_ERROR_INVALID_PARAMETER;
3284 int ret = MM_ERROR_NONE;
3285 camera_s *handle = (camera_s *)camera;
3289 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3290 MMCAM_TAG_SOFTWARE, &soft, &soft_size,
3292 if (ret == MM_ERROR_NONE) {
3294 *software = strdup(soft);
3296 *software = strdup("");
3300 return __convert_camera_error_code(__func__, ret);
3304 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
3306 if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
3307 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3308 return CAMERA_ERROR_INVALID_PARAMETER;
3311 int ret = MM_ERROR_NONE;
3312 camera_s *handle = (camera_s *)camera;
3314 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3315 MMCAM_TAG_LATITUDE, latitude,
3316 MMCAM_TAG_LONGITUDE, longitude,
3317 MMCAM_TAG_ALTITUDE, altitude,
3320 return __convert_camera_error_code(__func__, ret);
3324 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
3326 if (camera == NULL || mode == NULL) {
3327 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3328 return CAMERA_ERROR_INVALID_PARAMETER;
3331 int ret = MM_ERROR_NONE;
3332 camera_s *handle = (camera_s *)camera;
3334 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3335 MMCAM_STROBE_MODE, mode,
3338 return __convert_camera_error_code(__func__, ret);
3342 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
3344 if (camera == NULL || foreach_cb == NULL) {
3345 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3346 return CAMERA_ERROR_INVALID_PARAMETER;
3349 int ret = MM_ERROR_NONE;
3351 camera_s *handle = (camera_s *)camera;
3352 MMCamAttrsInfo af_range;
3353 MMCamAttrsInfo focus_mode;
3355 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE, &af_range);
3356 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE, &focus_mode);
3357 if (ret != MM_ERROR_NONE) {
3358 return __convert_camera_error_code(__func__, ret);
3361 for (i = 0 ; i < af_range.int_array.count ; i++) {
3362 if (!foreach_cb(af_range.int_array.array[i], user_data)) {
3367 return CAMERA_ERROR_NONE;
3371 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
3373 if (camera == NULL || foreach_cb == NULL) {
3374 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3375 return CAMERA_ERROR_INVALID_PARAMETER;
3378 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3379 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3380 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3381 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3382 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3383 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3384 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3385 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3386 -1 /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3389 int ret = MM_ERROR_NONE;
3390 camera_s *handle = (camera_s *)camera;
3391 MMCamAttrsInfo info;
3393 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE, &info);
3394 if (ret != MM_ERROR_NONE) {
3395 return __convert_camera_error_code(__func__, ret);
3398 for (i = 0 ; i < info.int_array.count ; i++) {
3399 if (info.int_array.array[i] >= MM_CAMCORDER_AUTO_EXPOSURE_OFF &&
3400 info.int_array.array[i] <= MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2) {
3401 if (maptable[info.int_array.array[i]] != -1) {
3402 if (!foreach_cb(maptable[info.int_array.array[i]], user_data)) {
3407 LOGW("unknown value %d", info.int_array.array[i]);
3411 return CAMERA_ERROR_NONE;
3415 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
3417 if (camera == NULL || foreach_cb == NULL) {
3418 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3419 return CAMERA_ERROR_INVALID_PARAMETER;
3423 int ret = MM_ERROR_NONE;
3424 camera_s *handle = (camera_s *)camera;
3425 MMCamAttrsInfo info;
3427 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO, &info);
3428 if (ret != MM_ERROR_NONE) {
3429 return __convert_camera_error_code(__func__, ret);
3432 for (i = 0 ; i < info.int_array.count ; i++) {
3433 if (!foreach_cb(info.int_array.array[i], user_data)) {
3438 return CAMERA_ERROR_NONE;
3442 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
3444 if (camera == NULL || foreach_cb == NULL) {
3445 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3446 return CAMERA_ERROR_INVALID_PARAMETER;
3450 int ret = MM_ERROR_NONE;
3451 camera_s *handle = (camera_s *)camera;
3452 MMCamAttrsInfo info;
3454 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB, &info);
3455 if (ret != MM_ERROR_NONE) {
3456 return __convert_camera_error_code(__func__, ret);
3459 for (i = 0 ; i < info.int_array.count ; i++) {
3460 if (!foreach_cb(info.int_array.array[i], user_data)) {
3465 return CAMERA_ERROR_NONE;
3469 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
3471 if (camera == NULL || foreach_cb == NULL) {
3472 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3473 return CAMERA_ERROR_INVALID_PARAMETER;
3477 int ret = MM_ERROR_NONE;
3478 camera_s *handle = (camera_s *)camera;
3479 MMCamAttrsInfo info;
3481 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE, &info);
3482 if (ret != MM_ERROR_NONE) {
3483 return __convert_camera_error_code(__func__, ret);
3486 for (i = 0 ; i < info.int_array.count ; i++) {
3487 if (!foreach_cb(info.int_array.array[i], user_data)) {
3492 return CAMERA_ERROR_NONE;
3496 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
3498 if (camera == NULL || foreach_cb == NULL) {
3499 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3500 return CAMERA_ERROR_INVALID_PARAMETER;
3504 int ret = MM_ERROR_NONE;
3505 camera_s *handle = (camera_s *)camera;
3506 MMCamAttrsInfo info;
3508 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE, &info);
3509 if (ret != MM_ERROR_NONE) {
3510 return __convert_camera_error_code(__func__, ret);
3513 for (i = 0 ; i < info.int_array.count ; i++) {
3514 if (!foreach_cb(info.int_array.array[i], user_data)) {
3519 return CAMERA_ERROR_NONE;
3523 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
3525 if (camera == NULL || foreach_cb == NULL) {
3526 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3527 return CAMERA_ERROR_INVALID_PARAMETER;
3531 int ret = MM_ERROR_NONE;
3532 camera_s *handle = (camera_s *)camera;
3533 MMCamAttrsInfo info;
3535 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE, &info);
3536 if (ret != MM_ERROR_NONE) {
3537 return __convert_camera_error_code(__func__, ret);
3540 for (i = 0 ; i < info.int_array.count ; i++) {
3541 if (!foreach_cb(info.int_array.array[i], user_data)) {
3546 return CAMERA_ERROR_NONE;
3550 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
3552 if (camera == NULL || foreach_cb == NULL) {
3553 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3554 return CAMERA_ERROR_INVALID_PARAMETER;
3557 int ret = MM_ERROR_NONE;
3558 camera_s *handle = (camera_s *)camera;
3559 MMCamAttrsInfo info;
3564 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3565 MMCAM_CAMERA_WIDTH, &width,
3566 MMCAM_CAMERA_HEIGHT, &height,
3568 if (ret != MM_ERROR_NONE) {
3569 return __convert_camera_error_code(__func__, ret);
3572 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3573 if (ret != MM_ERROR_NONE) {
3574 return __convert_camera_error_code(__func__, ret);
3577 for (i = 0 ; i < info.int_array.count ; i++) {
3578 if (!foreach_cb(info.int_array.array[i], user_data)) {
3583 return CAMERA_ERROR_NONE;
3587 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)
3589 if (camera == NULL || foreach_cb == NULL) {
3590 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3591 return CAMERA_ERROR_INVALID_PARAMETER;
3594 int ret = MM_ERROR_NONE;
3595 camera_s *handle = (camera_s *)camera;
3596 MMCamAttrsInfo info;
3599 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3600 if (ret != MM_ERROR_NONE) {
3601 return __convert_camera_error_code(__func__, ret);
3604 for (i = 0 ; i < info.int_array.count ; i++) {
3605 if (!foreach_cb(info.int_array.array[i], user_data)) {
3610 return CAMERA_ERROR_NONE;
3614 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
3616 if (camera == NULL || foreach_cb == NULL) {
3617 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3618 return CAMERA_ERROR_INVALID_PARAMETER;
3622 int ret = MM_ERROR_NONE;
3623 camera_s *handle = (camera_s *)camera;
3624 MMCamAttrsInfo info;
3626 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FLIP, &info);
3627 if (ret != MM_ERROR_NONE) {
3628 return __convert_camera_error_code(__func__, ret);
3631 for (i = 0 ; i < info.int_array.count ; i++) {
3632 if (!foreach_cb(info.int_array.array[i], user_data)) {
3637 return CAMERA_ERROR_NONE;
3641 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
3643 if (camera == NULL || foreach_cb == NULL) {
3644 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3645 return CAMERA_ERROR_INVALID_PARAMETER;
3649 int ret = MM_ERROR_NONE;
3650 camera_s *handle = (camera_s *)camera;
3651 MMCamAttrsInfo info;
3653 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ROTATION, &info);
3654 if (ret != MM_ERROR_NONE) {
3655 return __convert_camera_error_code(__func__, ret);
3658 for (i = 0 ; i < info.int_array.count ; i++) {
3659 if (!foreach_cb(info.int_array.array[i], user_data)) {
3664 return CAMERA_ERROR_NONE;
3668 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
3670 if (camera == NULL) {
3671 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3672 return CAMERA_ERROR_INVALID_PARAMETER;
3675 if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
3676 LOGE("INVALID_PARAMETER - %d", rotation);
3677 return CAMERA_ERROR_INVALID_PARAMETER;
3680 int ret = MM_ERROR_NONE;
3681 camera_s *handle = (camera_s *)camera;
3683 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3684 MMCAM_CAMERA_ROTATION, rotation,
3687 return __convert_camera_error_code(__func__, ret);
3691 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
3693 if (camera == NULL || rotation == NULL) {
3694 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3695 return CAMERA_ERROR_INVALID_PARAMETER;
3698 int ret = MM_ERROR_NONE;
3699 camera_s *handle = (camera_s *)camera;
3701 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3702 MMCAM_CAMERA_ROTATION, rotation,
3705 return __convert_camera_error_code(__func__, ret);
3709 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
3711 if (camera == NULL) {
3712 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3713 return CAMERA_ERROR_INVALID_PARAMETER;
3716 if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
3717 LOGE("INVALID_PARAMETER - %d", flip);
3718 return CAMERA_ERROR_INVALID_PARAMETER;
3721 int ret = MM_ERROR_NONE;
3722 camera_s *handle = (camera_s *)camera;
3724 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3725 MMCAM_CAMERA_FLIP, flip,
3728 return __convert_camera_error_code(__func__, ret);
3732 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
3734 if (camera == NULL || flip == NULL) {
3735 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3736 return CAMERA_ERROR_INVALID_PARAMETER;
3739 int ret = MM_ERROR_NONE;
3740 camera_s *handle = (camera_s *)camera;
3742 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3743 MMCAM_CAMERA_FLIP, flip,
3746 return __convert_camera_error_code(__func__, ret);
3750 int _camera_set_use(camera_h camera, bool used)
3752 camera_s *handle = (camera_s *)camera;
3754 if (handle == NULL) {
3755 LOGE("handle is NULL");
3756 return CAMERA_ERROR_INVALID_PARAMETER;
3759 handle->is_used_in_recorder = used;
3761 return CAMERA_ERROR_NONE;
3765 bool _camera_is_used(camera_h camera)
3767 camera_s *handle = (camera_s *)camera;
3769 if (handle == NULL) {
3770 LOGE("handle is NULL");
3774 return handle->is_used_in_recorder;
3778 int _camera_get_mm_handle(camera_h camera, MMHandleType *handle)
3780 if (camera == NULL || handle == NULL) {
3781 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3782 return CAMERA_ERROR_INVALID_PARAMETER;
3785 camera_s *camera_handle = (camera_s*)camera;
3787 *handle = camera_handle->mm_handle;
3789 return CAMERA_ERROR_NONE;
3793 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data)
3795 if( camera == NULL ){
3796 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3797 return CAMERA_ERROR_INVALID_PARAMETER;
3800 camera_s *handle = (camera_s *)camera;
3801 handle->relay_message_callback = callback;
3802 handle->relay_user_data = user_data;
3804 return CAMERA_ERROR_NONE;
3808 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
3810 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3811 in_format >= MM_PIXEL_FORMAT_NUM ||
3812 out_format == NULL) {
3813 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
3814 return CAMERA_ERROR_INVALID_PARAMETER;
3817 switch (in_format) {
3818 case MM_PIXEL_FORMAT_NV12:
3819 case MM_PIXEL_FORMAT_NV12T:
3820 *out_format = TBM_FORMAT_NV12;
3822 case MM_PIXEL_FORMAT_NV16:
3823 *out_format = TBM_FORMAT_NV16;
3825 case MM_PIXEL_FORMAT_NV21:
3826 *out_format = TBM_FORMAT_NV21;
3828 case MM_PIXEL_FORMAT_YUYV:
3829 *out_format = TBM_FORMAT_YUYV;
3831 case MM_PIXEL_FORMAT_UYVY:
3832 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3833 *out_format = TBM_FORMAT_UYVY;
3835 case MM_PIXEL_FORMAT_422P:
3836 *out_format = TBM_FORMAT_YUV422;
3838 case MM_PIXEL_FORMAT_I420:
3839 *out_format = TBM_FORMAT_YUV420;
3841 case MM_PIXEL_FORMAT_YV12:
3842 *out_format = TBM_FORMAT_YVU420;
3844 case MM_PIXEL_FORMAT_RGB565:
3845 *out_format = TBM_FORMAT_RGB565;
3847 case MM_PIXEL_FORMAT_RGB888:
3848 *out_format = TBM_FORMAT_RGB888;
3850 case MM_PIXEL_FORMAT_RGBA:
3851 *out_format = TBM_FORMAT_RGBA8888;
3853 case MM_PIXEL_FORMAT_ARGB:
3854 *out_format = TBM_FORMAT_ARGB8888;
3857 LOGE("invalid in_format %d", in_format);
3858 return CAMERA_ERROR_INVALID_PARAMETER;
3861 return CAMERA_ERROR_NONE;
3865 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
3867 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3868 in_format >= MM_PIXEL_FORMAT_NUM ||
3870 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
3871 return CAMERA_ERROR_INVALID_PARAMETER;
3874 switch (in_format) {
3875 case MM_PIXEL_FORMAT_NV12:
3876 case MM_PIXEL_FORMAT_NV12T:
3877 *mimetype = MEDIA_FORMAT_NV12;
3879 case MM_PIXEL_FORMAT_NV16:
3880 *mimetype = MEDIA_FORMAT_NV16;
3882 case MM_PIXEL_FORMAT_NV21:
3883 *mimetype = MEDIA_FORMAT_NV21;
3885 case MM_PIXEL_FORMAT_YUYV:
3886 *mimetype = MEDIA_FORMAT_YUYV;
3888 case MM_PIXEL_FORMAT_UYVY:
3889 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3890 *mimetype = MEDIA_FORMAT_UYVY;
3892 case MM_PIXEL_FORMAT_422P:
3893 *mimetype = MEDIA_FORMAT_422P;
3895 case MM_PIXEL_FORMAT_I420:
3896 *mimetype = MEDIA_FORMAT_I420;
3898 case MM_PIXEL_FORMAT_YV12:
3899 *mimetype = MEDIA_FORMAT_YV12;
3901 case MM_PIXEL_FORMAT_RGB565:
3902 *mimetype = MEDIA_FORMAT_RGB565;
3904 case MM_PIXEL_FORMAT_RGB888:
3905 *mimetype = MEDIA_FORMAT_RGB888;
3907 case MM_PIXEL_FORMAT_RGBA:
3908 *mimetype = MEDIA_FORMAT_RGBA;
3910 case MM_PIXEL_FORMAT_ARGB:
3911 *mimetype = MEDIA_FORMAT_ARGB;
3914 LOGE("invalid in_format %d", in_format);
3915 return CAMERA_ERROR_INVALID_PARAMETER;
3918 return CAMERA_ERROR_NONE;
3922 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
3925 void *internal_buffer = NULL;
3926 tbm_surface_h tsurf = NULL;
3928 if (pkt == NULL || user_data == NULL) {
3929 LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
3930 return MEDIA_PACKET_FINALIZE;
3933 ret = media_packet_get_extra(pkt, &internal_buffer);
3934 if (ret != MEDIA_PACKET_ERROR_NONE) {
3935 LOGE("media_packet_get_extra failed 0x%x", ret);
3936 return MEDIA_PACKET_FINALIZE;
3939 /*LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret);*/
3941 if (internal_buffer) {
3942 gst_buffer_unref((GstBuffer *)internal_buffer);
3943 internal_buffer = NULL;
3946 ret = media_packet_get_tbm_surface(pkt, &tsurf);
3947 if (ret != MEDIA_PACKET_ERROR_NONE) {
3948 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
3949 return MEDIA_PACKET_FINALIZE;
3953 tbm_surface_destroy(tsurf);
3957 return MEDIA_PACKET_FINALIZE;
3961 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
3963 if (camera == NULL) {
3964 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3965 return CAMERA_ERROR_INVALID_PARAMETER;
3968 if (camera_attr_is_supported_hdr_capture(camera) == false) {
3969 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3970 return CAMERA_ERROR_NOT_SUPPORTED;
3973 int ret = MM_ERROR_NONE;
3974 camera_s *handle = (camera_s *)camera;
3976 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3977 MMCAM_CAMERA_HDR_CAPTURE, mode,
3980 if (ret == MM_ERROR_NONE) {
3981 if (mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL) {
3982 handle->hdr_keep_mode = true;
3984 handle->hdr_keep_mode = false;
3988 return __convert_camera_error_code(__func__, ret);
3992 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
3994 if (camera == NULL) {
3995 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3996 return CAMERA_ERROR_INVALID_PARAMETER;
3999 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4000 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4001 return CAMERA_ERROR_NOT_SUPPORTED;
4005 LOGE("INVALID_PARAMETER(0x%08x) - mode", CAMERA_ERROR_INVALID_PARAMETER);
4006 return CAMERA_ERROR_INVALID_PARAMETER;
4009 int ret = MM_ERROR_NONE;
4010 camera_s *handle = (camera_s *)camera;
4012 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4013 MMCAM_CAMERA_HDR_CAPTURE, mode,
4016 return __convert_camera_error_code(__func__, ret);
4020 bool camera_attr_is_supported_hdr_capture(camera_h camera)
4022 if (camera == NULL) {
4023 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4027 int ret = MM_ERROR_NONE;
4029 camera_s *handle = (camera_s *)camera;
4030 MMCamAttrsInfo hdr_info;
4032 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE, &hdr_info);
4033 set_last_result(__convert_camera_error_code(__func__, ret));
4034 if (ret != MM_ERROR_NONE) {
4035 LOGE("MMCAM_CAMERA_HDR_CAPTURE get attr info failed");
4039 for (i = 0; i < hdr_info.int_array.count ; i++) {
4040 if (hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON) {
4041 LOGD("HDR capture supported");
4046 LOGD("HDR capture NOT supported");
4052 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
4054 if (camera == NULL) {
4055 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4056 return CAMERA_ERROR_INVALID_PARAMETER;
4059 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4060 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4061 return CAMERA_ERROR_NOT_SUPPORTED;
4064 if (callback == NULL) {
4065 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
4066 return CAMERA_ERROR_INVALID_PARAMETER;
4069 camera_s *handle = (camera_s *)camera;
4071 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)callback;
4072 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)user_data;
4074 return CAMERA_ERROR_NONE;
4078 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
4080 if (camera == NULL) {
4081 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4082 return CAMERA_ERROR_INVALID_PARAMETER;
4085 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4086 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4087 return CAMERA_ERROR_NOT_SUPPORTED;
4090 camera_s *handle = (camera_s *)camera;
4092 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4093 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4095 return CAMERA_ERROR_NONE;
4099 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
4101 if (camera == NULL) {
4102 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4103 return CAMERA_ERROR_INVALID_PARAMETER;
4106 if (camera_attr_is_supported_anti_shake(camera) == false) {
4107 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4108 return CAMERA_ERROR_NOT_SUPPORTED;
4111 int ret = MM_ERROR_NONE;
4112 int mode = MM_CAMCORDER_AHS_OFF;
4113 camera_s *handle = (camera_s *)camera;
4116 mode = MM_CAMCORDER_AHS_ON;
4119 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4120 MMCAM_CAMERA_ANTI_HANDSHAKE, mode,
4123 return __convert_camera_error_code(__func__, ret);
4127 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
4129 if (camera == NULL) {
4130 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4131 return CAMERA_ERROR_INVALID_PARAMETER;
4134 if (camera_attr_is_supported_anti_shake(camera) == false) {
4135 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4136 return CAMERA_ERROR_NOT_SUPPORTED;
4139 if (enabled == NULL) {
4140 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4141 return CAMERA_ERROR_INVALID_PARAMETER;
4144 int ret = MM_ERROR_NONE;
4145 camera_s *handle = (camera_s *)camera;
4147 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4148 MMCAM_CAMERA_ANTI_HANDSHAKE, enabled,
4151 return __convert_camera_error_code(__func__, ret);
4155 bool camera_attr_is_supported_anti_shake(camera_h camera)
4157 if (camera == NULL) {
4158 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4163 int ret = MM_ERROR_NONE;
4164 camera_s *handle = (camera_s *)camera;
4165 MMCamAttrsInfo ash_info;
4167 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE, &ash_info);
4168 set_last_result(__convert_camera_error_code(__func__, ret));
4169 if (ret != MM_ERROR_NONE) {
4170 LOGE("MMCAM_CAMERA_ANTI_HANDSHAKE get attr info failed");
4174 for (i = 0 ; i < ash_info.int_array.count ; i++) {
4175 if (ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON) {
4184 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
4186 if (camera == NULL) {
4187 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4188 return CAMERA_ERROR_INVALID_PARAMETER;
4191 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4192 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4193 return CAMERA_ERROR_NOT_SUPPORTED;
4196 int ret = MM_ERROR_NONE;
4197 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4198 camera_s *handle = (camera_s*)camera;
4201 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
4204 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4205 MMCAM_CAMERA_VIDEO_STABILIZATION, mode,
4208 return __convert_camera_error_code(__func__, ret);
4212 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
4214 if (camera == NULL) {
4215 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4216 return CAMERA_ERROR_INVALID_PARAMETER;
4219 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4220 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4221 return CAMERA_ERROR_NOT_SUPPORTED;
4224 if (enabled == NULL) {
4225 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4226 return CAMERA_ERROR_INVALID_PARAMETER;
4229 int ret = MM_ERROR_NONE;
4230 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4231 camera_s *handle = (camera_s *)camera;
4233 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4234 MMCAM_CAMERA_VIDEO_STABILIZATION, &mode,
4236 if (ret == MM_ERROR_NONE) {
4237 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
4240 return __convert_camera_error_code(__func__, ret);
4244 bool camera_attr_is_supported_video_stabilization(camera_h camera)
4246 if (camera == NULL) {
4247 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4252 int ret = MM_ERROR_NONE;
4253 camera_s *handle = (camera_s *)camera;
4254 MMCamAttrsInfo vs_info;
4256 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION, &vs_info);
4257 set_last_result(__convert_camera_error_code(__func__, ret));
4258 if (ret != MM_ERROR_NONE) {
4259 LOGE("MMCAM_CAMERA_VIDEO_STABILIZATION get attr info failed");
4263 for (i = 0 ; i < vs_info.int_array.count ; i++) {
4264 if (vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
4273 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
4275 if (camera == NULL) {
4276 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4277 return CAMERA_ERROR_INVALID_PARAMETER;
4280 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4281 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4282 return CAMERA_ERROR_NOT_SUPPORTED;
4285 int ret = MM_ERROR_NONE;
4286 int mode = MM_CAMCORDER_WDR_OFF;
4287 camera_s *handle = (camera_s *)camera;
4290 mode = MM_CAMCORDER_WDR_ON;
4293 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4294 MMCAM_CAMERA_WDR, mode,
4297 return __convert_camera_error_code(__func__, ret);
4301 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
4303 if (camera == NULL) {
4304 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4305 return CAMERA_ERROR_INVALID_PARAMETER;
4308 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4309 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4310 return CAMERA_ERROR_NOT_SUPPORTED;
4313 if (enabled == NULL) {
4314 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4315 return CAMERA_ERROR_INVALID_PARAMETER;
4318 int ret = MM_ERROR_NONE;
4319 int mode = MM_CAMCORDER_WDR_OFF;
4320 camera_s *handle = (camera_s *)camera;
4322 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4323 MMCAM_CAMERA_WDR, &mode,
4326 if (ret == MM_ERROR_NONE) {
4330 return __convert_camera_error_code(__func__, ret);
4334 bool camera_attr_is_supported_auto_contrast(camera_h camera)
4336 if (camera == NULL) {
4337 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4342 int ret = MM_ERROR_NONE;
4343 camera_s *handle = (camera_s *)camera;
4344 MMCamAttrsInfo info;
4346 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WDR, &info);
4347 set_last_result(__convert_camera_error_code(__func__, ret));
4348 if (ret != MM_ERROR_NONE) {
4349 LOGE("MMCAM_CAMERA_WDR get attr info failed");
4353 for (i = 0 ; i < info.int_array.count ; i++) {
4354 if (info.int_array.array[i] == MM_CAMCORDER_WDR_ON) {
4363 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
4365 if (camera == NULL) {
4366 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4367 return CAMERA_ERROR_INVALID_PARAMETER;
4370 int ret = MM_ERROR_NONE;
4371 camera_s *handle = (camera_s *)camera;
4373 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4374 "capture-sound-enable", !disable,
4376 if (ret != MM_ERROR_NONE) {
4377 LOGE("CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound");
4378 return CAMERA_ERROR_INVALID_OPERATION;
4381 return CAMERA_ERROR_NONE;