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 MMCamRecordingReport *report = NULL;
534 MMCamFaceDetectInfo *cam_fd_info = NULL;
536 if (handle->relay_message_callback) {
537 handle->relay_message_callback(message, param, handle->relay_user_data);
541 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
542 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
543 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
544 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED &&
545 (m->state.previous < MM_CAMCORDER_STATE_NONE ||
546 m->state.previous > MM_CAMCORDER_STATE_PAUSED ||
547 m->state.code != 0)) {
548 LOGI( "Invalid state changed message");
552 previous_state = handle->state;
553 handle->state = __camera_state_convert(m->state.current );
555 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
556 switch (m->state.code) {
557 case ASM_EVENT_SOURCE_CALL_START:
558 case ASM_EVENT_SOURCE_CALL_END:
559 policy = CAMERA_POLICY_SOUND_BY_CALL;
560 LOGW("CAMERA_POLICY_SOUND_BY_CALL");
562 case ASM_EVENT_SOURCE_ALARM_START:
563 case ASM_EVENT_SOURCE_ALARM_END:
564 policy = CAMERA_POLICY_SOUND_BY_ALARM;
565 LOGW("CAMERA_POLICY_SOUND_BY_ALARM");
568 policy = CAMERA_POLICY_SOUND;
569 LOGW("CAMERA_POLICY_SOUND");
572 } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
573 policy = CAMERA_POLICY_SECURITY;
574 LOGW("CAMERA_POLICY_SECURITY");
577 if (previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
578 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
581 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
584 /* should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state */
585 if (policy != CAMERA_POLICY_NONE &&
586 m->state.current == MM_CAMCORDER_STATE_NULL) {
587 if (handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED]) {
588 ((camera_interrupted_cb)handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED])(policy,
591 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED]);
593 LOGW("_CAMERA_EVENT_TYPE_INTERRUPTED cb is NULL");
597 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED :
598 if (handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]) {
599 ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])(m->code,
600 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
603 case MM_MESSAGE_CAMCORDER_CAPTURED:
604 handle->current_capture_complete_count = m->code;
605 if (handle->capture_count == 1 ||
606 m->code == handle->capture_count ||
607 (handle->is_continuous_shot_break &&
608 handle->state == CAMERA_STATE_CAPTURING)) {
609 /* pseudo state change */
610 previous_state = handle->state ;
611 handle->state = CAMERA_STATE_CAPTURED;
612 if (previous_state != handle->state &&
613 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
614 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
617 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
619 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
620 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
624 case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
625 case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
626 report = (MMCamRecordingReport *)m->data;
627 if (report != NULL && report->recording_filename) {
628 free(report->recording_filename);
629 report->recording_filename = NULL;
636 case MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED:
637 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
638 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
641 case MM_MESSAGE_CAMCORDER_ERROR:
643 case MM_ERROR_CAMCORDER_DEVICE :
644 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
645 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
646 camera_error = CAMERA_ERROR_DEVICE;
648 case MM_ERROR_CAMCORDER_GST_CORE:
649 case MM_ERROR_CAMCORDER_GST_LIBRARY:
650 case MM_ERROR_CAMCORDER_GST_RESOURCE:
651 case MM_ERROR_CAMCORDER_GST_STREAM:
652 case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
653 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
654 case MM_ERROR_CAMCORDER_ENCODER:
655 case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
656 case MM_ERROR_CAMCORDER_ENCODER_WORKING:
657 case MM_ERROR_CAMCORDER_MNOTE_CREATION:
658 case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY:
659 case MM_ERROR_CAMCORDER_INTERNAL:
660 case MM_ERROR_FILE_NOT_FOUND:
661 case MM_ERROR_FILE_READ:
662 camera_error = CAMERA_ERROR_INVALID_OPERATION;
664 case MM_ERROR_CAMCORDER_LOW_MEMORY:
665 case MM_ERROR_CAMCORDER_MNOTE_MALLOC:
666 camera_error = CAMERA_ERROR_OUT_OF_MEMORY;
668 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
669 camera_error = CAMERA_ERROR_ESD;
672 camera_error = CAMERA_ERROR_INVALID_OPERATION;
676 /* set capture completed flag as true to release camera handle */
677 handle->is_capture_completed = true;
679 if (camera_error != 0 && handle->user_cb[_CAMERA_EVENT_TYPE_ERROR]) {
680 ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(camera_error,
682 handle->user_data[_CAMERA_EVENT_TYPE_ERROR]);
686 case MM_MESSAGE_CAMCORDER_HDR_PROGRESS:
687 if (handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS]) {
688 ((camera_attr_hdr_progress_cb)handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS])(m->code,
689 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
692 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
693 cam_fd_info = (MMCamFaceDetectInfo *)(m->data);
695 camera_detected_face_s faces[cam_fd_info->num_of_faces];
696 handle->num_of_faces = cam_fd_info->num_of_faces > MAX_DETECTED_FACE ? MAX_DETECTED_FACE : cam_fd_info->num_of_faces;
698 for (i = 0 ; i < handle->num_of_faces ; i++) {
699 faces[i].id = cam_fd_info->face_info[i].id;
700 faces[i].score = cam_fd_info->face_info[i].score;
701 faces[i].x = cam_fd_info->face_info[i].rect.x;
702 faces[i].y = cam_fd_info->face_info[i].rect.y;
703 faces[i].width = cam_fd_info->face_info[i].rect.width;
704 faces[i].height = cam_fd_info->face_info[i].rect.height;
705 handle->faceinfo[i] = faces[i]; //cache face coordinate
708 if (handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
709 ((camera_face_detected_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
710 handle->num_of_faces,
711 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION]);
714 handle->num_of_faces = 0;
725 static int __capture_completed_event_cb(void *data)
727 camera_s *handle = (camera_s *)data;
728 camera_state_e previous_state = CAMERA_STATE_NONE;
730 if (handle == NULL) {
731 LOGE("handle is NULL");
735 if (handle->current_capture_count > 0 &&
736 handle->current_capture_count == handle->current_capture_complete_count &&
737 handle->state == CAMERA_STATE_CAPTURING) {
738 /* pseudo state change */
739 previous_state = handle->state;
740 handle->state = CAMERA_STATE_CAPTURED;
742 if (previous_state != handle->state &&
743 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
744 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
747 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
750 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
751 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
758 int camera_create(camera_device_e device, camera_h* camera)
761 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
762 return CAMERA_ERROR_INVALID_PARAMETER;
765 int ret = MM_ERROR_NONE;;
769 camera_s *handle = NULL;
772 LOGW("device name = [%d]",device);
774 info.videodev_type = device;
776 handle = (camera_s*)malloc( sizeof(camera_s) );
777 if (handle == NULL) {
779 return CAMERA_ERROR_OUT_OF_MEMORY;
782 memset(handle, 0x0, sizeof(camera_s));
784 ret = mm_camcorder_create(&handle->mm_handle, &info);
785 if (ret != MM_ERROR_NONE) {
787 return __convert_camera_error_code(__func__,ret);
790 preview_format = MM_PIXEL_FORMAT_YUYV;
791 rotation = MM_DISPLAY_ROTATION_NONE;
792 ret = mm_camcorder_get_attributes(handle->mm_handle, &error,
793 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
794 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
795 MMCAM_CAPTURE_WIDTH, &handle->capture_width,
796 MMCAM_CAPTURE_HEIGHT, &handle->capture_height,
798 if (ret != MM_ERROR_NONE) {
799 LOGE("mm_camcorder_get_attributes fail(%x)", ret);
801 LOGE("failed attribute name %s", error);
805 mm_camcorder_destroy(handle->mm_handle);
808 return __convert_camera_error_code(__func__, ret);
811 ret = mm_camcorder_set_attributes(handle->mm_handle, &error,
812 MMCAM_MODE, MM_CAMCORDER_MODE_VIDEO_CAPTURE,
813 MMCAM_CAMERA_FORMAT, preview_format,
814 MMCAM_IMAGE_ENCODER, MM_IMAGE_CODEC_JPEG,
815 MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
816 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL,
817 MMCAM_DISPLAY_ROTATION, rotation,
818 MMCAM_CAPTURE_COUNT, 1,
821 handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
823 if (ret != MM_ERROR_NONE) {
824 LOGE("mm_camcorder_set_attributes fail(%x)", ret);
826 LOGE("failed attribute name %s", error);
830 mm_camcorder_destroy(handle->mm_handle);
833 return __convert_camera_error_code(__func__, ret);
836 handle->state = CAMERA_STATE_CREATED;
837 handle->relay_message_callback = NULL;
838 handle->relay_user_data = NULL;
839 handle->capture_resolution_modified = false;
840 handle->hdr_keep_mode = false;
841 handle->focus_area_valid = false;
842 handle->is_used_in_recorder = false;
843 handle->on_continuous_focusing = false;
844 handle->cached_focus_mode = -1;
846 g_mutex_init(&handle->idle_cb_lock);
848 mm_camcorder_set_message_callback(handle->mm_handle,
849 __mm_camera_message_callback,
852 *camera = (camera_h)handle;
854 LOGW("camera handle %p", handle);
856 return __convert_camera_error_code(__func__, ret);
860 int camera_destroy(camera_h camera)
862 if (camera == NULL) {
863 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
864 return CAMERA_ERROR_INVALID_PARAMETER;
867 int ret = MM_ERROR_NONE;
868 camera_s *handle = (camera_s *)camera;
870 if (handle->is_used_in_recorder) {
871 LOGE("camera is using in another recorder.");
872 return CAMERA_ERROR_INVALID_OPERATION;
875 LOGW("camera handle %p", handle);
877 if (handle->pkt_fmt) {
878 media_format_unref(handle->pkt_fmt);
879 handle->pkt_fmt = NULL;
882 ret = mm_camcorder_destroy(handle->mm_handle);
883 if (ret == MM_ERROR_NONE) {
884 _camera_remove_cb_message(handle);
885 g_mutex_clear(&handle->idle_cb_lock);
887 if (handle->wl_info) {
888 free(handle->wl_info);
889 handle->wl_info = NULL;
891 #endif /* HAVE_WAYLAND */
895 return __convert_camera_error_code(__func__, ret);
899 int camera_start_preview(camera_h camera)
901 if (camera == NULL) {
902 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
903 return CAMERA_ERROR_INVALID_PARAMETER;
906 int ret = MM_ERROR_NONE;
907 camera_s *handle = (camera_s *)camera;
908 camera_state_e capi_state = CAMERA_STATE_NONE;
909 MMCamcorderStateType mm_state = MM_CAMCORDER_STATE_NONE;
911 camera_get_state(camera, &capi_state);
912 if (capi_state == CAMERA_STATE_CAPTURED) {
913 ret = mm_camcorder_capture_stop(handle->mm_handle);
914 return __convert_camera_error_code(__func__, ret);
917 /* for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback */
918 mm_camcorder_set_video_capture_callback(handle->mm_handle,
919 (mm_camcorder_video_capture_callback)__mm_capture_callback,
922 mm_camcorder_get_state(handle->mm_handle, &mm_state);
923 if (mm_state != MM_CAMCORDER_STATE_READY) {
924 ret = mm_camcorder_realize(handle->mm_handle);
925 if (ret != MM_ERROR_NONE) {
926 LOGE("mm_camcorder_realize failed 0x%x", ret);
927 return __convert_camera_error_code(__func__, ret);
931 ret = mm_camcorder_start(handle->mm_handle);
932 if (ret != MM_ERROR_NONE) {
933 LOGE("mm_camcorder_start failed 0x%x, call mm_camcorder_unrealize", ret);
934 mm_camcorder_unrealize(handle->mm_handle);
937 return __convert_camera_error_code(__func__, ret);
941 int camera_stop_preview(camera_h camera)
943 if (camera == NULL) {
944 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
945 return CAMERA_ERROR_INVALID_PARAMETER;
948 int ret = MM_ERROR_NONE;;
949 camera_s *handle = (camera_s *)camera;
950 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
952 mm_camcorder_get_state(handle->mm_handle, &state);
953 if (state == MM_CAMCORDER_STATE_PREPARE) {
954 ret = mm_camcorder_stop(handle->mm_handle);
955 if (ret != MM_ERROR_NONE) {
956 LOGE("mm_camcorder_stop failed 0x%x", ret);
957 return __convert_camera_error_code(__func__, ret);
961 camera_stop_face_detection(camera);
963 ret = mm_camcorder_unrealize(handle->mm_handle);
965 return __convert_camera_error_code(__func__, ret);
969 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
971 if (camera == NULL) {
972 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
973 return CAMERA_ERROR_INVALID_PARAMETER;
976 camera_s *handle = (camera_s *)camera;
977 int ret = MM_ERROR_NONE;
978 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
980 mm_camcorder_get_state(handle->mm_handle, &state);
981 if (state != MM_CAMCORDER_STATE_PREPARE &&
982 state != MM_CAMCORDER_STATE_RECORDING &&
983 state != MM_CAMCORDER_STATE_PAUSED) {
984 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
985 return CAMERA_ERROR_INVALID_STATE;
988 if (handle->capture_resolution_modified) {
989 mm_camcorder_set_attributes(handle->mm_handle, NULL,
990 MMCAM_CAPTURE_WIDTH, handle->capture_width,
991 MMCAM_CAPTURE_HEIGHT, handle->capture_height,
994 handle->capture_resolution_modified = false;
997 mm_camcorder_set_attributes(handle->mm_handle, NULL,
998 MMCAM_CAPTURE_COUNT, 1,
1001 handle->capture_count = 1;
1002 handle->is_continuous_shot_break = false;
1003 handle->current_capture_count = 0;
1004 handle->current_capture_complete_count = 0;
1005 handle->is_capture_completed = false;
1007 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
1008 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
1009 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
1010 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
1012 ret = mm_camcorder_capture_start(handle->mm_handle);
1013 if (ret != MM_ERROR_NONE) {
1014 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1015 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1016 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1017 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1020 return __convert_camera_error_code(__func__, ret);
1024 bool camera_is_supported_continuous_capture(camera_h camera)
1026 if (camera == NULL) {
1027 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1031 int ret = MM_ERROR_NONE;
1032 camera_s *handle = (camera_s *)camera;
1033 MMCamAttrsInfo info;
1035 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_COUNT, &info);
1036 set_last_result(__convert_camera_error_code(__func__, ret));
1037 if (ret != MM_ERROR_NONE) {
1038 LOGE("MMCAM_CAPTURE_COUNT info get failed 0x%x", ret);
1042 if (info.int_range.max > 1) {
1050 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)
1052 if (camera == NULL) {
1053 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1054 return CAMERA_ERROR_INVALID_PARAMETER;
1057 if (camera_is_supported_continuous_capture(camera) == false) {
1058 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1059 return CAMERA_ERROR_NOT_SUPPORTED;
1062 if (count < 2 || interval < 0) {
1063 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1064 return CAMERA_ERROR_INVALID_PARAMETER;
1067 camera_s *handle = (camera_s *)camera;
1068 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
1069 int supported_zsl = FALSE;
1070 int ret = MM_ERROR_NONE;
1072 mm_camcorder_get_state(handle->mm_handle, &state);
1073 if (state != MM_CAMCORDER_STATE_PREPARE) {
1074 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1075 return CAMERA_ERROR_INVALID_STATE;
1078 supported_zsl = FALSE;
1080 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1081 MMCAM_CAPTURE_COUNT, count,
1082 MMCAM_CAPTURE_INTERVAL, interval,
1084 if (ret != MM_ERROR_NONE) {
1085 LOGE("error set continuous shot attribute 0x%x", ret);
1086 return __convert_camera_error_code(__func__, ret);
1089 handle->capture_count = count;
1090 handle->is_continuous_shot_break = false;
1091 handle->current_capture_count = 0;
1092 handle->current_capture_complete_count = 0;
1093 handle->is_capture_completed = false;
1095 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1096 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1098 if (ret != MM_ERROR_NONE) {
1099 LOGE("(%x) error get continuous shot attribute", ret);
1102 if (!supported_zsl) {
1108 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1109 MMCAM_CAMERA_WIDTH, &preview_width,
1110 MMCAM_CAMERA_HEIGHT, &preview_height,
1111 MMCAM_CAPTURE_WIDTH, &capture_width,
1112 MMCAM_CAPTURE_HEIGHT, &capture_height,
1115 if (preview_width != capture_width || preview_height != capture_height) {
1116 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1117 MMCAM_CAPTURE_WIDTH, preview_width,
1118 MMCAM_CAPTURE_HEIGHT, preview_height,
1121 handle->capture_resolution_modified = true;
1125 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
1126 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
1127 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
1128 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
1130 ret = mm_camcorder_capture_start(handle->mm_handle);
1131 if(ret != MM_ERROR_NONE ){
1132 LOGE("mm_camcorder_capture_start failed 0x%x", ret);
1133 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1134 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1135 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1136 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1139 return __convert_camera_error_code(__func__, ret);
1144 int camera_stop_continuous_capture(camera_h camera)
1146 if (camera == NULL) {
1147 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1148 return CAMERA_ERROR_INVALID_PARAMETER;
1151 if (camera_is_supported_continuous_capture(camera) == false) {
1152 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1153 return CAMERA_ERROR_NOT_SUPPORTED;
1156 camera_s *handle = (camera_s *)camera;
1157 int ret = MM_ERROR_NONE;
1158 camera_state_e state = CAMERA_STATE_NONE;
1160 camera_get_state(camera, &state);
1161 if (state != CAMERA_STATE_CAPTURING && handle->capture_count > 1) {
1162 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1163 return CAMERA_ERROR_INVALID_STATE;
1166 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1167 "capture-break-cont-shot", 1,
1169 if (ret == MM_ERROR_NONE) {
1170 handle->is_continuous_shot_break = true;
1172 if (handle->current_capture_count > 0) {
1173 handle->is_capture_completed = true;
1176 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
1179 return __convert_camera_error_code(__func__, ret);
1183 bool camera_is_supported_face_detection(camera_h camera)
1185 if (camera == NULL) {
1186 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1191 int ret = MM_ERROR_NONE;
1192 camera_s *handle = (camera_s *)camera;
1193 MMCamAttrsInfo info;
1195 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
1196 set_last_result(__convert_camera_error_code(__func__, ret));
1197 if (ret != MM_ERROR_NONE) {
1198 LOGE("MMCAM_DETECT_MODE get attr info failed");
1202 if (info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY) {
1203 for (i = 0 ; i < info.int_array.count ; i++) {
1204 if (info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON) {
1205 LOGD("face detection supported");
1211 LOGD("face detection NOT supported");
1217 bool camera_is_supported_zero_shutter_lag(camera_h camera)
1219 int ret = MM_ERROR_NONE;
1220 int supported_zsl = false;
1221 camera_s *handle = (camera_s *)camera;
1223 if (camera == NULL) {
1224 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1228 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1229 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1231 set_last_result(__convert_camera_error_code(__func__, ret));
1232 if (ret != MM_ERROR_NONE) {
1233 LOGE("MMCAM_SUPPORT_ZSL_CAPTURE get failed");
1237 LOGD("support zero shutter lag : %d", supported_zsl);
1239 return supported_zsl;
1243 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
1245 int ret = MM_ERROR_NONE;
1246 int supported = false;
1247 camera_s *handle = (camera_s *)camera;
1249 if (camera == NULL) {
1250 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1254 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1255 MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, &supported,
1257 set_last_result(__convert_camera_error_code(__func__, ret));
1258 if (ret != MM_ERROR_NONE) {
1259 LOGE("MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB get failed");
1263 LOGD("support media packet preview callback : %d", supported);
1269 int camera_get_device_count(camera_h camera, int *device_count)
1271 int ret = MM_ERROR_NONE;
1272 camera_s *handle = (camera_s *)camera;
1274 if (camera == NULL || device_count == NULL) {
1275 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1276 return CAMERA_ERROR_INVALID_PARAMETER;
1279 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1280 MMCAM_CAMERA_DEVICE_COUNT, device_count,
1283 return __convert_camera_error_code(__func__, ret);
1287 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
1289 if (camera == NULL) {
1290 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1291 return CAMERA_ERROR_INVALID_PARAMETER;
1294 if (camera_is_supported_face_detection(camera) == false) {
1295 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1296 return CAMERA_ERROR_NOT_SUPPORTED;
1299 camera_s *handle = (camera_s *)camera;
1300 camera_state_e state = CAMERA_STATE_NONE;
1301 int ret = MM_ERROR_NONE;
1303 camera_get_state(camera, &state);
1304 if (state != CAMERA_STATE_PREVIEW) {
1305 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1306 return CAMERA_ERROR_INVALID_STATE;
1309 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1310 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON,
1312 if (ret == MM_ERROR_NONE) {
1313 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)callback;
1314 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)user_data;
1315 handle->num_of_faces = 0;
1318 return __convert_camera_error_code(__func__,ret);
1322 int camera_stop_face_detection(camera_h camera)
1324 if (camera == NULL) {
1325 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1326 return CAMERA_ERROR_INVALID_PARAMETER;
1329 camera_s *handle = (camera_s *)camera;
1330 int ret = MM_ERROR_NONE;
1332 if (camera_is_supported_face_detection(camera) == false) {
1333 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1334 return CAMERA_ERROR_NOT_SUPPORTED;
1337 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1338 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF,
1340 if (ret == MM_ERROR_NONE) {
1341 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1342 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1343 handle->num_of_faces = 0;
1346 return __convert_camera_error_code(__func__,ret);
1350 int camera_get_state(camera_h camera, camera_state_e *state)
1352 if (camera == NULL || state == NULL) {
1353 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1354 return CAMERA_ERROR_INVALID_PARAMETER;
1357 camera_s *handle = (camera_s *)camera;
1358 camera_state_e capi_state = CAMERA_STATE_NONE;
1359 MMCamcorderStateType mmstate = MM_CAMCORDER_STATE_NONE;
1361 mm_camcorder_get_state(handle->mm_handle, &mmstate);
1362 capi_state = __camera_state_convert(mmstate);
1364 if ((handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed) &&
1365 (handle->current_capture_count > 0 || handle->is_capture_completed) &&
1366 mmstate == MM_CAMCORDER_STATE_CAPTURING) {
1367 capi_state = CAMERA_STATE_CAPTURED;
1370 *state = capi_state;
1372 return CAMERA_ERROR_NONE;
1376 int camera_start_focusing(camera_h camera, bool continuous)
1378 if (camera == NULL) {
1379 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1380 return CAMERA_ERROR_INVALID_PARAMETER;
1383 camera_s *handle = (camera_s *)camera;
1385 if (handle->cached_focus_mode != -1) {
1386 LOGD("apply cached focus mode %d", handle->cached_focus_mode);
1388 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1389 MMCAM_CAMERA_AF_SCAN_RANGE, handle->cached_focus_mode,
1392 handle->cached_focus_mode = -1;
1396 return __camera_start_continuous_focusing(camera);
1398 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1399 MMCAM_CAMERA_FOCUS_MODE, handle->focus_area_valid ? \
1400 MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO : MM_CAMCORDER_FOCUS_MODE_AUTO,
1403 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s *)camera)->mm_handle));
1408 int __camera_start_continuous_focusing(camera_h camera)
1410 if (camera == NULL) {
1411 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1412 return CAMERA_ERROR_INVALID_PARAMETER;
1415 camera_s *handle = (camera_s *)camera;
1416 int ret = MM_ERROR_NONE;
1417 int mode = MM_CAMCORDER_FOCUS_MODE_NONE;
1419 handle->on_continuous_focusing = true;
1420 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1421 MMCAM_CAMERA_FOCUS_MODE, &mode,
1424 if (mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS) {
1425 ret = mm_camcorder_start_focusing(handle->mm_handle);
1427 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1428 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS,
1432 return __convert_camera_error_code(__func__, ret);
1436 int camera_cancel_focusing(camera_h camera)
1438 if (camera == NULL) {
1439 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1440 return CAMERA_ERROR_INVALID_PARAMETER;
1443 camera_s *handle = (camera_s *)camera;
1445 handle->on_continuous_focusing = false;
1447 return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
1451 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
1453 int ret = MM_ERROR_NONE;
1454 int set_surface = MM_DISPLAY_SURFACE_X;
1455 void *set_handle = NULL;
1456 camera_s *handle = NULL;
1458 Evas_Object *obj = NULL;
1459 const char *object_type = NULL;
1461 if (camera == NULL) {
1462 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1463 return CAMERA_ERROR_INVALID_PARAMETER;
1466 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
1467 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
1468 return CAMERA_ERROR_INVALID_PARAMETER;
1471 handle = (camera_s *)camera;
1472 handle->display_type = type;
1474 if (type == CAMERA_DISPLAY_TYPE_NONE) {
1476 set_surface = MM_DISPLAY_SURFACE_NULL;
1477 handle->display_handle = 0;
1479 LOGD("display type NONE");
1481 obj = (Evas_Object *)display;
1482 object_type = evas_object_type_get(obj);
1484 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
1486 MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)malloc(sizeof(MMCamWaylandInfo));
1488 if (wl_info == NULL) {
1489 LOGE("wl_info alloc failed : %d", sizeof(MMCamWaylandInfo));
1490 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_LOW_MEMORY);
1493 memset(wl_info, 0x0, sizeof(MMCamWaylandInfo));
1495 wl_info->evas_obj = (void *)obj;
1496 wl_info->window = (void *)elm_win_wl_window_get(obj);
1497 wl_info->surface = (void *)ecore_wl_window_surface_get(wl_info->window);
1498 wl_info->display = (void *)ecore_wl_display_get();
1500 if (wl_info->window == NULL || wl_info->surface == NULL || wl_info->display == NULL) {
1501 LOGE("something is NULL %p, %p, %p", wl_info->window, wl_info->surface, wl_info->display);
1503 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_INTERNAL);
1506 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
1507 &wl_info->window_width, &wl_info->window_height);
1509 if (handle->wl_info) {
1510 free(handle->wl_info);
1511 handle->wl_info = NULL;
1514 /* set wayland info */
1515 handle->wl_info = (void *)wl_info;
1516 set_surface = MM_DISPLAY_SURFACE_X;
1517 set_handle = (void *)wl_info;
1519 LOGD("wayland obj %p, window %p, surface %p, display %p, size %d,%d,%dx%d",
1520 wl_info->evas_obj, wl_info->window, wl_info->surface, wl_info->display,
1521 wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
1522 #else /* HAVE_WAYLAND */
1523 /* x window overlay surface */
1524 handle->display_handle = (void *)elm_win_xwindow_get(obj);
1525 set_surface = MM_DISPLAY_SURFACE_X;
1526 set_handle = &(handle->display_handle);
1528 LOGD("display type OVERLAY : handle %p, %d", set_handle, (int)handle->display_handle);
1529 #endif /* HAVE_WAYLAND */
1530 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
1531 /* evas object surface */
1532 handle->display_handle = display;
1533 set_surface = MM_DISPLAY_SURFACE_EVAS;
1534 set_handle = display;
1536 LOGD("display type EVAS : handle %p", set_handle);
1538 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
1539 return CAMERA_ERROR_INVALID_PARAMETER;
1542 LOGE("failed to get evas object type from %p", obj);
1543 return CAMERA_ERROR_INVALID_PARAMETER;
1547 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1548 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
1549 MMCAM_DISPLAY_SURFACE, set_surface,
1552 if (ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE) {
1553 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1554 MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *),
1558 return __convert_camera_error_code(__func__, ret);
1562 int camera_set_preview_resolution(camera_h camera, int width, int height)
1564 if( camera == NULL){
1565 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1566 return CAMERA_ERROR_INVALID_PARAMETER;
1569 int ret = MM_ERROR_NONE;
1570 camera_s *handle = (camera_s *)camera;
1571 MMCamAttrsInfo info;
1575 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1576 MMCAM_CAMERA_FPS, &mm_fps,
1579 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
1580 if (ret != MM_ERROR_NONE) {
1581 return __convert_camera_error_code(__func__, ret);
1584 for (i = 0 ; i < info.int_array.count ; i++) {
1585 if (info.int_array.array[i] == mm_fps) {
1588 if (i == info.int_array.count - 1) {
1589 LOGE("Not supported resolution: Current set Resolution's FPS is not supported in wanted resolution.");
1590 return CAMERA_ERROR_NOT_SUPPORTED;
1594 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1595 MMCAM_CAMERA_WIDTH, width,
1596 MMCAM_CAMERA_HEIGHT, height,
1599 return __convert_camera_error_code(__func__, ret);
1603 int camera_set_capture_resolution(camera_h camera, int width, int height)
1605 if (camera == NULL) {
1606 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1607 return CAMERA_ERROR_INVALID_PARAMETER;
1610 int ret = MM_ERROR_NONE;
1611 camera_s *handle = (camera_s *)camera;
1613 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1614 MMCAM_CAPTURE_WIDTH, width,
1615 MMCAM_CAPTURE_HEIGHT, height,
1617 if (ret == MM_ERROR_NONE) {
1618 handle->capture_width = width;
1619 handle->capture_height = height;
1622 return __convert_camera_error_code(__func__, ret);
1626 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
1628 if (camera == NULL) {
1629 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1630 return CAMERA_ERROR_INVALID_PARAMETER;
1633 int ret = MM_ERROR_NONE;
1634 camera_s *handle = (camera_s *)camera;
1636 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1637 MMCAM_CAPTURE_FORMAT, format,
1640 return __convert_camera_error_code(__func__, ret);
1644 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
1646 if (camera == NULL) {
1647 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1648 return CAMERA_ERROR_INVALID_PARAMETER;
1652 int ret = MM_ERROR_NONE;
1653 camera_s *handle = (camera_s *)camera;
1655 if (format == CAMERA_PIXEL_FORMAT_UYVY) {
1656 bool supported_ITLV_UYVY = false;
1657 MMCamAttrsInfo supported_format;
1658 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1659 for (i = 0 ; i < supported_format.int_array.count ; i++) {
1660 if (supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1661 supported_ITLV_UYVY = true;
1664 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1665 MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ? MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY,
1668 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1669 MMCAM_CAMERA_FORMAT, format,
1673 return __convert_camera_error_code(__func__, ret);
1677 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
1679 if (camera == NULL || width == NULL || height == NULL) {
1680 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1681 return CAMERA_ERROR_INVALID_PARAMETER;
1684 int ret = MM_ERROR_NONE;
1685 camera_s *handle = (camera_s *)camera;
1687 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1688 MMCAM_CAMERA_WIDTH, width,
1689 MMCAM_CAMERA_HEIGHT, height,
1692 return __convert_camera_error_code(__func__, ret);
1696 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
1698 if (camera == NULL) {
1699 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1700 return CAMERA_ERROR_INVALID_PARAMETER;
1703 if (rotation > CAMERA_ROTATION_270) {
1704 return CAMERA_ERROR_INVALID_PARAMETER;
1707 int ret = MM_ERROR_NONE;
1708 camera_s *handle = (camera_s *)camera;
1710 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1711 MMCAM_DISPLAY_ROTATION, rotation,
1714 return __convert_camera_error_code(__func__, ret);
1718 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
1720 if (camera == NULL || rotation == NULL) {
1721 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1722 return CAMERA_ERROR_INVALID_PARAMETER;
1725 int ret = MM_ERROR_NONE;
1726 camera_s *handle = (camera_s *)camera;
1728 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1729 MMCAM_DISPLAY_ROTATION, rotation,
1732 return __convert_camera_error_code(__func__, ret);
1736 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
1738 if (camera == NULL) {
1739 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1740 return CAMERA_ERROR_INVALID_PARAMETER;
1743 if (flip > CAMERA_FLIP_BOTH) {
1744 return CAMERA_ERROR_INVALID_PARAMETER;
1747 int ret = MM_ERROR_NONE;
1748 camera_s *handle = (camera_s *)camera;
1750 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1751 MMCAM_DISPLAY_FLIP, flip,
1754 return __convert_camera_error_code(__func__, ret);
1758 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
1760 if (camera == NULL || flip == NULL) {
1761 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1762 return CAMERA_ERROR_INVALID_PARAMETER;
1765 int ret = MM_ERROR_NONE;
1766 camera_s *handle = (camera_s *)camera;
1768 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1769 MMCAM_DISPLAY_FLIP, flip,
1772 return __convert_camera_error_code(__func__, ret);
1776 int camera_set_display_visible(camera_h camera, bool visible)
1778 if (camera == NULL) {
1779 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1780 return CAMERA_ERROR_INVALID_PARAMETER;
1783 int ret = MM_ERROR_NONE;
1784 camera_s *handle = (camera_s *)camera;
1786 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1787 MMCAM_DISPLAY_VISIBLE, visible,
1790 return __convert_camera_error_code(__func__, ret);
1794 int camera_is_display_visible(camera_h camera, bool* visible)
1796 if (camera == NULL || visible == NULL) {
1797 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1798 return CAMERA_ERROR_INVALID_PARAMETER;
1801 int ret = MM_ERROR_NONE;
1803 camera_s *handle = (camera_s *)camera;
1805 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1806 MMCAM_DISPLAY_VISIBLE, &result,
1809 if (ret == MM_ERROR_NONE) {
1813 return __convert_camera_error_code(__func__, ret);
1817 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
1819 if (camera == NULL) {
1820 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1821 return CAMERA_ERROR_INVALID_PARAMETER;
1824 if (mode > CAMERA_DISPLAY_MODE_CROPPED_FULL) {
1825 return CAMERA_ERROR_INVALID_PARAMETER;
1828 int ret = MM_ERROR_NONE;
1829 camera_s *handle = (camera_s *)camera;
1831 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1832 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1835 return __convert_camera_error_code(__func__, ret);
1839 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
1841 if (camera == NULL || mode == NULL) {
1842 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1843 return CAMERA_ERROR_INVALID_PARAMETER;
1846 int ret = MM_ERROR_NONE;
1847 camera_s *handle = (camera_s *)camera;
1849 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1850 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1853 return __convert_camera_error_code(__func__, ret);
1857 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
1859 if (camera == NULL || width == NULL || height == NULL) {
1860 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1861 return CAMERA_ERROR_INVALID_PARAMETER;
1864 camera_s *handle = (camera_s *)camera;
1866 *width = handle->capture_width;
1867 *height = handle->capture_height;
1869 return CAMERA_ERROR_NONE;
1873 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
1875 if (camera == NULL || format == NULL) {
1876 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1877 return CAMERA_ERROR_INVALID_PARAMETER;
1880 int ret = MM_ERROR_NONE;
1881 camera_s *handle = (camera_s *)camera;
1883 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1884 MMCAM_CAPTURE_FORMAT, format,
1887 return __convert_camera_error_code(__func__, ret);
1891 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
1893 if (camera == NULL || format == NULL) {
1894 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1895 return CAMERA_ERROR_INVALID_PARAMETER;
1898 int ret = MM_ERROR_NONE;
1899 camera_s *handle = (camera_s *)camera;
1901 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1902 MMCAM_CAMERA_FORMAT, format,
1905 if ((MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1906 *format = CAMERA_PIXEL_FORMAT_UYVY;
1909 return __convert_camera_error_code(__func__, ret);
1913 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
1915 if (camera == NULL || callback == NULL) {
1916 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1917 return CAMERA_ERROR_INVALID_PARAMETER;
1920 camera_s *handle = (camera_s *)camera;
1921 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)callback;
1922 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)user_data;
1924 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1925 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1928 return CAMERA_ERROR_NONE;
1932 int camera_unset_preview_cb(camera_h camera)
1934 if (camera == NULL) {
1935 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1936 return CAMERA_ERROR_INVALID_PARAMETER;
1939 camera_s *handle = (camera_s *)camera;
1941 if (handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1942 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1943 (mm_camcorder_video_stream_callback)NULL,
1947 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1948 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1950 return CAMERA_ERROR_NONE;
1954 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
1956 if (camera == NULL) {
1957 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
1958 return CAMERA_ERROR_INVALID_PARAMETER;
1961 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1962 LOGE("NOT SUPPORTED");
1963 return CAMERA_ERROR_NOT_SUPPORTED;
1966 if (callback == NULL) {
1967 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
1968 return CAMERA_ERROR_INVALID_PARAMETER;
1971 camera_s *handle = (camera_s *)camera;
1972 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)callback;
1973 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)user_data;
1975 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1976 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1979 return CAMERA_ERROR_NONE;
1983 int camera_unset_media_packet_preview_cb(camera_h camera)
1985 if (camera == NULL) {
1986 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1987 return CAMERA_ERROR_INVALID_PARAMETER;
1990 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1991 LOGE("NOT SUPPORTED");
1992 return CAMERA_ERROR_NOT_SUPPORTED;
1995 camera_s *handle = (camera_s *)camera;
1997 if (handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] == NULL) {
1998 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1999 (mm_camcorder_video_stream_callback)NULL,
2003 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
2004 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
2006 return CAMERA_ERROR_NONE;
2010 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
2012 if (camera == NULL || callback == NULL) {
2013 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2014 return CAMERA_ERROR_INVALID_PARAMETER;
2017 camera_s *handle = (camera_s *)camera;
2018 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)callback;
2019 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)user_data;
2021 return CAMERA_ERROR_NONE;
2025 int camera_unset_state_changed_cb(camera_h camera)
2027 if (camera == NULL) {
2028 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2029 return CAMERA_ERROR_INVALID_PARAMETER;
2032 camera_s *handle = (camera_s *)camera;
2033 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2034 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2036 return CAMERA_ERROR_NONE;
2040 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
2042 if (camera == NULL || callback == NULL) {
2043 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2044 return CAMERA_ERROR_INVALID_PARAMETER;
2047 camera_s *handle = (camera_s *)camera;
2048 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)callback;
2049 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)user_data;
2051 return CAMERA_ERROR_NONE;
2055 int camera_unset_interrupted_cb(camera_h camera)
2057 if (camera == NULL) {
2058 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2059 return CAMERA_ERROR_INVALID_PARAMETER;
2062 camera_s *handle = (camera_s *)camera;
2064 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2065 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2067 return CAMERA_ERROR_NONE;
2071 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
2073 if (camera == NULL || callback == NULL) {
2074 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2075 return CAMERA_ERROR_INVALID_PARAMETER;
2078 camera_s *handle = (camera_s *)camera;
2080 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)callback;
2081 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)user_data;
2083 return CAMERA_ERROR_NONE;
2087 int camera_unset_focus_changed_cb(camera_h camera)
2089 if (camera == NULL) {
2090 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2091 return CAMERA_ERROR_INVALID_PARAMETER;
2094 camera_s *handle = (camera_s *)camera;
2096 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2097 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2099 return CAMERA_ERROR_NONE;
2103 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
2105 if (camera == NULL || callback == NULL) {
2106 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2107 return CAMERA_ERROR_INVALID_PARAMETER;
2110 camera_s *handle = (camera_s *)camera;
2112 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)callback;
2113 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)user_data;
2115 return CAMERA_ERROR_NONE;
2119 int camera_unset_error_cb(camera_h camera)
2121 if (camera == NULL) {
2122 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2123 return CAMERA_ERROR_INVALID_PARAMETER;
2126 camera_s *handle = (camera_s *)camera;
2128 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2129 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2131 return CAMERA_ERROR_NONE;
2135 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
2137 if (camera == NULL || foreach_cb == NULL) {
2138 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2139 return CAMERA_ERROR_INVALID_PARAMETER;
2143 int ret = MM_ERROR_NONE;
2144 camera_s *handle = (camera_s *)camera;
2145 MMCamAttrsInfo preview_width;
2146 MMCamAttrsInfo preview_height;
2148 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH, &preview_width);
2149 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT, &preview_height);
2150 if (ret != CAMERA_ERROR_NONE) {
2151 return __convert_camera_error_code(__func__, ret);
2154 for (i = 0 ; i < preview_width.int_array.count ; i++) {
2155 if (!foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i], user_data)) {
2160 return CAMERA_ERROR_NONE;
2164 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
2166 if (camera == NULL || foreach_cb == NULL) {
2167 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2168 return CAMERA_ERROR_INVALID_PARAMETER;
2172 int ret = MM_ERROR_NONE;
2173 camera_s *handle = (camera_s *)camera;
2174 MMCamAttrsInfo capture_width;
2175 MMCamAttrsInfo capture_height;
2177 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH, &capture_width);
2178 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT, &capture_height);
2179 if (ret != CAMERA_ERROR_NONE) {
2180 return __convert_camera_error_code(__func__, ret);
2183 for (i = 0 ; i < capture_width.int_array.count ; i++) {
2184 if (!foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i], user_data)) {
2189 return CAMERA_ERROR_NONE;
2193 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
2195 if (camera == NULL || foreach_cb == NULL) {
2196 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2197 return CAMERA_ERROR_INVALID_PARAMETER;
2201 int ret = MM_ERROR_NONE;
2202 camera_s *handle = (camera_s *)camera;
2203 MMCamAttrsInfo format;
2205 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT, &format);
2206 if (ret != CAMERA_ERROR_NONE) {
2207 return __convert_camera_error_code(__func__, ret);
2210 for (i = 0 ; i < format.int_array.count ; i++) {
2211 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2212 if (!foreach_cb(format.int_array.array[i], user_data)) {
2218 return CAMERA_ERROR_NONE;
2222 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
2224 if (camera == NULL || foreach_cb == NULL) {
2225 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2226 return CAMERA_ERROR_INVALID_PARAMETER;
2230 int ret = MM_ERROR_NONE;
2231 camera_s *handle = (camera_s *)camera;
2232 MMCamAttrsInfo format;
2234 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT, &format);
2235 if (ret != CAMERA_ERROR_NONE) {
2236 return __convert_camera_error_code(__func__, ret);
2239 for (i = 0 ; i < format.int_array.count ; i++) {
2240 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2241 if (!foreach_cb(format.int_array.array[i], user_data)) {
2247 return CAMERA_ERROR_NONE;
2251 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
2253 if (camera == NULL || width == NULL || height == NULL) {
2254 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2255 return CAMERA_ERROR_INVALID_PARAMETER;
2258 enum MMCamcorderPreviewType wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2262 int ret = MM_ERROR_NONE;
2263 camera_s *handle = (camera_s *)camera;
2264 MMCamAttrsInfo width_info;
2265 MMCamAttrsInfo height_info;
2267 camera_get_capture_resolution(camera, &capture_w, &capture_h);
2268 ratio = (double)capture_w / (double)capture_h;
2270 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
2271 } else if (ratio == 1.0) {
2272 wide = MM_CAMCORDER_PREVIEW_TYPE_SQUARE;
2274 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2277 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH, &width_info);
2278 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
2279 if (ret != MM_ERROR_NONE) {
2280 return __convert_camera_error_code(__func__, ret);
2283 if (width && (unsigned int)width_info.int_array.count > wide) {
2284 *width = width_info.int_array.array[wide];
2286 LOGE("there is no width value for resolution %dx%d type %d", capture_w, capture_h, wide);
2287 return CAMERA_ERROR_INVALID_OPERATION;
2290 if (height && (unsigned int)height_info.int_array.count > wide) {
2291 *height = height_info.int_array.array[wide];
2293 LOGE("there is no height value for resolution %dx%d type %d", capture_w, capture_h, wide);
2294 return CAMERA_ERROR_INVALID_OPERATION;
2297 LOGI("recommend resolution %dx%d, type %d", *width, *height, wide);
2299 return CAMERA_ERROR_NONE;
2303 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
2305 if (camera == NULL || angle == NULL) {
2306 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2307 return CAMERA_ERROR_INVALID_PARAMETER;
2310 int ret = MM_ERROR_NONE;
2311 camera_s *handle = (camera_s *)camera;
2312 int rotation = MM_DISPLAY_ROTATION_NONE;
2314 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2315 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
2318 if (ret == MM_ERROR_NONE) {
2320 case MM_DISPLAY_ROTATION_NONE:
2323 case MM_DISPLAY_ROTATION_90:
2326 case MM_DISPLAY_ROTATION_180:
2329 case MM_DISPLAY_ROTATION_270:
2338 return __convert_camera_error_code(__func__, ret);
2342 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
2344 if (camera == NULL) {
2345 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2346 return CAMERA_ERROR_INVALID_PARAMETER;
2349 int ret = MM_ERROR_NONE;
2350 camera_s *handle = (camera_s *)camera;
2352 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2353 MMCAM_DISPLAY_MODE, mode,
2356 return __convert_camera_error_code(__func__, ret);
2360 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
2362 if (camera == NULL || mode == NULL) {
2363 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2364 return CAMERA_ERROR_INVALID_PARAMETER;
2367 int ret = MM_ERROR_NONE;
2368 camera_s *handle = (camera_s *)camera;
2370 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2371 MMCAM_DISPLAY_MODE, mode,
2374 return __convert_camera_error_code(__func__, ret);
2378 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
2380 if (camera == NULL || foreach_cb == NULL) {
2381 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2382 return CAMERA_ERROR_INVALID_PARAMETER;
2386 int ret = MM_ERROR_NONE;
2387 camera_s *handle = (camera_s *)camera;
2388 MMCamAttrsInfo info;
2390 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DISPLAY_MODE, &info);
2391 if (ret != CAMERA_ERROR_NONE) {
2392 return __convert_camera_error_code(__func__, ret);
2395 for (i = 0 ; i < info.int_array.count ; i++) {
2396 if (!foreach_cb(info.int_array.array[i], user_data)) {
2401 return CAMERA_ERROR_NONE;
2405 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
2407 if (camera == NULL) {
2408 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2409 return CAMERA_ERROR_INVALID_PARAMETER;
2412 int ret = MM_ERROR_NONE;
2413 camera_s *handle = (camera_s *)camera;
2415 if (fps == CAMERA_ATTR_FPS_AUTO) {
2416 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2417 MMCAM_CAMERA_FPS_AUTO, true,
2420 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2421 MMCAM_CAMERA_FPS_AUTO, false,
2422 MMCAM_CAMERA_FPS, fps,
2426 return __convert_camera_error_code(__func__, ret);
2430 int camera_attr_set_image_quality(camera_h camera, int quality)
2432 if (camera == NULL) {
2433 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2434 return CAMERA_ERROR_INVALID_PARAMETER;
2437 int ret = MM_ERROR_NONE;
2438 camera_s *handle = (camera_s *)camera;
2440 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2441 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2444 return __convert_camera_error_code(__func__, ret);
2448 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
2450 if (camera == NULL || fps == NULL) {
2451 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2452 return CAMERA_ERROR_INVALID_PARAMETER;
2455 int ret = MM_ERROR_NONE;
2457 int is_auto = false;
2458 camera_s *handle = (camera_s *)camera;
2460 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2461 MMCAM_CAMERA_FPS, &mm_fps,
2462 MMCAM_CAMERA_FPS_AUTO, &is_auto,
2464 if (ret == MM_ERROR_NONE) {
2466 *fps = CAMERA_ATTR_FPS_AUTO;
2472 return __convert_camera_error_code(__func__, ret);
2476 int camera_attr_get_image_quality(camera_h camera, int *quality)
2478 if (camera == NULL || quality == NULL) {
2479 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2480 return CAMERA_ERROR_INVALID_PARAMETER;
2483 int ret = MM_ERROR_NONE;
2484 camera_s *handle = (camera_s *)camera;
2486 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2487 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2490 return __convert_camera_error_code(__func__, ret);
2494 int camera_attr_set_zoom(camera_h camera, int zoom)
2496 if (camera == NULL) {
2497 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2498 return CAMERA_ERROR_INVALID_PARAMETER;
2501 int ret = MM_ERROR_NONE;
2502 camera_s *handle = (camera_s *)camera;
2504 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2505 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2508 return __convert_camera_error_code(__func__, ret);
2512 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
2514 if (camera == NULL) {
2515 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2516 return CAMERA_ERROR_INVALID_PARAMETER;
2519 int ret = MM_ERROR_NONE;
2520 camera_s *handle = (camera_s *)camera;
2522 bool should_change_focus_mode = false;
2524 mm_camcorder_get_attributes(handle->mm_handle, NULL,
2525 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2528 if (focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO &&
2529 focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2530 focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO) {
2531 should_change_focus_mode = true;
2534 if (mode != CAMERA_ATTR_AF_NONE &&
2535 focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2536 !handle->on_continuous_focusing) {
2537 handle->cached_focus_mode = mode;
2538 LOGD("af mode will be set actually start focusing");
2539 return __convert_camera_error_code(__func__, MM_ERROR_NONE);
2541 handle->cached_focus_mode = -1;
2544 if (mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode) {
2545 mm_camcorder_set_attributes(handle->mm_handle, NULL,
2546 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO,
2551 case CAMERA_ATTR_AF_NONE:
2552 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2553 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
2554 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NONE,
2557 case CAMERA_ATTR_AF_NORMAL:
2558 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2559 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NORMAL,
2562 case CAMERA_ATTR_AF_MACRO:
2563 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2564 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_MACRO,
2567 case CAMERA_ATTR_AF_FULL:
2568 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2569 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_FULL,
2573 LOGE("invalid mode %d", mode);
2574 return CAMERA_ERROR_INVALID_PARAMETER;
2577 return __convert_camera_error_code(__func__, ret);
2581 int camera_attr_set_af_area(camera_h camera, int x, int y)
2583 if (camera == NULL) {
2584 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2585 return CAMERA_ERROR_INVALID_PARAMETER;
2588 int ret = MM_ERROR_NONE;
2589 camera_s *handle = (camera_s *)camera;
2590 camera_attr_af_mode_e mode;
2592 camera_attr_get_af_mode(camera, &mode);
2593 if (mode == CAMERA_ATTR_AF_NONE) {
2594 LOGE("INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE", CAMERA_ERROR_INVALID_OPERATION);
2595 return CAMERA_ERROR_INVALID_OPERATION;
2598 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2599 MMCAM_CAMERA_AF_TOUCH_X, x,
2600 MMCAM_CAMERA_AF_TOUCH_Y, y,
2602 if (ret == MM_ERROR_NONE) {
2603 handle->focus_area_valid = true;
2606 return __convert_camera_error_code(__func__, ret);
2610 int camera_attr_clear_af_area(camera_h camera)
2612 if (camera == NULL) {
2613 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2614 return CAMERA_ERROR_INVALID_PARAMETER;
2617 camera_s *handle = (camera_s *)camera;
2619 handle->focus_area_valid = false;
2625 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
2627 if (camera == NULL) {
2628 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2629 return CAMERA_ERROR_INVALID_PARAMETER;
2632 int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, /* CAMERA_ATTR_EXPOSURE_MODE_OFF */
2633 MM_CAMCORDER_AUTO_EXPOSURE_ALL, /* CAMERA_ATTR_EXPOSURE_MODE_ALL */
2634 MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, /* CAMERA_ATTR_EXPOSURE_MODE_CENTER */
2635 MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, /* CAMERA_ATTR_EXPOSURE_MODE_SPOT */
2636 MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1, /* CAMERA_ATTR_EXPOSURE_MODE_CUSTOM */
2639 int ret = MM_ERROR_NONE;
2640 camera_s *handle = (camera_s *)camera;
2642 if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
2643 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2644 return CAMERA_ERROR_INVALID_PARAMETER;
2647 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2648 MMCAM_CAMERA_EXPOSURE_MODE, maptable[mode],
2651 return __convert_camera_error_code(__func__, ret);
2655 int camera_attr_set_exposure(camera_h camera, int value)
2657 if (camera == NULL) {
2658 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2659 return CAMERA_ERROR_INVALID_PARAMETER;
2662 int ret = MM_ERROR_NONE;
2663 camera_s *handle = (camera_s *)camera;
2665 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2666 MMCAM_CAMERA_EXPOSURE_VALUE, value,
2669 return __convert_camera_error_code(__func__, ret);
2673 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
2675 if (camera == NULL) {
2676 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2677 return CAMERA_ERROR_INVALID_PARAMETER;
2680 int ret = MM_ERROR_NONE;
2681 camera_s *handle = (camera_s*)camera;
2683 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2684 MMCAM_CAMERA_ISO, iso,
2687 return __convert_camera_error_code(__func__, ret);
2691 int camera_attr_set_brightness(camera_h camera, int level)
2693 if (camera == NULL) {
2694 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2695 return CAMERA_ERROR_INVALID_PARAMETER;
2698 int ret = MM_ERROR_NONE;
2699 camera_s *handle = (camera_s *)camera;
2701 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2702 MMCAM_FILTER_BRIGHTNESS, level,
2705 return __convert_camera_error_code(__func__, ret);
2709 int camera_attr_set_contrast(camera_h camera, int level)
2711 if (camera == NULL) {
2712 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2713 return CAMERA_ERROR_INVALID_PARAMETER;
2716 int ret = MM_ERROR_NONE;
2717 camera_s *handle = (camera_s *)camera;
2719 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2720 MMCAM_FILTER_CONTRAST, level,
2723 return __convert_camera_error_code(__func__, ret);
2727 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
2729 if (camera == NULL) {
2730 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2731 return CAMERA_ERROR_INVALID_PARAMETER;
2734 int ret = MM_ERROR_NONE;
2735 camera_s *handle = (camera_s *)camera;
2737 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2738 MMCAM_FILTER_WB, wb,
2741 return __convert_camera_error_code(__func__, ret);
2745 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
2747 if (camera == NULL) {
2748 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2749 return CAMERA_ERROR_INVALID_PARAMETER;
2752 int ret = MM_ERROR_NONE;
2753 camera_s *handle = (camera_s *)camera;
2755 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2756 MMCAM_FILTER_COLOR_TONE, effect,
2759 return __convert_camera_error_code(__func__, ret);
2763 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
2765 if (camera == NULL) {
2766 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2767 return CAMERA_ERROR_INVALID_PARAMETER;
2770 int ret = MM_ERROR_NONE;
2771 camera_s *handle = (camera_s *)camera;
2773 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2774 MMCAM_FILTER_SCENE_MODE, mode,
2777 return __convert_camera_error_code(__func__, ret);
2781 int camera_attr_enable_tag(camera_h camera, bool enable)
2783 if (camera == NULL) {
2784 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2785 return CAMERA_ERROR_INVALID_PARAMETER;
2788 int ret = MM_ERROR_NONE;
2789 camera_s *handle = (camera_s *)camera;
2791 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2792 MMCAM_TAG_ENABLE, enable,
2795 return __convert_camera_error_code(__func__, ret);
2799 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
2801 if (camera == NULL) {
2802 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2803 return CAMERA_ERROR_INVALID_PARAMETER;
2806 int ret = MM_ERROR_NONE;
2807 camera_s *handle = (camera_s *)camera;
2809 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2810 MMCAM_TAG_IMAGE_DESCRIPTION, description, strlen(description),
2813 return __convert_camera_error_code(__func__, ret);
2817 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
2819 if (camera == NULL) {
2820 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2821 return CAMERA_ERROR_INVALID_PARAMETER;
2824 int ret = MM_ERROR_NONE;
2825 camera_s *handle = (camera_s *)camera;
2827 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2828 MMCAM_TAG_ORIENTATION, orientation,
2831 return __convert_camera_error_code(__func__, ret);
2835 int camera_attr_set_tag_software(camera_h camera, const char *software)
2837 if (camera == NULL) {
2838 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2839 return CAMERA_ERROR_INVALID_PARAMETER;
2842 int ret = MM_ERROR_NONE;
2843 camera_s *handle = (camera_s *)camera;
2845 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2846 MMCAM_TAG_SOFTWARE, software, strlen(software),
2849 return __convert_camera_error_code(__func__, ret);
2853 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
2855 if (camera == NULL) {
2856 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2857 return CAMERA_ERROR_INVALID_PARAMETER;
2860 int ret = MM_ERROR_NONE;
2861 camera_s *handle = (camera_s *)camera;
2863 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2864 MMCAM_TAG_GPS_ENABLE, true,
2865 MMCAM_TAG_LATITUDE, latitude,
2866 MMCAM_TAG_LONGITUDE, longitude,
2867 MMCAM_TAG_ALTITUDE, altitude,
2870 return __convert_camera_error_code(__func__, ret);
2874 int camera_attr_remove_geotag(camera_h camera)
2876 if (camera == NULL) {
2877 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2878 return CAMERA_ERROR_INVALID_PARAMETER;
2881 int ret = MM_ERROR_NONE;
2882 camera_s *handle = (camera_s *)camera;
2884 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2885 MMCAM_TAG_GPS_ENABLE, false,
2888 return __convert_camera_error_code(__func__, ret);
2892 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
2894 if (camera == NULL) {
2895 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2896 return CAMERA_ERROR_INVALID_PARAMETER;
2899 int ret = MM_ERROR_NONE;
2900 camera_s *handle = (camera_s *)camera;
2902 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2903 MMCAM_STROBE_MODE, mode,
2906 return __convert_camera_error_code(__func__, ret);
2910 int camera_attr_get_zoom(camera_h camera, int *zoom)
2912 if (camera == NULL || zoom == NULL) {
2913 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2914 return CAMERA_ERROR_INVALID_PARAMETER;
2917 int ret = MM_ERROR_NONE;
2918 camera_s *handle = (camera_s *)camera;
2920 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2921 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2924 return __convert_camera_error_code(__func__, ret);
2928 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
2930 if (camera == NULL || min == NULL || max == NULL) {
2931 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2932 return CAMERA_ERROR_INVALID_PARAMETER;
2935 int ret = MM_ERROR_NONE;
2936 camera_s *handle = (camera_s *)camera;
2937 MMCamAttrsInfo ainfo;
2939 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
2940 if (ret == MM_ERROR_NONE) {
2941 *min = ainfo.int_range.min;
2942 *max = ainfo.int_range.max;
2945 return __convert_camera_error_code(__func__, ret);
2949 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
2951 if (camera == NULL || mode == NULL) {
2952 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2953 return CAMERA_ERROR_INVALID_PARAMETER;
2956 int ret = MM_ERROR_NONE;
2960 camera_s *handle = (camera_s *)camera;
2962 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2963 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2964 MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
2965 MMCAM_DETECT_MODE, &detect_mode,
2967 if (ret == MM_ERROR_NONE) {
2968 switch (focus_mode) {
2969 case MM_CAMCORDER_FOCUS_MODE_NONE:
2970 case MM_CAMCORDER_FOCUS_MODE_PAN:
2971 case MM_CAMCORDER_FOCUS_MODE_MANUAL:
2972 *mode = CAMERA_ATTR_AF_NONE;
2974 case MM_CAMCORDER_FOCUS_MODE_AUTO:
2975 case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
2976 case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
2978 case MM_CAMCORDER_AUTO_FOCUS_NONE:
2979 *mode = CAMERA_ATTR_AF_NORMAL;
2981 case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
2982 *mode = CAMERA_ATTR_AF_NORMAL;
2984 case MM_CAMCORDER_AUTO_FOCUS_MACRO:
2985 *mode = CAMERA_ATTR_AF_MACRO;
2987 case MM_CAMCORDER_AUTO_FOCUS_FULL:
2988 *mode = CAMERA_ATTR_AF_FULL;
2991 *mode = CAMERA_ATTR_AF_NORMAL;
2996 *mode = CAMERA_ATTR_AF_NONE;
3001 return __convert_camera_error_code(__func__, ret);
3005 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
3007 if (camera == NULL || mode == NULL) {
3008 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3009 return CAMERA_ERROR_INVALID_PARAMETER;
3012 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3013 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3014 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3015 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3016 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3017 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3018 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3019 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3020 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3022 int ret = MM_ERROR_NONE;
3024 camera_s *handle = (camera_s *)camera;
3026 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3027 MMCAM_CAMERA_EXPOSURE_MODE, &exposure_mode,
3030 if (ret == CAMERA_ERROR_NONE) {
3031 *mode = maptable[abs(exposure_mode%9)];
3034 return __convert_camera_error_code(__func__, ret);
3038 int camera_attr_get_exposure(camera_h camera, int *value)
3040 if (camera == NULL || value == NULL) {
3041 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3042 return CAMERA_ERROR_INVALID_PARAMETER;
3045 int ret = MM_ERROR_NONE;
3046 camera_s *handle = (camera_s *)camera;
3048 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3049 MMCAM_CAMERA_EXPOSURE_VALUE, value,
3052 return __convert_camera_error_code(__func__, ret);
3056 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
3058 if (camera == NULL || min == NULL || max == NULL) {
3059 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3060 return CAMERA_ERROR_INVALID_PARAMETER;
3063 int ret = MM_ERROR_NONE;
3064 camera_s *handle = (camera_s *)camera;
3065 MMCamAttrsInfo ainfo;
3067 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
3068 if (ret == MM_ERROR_NONE) {
3069 *min = ainfo.int_range.min;
3070 *max = ainfo.int_range.max;
3073 return __convert_camera_error_code(__func__, ret);
3077 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
3079 if (camera == NULL || iso == NULL) {
3080 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3081 return CAMERA_ERROR_INVALID_PARAMETER;
3084 int ret = MM_ERROR_NONE;
3085 camera_s *handle = (camera_s *)camera;
3087 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3088 MMCAM_CAMERA_ISO, iso,
3091 return __convert_camera_error_code(__func__, ret);
3095 int camera_attr_get_brightness(camera_h camera, int *level)
3097 if (camera == NULL || level == NULL) {
3098 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3099 return CAMERA_ERROR_INVALID_PARAMETER;
3102 int ret = MM_ERROR_NONE;
3103 camera_s *handle = (camera_s *)camera;
3105 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3106 MMCAM_FILTER_BRIGHTNESS, level,
3109 return __convert_camera_error_code(__func__, ret);
3113 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
3115 if (camera == NULL || min == NULL || max == NULL) {
3116 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3117 return CAMERA_ERROR_INVALID_PARAMETER;
3120 int ret = MM_ERROR_NONE;
3121 camera_s *handle = (camera_s *)camera;
3122 MMCamAttrsInfo ainfo;
3124 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
3125 if (ret == MM_ERROR_NONE) {
3126 *min = ainfo.int_range.min;
3127 *max = ainfo.int_range.max;
3130 return __convert_camera_error_code(__func__, ret);
3134 int camera_attr_get_contrast(camera_h camera, int *level)
3136 if (camera == NULL || level == NULL) {
3137 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3138 return CAMERA_ERROR_INVALID_PARAMETER;
3141 int ret = MM_ERROR_NONE;
3142 camera_s *handle = (camera_s *)camera;
3144 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3145 MMCAM_FILTER_CONTRAST, level,
3148 return __convert_camera_error_code(__func__, ret);
3152 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
3154 if (camera == NULL || min == NULL || max == NULL) {
3155 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3156 return CAMERA_ERROR_INVALID_PARAMETER;
3159 int ret = MM_ERROR_NONE;
3160 camera_s *handle = (camera_s *)camera;
3161 MMCamAttrsInfo ainfo;
3163 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
3164 if (ret == MM_ERROR_NONE) {
3165 *min = ainfo.int_range.min;
3166 *max = ainfo.int_range.max;
3169 return __convert_camera_error_code(__func__, ret);
3173 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
3175 if (camera == NULL || wb == NULL) {
3176 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3177 return CAMERA_ERROR_INVALID_PARAMETER;
3180 int ret = MM_ERROR_NONE;
3181 camera_s *handle = (camera_s *)camera;
3183 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3184 MMCAM_FILTER_WB, wb,
3187 return __convert_camera_error_code(__func__, ret);
3191 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
3193 if (camera == NULL || effect == NULL) {
3194 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3195 return CAMERA_ERROR_INVALID_PARAMETER;
3198 int ret = MM_ERROR_NONE;
3199 camera_s *handle = (camera_s *)camera;
3201 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3202 MMCAM_FILTER_COLOR_TONE, effect,
3205 return __convert_camera_error_code(__func__, ret);
3209 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
3211 if (camera == NULL || mode == NULL) {
3212 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3213 return CAMERA_ERROR_INVALID_PARAMETER;
3216 int ret = MM_ERROR_NONE;
3217 camera_s *handle = (camera_s *)camera;
3219 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3220 MMCAM_FILTER_SCENE_MODE, mode,
3223 return __convert_camera_error_code(__func__, ret);
3227 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
3229 if (camera == NULL || enable == NULL) {
3230 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3231 return CAMERA_ERROR_INVALID_PARAMETER;
3234 int ret = MM_ERROR_NONE;
3235 camera_s *handle = (camera_s *)camera;
3237 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3238 MMCAM_TAG_ENABLE, enable,
3241 return __convert_camera_error_code(__func__, ret);
3245 int camera_attr_get_tag_image_description(camera_h camera, char **description)
3247 if (camera == NULL || description == NULL) {
3248 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3249 return CAMERA_ERROR_INVALID_PARAMETER;
3252 int ret = MM_ERROR_NONE;
3253 camera_s *handle = (camera_s *)camera;
3254 char *ndescription = NULL;
3257 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3258 MMCAM_TAG_IMAGE_DESCRIPTION, &ndescription, &desc_size,
3260 if (ret == MM_ERROR_NONE) {
3261 if (ndescription != NULL) {
3262 *description = strdup(ndescription);
3264 *description = strdup("");
3268 return __convert_camera_error_code(__func__, ret);
3272 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
3274 if (camera == NULL || orientation == NULL) {
3275 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3276 return CAMERA_ERROR_INVALID_PARAMETER;
3279 int ret = MM_ERROR_NONE;
3280 camera_s *handle = (camera_s *)camera;
3282 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3283 MMCAM_TAG_ORIENTATION, orientation,
3286 return __convert_camera_error_code(__func__, ret);
3290 int camera_attr_get_tag_software(camera_h camera, char **software)
3292 if (camera == NULL || software == NULL) {
3293 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3294 return CAMERA_ERROR_INVALID_PARAMETER;
3297 int ret = MM_ERROR_NONE;
3298 camera_s *handle = (camera_s *)camera;
3302 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3303 MMCAM_TAG_SOFTWARE, &soft, &soft_size,
3305 if (ret == MM_ERROR_NONE) {
3307 *software = strdup(soft);
3309 *software = strdup("");
3313 return __convert_camera_error_code(__func__, ret);
3317 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
3319 if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
3320 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3321 return CAMERA_ERROR_INVALID_PARAMETER;
3324 int ret = MM_ERROR_NONE;
3325 camera_s *handle = (camera_s *)camera;
3327 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3328 MMCAM_TAG_LATITUDE, latitude,
3329 MMCAM_TAG_LONGITUDE, longitude,
3330 MMCAM_TAG_ALTITUDE, altitude,
3333 return __convert_camera_error_code(__func__, ret);
3337 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
3339 if (camera == NULL || mode == NULL) {
3340 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3341 return CAMERA_ERROR_INVALID_PARAMETER;
3344 int ret = MM_ERROR_NONE;
3345 camera_s *handle = (camera_s *)camera;
3347 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3348 MMCAM_STROBE_MODE, mode,
3351 return __convert_camera_error_code(__func__, ret);
3355 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
3357 if (camera == NULL || foreach_cb == NULL) {
3358 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3359 return CAMERA_ERROR_INVALID_PARAMETER;
3362 int ret = MM_ERROR_NONE;
3364 camera_s *handle = (camera_s *)camera;
3365 MMCamAttrsInfo af_range;
3366 MMCamAttrsInfo focus_mode;
3368 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE, &af_range);
3369 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE, &focus_mode);
3370 if (ret != MM_ERROR_NONE) {
3371 return __convert_camera_error_code(__func__, ret);
3374 for (i = 0 ; i < af_range.int_array.count ; i++) {
3375 if (!foreach_cb(af_range.int_array.array[i], user_data)) {
3380 return CAMERA_ERROR_NONE;
3384 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
3386 if (camera == NULL || foreach_cb == NULL) {
3387 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3388 return CAMERA_ERROR_INVALID_PARAMETER;
3391 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3392 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3393 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3394 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3395 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3396 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3397 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3398 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3399 -1 /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3402 int ret = MM_ERROR_NONE;
3403 camera_s *handle = (camera_s *)camera;
3404 MMCamAttrsInfo info;
3406 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE, &info);
3407 if (ret != MM_ERROR_NONE) {
3408 return __convert_camera_error_code(__func__, ret);
3411 for (i = 0 ; i < info.int_array.count ; i++) {
3412 if (info.int_array.array[i] >= MM_CAMCORDER_AUTO_EXPOSURE_OFF &&
3413 info.int_array.array[i] <= MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2) {
3414 if (maptable[info.int_array.array[i]] != -1) {
3415 if (!foreach_cb(maptable[info.int_array.array[i]], user_data)) {
3420 LOGW("unknown value %d", info.int_array.array[i]);
3424 return CAMERA_ERROR_NONE;
3428 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
3430 if (camera == NULL || foreach_cb == NULL) {
3431 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3432 return CAMERA_ERROR_INVALID_PARAMETER;
3436 int ret = MM_ERROR_NONE;
3437 camera_s *handle = (camera_s *)camera;
3438 MMCamAttrsInfo info;
3440 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO, &info);
3441 if (ret != MM_ERROR_NONE) {
3442 return __convert_camera_error_code(__func__, ret);
3445 for (i = 0 ; i < info.int_array.count ; i++) {
3446 if (!foreach_cb(info.int_array.array[i], user_data)) {
3451 return CAMERA_ERROR_NONE;
3455 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
3457 if (camera == NULL || foreach_cb == NULL) {
3458 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3459 return CAMERA_ERROR_INVALID_PARAMETER;
3463 int ret = MM_ERROR_NONE;
3464 camera_s *handle = (camera_s *)camera;
3465 MMCamAttrsInfo info;
3467 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB, &info);
3468 if (ret != MM_ERROR_NONE) {
3469 return __convert_camera_error_code(__func__, ret);
3472 for (i = 0 ; i < info.int_array.count ; i++) {
3473 if (!foreach_cb(info.int_array.array[i], user_data)) {
3478 return CAMERA_ERROR_NONE;
3482 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
3484 if (camera == NULL || foreach_cb == NULL) {
3485 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3486 return CAMERA_ERROR_INVALID_PARAMETER;
3490 int ret = MM_ERROR_NONE;
3491 camera_s *handle = (camera_s *)camera;
3492 MMCamAttrsInfo info;
3494 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE, &info);
3495 if (ret != MM_ERROR_NONE) {
3496 return __convert_camera_error_code(__func__, ret);
3499 for (i = 0 ; i < info.int_array.count ; i++) {
3500 if (!foreach_cb(info.int_array.array[i], user_data)) {
3505 return CAMERA_ERROR_NONE;
3509 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
3511 if (camera == NULL || foreach_cb == NULL) {
3512 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3513 return CAMERA_ERROR_INVALID_PARAMETER;
3517 int ret = MM_ERROR_NONE;
3518 camera_s *handle = (camera_s *)camera;
3519 MMCamAttrsInfo info;
3521 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE, &info);
3522 if (ret != MM_ERROR_NONE) {
3523 return __convert_camera_error_code(__func__, ret);
3526 for (i = 0 ; i < info.int_array.count ; i++) {
3527 if (!foreach_cb(info.int_array.array[i], user_data)) {
3532 return CAMERA_ERROR_NONE;
3536 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
3538 if (camera == NULL || foreach_cb == NULL) {
3539 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3540 return CAMERA_ERROR_INVALID_PARAMETER;
3544 int ret = MM_ERROR_NONE;
3545 camera_s *handle = (camera_s *)camera;
3546 MMCamAttrsInfo info;
3548 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE, &info);
3549 if (ret != MM_ERROR_NONE) {
3550 return __convert_camera_error_code(__func__, ret);
3553 for (i = 0 ; i < info.int_array.count ; i++) {
3554 if (!foreach_cb(info.int_array.array[i], user_data)) {
3559 return CAMERA_ERROR_NONE;
3563 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
3565 if (camera == NULL || foreach_cb == NULL) {
3566 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3567 return CAMERA_ERROR_INVALID_PARAMETER;
3570 int ret = MM_ERROR_NONE;
3571 camera_s *handle = (camera_s *)camera;
3572 MMCamAttrsInfo info;
3577 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3578 MMCAM_CAMERA_WIDTH, &width,
3579 MMCAM_CAMERA_HEIGHT, &height,
3581 if (ret != MM_ERROR_NONE) {
3582 return __convert_camera_error_code(__func__, ret);
3585 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3586 if (ret != MM_ERROR_NONE) {
3587 return __convert_camera_error_code(__func__, ret);
3590 for (i = 0 ; i < info.int_array.count ; i++) {
3591 if (!foreach_cb(info.int_array.array[i], user_data)) {
3596 return CAMERA_ERROR_NONE;
3600 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)
3602 if (camera == NULL || foreach_cb == NULL) {
3603 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3604 return CAMERA_ERROR_INVALID_PARAMETER;
3607 int ret = MM_ERROR_NONE;
3608 camera_s *handle = (camera_s *)camera;
3609 MMCamAttrsInfo info;
3612 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3613 if (ret != MM_ERROR_NONE) {
3614 return __convert_camera_error_code(__func__, ret);
3617 for (i = 0 ; i < info.int_array.count ; i++) {
3618 if (!foreach_cb(info.int_array.array[i], user_data)) {
3623 return CAMERA_ERROR_NONE;
3627 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
3629 if (camera == NULL || foreach_cb == NULL) {
3630 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3631 return CAMERA_ERROR_INVALID_PARAMETER;
3635 int ret = MM_ERROR_NONE;
3636 camera_s *handle = (camera_s *)camera;
3637 MMCamAttrsInfo info;
3639 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FLIP, &info);
3640 if (ret != MM_ERROR_NONE) {
3641 return __convert_camera_error_code(__func__, ret);
3644 for (i = 0 ; i < info.int_array.count ; i++) {
3645 if (!foreach_cb(info.int_array.array[i], user_data)) {
3650 return CAMERA_ERROR_NONE;
3654 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
3656 if (camera == NULL || foreach_cb == NULL) {
3657 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3658 return CAMERA_ERROR_INVALID_PARAMETER;
3662 int ret = MM_ERROR_NONE;
3663 camera_s *handle = (camera_s *)camera;
3664 MMCamAttrsInfo info;
3666 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ROTATION, &info);
3667 if (ret != MM_ERROR_NONE) {
3668 return __convert_camera_error_code(__func__, ret);
3671 for (i = 0 ; i < info.int_array.count ; i++) {
3672 if (!foreach_cb(info.int_array.array[i], user_data)) {
3677 return CAMERA_ERROR_NONE;
3681 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
3683 if (camera == NULL) {
3684 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3685 return CAMERA_ERROR_INVALID_PARAMETER;
3688 if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
3689 LOGE("INVALID_PARAMETER - %d", rotation);
3690 return CAMERA_ERROR_INVALID_PARAMETER;
3693 int ret = MM_ERROR_NONE;
3694 camera_s *handle = (camera_s *)camera;
3696 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3697 MMCAM_CAMERA_ROTATION, rotation,
3700 return __convert_camera_error_code(__func__, ret);
3704 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
3706 if (camera == NULL || rotation == NULL) {
3707 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3708 return CAMERA_ERROR_INVALID_PARAMETER;
3711 int ret = MM_ERROR_NONE;
3712 camera_s *handle = (camera_s *)camera;
3714 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3715 MMCAM_CAMERA_ROTATION, rotation,
3718 return __convert_camera_error_code(__func__, ret);
3722 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
3724 if (camera == NULL) {
3725 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3726 return CAMERA_ERROR_INVALID_PARAMETER;
3729 if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
3730 LOGE("INVALID_PARAMETER - %d", flip);
3731 return CAMERA_ERROR_INVALID_PARAMETER;
3734 int ret = MM_ERROR_NONE;
3735 camera_s *handle = (camera_s *)camera;
3737 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3738 MMCAM_CAMERA_FLIP, flip,
3741 return __convert_camera_error_code(__func__, ret);
3745 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
3747 if (camera == NULL || flip == NULL) {
3748 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3749 return CAMERA_ERROR_INVALID_PARAMETER;
3752 int ret = MM_ERROR_NONE;
3753 camera_s *handle = (camera_s *)camera;
3755 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3756 MMCAM_CAMERA_FLIP, flip,
3759 return __convert_camera_error_code(__func__, ret);
3763 int _camera_set_use(camera_h camera, bool used)
3765 camera_s *handle = (camera_s *)camera;
3767 if (handle == NULL) {
3768 LOGE("handle is NULL");
3769 return CAMERA_ERROR_INVALID_PARAMETER;
3772 handle->is_used_in_recorder = used;
3774 return CAMERA_ERROR_NONE;
3778 bool _camera_is_used(camera_h camera)
3780 camera_s *handle = (camera_s *)camera;
3782 if (handle == NULL) {
3783 LOGE("handle is NULL");
3787 return handle->is_used_in_recorder;
3791 int _camera_get_mm_handle(camera_h camera, MMHandleType *handle)
3793 if (camera == NULL || handle == NULL) {
3794 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3795 return CAMERA_ERROR_INVALID_PARAMETER;
3798 camera_s *camera_handle = (camera_s*)camera;
3800 *handle = camera_handle->mm_handle;
3802 return CAMERA_ERROR_NONE;
3806 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data)
3808 if( camera == NULL ){
3809 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3810 return CAMERA_ERROR_INVALID_PARAMETER;
3813 camera_s *handle = (camera_s *)camera;
3814 handle->relay_message_callback = callback;
3815 handle->relay_user_data = user_data;
3817 return CAMERA_ERROR_NONE;
3821 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
3823 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3824 in_format >= MM_PIXEL_FORMAT_NUM ||
3825 out_format == NULL) {
3826 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
3827 return CAMERA_ERROR_INVALID_PARAMETER;
3830 switch (in_format) {
3831 case MM_PIXEL_FORMAT_NV12:
3832 case MM_PIXEL_FORMAT_NV12T:
3833 *out_format = TBM_FORMAT_NV12;
3835 case MM_PIXEL_FORMAT_NV16:
3836 *out_format = TBM_FORMAT_NV16;
3838 case MM_PIXEL_FORMAT_NV21:
3839 *out_format = TBM_FORMAT_NV21;
3841 case MM_PIXEL_FORMAT_YUYV:
3842 *out_format = TBM_FORMAT_YUYV;
3844 case MM_PIXEL_FORMAT_UYVY:
3845 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3846 *out_format = TBM_FORMAT_UYVY;
3848 case MM_PIXEL_FORMAT_422P:
3849 *out_format = TBM_FORMAT_YUV422;
3851 case MM_PIXEL_FORMAT_I420:
3852 *out_format = TBM_FORMAT_YUV420;
3854 case MM_PIXEL_FORMAT_YV12:
3855 *out_format = TBM_FORMAT_YVU420;
3857 case MM_PIXEL_FORMAT_RGB565:
3858 *out_format = TBM_FORMAT_RGB565;
3860 case MM_PIXEL_FORMAT_RGB888:
3861 *out_format = TBM_FORMAT_RGB888;
3863 case MM_PIXEL_FORMAT_RGBA:
3864 *out_format = TBM_FORMAT_RGBA8888;
3866 case MM_PIXEL_FORMAT_ARGB:
3867 *out_format = TBM_FORMAT_ARGB8888;
3870 LOGE("invalid in_format %d", in_format);
3871 return CAMERA_ERROR_INVALID_PARAMETER;
3874 return CAMERA_ERROR_NONE;
3878 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
3880 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3881 in_format >= MM_PIXEL_FORMAT_NUM ||
3883 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
3884 return CAMERA_ERROR_INVALID_PARAMETER;
3887 switch (in_format) {
3888 case MM_PIXEL_FORMAT_NV12:
3889 case MM_PIXEL_FORMAT_NV12T:
3890 *mimetype = MEDIA_FORMAT_NV12;
3892 case MM_PIXEL_FORMAT_NV16:
3893 *mimetype = MEDIA_FORMAT_NV16;
3895 case MM_PIXEL_FORMAT_NV21:
3896 *mimetype = MEDIA_FORMAT_NV21;
3898 case MM_PIXEL_FORMAT_YUYV:
3899 *mimetype = MEDIA_FORMAT_YUYV;
3901 case MM_PIXEL_FORMAT_UYVY:
3902 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3903 *mimetype = MEDIA_FORMAT_UYVY;
3905 case MM_PIXEL_FORMAT_422P:
3906 *mimetype = MEDIA_FORMAT_422P;
3908 case MM_PIXEL_FORMAT_I420:
3909 *mimetype = MEDIA_FORMAT_I420;
3911 case MM_PIXEL_FORMAT_YV12:
3912 *mimetype = MEDIA_FORMAT_YV12;
3914 case MM_PIXEL_FORMAT_RGB565:
3915 *mimetype = MEDIA_FORMAT_RGB565;
3917 case MM_PIXEL_FORMAT_RGB888:
3918 *mimetype = MEDIA_FORMAT_RGB888;
3920 case MM_PIXEL_FORMAT_RGBA:
3921 *mimetype = MEDIA_FORMAT_RGBA;
3923 case MM_PIXEL_FORMAT_ARGB:
3924 *mimetype = MEDIA_FORMAT_ARGB;
3927 LOGE("invalid in_format %d", in_format);
3928 return CAMERA_ERROR_INVALID_PARAMETER;
3931 return CAMERA_ERROR_NONE;
3935 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
3938 void *internal_buffer = NULL;
3939 tbm_surface_h tsurf = NULL;
3941 if (pkt == NULL || user_data == NULL) {
3942 LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
3943 return MEDIA_PACKET_FINALIZE;
3946 ret = media_packet_get_extra(pkt, &internal_buffer);
3947 if (ret != MEDIA_PACKET_ERROR_NONE) {
3948 LOGE("media_packet_get_extra failed 0x%x", ret);
3949 return MEDIA_PACKET_FINALIZE;
3952 /*LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret);*/
3954 if (internal_buffer) {
3955 gst_buffer_unref((GstBuffer *)internal_buffer);
3956 internal_buffer = NULL;
3959 ret = media_packet_get_tbm_surface(pkt, &tsurf);
3960 if (ret != MEDIA_PACKET_ERROR_NONE) {
3961 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
3962 return MEDIA_PACKET_FINALIZE;
3966 tbm_surface_destroy(tsurf);
3970 return MEDIA_PACKET_FINALIZE;
3974 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
3976 if (camera == NULL) {
3977 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3978 return CAMERA_ERROR_INVALID_PARAMETER;
3981 if (camera_attr_is_supported_hdr_capture(camera) == false) {
3982 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3983 return CAMERA_ERROR_NOT_SUPPORTED;
3986 int ret = MM_ERROR_NONE;
3987 camera_s *handle = (camera_s *)camera;
3989 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3990 MMCAM_CAMERA_HDR_CAPTURE, mode,
3993 if (ret == MM_ERROR_NONE) {
3994 if (mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL) {
3995 handle->hdr_keep_mode = true;
3997 handle->hdr_keep_mode = false;
4001 return __convert_camera_error_code(__func__, ret);
4005 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
4007 if (camera == NULL) {
4008 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4009 return CAMERA_ERROR_INVALID_PARAMETER;
4012 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4013 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4014 return CAMERA_ERROR_NOT_SUPPORTED;
4018 LOGE("INVALID_PARAMETER(0x%08x) - mode", CAMERA_ERROR_INVALID_PARAMETER);
4019 return CAMERA_ERROR_INVALID_PARAMETER;
4022 int ret = MM_ERROR_NONE;
4023 camera_s *handle = (camera_s *)camera;
4025 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4026 MMCAM_CAMERA_HDR_CAPTURE, mode,
4029 return __convert_camera_error_code(__func__, ret);
4033 bool camera_attr_is_supported_hdr_capture(camera_h camera)
4035 if (camera == NULL) {
4036 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4040 int ret = MM_ERROR_NONE;
4042 camera_s *handle = (camera_s *)camera;
4043 MMCamAttrsInfo hdr_info;
4045 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE, &hdr_info);
4046 set_last_result(__convert_camera_error_code(__func__, ret));
4047 if (ret != MM_ERROR_NONE) {
4048 LOGE("MMCAM_CAMERA_HDR_CAPTURE get attr info failed");
4052 for (i = 0; i < hdr_info.int_array.count ; i++) {
4053 if (hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON) {
4054 LOGD("HDR capture supported");
4059 LOGD("HDR capture NOT supported");
4065 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
4067 if (camera == NULL) {
4068 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4069 return CAMERA_ERROR_INVALID_PARAMETER;
4072 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4073 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4074 return CAMERA_ERROR_NOT_SUPPORTED;
4077 if (callback == NULL) {
4078 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
4079 return CAMERA_ERROR_INVALID_PARAMETER;
4082 camera_s *handle = (camera_s *)camera;
4084 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)callback;
4085 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)user_data;
4087 return CAMERA_ERROR_NONE;
4091 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
4093 if (camera == NULL) {
4094 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4095 return CAMERA_ERROR_INVALID_PARAMETER;
4098 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4099 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4100 return CAMERA_ERROR_NOT_SUPPORTED;
4103 camera_s *handle = (camera_s *)camera;
4105 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4106 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4108 return CAMERA_ERROR_NONE;
4112 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
4114 if (camera == NULL) {
4115 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4116 return CAMERA_ERROR_INVALID_PARAMETER;
4119 if (camera_attr_is_supported_anti_shake(camera) == false) {
4120 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4121 return CAMERA_ERROR_NOT_SUPPORTED;
4124 int ret = MM_ERROR_NONE;
4125 int mode = MM_CAMCORDER_AHS_OFF;
4126 camera_s *handle = (camera_s *)camera;
4129 mode = MM_CAMCORDER_AHS_ON;
4132 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4133 MMCAM_CAMERA_ANTI_HANDSHAKE, mode,
4136 return __convert_camera_error_code(__func__, ret);
4140 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
4142 if (camera == NULL) {
4143 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4144 return CAMERA_ERROR_INVALID_PARAMETER;
4147 if (camera_attr_is_supported_anti_shake(camera) == false) {
4148 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4149 return CAMERA_ERROR_NOT_SUPPORTED;
4152 if (enabled == NULL) {
4153 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4154 return CAMERA_ERROR_INVALID_PARAMETER;
4157 int ret = MM_ERROR_NONE;
4158 camera_s *handle = (camera_s *)camera;
4160 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4161 MMCAM_CAMERA_ANTI_HANDSHAKE, enabled,
4164 return __convert_camera_error_code(__func__, ret);
4168 bool camera_attr_is_supported_anti_shake(camera_h camera)
4170 if (camera == NULL) {
4171 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4176 int ret = MM_ERROR_NONE;
4177 camera_s *handle = (camera_s *)camera;
4178 MMCamAttrsInfo ash_info;
4180 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE, &ash_info);
4181 set_last_result(__convert_camera_error_code(__func__, ret));
4182 if (ret != MM_ERROR_NONE) {
4183 LOGE("MMCAM_CAMERA_ANTI_HANDSHAKE get attr info failed");
4187 for (i = 0 ; i < ash_info.int_array.count ; i++) {
4188 if (ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON) {
4197 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
4199 if (camera == NULL) {
4200 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4201 return CAMERA_ERROR_INVALID_PARAMETER;
4204 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4205 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4206 return CAMERA_ERROR_NOT_SUPPORTED;
4209 int ret = MM_ERROR_NONE;
4210 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4211 camera_s *handle = (camera_s*)camera;
4214 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
4217 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4218 MMCAM_CAMERA_VIDEO_STABILIZATION, mode,
4221 return __convert_camera_error_code(__func__, ret);
4225 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
4227 if (camera == NULL) {
4228 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4229 return CAMERA_ERROR_INVALID_PARAMETER;
4232 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4233 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4234 return CAMERA_ERROR_NOT_SUPPORTED;
4237 if (enabled == NULL) {
4238 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4239 return CAMERA_ERROR_INVALID_PARAMETER;
4242 int ret = MM_ERROR_NONE;
4243 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4244 camera_s *handle = (camera_s *)camera;
4246 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4247 MMCAM_CAMERA_VIDEO_STABILIZATION, &mode,
4249 if (ret == MM_ERROR_NONE) {
4250 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
4253 return __convert_camera_error_code(__func__, ret);
4257 bool camera_attr_is_supported_video_stabilization(camera_h camera)
4259 if (camera == NULL) {
4260 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4265 int ret = MM_ERROR_NONE;
4266 camera_s *handle = (camera_s *)camera;
4267 MMCamAttrsInfo vs_info;
4269 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION, &vs_info);
4270 set_last_result(__convert_camera_error_code(__func__, ret));
4271 if (ret != MM_ERROR_NONE) {
4272 LOGE("MMCAM_CAMERA_VIDEO_STABILIZATION get attr info failed");
4276 for (i = 0 ; i < vs_info.int_array.count ; i++) {
4277 if (vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
4286 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
4288 if (camera == NULL) {
4289 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4290 return CAMERA_ERROR_INVALID_PARAMETER;
4293 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4294 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4295 return CAMERA_ERROR_NOT_SUPPORTED;
4298 int ret = MM_ERROR_NONE;
4299 int mode = MM_CAMCORDER_WDR_OFF;
4300 camera_s *handle = (camera_s *)camera;
4303 mode = MM_CAMCORDER_WDR_ON;
4306 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4307 MMCAM_CAMERA_WDR, mode,
4310 return __convert_camera_error_code(__func__, ret);
4314 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
4316 if (camera == NULL) {
4317 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4318 return CAMERA_ERROR_INVALID_PARAMETER;
4321 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4322 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4323 return CAMERA_ERROR_NOT_SUPPORTED;
4326 if (enabled == NULL) {
4327 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4328 return CAMERA_ERROR_INVALID_PARAMETER;
4331 int ret = MM_ERROR_NONE;
4332 int mode = MM_CAMCORDER_WDR_OFF;
4333 camera_s *handle = (camera_s *)camera;
4335 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4336 MMCAM_CAMERA_WDR, &mode,
4339 if (ret == MM_ERROR_NONE) {
4343 return __convert_camera_error_code(__func__, ret);
4347 bool camera_attr_is_supported_auto_contrast(camera_h camera)
4349 if (camera == NULL) {
4350 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4355 int ret = MM_ERROR_NONE;
4356 camera_s *handle = (camera_s *)camera;
4357 MMCamAttrsInfo info;
4359 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WDR, &info);
4360 set_last_result(__convert_camera_error_code(__func__, ret));
4361 if (ret != MM_ERROR_NONE) {
4362 LOGE("MMCAM_CAMERA_WDR get attr info failed");
4366 for (i = 0 ; i < info.int_array.count ; i++) {
4367 if (info.int_array.array[i] == MM_CAMCORDER_WDR_ON) {
4376 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
4378 if (camera == NULL) {
4379 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4380 return CAMERA_ERROR_INVALID_PARAMETER;
4383 int ret = MM_ERROR_NONE;
4384 camera_s *handle = (camera_s *)camera;
4386 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4387 "capture-sound-enable", !disable,
4389 if (ret != MM_ERROR_NONE) {
4390 LOGE("CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound");
4391 return CAMERA_ERROR_INVALID_OPERATION;
4394 return CAMERA_ERROR_NONE;