2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <audio-session-manager-types.h>
23 #include <mm_camcorder.h>
27 #include <camera_private.h>
31 #include <tbm_bufmgr.h>
32 #include <tbm_surface_internal.h>
35 #include <Elementary.h>
40 #define LOG_TAG "TIZEN_N_CAMERA"
42 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType *stream, void *user_data);
43 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data);
46 void _camera_remove_cb_message(camera_s *handle)
50 camera_cb_data *cb_data = NULL;
53 LOGE("handle is NULL");
59 g_mutex_lock(&handle->idle_cb_lock);
61 if (handle->cb_data_list) {
62 list = handle->cb_data_list;
66 list = g_list_next(list);
69 LOGW("cb_data is NULL");
71 ret = g_idle_remove_by_data (cb_data);
72 LOGW("Remove cb_data[%p]. ret[%d]", cb_data, ret);
74 handle->cb_data_list = g_list_remove(handle->cb_data_list, cb_data);
80 g_list_free(handle->cb_data_list);
81 handle->cb_data_list = NULL;
83 LOGW("There is no remained callback");
86 g_mutex_unlock(&handle->idle_cb_lock);
94 int __convert_camera_error_code(const char *func, int code)
96 int ret = CAMERA_ERROR_NONE;
97 const char *errorstr = NULL;
101 ret = CAMERA_ERROR_NONE;
102 errorstr = "ERROR_NONE";
104 case MM_ERROR_CAMCORDER_INVALID_ARGUMENT:
105 case MM_ERROR_COMMON_INVALID_ATTRTYPE:
106 ret = CAMERA_ERROR_INVALID_PARAMETER;
107 errorstr = "INVALID_PARAMETER";
109 case MM_ERROR_CAMCORDER_NOT_INITIALIZED:
110 case MM_ERROR_CAMCORDER_INVALID_STATE:
111 ret = CAMERA_ERROR_INVALID_STATE;
112 errorstr = "INVALID_STATE";
114 case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND:
115 ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
116 errorstr = "DEVICE_NOT_FOUND";
118 case MM_ERROR_CAMCORDER_DEVICE_BUSY:
119 case MM_ERROR_CAMCORDER_DEVICE_OPEN:
120 case MM_ERROR_CAMCORDER_CMD_IS_RUNNING:
121 ret = CAMERA_ERROR_DEVICE_BUSY;
122 errorstr = "DEVICE_BUSY";
124 case MM_ERROR_CAMCORDER_DEVICE:
125 case MM_ERROR_CAMCORDER_DEVICE_IO:
126 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
127 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
128 case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER:
129 ret = CAMERA_ERROR_DEVICE;
130 errorstr = "ERROR_DEVICE";
132 case MM_ERROR_CAMCORDER_GST_CORE:
133 case MM_ERROR_CAMCORDER_GST_LIBRARY:
134 case MM_ERROR_CAMCORDER_GST_RESOURCE:
135 case MM_ERROR_CAMCORDER_GST_STREAM:
136 case MM_ERROR_CAMCORDER_GST_STATECHANGE:
137 case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
138 case MM_ERROR_CAMCORDER_GST_LINK:
139 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
140 case MM_ERROR_CAMCORDER_ENCODER:
141 case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
142 case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE:
143 case MM_ERROR_CAMCORDER_ENCODER_WORKING:
144 case MM_ERROR_CAMCORDER_INTERNAL:
145 case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT:
146 case MM_ERROR_CAMCORDER_DSP_FAIL:
147 case MM_ERROR_CAMCORDER_AUDIO_EMPTY:
148 case MM_ERROR_CAMCORDER_CREATE_CONFIGURE:
149 case MM_ERROR_CAMCORDER_FILE_SIZE_OVER:
150 case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF:
151 case MM_ERROR_CAMCORDER_INVALID_CONDITION:
152 ret = CAMERA_ERROR_INVALID_OPERATION;
153 errorstr = "INVALID_OPERATION";
155 case MM_ERROR_CAMCORDER_RESOURCE_CREATION:
156 case MM_ERROR_COMMON_OUT_OF_MEMORY:
157 ret = CAMERA_ERROR_OUT_OF_MEMORY;
158 errorstr = "OUT_OF_MEMORY";
160 case MM_ERROR_POLICY_BLOCKED:
161 ret = CAMERA_ERROR_SOUND_POLICY;
162 errorstr = "ERROR_SOUND_POLICY";
164 case MM_ERROR_POLICY_BLOCKED_BY_CALL:
165 ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
166 errorstr = "ERROR_SOUND_POLICY_BY_CALL";
168 case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
169 ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
170 errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
172 case MM_ERROR_POLICY_RESTRICTED:
173 ret = CAMERA_ERROR_SECURITY_RESTRICTED;
174 errorstr = "ERROR_RESTRICTED";
176 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
177 ret = CAMERA_ERROR_ESD;
178 errorstr = "ERROR_ESD";
180 case MM_ERROR_COMMON_INVALID_PERMISSION:
181 ret = CAMERA_ERROR_PERMISSION_DENIED;
182 errorstr = "ERROR_PERMISSION_DENIED";
184 case MM_ERROR_COMMON_OUT_OF_ARRAY:
185 case MM_ERROR_COMMON_OUT_OF_RANGE:
186 case MM_ERROR_COMMON_ATTR_NOT_EXIST:
187 case MM_ERROR_CAMCORDER_NOT_SUPPORTED:
188 ret = CAMERA_ERROR_NOT_SUPPORTED;
189 errorstr = "ERROR_NOT_SUPPORTED";
192 ret = CAMERA_ERROR_INVALID_OPERATION;
193 errorstr = "INVALID_OPERATION";
196 if (code != MM_ERROR_NONE) {
197 LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func ? func : "NULL_FUNC", errorstr, ret, code);
204 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType *stream, void *user_data)
206 if (user_data == NULL || stream == NULL) {
210 camera_s *handle = (camera_s *)user_data;
212 if (handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW]) {
213 camera_preview_data_s frame;
215 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
216 frame.format = MM_PIXEL_FORMAT_UYVY;
218 frame.format = stream->format;
220 frame.width = stream->width;
221 frame.height = stream->height;
222 frame.timestamp = stream->timestamp;
223 frame.num_of_planes = stream->num_planes;
225 switch (stream->data_type) {
226 case MM_CAM_STREAM_DATA_YUV420:
227 frame.data.single_plane.yuv = stream->data.yuv420.yuv;
228 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
230 case MM_CAM_STREAM_DATA_YUV422:
231 frame.data.single_plane.yuv = stream->data.yuv422.yuv;
232 frame.data.single_plane.size = stream->data.yuv422.length_yuv;
234 case MM_CAM_STREAM_DATA_YUV420SP:
235 frame.data.double_plane.y = stream->data.yuv420sp.y;
236 frame.data.double_plane.uv = stream->data.yuv420sp.uv;
237 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
238 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
240 case MM_CAM_STREAM_DATA_YUV420P:
241 frame.data.triple_plane.y = stream->data.yuv420p.y;
242 frame.data.triple_plane.u = stream->data.yuv420p.u;
243 frame.data.triple_plane.v = stream->data.yuv420p.v;
244 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
245 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
246 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
248 case MM_CAM_STREAM_DATA_YUV422P:
249 frame.data.triple_plane.y = stream->data.yuv422p.y;
250 frame.data.triple_plane.u = stream->data.yuv422p.u;
251 frame.data.triple_plane.v = stream->data.yuv422p.v;
252 frame.data.triple_plane.y_size = stream->data.yuv422p.length_y;
253 frame.data.triple_plane.u_size = stream->data.yuv422p.length_u;
254 frame.data.triple_plane.v_size = stream->data.yuv422p.length_v;
260 ((camera_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW])(&frame, handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW]);
263 if (handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
264 media_packet_h pkt = NULL;
265 tbm_surface_h tsurf = NULL;
266 uint32_t bo_format = 0;
270 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
271 bool make_pkt_fmt = false;
272 tbm_surface_info_s tsurf_info;
274 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
276 /* create tbm surface */
277 for (i = 0, bo_num = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++) {
281 tsurf_info.planes[i].stride = stream->stride[i];
284 /* get tbm surface format */
285 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
286 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
288 if (bo_num > 0 && ret == CAMERA_ERROR_NONE) {
289 tsurf_info.width = stream->width;
290 tsurf_info.height = stream->height;
291 tsurf_info.format = bo_format;
292 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
293 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
296 case TBM_FORMAT_NV12:
297 case TBM_FORMAT_NV21:
298 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
299 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
300 tsurf_info.planes[0].offset = 0;
302 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
304 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
306 case TBM_FORMAT_YUV420:
307 case TBM_FORMAT_YVU420:
308 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
309 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
310 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
311 tsurf_info.planes[0].offset = 0;
313 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
314 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
316 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
318 case TBM_FORMAT_UYVY:
319 case TBM_FORMAT_YUYV:
320 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
321 tsurf_info.planes[0].offset = 0;
322 tsurf_info.size = tsurf_info.planes[0].size;
328 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, (tbm_bo *)stream->bo, bo_num);
329 /*LOGD("tbm surface %p", tsurf);*/
333 /* check media packet format */
334 if (handle->pkt_fmt) {
335 int pkt_fmt_width = 0;
336 int pkt_fmt_height = 0;
337 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
339 media_format_get_video_info(handle->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
340 if (pkt_fmt_mimetype != mimetype ||
341 pkt_fmt_width != stream->width ||
342 pkt_fmt_height != stream->height) {
343 LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
344 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
345 media_format_unref(handle->pkt_fmt);
346 handle->pkt_fmt = NULL;
353 /* create packet format */
355 LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
356 ret = media_format_create(&handle->pkt_fmt);
357 if (ret == MEDIA_FORMAT_ERROR_NONE) {
358 ret = media_format_set_video_mime(handle->pkt_fmt, mimetype);
359 ret |= media_format_set_video_width(handle->pkt_fmt, stream->width);
360 ret |= media_format_set_video_height(handle->pkt_fmt, stream->height);
361 LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
363 LOGW("media_format_create failed");
367 /* create media packet */
368 ret = media_packet_create_from_tbm_surface(handle->pkt_fmt, tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize, (void *)handle, &pkt);
369 if (ret != MEDIA_PACKET_ERROR_NONE) {
370 LOGE("media_packet_create_from_tbm_surface failed");
372 tbm_surface_destroy(tsurf);
376 LOGE("failed to create tbm surface %dx%d, format %d, bo_num %d", stream->width, stream->height, stream->format, bo_num);
380 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
382 /* set internal buffer */
383 ret = media_packet_set_extra(pkt, stream->internal_buffer);
384 if (ret != MEDIA_PACKET_ERROR_NONE) {
385 LOGE("media_packet_set_extra failed");
387 media_packet_destroy(pkt);
390 /* set timestamp : msec -> nsec */
391 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE) {
392 LOGW("media_packet_set_pts failed");
395 /* increase ref count of gst buffer */
396 gst_buffer_ref((GstBuffer *)stream->internal_buffer);
398 /* call media packet callback */
399 ((camera_media_packet_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt, handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
408 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data)
410 if (user_data == NULL || frame == NULL) {
414 camera_s *handle = (camera_s *)user_data;
415 int ret = MM_ERROR_NONE;
416 unsigned char *exif = NULL;
418 MMCamcorderCaptureDataType *scrnl = NULL;
421 handle->current_capture_count++;
423 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE]) {
424 camera_image_data_s image = { NULL, 0, 0, 0, 0, NULL, 0 };
425 camera_image_data_s thumb = { NULL, 0, 0, 0, 0, NULL, 0 };
426 camera_image_data_s postview = { NULL, 0, 0, 0, 0, NULL, 0 };
429 image.data = frame->data;
430 image.size = frame->length;
431 image.width = frame->width;
432 image.height = frame->height;
433 image.format = frame->format;
435 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
436 "captured-exif-raw-data", &exif, &exif_size,
438 if (ret == MM_ERROR_NONE) {
440 image.exif_size = exif_size;
445 thumb.data = thumbnail->data;
446 thumb.size = thumbnail->length;
447 thumb.width = thumbnail->width;
448 thumb.height = thumbnail->height;
449 thumb.format = thumbnail->format;
452 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
453 "captured-screennail", &scrnl, &scrnl_size,
455 if (ret == MM_ERROR_NONE && scrnl) {
456 postview.data = scrnl->data;
457 postview.size = scrnl->length;
458 postview.width = scrnl->width;
459 postview.height = scrnl->height;
460 postview.format = scrnl->format;
463 ((camera_capturing_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE])(&image,
464 scrnl ? &postview : NULL,
465 thumbnail ? &thumb : NULL,
466 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE]);
469 /* update captured state */
470 if (handle->capture_count == 1 && handle->hdr_keep_mode) {
471 if (handle->current_capture_count == 2) {
472 handle->is_capture_completed = true;
474 } else if (handle->capture_count == handle->current_capture_count ||
475 handle->is_continuous_shot_break) {
476 handle->is_capture_completed = true;
483 static camera_state_e __camera_state_convert(MMCamcorderStateType mm_state)
485 camera_state_e state = CAMERA_STATE_NONE;
488 case MM_CAMCORDER_STATE_NONE:
489 state = CAMERA_STATE_NONE;
491 case MM_CAMCORDER_STATE_NULL:
492 state = CAMERA_STATE_CREATED;
494 case MM_CAMCORDER_STATE_READY:
495 state = CAMERA_STATE_CREATED;
497 case MM_CAMCORDER_STATE_PREPARE:
498 state = CAMERA_STATE_PREVIEW;
500 case MM_CAMCORDER_STATE_CAPTURING:
501 state = CAMERA_STATE_CAPTURING;
503 case MM_CAMCORDER_STATE_RECORDING:
504 state = CAMERA_STATE_PREVIEW;
506 case MM_CAMCORDER_STATE_PAUSED:
507 state = CAMERA_STATE_PREVIEW;
510 state = CAMERA_STATE_NONE;
518 static int __mm_camera_message_callback(int message, void *param, void *user_data)
520 if (user_data == NULL || param == NULL) {
525 int camera_error = 0;
526 camera_s *handle = (camera_s *)user_data;
527 MMMessageParamType *m = (MMMessageParamType *)param;
528 camera_state_e previous_state;
529 camera_policy_e policy = CAMERA_POLICY_NONE;
530 MMCamRecordingReport *report = NULL;
531 MMCamFaceDetectInfo *cam_fd_info = NULL;
533 if (handle->relay_message_callback) {
534 handle->relay_message_callback(message, param, handle->relay_user_data);
538 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
539 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
540 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
541 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED &&
542 (m->state.previous < MM_CAMCORDER_STATE_NONE ||
543 m->state.previous > MM_CAMCORDER_STATE_PAUSED ||
544 m->state.code != 0)) {
545 LOGI( "Invalid state changed message");
549 previous_state = handle->state;
550 handle->state = __camera_state_convert(m->state.current );
552 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
553 switch (m->state.code) {
554 case ASM_EVENT_SOURCE_CALL_START:
555 case ASM_EVENT_SOURCE_CALL_END:
556 policy = CAMERA_POLICY_SOUND_BY_CALL;
557 LOGW("CAMERA_POLICY_SOUND_BY_CALL");
559 case ASM_EVENT_SOURCE_ALARM_START:
560 case ASM_EVENT_SOURCE_ALARM_END:
561 policy = CAMERA_POLICY_SOUND_BY_ALARM;
562 LOGW("CAMERA_POLICY_SOUND_BY_ALARM");
565 policy = CAMERA_POLICY_SOUND;
566 LOGW("CAMERA_POLICY_SOUND");
569 } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
570 policy = CAMERA_POLICY_SECURITY;
571 LOGW("CAMERA_POLICY_SECURITY");
574 if (previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
575 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
578 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
581 /* should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state */
582 if (policy != CAMERA_POLICY_NONE &&
583 m->state.current == MM_CAMCORDER_STATE_NULL) {
584 if (handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED]) {
585 ((camera_interrupted_cb)handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED])(policy,
588 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED]);
590 LOGW("_CAMERA_EVENT_TYPE_INTERRUPTED cb is NULL");
594 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED :
595 if (handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]) {
596 ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])(m->code,
597 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
600 case MM_MESSAGE_CAMCORDER_CAPTURED:
601 handle->current_capture_complete_count = m->code;
602 if (handle->capture_count == 1 ||
603 m->code == handle->capture_count ||
604 (handle->is_continuous_shot_break &&
605 handle->state == CAMERA_STATE_CAPTURING)) {
606 /* pseudo state change */
607 previous_state = handle->state ;
608 handle->state = CAMERA_STATE_CAPTURED;
609 if (previous_state != handle->state &&
610 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
611 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
614 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
616 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
617 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
621 case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
622 case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
623 report = (MMCamRecordingReport *)m->data;
624 if (report != NULL && report->recording_filename) {
625 free(report->recording_filename);
626 report->recording_filename = NULL;
633 case MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED:
634 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
635 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
638 case MM_MESSAGE_CAMCORDER_ERROR:
640 case MM_ERROR_CAMCORDER_DEVICE :
641 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
642 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
643 camera_error = CAMERA_ERROR_DEVICE;
645 case MM_ERROR_CAMCORDER_GST_CORE:
646 case MM_ERROR_CAMCORDER_GST_LIBRARY:
647 case MM_ERROR_CAMCORDER_GST_RESOURCE:
648 case MM_ERROR_CAMCORDER_GST_STREAM:
649 case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
650 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
651 case MM_ERROR_CAMCORDER_ENCODER:
652 case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
653 case MM_ERROR_CAMCORDER_ENCODER_WORKING:
654 case MM_ERROR_CAMCORDER_MNOTE_CREATION:
655 case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY:
656 case MM_ERROR_CAMCORDER_INTERNAL:
657 case MM_ERROR_FILE_NOT_FOUND:
658 case MM_ERROR_FILE_READ:
659 camera_error = CAMERA_ERROR_INVALID_OPERATION;
661 case MM_ERROR_CAMCORDER_LOW_MEMORY:
662 case MM_ERROR_CAMCORDER_MNOTE_MALLOC:
663 camera_error = CAMERA_ERROR_OUT_OF_MEMORY;
665 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
666 camera_error = CAMERA_ERROR_ESD;
669 camera_error = CAMERA_ERROR_INVALID_OPERATION;
673 /* set capture completed flag as true to release camera handle */
674 handle->is_capture_completed = true;
676 if (camera_error != 0 && handle->user_cb[_CAMERA_EVENT_TYPE_ERROR]) {
677 ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(camera_error,
679 handle->user_data[_CAMERA_EVENT_TYPE_ERROR]);
683 case MM_MESSAGE_CAMCORDER_HDR_PROGRESS:
684 if (handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS]) {
685 ((camera_attr_hdr_progress_cb)handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS])(m->code,
686 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
689 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
690 cam_fd_info = (MMCamFaceDetectInfo *)(m->data);
692 camera_detected_face_s faces[cam_fd_info->num_of_faces];
693 handle->num_of_faces = cam_fd_info->num_of_faces > MAX_DETECTED_FACE ? MAX_DETECTED_FACE : cam_fd_info->num_of_faces;
695 for (i = 0 ; i < handle->num_of_faces ; i++) {
696 faces[i].id = cam_fd_info->face_info[i].id;
697 faces[i].score = cam_fd_info->face_info[i].score;
698 faces[i].x = cam_fd_info->face_info[i].rect.x;
699 faces[i].y = cam_fd_info->face_info[i].rect.y;
700 faces[i].width = cam_fd_info->face_info[i].rect.width;
701 faces[i].height = cam_fd_info->face_info[i].rect.height;
702 handle->faceinfo[i] = faces[i]; //cache face coordinate
705 if (handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
706 ((camera_face_detected_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
707 handle->num_of_faces,
708 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION]);
711 handle->num_of_faces = 0;
722 static int __capture_completed_event_cb(void *data)
724 camera_s *handle = (camera_s *)data;
725 camera_state_e previous_state = CAMERA_STATE_NONE;
727 if (handle == NULL) {
728 LOGE("handle is NULL");
732 if (handle->current_capture_count > 0 &&
733 handle->current_capture_count == handle->current_capture_complete_count &&
734 handle->state == CAMERA_STATE_CAPTURING) {
735 /* pseudo state change */
736 previous_state = handle->state;
737 handle->state = CAMERA_STATE_CAPTURED;
739 if (previous_state != handle->state &&
740 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
741 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
744 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
747 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
748 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
755 int camera_create(camera_device_e device, camera_h* camera)
758 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
759 return CAMERA_ERROR_INVALID_PARAMETER;
762 int ret = MM_ERROR_NONE;;
766 camera_s *handle = NULL;
769 LOGW("device name = [%d]",device);
771 info.videodev_type = device;
773 handle = (camera_s*)malloc( sizeof(camera_s) );
774 if (handle == NULL) {
776 return CAMERA_ERROR_OUT_OF_MEMORY;
779 memset(handle, 0x0, sizeof(camera_s));
781 ret = mm_camcorder_create(&handle->mm_handle, &info);
782 if (ret != MM_ERROR_NONE) {
784 return __convert_camera_error_code(__func__,ret);
787 preview_format = MM_PIXEL_FORMAT_YUYV;
788 rotation = MM_DISPLAY_ROTATION_NONE;
789 ret = mm_camcorder_get_attributes(handle->mm_handle, &error,
790 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
791 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
792 MMCAM_CAPTURE_WIDTH, &handle->capture_width,
793 MMCAM_CAPTURE_HEIGHT, &handle->capture_height,
795 if (ret != MM_ERROR_NONE) {
796 LOGE("mm_camcorder_get_attributes fail(%x)", ret);
798 LOGE("failed attribute name %s", error);
802 mm_camcorder_destroy(handle->mm_handle);
805 return __convert_camera_error_code(__func__, ret);
808 ret = mm_camcorder_set_attributes(handle->mm_handle, &error,
809 MMCAM_MODE, MM_CAMCORDER_MODE_VIDEO_CAPTURE,
810 MMCAM_CAMERA_FORMAT, preview_format,
811 MMCAM_IMAGE_ENCODER, MM_IMAGE_CODEC_JPEG,
812 MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
813 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL,
814 MMCAM_DISPLAY_ROTATION, rotation,
815 MMCAM_CAPTURE_COUNT, 1,
818 handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
820 if (ret != MM_ERROR_NONE) {
821 LOGE("mm_camcorder_set_attributes fail(%x)", ret);
823 LOGE("failed attribute name %s", error);
827 mm_camcorder_destroy(handle->mm_handle);
830 return __convert_camera_error_code(__func__, ret);
833 handle->state = CAMERA_STATE_CREATED;
834 handle->relay_message_callback = NULL;
835 handle->relay_user_data = NULL;
836 handle->capture_resolution_modified = false;
837 handle->hdr_keep_mode = false;
838 handle->focus_area_valid = false;
839 handle->is_used_in_recorder = false;
840 handle->on_continuous_focusing = false;
841 handle->cached_focus_mode = -1;
843 g_mutex_init(&handle->idle_cb_lock);
845 mm_camcorder_set_message_callback(handle->mm_handle,
846 __mm_camera_message_callback,
849 *camera = (camera_h)handle;
851 LOGW("camera handle %p", handle);
853 return __convert_camera_error_code(__func__, ret);
857 int camera_destroy(camera_h camera)
859 if (camera == NULL) {
860 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
861 return CAMERA_ERROR_INVALID_PARAMETER;
864 int ret = MM_ERROR_NONE;
865 camera_s *handle = (camera_s *)camera;
867 if (handle->is_used_in_recorder) {
868 LOGE("camera is using in another recorder.");
869 return CAMERA_ERROR_INVALID_OPERATION;
872 LOGW("camera handle %p", handle);
874 if (handle->pkt_fmt) {
875 media_format_unref(handle->pkt_fmt);
876 handle->pkt_fmt = NULL;
879 ret = mm_camcorder_destroy(handle->mm_handle);
880 if (ret == MM_ERROR_NONE) {
881 _camera_remove_cb_message(handle);
882 g_mutex_clear(&handle->idle_cb_lock);
884 if (handle->wl_info) {
885 free(handle->wl_info);
886 handle->wl_info = NULL;
888 #endif /* HAVE_WAYLAND */
892 return __convert_camera_error_code(__func__, ret);
896 int camera_start_preview(camera_h camera)
898 if (camera == NULL) {
899 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
900 return CAMERA_ERROR_INVALID_PARAMETER;
903 int ret = MM_ERROR_NONE;
904 camera_s *handle = (camera_s *)camera;
905 camera_state_e capi_state = CAMERA_STATE_NONE;
906 MMCamcorderStateType mm_state = MM_CAMCORDER_STATE_NONE;
908 camera_get_state(camera, &capi_state);
909 if (capi_state == CAMERA_STATE_CAPTURED) {
910 ret = mm_camcorder_capture_stop(handle->mm_handle);
911 return __convert_camera_error_code(__func__, ret);
914 /* for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback */
915 mm_camcorder_set_video_capture_callback(handle->mm_handle,
916 (mm_camcorder_video_capture_callback)__mm_capture_callback,
919 mm_camcorder_get_state(handle->mm_handle, &mm_state);
920 if (mm_state != MM_CAMCORDER_STATE_READY) {
921 ret = mm_camcorder_realize(handle->mm_handle);
922 if (ret != MM_ERROR_NONE) {
923 LOGE("mm_camcorder_realize failed 0x%x", ret);
924 return __convert_camera_error_code(__func__, ret);
928 ret = mm_camcorder_start(handle->mm_handle);
929 if (ret != MM_ERROR_NONE) {
930 LOGE("mm_camcorder_start failed 0x%x, call mm_camcorder_unrealize", ret);
931 mm_camcorder_unrealize(handle->mm_handle);
934 return __convert_camera_error_code(__func__, ret);
938 int camera_stop_preview(camera_h camera)
940 if (camera == NULL) {
941 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
942 return CAMERA_ERROR_INVALID_PARAMETER;
945 int ret = MM_ERROR_NONE;;
946 camera_s *handle = (camera_s *)camera;
947 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
949 mm_camcorder_get_state(handle->mm_handle, &state);
950 if (state == MM_CAMCORDER_STATE_PREPARE) {
951 ret = mm_camcorder_stop(handle->mm_handle);
952 if (ret != MM_ERROR_NONE) {
953 LOGE("mm_camcorder_stop failed 0x%x", ret);
954 return __convert_camera_error_code(__func__, ret);
958 camera_stop_face_detection(camera);
960 ret = mm_camcorder_unrealize(handle->mm_handle);
962 return __convert_camera_error_code(__func__, ret);
966 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
968 if (camera == NULL) {
969 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
970 return CAMERA_ERROR_INVALID_PARAMETER;
973 camera_s *handle = (camera_s *)camera;
974 int ret = MM_ERROR_NONE;
975 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
977 mm_camcorder_get_state(handle->mm_handle, &state);
978 if (state != MM_CAMCORDER_STATE_PREPARE &&
979 state != MM_CAMCORDER_STATE_RECORDING &&
980 state != MM_CAMCORDER_STATE_PAUSED) {
981 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
982 return CAMERA_ERROR_INVALID_STATE;
985 if (handle->capture_resolution_modified) {
986 mm_camcorder_set_attributes(handle->mm_handle, NULL,
987 MMCAM_CAPTURE_WIDTH, handle->capture_width,
988 MMCAM_CAPTURE_HEIGHT, handle->capture_height,
991 handle->capture_resolution_modified = false;
994 mm_camcorder_set_attributes(handle->mm_handle, NULL,
995 MMCAM_CAPTURE_COUNT, 1,
998 handle->capture_count = 1;
999 handle->is_continuous_shot_break = false;
1000 handle->current_capture_count = 0;
1001 handle->current_capture_complete_count = 0;
1002 handle->is_capture_completed = false;
1004 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
1005 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
1006 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
1007 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
1009 ret = mm_camcorder_capture_start(handle->mm_handle);
1010 if (ret != MM_ERROR_NONE) {
1011 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1012 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1013 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1014 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1017 return __convert_camera_error_code(__func__, ret);
1021 bool camera_is_supported_continuous_capture(camera_h camera)
1023 if (camera == NULL) {
1024 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1028 int ret = MM_ERROR_NONE;
1029 camera_s *handle = (camera_s *)camera;
1030 MMCamAttrsInfo info;
1032 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_COUNT, &info);
1033 set_last_result(__convert_camera_error_code(__func__, ret));
1034 if (ret != MM_ERROR_NONE) {
1035 LOGE("MMCAM_CAPTURE_COUNT info get failed 0x%x", ret);
1039 if (info.int_range.max > 1) {
1047 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)
1049 if (camera == NULL) {
1050 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1051 return CAMERA_ERROR_INVALID_PARAMETER;
1054 if (camera_is_supported_continuous_capture(camera) == false) {
1055 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1056 return CAMERA_ERROR_NOT_SUPPORTED;
1059 if (count < 2 || interval < 0) {
1060 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1061 return CAMERA_ERROR_INVALID_PARAMETER;
1064 camera_s *handle = (camera_s *)camera;
1065 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
1066 int supported_zsl = FALSE;
1067 int ret = MM_ERROR_NONE;
1069 mm_camcorder_get_state(handle->mm_handle, &state);
1070 if (state != MM_CAMCORDER_STATE_PREPARE) {
1071 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1072 return CAMERA_ERROR_INVALID_STATE;
1075 supported_zsl = FALSE;
1077 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1078 MMCAM_CAPTURE_COUNT, count,
1079 MMCAM_CAPTURE_INTERVAL, interval,
1081 if (ret != MM_ERROR_NONE) {
1082 LOGE("error set continuous shot attribute 0x%x", ret);
1083 return __convert_camera_error_code(__func__, ret);
1086 handle->capture_count = count;
1087 handle->is_continuous_shot_break = false;
1088 handle->current_capture_count = 0;
1089 handle->current_capture_complete_count = 0;
1090 handle->is_capture_completed = false;
1092 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1093 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1095 if (ret != MM_ERROR_NONE) {
1096 LOGE("(%x) error get continuous shot attribute", ret);
1099 if (!supported_zsl) {
1105 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1106 MMCAM_CAMERA_WIDTH, &preview_width,
1107 MMCAM_CAMERA_HEIGHT, &preview_height,
1108 MMCAM_CAPTURE_WIDTH, &capture_width,
1109 MMCAM_CAPTURE_HEIGHT, &capture_height,
1112 if (preview_width != capture_width || preview_height != capture_height) {
1113 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1114 MMCAM_CAPTURE_WIDTH, preview_width,
1115 MMCAM_CAPTURE_HEIGHT, preview_height,
1118 handle->capture_resolution_modified = true;
1122 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
1123 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
1124 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
1125 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
1127 ret = mm_camcorder_capture_start(handle->mm_handle);
1128 if(ret != MM_ERROR_NONE ){
1129 LOGE("mm_camcorder_capture_start failed 0x%x", ret);
1130 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1131 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1132 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1133 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1136 return __convert_camera_error_code(__func__, ret);
1141 int camera_stop_continuous_capture(camera_h camera)
1143 if (camera == NULL) {
1144 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1145 return CAMERA_ERROR_INVALID_PARAMETER;
1148 if (camera_is_supported_continuous_capture(camera) == false) {
1149 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1150 return CAMERA_ERROR_NOT_SUPPORTED;
1153 camera_s *handle = (camera_s *)camera;
1154 int ret = MM_ERROR_NONE;
1155 camera_state_e state = CAMERA_STATE_NONE;
1157 camera_get_state(camera, &state);
1158 if (state != CAMERA_STATE_CAPTURING && handle->capture_count > 1) {
1159 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1160 return CAMERA_ERROR_INVALID_STATE;
1163 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1164 "capture-break-cont-shot", 1,
1166 if (ret == MM_ERROR_NONE) {
1167 handle->is_continuous_shot_break = true;
1169 if (handle->current_capture_count > 0) {
1170 handle->is_capture_completed = true;
1173 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
1176 return __convert_camera_error_code(__func__, ret);
1180 bool camera_is_supported_face_detection(camera_h camera)
1182 if (camera == NULL) {
1183 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1188 int ret = MM_ERROR_NONE;
1189 camera_s *handle = (camera_s *)camera;
1190 MMCamAttrsInfo info;
1192 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
1193 set_last_result(__convert_camera_error_code(__func__, ret));
1194 if (ret != MM_ERROR_NONE) {
1195 LOGE("MMCAM_DETECT_MODE get attr info failed");
1199 if (info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY) {
1200 for (i = 0 ; i < info.int_array.count ; i++) {
1201 if (info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON) {
1202 LOGD("face detection supported");
1208 LOGD("face detection NOT supported");
1214 bool camera_is_supported_zero_shutter_lag(camera_h camera)
1216 int ret = MM_ERROR_NONE;
1217 int supported_zsl = false;
1218 camera_s *handle = (camera_s *)camera;
1220 if (camera == NULL) {
1221 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1225 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1226 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1228 set_last_result(__convert_camera_error_code(__func__, ret));
1229 if (ret != MM_ERROR_NONE) {
1230 LOGE("MMCAM_SUPPORT_ZSL_CAPTURE get failed");
1234 LOGD("support zero shutter lag : %d", supported_zsl);
1236 return supported_zsl;
1240 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
1242 int ret = MM_ERROR_NONE;
1243 int supported = false;
1244 camera_s *handle = (camera_s *)camera;
1246 if (camera == NULL) {
1247 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1251 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1252 MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, &supported,
1254 set_last_result(__convert_camera_error_code(__func__, ret));
1255 if (ret != MM_ERROR_NONE) {
1256 LOGE("MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB get failed");
1260 LOGD("support media packet preview callback : %d", supported);
1266 int camera_get_device_count(camera_h camera, int *device_count)
1268 int ret = MM_ERROR_NONE;
1269 camera_s *handle = (camera_s *)camera;
1271 if (camera == NULL || device_count == NULL) {
1272 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1273 return CAMERA_ERROR_INVALID_PARAMETER;
1276 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1277 MMCAM_CAMERA_DEVICE_COUNT, device_count,
1280 return __convert_camera_error_code(__func__, ret);
1284 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
1286 if (camera == NULL) {
1287 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1288 return CAMERA_ERROR_INVALID_PARAMETER;
1291 if (camera_is_supported_face_detection(camera) == false) {
1292 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1293 return CAMERA_ERROR_NOT_SUPPORTED;
1296 camera_s *handle = (camera_s *)camera;
1297 camera_state_e state = CAMERA_STATE_NONE;
1298 int ret = MM_ERROR_NONE;
1300 camera_get_state(camera, &state);
1301 if (state != CAMERA_STATE_PREVIEW) {
1302 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1303 return CAMERA_ERROR_INVALID_STATE;
1306 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1307 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON,
1309 if (ret == MM_ERROR_NONE) {
1310 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)callback;
1311 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)user_data;
1312 handle->num_of_faces = 0;
1315 return __convert_camera_error_code(__func__,ret);
1319 int camera_stop_face_detection(camera_h camera)
1321 if (camera == NULL) {
1322 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1323 return CAMERA_ERROR_INVALID_PARAMETER;
1326 camera_s *handle = (camera_s *)camera;
1327 int ret = MM_ERROR_NONE;
1329 if (camera_is_supported_face_detection(camera) == false) {
1330 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1331 return CAMERA_ERROR_NOT_SUPPORTED;
1334 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1335 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF,
1337 if (ret == MM_ERROR_NONE) {
1338 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1339 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1340 handle->num_of_faces = 0;
1343 return __convert_camera_error_code(__func__,ret);
1347 int camera_get_state(camera_h camera, camera_state_e *state)
1349 if (camera == NULL || state == NULL) {
1350 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1351 return CAMERA_ERROR_INVALID_PARAMETER;
1354 camera_s *handle = (camera_s *)camera;
1355 camera_state_e capi_state = CAMERA_STATE_NONE;
1356 MMCamcorderStateType mmstate = MM_CAMCORDER_STATE_NONE;
1358 mm_camcorder_get_state(handle->mm_handle, &mmstate);
1359 capi_state = __camera_state_convert(mmstate);
1361 if ((handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed) &&
1362 (handle->current_capture_count > 0 || handle->is_capture_completed) &&
1363 mmstate == MM_CAMCORDER_STATE_CAPTURING) {
1364 capi_state = CAMERA_STATE_CAPTURED;
1367 *state = capi_state;
1369 return CAMERA_ERROR_NONE;
1373 int camera_start_focusing(camera_h camera, bool continuous)
1375 if (camera == NULL) {
1376 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1377 return CAMERA_ERROR_INVALID_PARAMETER;
1380 camera_s *handle = (camera_s *)camera;
1382 if (handle->cached_focus_mode != -1) {
1383 LOGD("apply cached focus mode %d", handle->cached_focus_mode);
1385 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1386 MMCAM_CAMERA_AF_SCAN_RANGE, handle->cached_focus_mode,
1389 handle->cached_focus_mode = -1;
1393 return __camera_start_continuous_focusing(camera);
1395 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1396 MMCAM_CAMERA_FOCUS_MODE, handle->focus_area_valid ? \
1397 MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO : MM_CAMCORDER_FOCUS_MODE_AUTO,
1400 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s *)camera)->mm_handle));
1405 int __camera_start_continuous_focusing(camera_h camera)
1407 if (camera == NULL) {
1408 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1409 return CAMERA_ERROR_INVALID_PARAMETER;
1412 camera_s *handle = (camera_s *)camera;
1413 int ret = MM_ERROR_NONE;
1414 int mode = MM_CAMCORDER_FOCUS_MODE_NONE;
1416 handle->on_continuous_focusing = true;
1417 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1418 MMCAM_CAMERA_FOCUS_MODE, &mode,
1421 if (mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS) {
1422 ret = mm_camcorder_start_focusing(handle->mm_handle);
1424 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1425 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS,
1429 return __convert_camera_error_code(__func__, ret);
1433 int camera_cancel_focusing(camera_h camera)
1435 if (camera == NULL) {
1436 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1437 return CAMERA_ERROR_INVALID_PARAMETER;
1440 camera_s *handle = (camera_s *)camera;
1442 handle->on_continuous_focusing = false;
1444 return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
1448 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
1450 int ret = MM_ERROR_NONE;
1451 int set_surface = MM_DISPLAY_SURFACE_X;
1452 void *set_handle = NULL;
1453 camera_s *handle = NULL;
1455 Evas_Object *obj = NULL;
1456 const char *object_type = NULL;
1458 if (camera == NULL) {
1459 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1460 return CAMERA_ERROR_INVALID_PARAMETER;
1463 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
1464 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
1465 return CAMERA_ERROR_INVALID_PARAMETER;
1468 handle = (camera_s *)camera;
1469 handle->display_type = type;
1471 if (type == CAMERA_DISPLAY_TYPE_NONE) {
1473 set_surface = MM_DISPLAY_SURFACE_NULL;
1474 handle->display_handle = 0;
1476 LOGD("display type NONE");
1478 obj = (Evas_Object *)display;
1479 object_type = evas_object_type_get(obj);
1481 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
1483 MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)malloc(sizeof(MMCamWaylandInfo));
1485 if (wl_info == NULL) {
1486 LOGE("wl_info alloc failed : %d", sizeof(MMCamWaylandInfo));
1487 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_LOW_MEMORY);
1490 memset(wl_info, 0x0, sizeof(MMCamWaylandInfo));
1492 wl_info->evas_obj = (void *)obj;
1493 wl_info->window = (void *)elm_win_wl_window_get(obj);
1494 wl_info->surface = (void *)ecore_wl_window_surface_get(wl_info->window);
1495 wl_info->display = (void *)ecore_wl_display_get();
1497 if (wl_info->window == NULL || wl_info->surface == NULL || wl_info->display == NULL) {
1498 LOGE("something is NULL %p, %p, %p", wl_info->window, wl_info->surface, wl_info->display);
1500 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_INTERNAL);
1503 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
1504 &wl_info->window_width, &wl_info->window_height);
1506 if (handle->wl_info) {
1507 free(handle->wl_info);
1508 handle->wl_info = NULL;
1511 /* set wayland info */
1512 handle->wl_info = (void *)wl_info;
1513 set_surface = MM_DISPLAY_SURFACE_X;
1514 set_handle = (void *)wl_info;
1516 LOGD("wayland obj %p, window %p, surface %p, display %p, size %d,%d,%dx%d",
1517 wl_info->evas_obj, wl_info->window, wl_info->surface, wl_info->display,
1518 wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
1519 #else /* HAVE_WAYLAND */
1520 /* x window overlay surface */
1521 handle->display_handle = (void *)elm_win_xwindow_get(obj);
1522 set_surface = MM_DISPLAY_SURFACE_X;
1523 set_handle = &(handle->display_handle);
1525 LOGD("display type OVERLAY : handle %p, %d", set_handle, (int)handle->display_handle);
1526 #endif /* HAVE_WAYLAND */
1527 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
1528 /* evas object surface */
1529 handle->display_handle = display;
1530 set_surface = MM_DISPLAY_SURFACE_EVAS;
1531 set_handle = display;
1533 LOGD("display type EVAS : handle %p", set_handle);
1535 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
1536 return CAMERA_ERROR_INVALID_PARAMETER;
1539 LOGE("failed to get evas object type from %p", obj);
1540 return CAMERA_ERROR_INVALID_PARAMETER;
1544 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1545 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
1546 MMCAM_DISPLAY_SURFACE, set_surface,
1549 if (ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE) {
1550 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1551 MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *),
1555 return __convert_camera_error_code(__func__, ret);
1559 int camera_set_preview_resolution(camera_h camera, int width, int height)
1561 if( camera == NULL){
1562 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1563 return CAMERA_ERROR_INVALID_PARAMETER;
1566 int ret = MM_ERROR_NONE;
1567 camera_s *handle = (camera_s *)camera;
1568 MMCamAttrsInfo info;
1572 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1573 MMCAM_CAMERA_FPS, &mm_fps,
1576 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
1577 if (ret != MM_ERROR_NONE) {
1578 return __convert_camera_error_code(__func__, ret);
1581 for (i = 0 ; i < info.int_array.count ; i++) {
1582 if (info.int_array.array[i] == mm_fps) {
1585 if (i == info.int_array.count - 1) {
1586 LOGE("Not supported resolution: Current set Resolution's FPS is not supported in wanted resolution.");
1587 return CAMERA_ERROR_NOT_SUPPORTED;
1591 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1592 MMCAM_CAMERA_WIDTH, width,
1593 MMCAM_CAMERA_HEIGHT, height,
1596 return __convert_camera_error_code(__func__, ret);
1600 int camera_set_capture_resolution(camera_h camera, int width, int height)
1602 if (camera == NULL) {
1603 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1604 return CAMERA_ERROR_INVALID_PARAMETER;
1607 int ret = MM_ERROR_NONE;
1608 camera_s *handle = (camera_s *)camera;
1610 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1611 MMCAM_CAPTURE_WIDTH, width,
1612 MMCAM_CAPTURE_HEIGHT, height,
1614 if (ret == MM_ERROR_NONE) {
1615 handle->capture_width = width;
1616 handle->capture_height = height;
1619 return __convert_camera_error_code(__func__, ret);
1623 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
1625 if (camera == NULL) {
1626 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1627 return CAMERA_ERROR_INVALID_PARAMETER;
1630 int ret = MM_ERROR_NONE;
1631 camera_s *handle = (camera_s *)camera;
1633 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1634 MMCAM_CAPTURE_FORMAT, format,
1637 return __convert_camera_error_code(__func__, ret);
1641 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
1643 if (camera == NULL) {
1644 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1645 return CAMERA_ERROR_INVALID_PARAMETER;
1649 int ret = MM_ERROR_NONE;
1650 camera_s *handle = (camera_s *)camera;
1652 if (format == CAMERA_PIXEL_FORMAT_UYVY) {
1653 bool supported_ITLV_UYVY = false;
1654 MMCamAttrsInfo supported_format;
1655 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1656 for (i = 0 ; i < supported_format.int_array.count ; i++) {
1657 if (supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1658 supported_ITLV_UYVY = true;
1661 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1662 MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ? MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY,
1665 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1666 MMCAM_CAMERA_FORMAT, format,
1670 return __convert_camera_error_code(__func__, ret);
1674 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
1676 if (camera == NULL || width == NULL || height == NULL) {
1677 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1678 return CAMERA_ERROR_INVALID_PARAMETER;
1681 int ret = MM_ERROR_NONE;
1682 camera_s *handle = (camera_s *)camera;
1684 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1685 MMCAM_CAMERA_WIDTH, width,
1686 MMCAM_CAMERA_HEIGHT, height,
1689 return __convert_camera_error_code(__func__, ret);
1693 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
1695 if (camera == NULL) {
1696 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1697 return CAMERA_ERROR_INVALID_PARAMETER;
1700 if (rotation > CAMERA_ROTATION_270) {
1701 return CAMERA_ERROR_INVALID_PARAMETER;
1704 int ret = MM_ERROR_NONE;
1705 camera_s *handle = (camera_s *)camera;
1707 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1708 MMCAM_DISPLAY_ROTATION, rotation,
1711 return __convert_camera_error_code(__func__, ret);
1715 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
1717 if (camera == NULL || rotation == NULL) {
1718 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1719 return CAMERA_ERROR_INVALID_PARAMETER;
1722 int ret = MM_ERROR_NONE;
1723 camera_s *handle = (camera_s *)camera;
1725 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1726 MMCAM_DISPLAY_ROTATION, rotation,
1729 return __convert_camera_error_code(__func__, ret);
1733 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
1735 if (camera == NULL) {
1736 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1737 return CAMERA_ERROR_INVALID_PARAMETER;
1740 if (flip > CAMERA_FLIP_BOTH) {
1741 return CAMERA_ERROR_INVALID_PARAMETER;
1744 int ret = MM_ERROR_NONE;
1745 camera_s *handle = (camera_s *)camera;
1747 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1748 MMCAM_DISPLAY_FLIP, flip,
1751 return __convert_camera_error_code(__func__, ret);
1755 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
1757 if (camera == NULL || flip == NULL) {
1758 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1759 return CAMERA_ERROR_INVALID_PARAMETER;
1762 int ret = MM_ERROR_NONE;
1763 camera_s *handle = (camera_s *)camera;
1765 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1766 MMCAM_DISPLAY_FLIP, flip,
1769 return __convert_camera_error_code(__func__, ret);
1773 int camera_set_display_visible(camera_h camera, bool visible)
1775 if (camera == NULL) {
1776 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1777 return CAMERA_ERROR_INVALID_PARAMETER;
1780 int ret = MM_ERROR_NONE;
1781 camera_s *handle = (camera_s *)camera;
1783 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1784 MMCAM_DISPLAY_VISIBLE, visible,
1787 return __convert_camera_error_code(__func__, ret);
1791 int camera_is_display_visible(camera_h camera, bool* visible)
1793 if (camera == NULL || visible == NULL) {
1794 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1795 return CAMERA_ERROR_INVALID_PARAMETER;
1798 int ret = MM_ERROR_NONE;
1800 camera_s *handle = (camera_s *)camera;
1802 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1803 MMCAM_DISPLAY_VISIBLE, &result,
1806 if (ret == MM_ERROR_NONE) {
1810 return __convert_camera_error_code(__func__, ret);
1814 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
1816 if (camera == NULL) {
1817 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1818 return CAMERA_ERROR_INVALID_PARAMETER;
1821 if (mode > CAMERA_DISPLAY_MODE_CROPPED_FULL) {
1822 return CAMERA_ERROR_INVALID_PARAMETER;
1825 int ret = MM_ERROR_NONE;
1826 camera_s *handle = (camera_s *)camera;
1828 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1829 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1832 return __convert_camera_error_code(__func__, ret);
1836 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
1838 if (camera == NULL || mode == NULL) {
1839 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1840 return CAMERA_ERROR_INVALID_PARAMETER;
1843 int ret = MM_ERROR_NONE;
1844 camera_s *handle = (camera_s *)camera;
1846 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1847 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1850 return __convert_camera_error_code(__func__, ret);
1854 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
1856 if (camera == NULL || width == NULL || height == NULL) {
1857 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1858 return CAMERA_ERROR_INVALID_PARAMETER;
1861 camera_s *handle = (camera_s *)camera;
1863 *width = handle->capture_width;
1864 *height = handle->capture_height;
1866 return CAMERA_ERROR_NONE;
1870 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
1872 if (camera == NULL || format == NULL) {
1873 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1874 return CAMERA_ERROR_INVALID_PARAMETER;
1877 int ret = MM_ERROR_NONE;
1878 camera_s *handle = (camera_s *)camera;
1880 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1881 MMCAM_CAPTURE_FORMAT, format,
1884 return __convert_camera_error_code(__func__, ret);
1888 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
1890 if (camera == NULL || format == NULL) {
1891 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1892 return CAMERA_ERROR_INVALID_PARAMETER;
1895 int ret = MM_ERROR_NONE;
1896 camera_s *handle = (camera_s *)camera;
1898 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1899 MMCAM_CAMERA_FORMAT, format,
1902 if ((MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1903 *format = CAMERA_PIXEL_FORMAT_UYVY;
1906 return __convert_camera_error_code(__func__, ret);
1910 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
1912 if (camera == NULL || callback == NULL) {
1913 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1914 return CAMERA_ERROR_INVALID_PARAMETER;
1917 camera_s *handle = (camera_s *)camera;
1918 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)callback;
1919 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)user_data;
1921 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1922 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1925 return CAMERA_ERROR_NONE;
1929 int camera_unset_preview_cb(camera_h camera)
1931 if (camera == NULL) {
1932 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1933 return CAMERA_ERROR_INVALID_PARAMETER;
1936 camera_s *handle = (camera_s *)camera;
1938 if (handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1939 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1940 (mm_camcorder_video_stream_callback)NULL,
1944 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1945 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1947 return CAMERA_ERROR_NONE;
1951 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
1953 if (camera == NULL) {
1954 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
1955 return CAMERA_ERROR_INVALID_PARAMETER;
1958 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1959 LOGE("NOT SUPPORTED");
1960 return CAMERA_ERROR_NOT_SUPPORTED;
1963 if (callback == NULL) {
1964 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
1965 return CAMERA_ERROR_INVALID_PARAMETER;
1968 camera_s *handle = (camera_s *)camera;
1969 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)callback;
1970 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)user_data;
1972 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1973 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1976 return CAMERA_ERROR_NONE;
1980 int camera_unset_media_packet_preview_cb(camera_h camera)
1982 if (camera == NULL) {
1983 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1984 return CAMERA_ERROR_INVALID_PARAMETER;
1987 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1988 LOGE("NOT SUPPORTED");
1989 return CAMERA_ERROR_NOT_SUPPORTED;
1992 camera_s *handle = (camera_s *)camera;
1994 if (handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] == NULL) {
1995 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1996 (mm_camcorder_video_stream_callback)NULL,
2000 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
2001 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
2003 return CAMERA_ERROR_NONE;
2007 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
2009 if (camera == NULL || callback == NULL) {
2010 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2011 return CAMERA_ERROR_INVALID_PARAMETER;
2014 camera_s *handle = (camera_s *)camera;
2015 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)callback;
2016 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)user_data;
2018 return CAMERA_ERROR_NONE;
2022 int camera_unset_state_changed_cb(camera_h camera)
2024 if (camera == NULL) {
2025 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2026 return CAMERA_ERROR_INVALID_PARAMETER;
2029 camera_s *handle = (camera_s *)camera;
2030 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2031 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2033 return CAMERA_ERROR_NONE;
2037 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
2039 if (camera == NULL || callback == NULL) {
2040 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2041 return CAMERA_ERROR_INVALID_PARAMETER;
2044 camera_s *handle = (camera_s *)camera;
2045 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)callback;
2046 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)user_data;
2048 return CAMERA_ERROR_NONE;
2052 int camera_unset_interrupted_cb(camera_h camera)
2054 if (camera == NULL) {
2055 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2056 return CAMERA_ERROR_INVALID_PARAMETER;
2059 camera_s *handle = (camera_s *)camera;
2061 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2062 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2064 return CAMERA_ERROR_NONE;
2068 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
2070 if (camera == NULL || callback == NULL) {
2071 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2072 return CAMERA_ERROR_INVALID_PARAMETER;
2075 camera_s *handle = (camera_s *)camera;
2077 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)callback;
2078 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)user_data;
2080 return CAMERA_ERROR_NONE;
2084 int camera_unset_focus_changed_cb(camera_h camera)
2086 if (camera == NULL) {
2087 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2088 return CAMERA_ERROR_INVALID_PARAMETER;
2091 camera_s *handle = (camera_s *)camera;
2093 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2094 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2096 return CAMERA_ERROR_NONE;
2100 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
2102 if (camera == NULL || callback == NULL) {
2103 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2104 return CAMERA_ERROR_INVALID_PARAMETER;
2107 camera_s *handle = (camera_s *)camera;
2109 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)callback;
2110 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)user_data;
2112 return CAMERA_ERROR_NONE;
2116 int camera_unset_error_cb(camera_h camera)
2118 if (camera == NULL) {
2119 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2120 return CAMERA_ERROR_INVALID_PARAMETER;
2123 camera_s *handle = (camera_s *)camera;
2125 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2126 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2128 return CAMERA_ERROR_NONE;
2132 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
2134 if (camera == NULL || foreach_cb == NULL) {
2135 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2136 return CAMERA_ERROR_INVALID_PARAMETER;
2140 int ret = MM_ERROR_NONE;
2141 camera_s *handle = (camera_s *)camera;
2142 MMCamAttrsInfo preview_width;
2143 MMCamAttrsInfo preview_height;
2145 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH, &preview_width);
2146 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT, &preview_height);
2147 if (ret != CAMERA_ERROR_NONE) {
2148 return __convert_camera_error_code(__func__, ret);
2151 for (i = 0 ; i < preview_width.int_array.count ; i++) {
2152 if (!foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i], user_data)) {
2157 return CAMERA_ERROR_NONE;
2161 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
2163 if (camera == NULL || foreach_cb == NULL) {
2164 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2165 return CAMERA_ERROR_INVALID_PARAMETER;
2169 int ret = MM_ERROR_NONE;
2170 camera_s *handle = (camera_s *)camera;
2171 MMCamAttrsInfo capture_width;
2172 MMCamAttrsInfo capture_height;
2174 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH, &capture_width);
2175 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT, &capture_height);
2176 if (ret != CAMERA_ERROR_NONE) {
2177 return __convert_camera_error_code(__func__, ret);
2180 for (i = 0 ; i < capture_width.int_array.count ; i++) {
2181 if (!foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i], user_data)) {
2186 return CAMERA_ERROR_NONE;
2190 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
2192 if (camera == NULL || foreach_cb == NULL) {
2193 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2194 return CAMERA_ERROR_INVALID_PARAMETER;
2198 int ret = MM_ERROR_NONE;
2199 camera_s *handle = (camera_s *)camera;
2200 MMCamAttrsInfo format;
2202 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT, &format);
2203 if (ret != CAMERA_ERROR_NONE) {
2204 return __convert_camera_error_code(__func__, ret);
2207 for (i = 0 ; i < format.int_array.count ; i++) {
2208 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2209 if (!foreach_cb(format.int_array.array[i], user_data)) {
2215 return CAMERA_ERROR_NONE;
2219 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
2221 if (camera == NULL || foreach_cb == NULL) {
2222 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2223 return CAMERA_ERROR_INVALID_PARAMETER;
2227 int ret = MM_ERROR_NONE;
2228 camera_s *handle = (camera_s *)camera;
2229 MMCamAttrsInfo format;
2231 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT, &format);
2232 if (ret != CAMERA_ERROR_NONE) {
2233 return __convert_camera_error_code(__func__, ret);
2236 for (i = 0 ; i < format.int_array.count ; i++) {
2237 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2238 if (!foreach_cb(format.int_array.array[i], user_data)) {
2244 return CAMERA_ERROR_NONE;
2248 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
2250 if (camera == NULL || width == NULL || height == NULL) {
2251 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2252 return CAMERA_ERROR_INVALID_PARAMETER;
2255 enum MMCamcorderPreviewType wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2259 int ret = MM_ERROR_NONE;
2260 camera_s *handle = (camera_s *)camera;
2261 MMCamAttrsInfo width_info;
2262 MMCamAttrsInfo height_info;
2264 camera_get_capture_resolution(camera, &capture_w, &capture_h);
2265 ratio = (double)capture_w / (double)capture_h;
2267 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
2268 } else if (ratio == 1.0) {
2269 wide = MM_CAMCORDER_PREVIEW_TYPE_SQUARE;
2271 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2274 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH, &width_info);
2275 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
2276 if (ret != MM_ERROR_NONE) {
2277 return __convert_camera_error_code(__func__, ret);
2280 if (width && (unsigned int)width_info.int_array.count > wide) {
2281 *width = width_info.int_array.array[wide];
2283 LOGE("there is no width value for resolution %dx%d type %d", capture_w, capture_h, wide);
2284 return CAMERA_ERROR_INVALID_OPERATION;
2287 if (height && (unsigned int)height_info.int_array.count > wide) {
2288 *height = height_info.int_array.array[wide];
2290 LOGE("there is no height value for resolution %dx%d type %d", capture_w, capture_h, wide);
2291 return CAMERA_ERROR_INVALID_OPERATION;
2294 LOGI("recommend resolution %dx%d, type %d", *width, *height, wide);
2296 return CAMERA_ERROR_NONE;
2300 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
2302 if (camera == NULL || angle == NULL) {
2303 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2304 return CAMERA_ERROR_INVALID_PARAMETER;
2307 int ret = MM_ERROR_NONE;
2308 camera_s *handle = (camera_s *)camera;
2309 int rotation = MM_DISPLAY_ROTATION_NONE;
2311 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2312 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
2315 if (ret == MM_ERROR_NONE) {
2317 case MM_DISPLAY_ROTATION_NONE:
2320 case MM_DISPLAY_ROTATION_90:
2323 case MM_DISPLAY_ROTATION_180:
2326 case MM_DISPLAY_ROTATION_270:
2335 return __convert_camera_error_code(__func__, ret);
2339 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
2341 if (camera == NULL) {
2342 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2343 return CAMERA_ERROR_INVALID_PARAMETER;
2346 int ret = MM_ERROR_NONE;
2347 camera_s *handle = (camera_s *)camera;
2349 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2350 MMCAM_DISPLAY_MODE, mode,
2353 return __convert_camera_error_code(__func__, ret);
2357 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
2359 if (camera == NULL || mode == NULL) {
2360 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2361 return CAMERA_ERROR_INVALID_PARAMETER;
2364 int ret = MM_ERROR_NONE;
2365 camera_s *handle = (camera_s *)camera;
2367 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2368 MMCAM_DISPLAY_MODE, mode,
2371 return __convert_camera_error_code(__func__, ret);
2375 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
2377 if (camera == NULL || foreach_cb == NULL) {
2378 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2379 return CAMERA_ERROR_INVALID_PARAMETER;
2383 int ret = MM_ERROR_NONE;
2384 camera_s *handle = (camera_s *)camera;
2385 MMCamAttrsInfo info;
2387 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DISPLAY_MODE, &info);
2388 if (ret != CAMERA_ERROR_NONE) {
2389 return __convert_camera_error_code(__func__, ret);
2392 for (i = 0 ; i < info.int_array.count ; i++) {
2393 if (!foreach_cb(info.int_array.array[i], user_data)) {
2398 return CAMERA_ERROR_NONE;
2402 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
2404 if (camera == NULL) {
2405 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2406 return CAMERA_ERROR_INVALID_PARAMETER;
2409 int ret = MM_ERROR_NONE;
2410 camera_s *handle = (camera_s *)camera;
2412 if (fps == CAMERA_ATTR_FPS_AUTO) {
2413 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2414 MMCAM_CAMERA_FPS_AUTO, true,
2417 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2418 MMCAM_CAMERA_FPS_AUTO, false,
2419 MMCAM_CAMERA_FPS, fps,
2423 return __convert_camera_error_code(__func__, ret);
2427 int camera_attr_set_image_quality(camera_h camera, int quality)
2429 if (camera == NULL) {
2430 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2431 return CAMERA_ERROR_INVALID_PARAMETER;
2434 int ret = MM_ERROR_NONE;
2435 camera_s *handle = (camera_s *)camera;
2437 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2438 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2441 return __convert_camera_error_code(__func__, ret);
2445 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
2447 if (camera == NULL || fps == NULL) {
2448 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2449 return CAMERA_ERROR_INVALID_PARAMETER;
2452 int ret = MM_ERROR_NONE;
2454 int is_auto = false;
2455 camera_s *handle = (camera_s *)camera;
2457 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2458 MMCAM_CAMERA_FPS, &mm_fps,
2459 MMCAM_CAMERA_FPS_AUTO, &is_auto,
2461 if (ret == MM_ERROR_NONE) {
2463 *fps = CAMERA_ATTR_FPS_AUTO;
2469 return __convert_camera_error_code(__func__, ret);
2473 int camera_attr_get_image_quality(camera_h camera, int *quality)
2475 if (camera == NULL || quality == NULL) {
2476 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2477 return CAMERA_ERROR_INVALID_PARAMETER;
2480 int ret = MM_ERROR_NONE;
2481 camera_s *handle = (camera_s *)camera;
2483 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2484 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2487 return __convert_camera_error_code(__func__, ret);
2491 int camera_attr_set_zoom(camera_h camera, int zoom)
2493 if (camera == NULL) {
2494 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2495 return CAMERA_ERROR_INVALID_PARAMETER;
2498 int ret = MM_ERROR_NONE;
2499 camera_s *handle = (camera_s *)camera;
2501 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2502 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2505 return __convert_camera_error_code(__func__, ret);
2509 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
2511 if (camera == NULL) {
2512 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2513 return CAMERA_ERROR_INVALID_PARAMETER;
2516 int ret = MM_ERROR_NONE;
2517 camera_s *handle = (camera_s *)camera;
2519 bool should_change_focus_mode = false;
2521 mm_camcorder_get_attributes(handle->mm_handle, NULL,
2522 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2525 if (focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO &&
2526 focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2527 focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO) {
2528 should_change_focus_mode = true;
2531 if (mode != CAMERA_ATTR_AF_NONE &&
2532 focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2533 !handle->on_continuous_focusing) {
2534 handle->cached_focus_mode = mode;
2535 LOGD("af mode will be set actually start focusing");
2536 return __convert_camera_error_code(__func__, MM_ERROR_NONE);
2538 handle->cached_focus_mode = -1;
2541 if (mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode) {
2542 mm_camcorder_set_attributes(handle->mm_handle, NULL,
2543 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO,
2548 case CAMERA_ATTR_AF_NONE:
2549 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2550 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
2551 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NONE,
2554 case CAMERA_ATTR_AF_NORMAL:
2555 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2556 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NORMAL,
2559 case CAMERA_ATTR_AF_MACRO:
2560 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2561 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_MACRO,
2564 case CAMERA_ATTR_AF_FULL:
2565 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2566 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_FULL,
2570 LOGE("invalid mode %d", mode);
2571 return CAMERA_ERROR_INVALID_PARAMETER;
2574 return __convert_camera_error_code(__func__, ret);
2578 int camera_attr_set_af_area(camera_h camera, int x, int y)
2580 if (camera == NULL) {
2581 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2582 return CAMERA_ERROR_INVALID_PARAMETER;
2585 int ret = MM_ERROR_NONE;
2586 camera_s *handle = (camera_s *)camera;
2587 camera_attr_af_mode_e mode;
2589 camera_attr_get_af_mode(camera, &mode);
2590 if (mode == CAMERA_ATTR_AF_NONE) {
2591 LOGE("INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE", CAMERA_ERROR_INVALID_OPERATION);
2592 return CAMERA_ERROR_INVALID_OPERATION;
2595 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2596 MMCAM_CAMERA_AF_TOUCH_X, x,
2597 MMCAM_CAMERA_AF_TOUCH_Y, y,
2599 if (ret == MM_ERROR_NONE) {
2600 handle->focus_area_valid = true;
2603 return __convert_camera_error_code(__func__, ret);
2607 int camera_attr_clear_af_area(camera_h camera)
2609 if (camera == NULL) {
2610 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2611 return CAMERA_ERROR_INVALID_PARAMETER;
2614 camera_s *handle = (camera_s *)camera;
2616 handle->focus_area_valid = false;
2622 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
2624 if (camera == NULL) {
2625 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2626 return CAMERA_ERROR_INVALID_PARAMETER;
2629 int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, /* CAMERA_ATTR_EXPOSURE_MODE_OFF */
2630 MM_CAMCORDER_AUTO_EXPOSURE_ALL, /* CAMERA_ATTR_EXPOSURE_MODE_ALL */
2631 MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, /* CAMERA_ATTR_EXPOSURE_MODE_CENTER */
2632 MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, /* CAMERA_ATTR_EXPOSURE_MODE_SPOT */
2633 MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1, /* CAMERA_ATTR_EXPOSURE_MODE_CUSTOM */
2636 int ret = MM_ERROR_NONE;
2637 camera_s *handle = (camera_s *)camera;
2639 if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
2640 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2641 return CAMERA_ERROR_INVALID_PARAMETER;
2644 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2645 MMCAM_CAMERA_EXPOSURE_MODE, maptable[mode],
2648 return __convert_camera_error_code(__func__, ret);
2652 int camera_attr_set_exposure(camera_h camera, int value)
2654 if (camera == NULL) {
2655 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2656 return CAMERA_ERROR_INVALID_PARAMETER;
2659 int ret = MM_ERROR_NONE;
2660 camera_s *handle = (camera_s *)camera;
2662 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2663 MMCAM_CAMERA_EXPOSURE_VALUE, value,
2666 return __convert_camera_error_code(__func__, ret);
2670 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
2672 if (camera == NULL) {
2673 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2674 return CAMERA_ERROR_INVALID_PARAMETER;
2677 int ret = MM_ERROR_NONE;
2678 camera_s *handle = (camera_s*)camera;
2680 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2681 MMCAM_CAMERA_ISO, iso,
2684 return __convert_camera_error_code(__func__, ret);
2688 int camera_attr_set_brightness(camera_h camera, int level)
2690 if (camera == NULL) {
2691 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2692 return CAMERA_ERROR_INVALID_PARAMETER;
2695 int ret = MM_ERROR_NONE;
2696 camera_s *handle = (camera_s *)camera;
2698 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2699 MMCAM_FILTER_BRIGHTNESS, level,
2702 return __convert_camera_error_code(__func__, ret);
2706 int camera_attr_set_contrast(camera_h camera, int level)
2708 if (camera == NULL) {
2709 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2710 return CAMERA_ERROR_INVALID_PARAMETER;
2713 int ret = MM_ERROR_NONE;
2714 camera_s *handle = (camera_s *)camera;
2716 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2717 MMCAM_FILTER_CONTRAST, level,
2720 return __convert_camera_error_code(__func__, ret);
2724 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
2726 if (camera == NULL) {
2727 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2728 return CAMERA_ERROR_INVALID_PARAMETER;
2731 int ret = MM_ERROR_NONE;
2732 camera_s *handle = (camera_s *)camera;
2734 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2735 MMCAM_FILTER_WB, wb,
2738 return __convert_camera_error_code(__func__, ret);
2742 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
2744 if (camera == NULL) {
2745 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2746 return CAMERA_ERROR_INVALID_PARAMETER;
2749 int ret = MM_ERROR_NONE;
2750 camera_s *handle = (camera_s *)camera;
2752 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2753 MMCAM_FILTER_COLOR_TONE, effect,
2756 return __convert_camera_error_code(__func__, ret);
2760 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
2762 if (camera == NULL) {
2763 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2764 return CAMERA_ERROR_INVALID_PARAMETER;
2767 int ret = MM_ERROR_NONE;
2768 camera_s *handle = (camera_s *)camera;
2770 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2771 MMCAM_FILTER_SCENE_MODE, mode,
2774 return __convert_camera_error_code(__func__, ret);
2778 int camera_attr_enable_tag(camera_h camera, bool enable)
2780 if (camera == NULL) {
2781 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2782 return CAMERA_ERROR_INVALID_PARAMETER;
2785 int ret = MM_ERROR_NONE;
2786 camera_s *handle = (camera_s *)camera;
2788 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2789 MMCAM_TAG_ENABLE, enable,
2792 return __convert_camera_error_code(__func__, ret);
2796 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
2798 if (camera == NULL) {
2799 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2800 return CAMERA_ERROR_INVALID_PARAMETER;
2803 int ret = MM_ERROR_NONE;
2804 camera_s *handle = (camera_s *)camera;
2806 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2807 MMCAM_TAG_IMAGE_DESCRIPTION, description, strlen(description),
2810 return __convert_camera_error_code(__func__, ret);
2814 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
2816 if (camera == NULL) {
2817 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2818 return CAMERA_ERROR_INVALID_PARAMETER;
2821 int ret = MM_ERROR_NONE;
2822 camera_s *handle = (camera_s *)camera;
2824 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2825 MMCAM_TAG_ORIENTATION, orientation,
2828 return __convert_camera_error_code(__func__, ret);
2832 int camera_attr_set_tag_software(camera_h camera, const char *software)
2834 if (camera == NULL) {
2835 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2836 return CAMERA_ERROR_INVALID_PARAMETER;
2839 int ret = MM_ERROR_NONE;
2840 camera_s *handle = (camera_s *)camera;
2842 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2843 MMCAM_TAG_SOFTWARE, software, strlen(software),
2846 return __convert_camera_error_code(__func__, ret);
2850 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
2852 if (camera == NULL) {
2853 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2854 return CAMERA_ERROR_INVALID_PARAMETER;
2857 int ret = MM_ERROR_NONE;
2858 camera_s *handle = (camera_s *)camera;
2860 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2861 MMCAM_TAG_GPS_ENABLE, true,
2862 MMCAM_TAG_LATITUDE, latitude,
2863 MMCAM_TAG_LONGITUDE, longitude,
2864 MMCAM_TAG_ALTITUDE, altitude,
2867 return __convert_camera_error_code(__func__, ret);
2871 int camera_attr_remove_geotag(camera_h camera)
2873 if (camera == NULL) {
2874 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2875 return CAMERA_ERROR_INVALID_PARAMETER;
2878 int ret = MM_ERROR_NONE;
2879 camera_s *handle = (camera_s *)camera;
2881 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2882 MMCAM_TAG_GPS_ENABLE, false,
2885 return __convert_camera_error_code(__func__, ret);
2889 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
2891 if (camera == NULL) {
2892 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2893 return CAMERA_ERROR_INVALID_PARAMETER;
2896 int ret = MM_ERROR_NONE;
2897 camera_s *handle = (camera_s *)camera;
2899 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2900 MMCAM_STROBE_MODE, mode,
2903 return __convert_camera_error_code(__func__, ret);
2907 int camera_attr_get_zoom(camera_h camera, int *zoom)
2909 if (camera == NULL || zoom == NULL) {
2910 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2911 return CAMERA_ERROR_INVALID_PARAMETER;
2914 int ret = MM_ERROR_NONE;
2915 camera_s *handle = (camera_s *)camera;
2917 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2918 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2921 return __convert_camera_error_code(__func__, ret);
2925 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
2927 if (camera == NULL || min == NULL || max == NULL) {
2928 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2929 return CAMERA_ERROR_INVALID_PARAMETER;
2932 int ret = MM_ERROR_NONE;
2933 camera_s *handle = (camera_s *)camera;
2934 MMCamAttrsInfo ainfo;
2936 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
2937 if (ret == MM_ERROR_NONE) {
2938 *min = ainfo.int_range.min;
2939 *max = ainfo.int_range.max;
2942 return __convert_camera_error_code(__func__, ret);
2946 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
2948 if (camera == NULL || mode == NULL) {
2949 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2950 return CAMERA_ERROR_INVALID_PARAMETER;
2953 int ret = MM_ERROR_NONE;
2957 camera_s *handle = (camera_s *)camera;
2959 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2960 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2961 MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
2962 MMCAM_DETECT_MODE, &detect_mode,
2964 if (ret == MM_ERROR_NONE) {
2965 switch (focus_mode) {
2966 case MM_CAMCORDER_FOCUS_MODE_NONE:
2967 case MM_CAMCORDER_FOCUS_MODE_PAN:
2968 case MM_CAMCORDER_FOCUS_MODE_MANUAL:
2969 *mode = CAMERA_ATTR_AF_NONE;
2971 case MM_CAMCORDER_FOCUS_MODE_AUTO:
2972 case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
2973 case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
2975 case MM_CAMCORDER_AUTO_FOCUS_NONE:
2976 *mode = CAMERA_ATTR_AF_NORMAL;
2978 case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
2979 *mode = CAMERA_ATTR_AF_NORMAL;
2981 case MM_CAMCORDER_AUTO_FOCUS_MACRO:
2982 *mode = CAMERA_ATTR_AF_MACRO;
2984 case MM_CAMCORDER_AUTO_FOCUS_FULL:
2985 *mode = CAMERA_ATTR_AF_FULL;
2988 *mode = CAMERA_ATTR_AF_NORMAL;
2993 *mode = CAMERA_ATTR_AF_NONE;
2998 return __convert_camera_error_code(__func__, ret);
3002 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
3004 if (camera == NULL || mode == NULL) {
3005 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3006 return CAMERA_ERROR_INVALID_PARAMETER;
3009 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3010 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3011 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3012 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3013 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3014 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3015 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3016 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3017 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3019 int ret = MM_ERROR_NONE;
3021 camera_s *handle = (camera_s *)camera;
3023 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3024 MMCAM_CAMERA_EXPOSURE_MODE, &exposure_mode,
3027 if (ret == CAMERA_ERROR_NONE) {
3028 *mode = maptable[abs(exposure_mode%9)];
3031 return __convert_camera_error_code(__func__, ret);
3035 int camera_attr_get_exposure(camera_h camera, int *value)
3037 if (camera == NULL || value == NULL) {
3038 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3039 return CAMERA_ERROR_INVALID_PARAMETER;
3042 int ret = MM_ERROR_NONE;
3043 camera_s *handle = (camera_s *)camera;
3045 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3046 MMCAM_CAMERA_EXPOSURE_VALUE, value,
3049 return __convert_camera_error_code(__func__, ret);
3053 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
3055 if (camera == NULL || min == NULL || max == NULL) {
3056 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3057 return CAMERA_ERROR_INVALID_PARAMETER;
3060 int ret = MM_ERROR_NONE;
3061 camera_s *handle = (camera_s *)camera;
3062 MMCamAttrsInfo ainfo;
3064 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
3065 if (ret == MM_ERROR_NONE) {
3066 *min = ainfo.int_range.min;
3067 *max = ainfo.int_range.max;
3070 return __convert_camera_error_code(__func__, ret);
3074 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
3076 if (camera == NULL || iso == NULL) {
3077 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3078 return CAMERA_ERROR_INVALID_PARAMETER;
3081 int ret = MM_ERROR_NONE;
3082 camera_s *handle = (camera_s *)camera;
3084 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3085 MMCAM_CAMERA_ISO, iso,
3088 return __convert_camera_error_code(__func__, ret);
3092 int camera_attr_get_brightness(camera_h camera, int *level)
3094 if (camera == NULL || level == NULL) {
3095 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3096 return CAMERA_ERROR_INVALID_PARAMETER;
3099 int ret = MM_ERROR_NONE;
3100 camera_s *handle = (camera_s *)camera;
3102 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3103 MMCAM_FILTER_BRIGHTNESS, level,
3106 return __convert_camera_error_code(__func__, ret);
3110 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
3112 if (camera == NULL || min == NULL || max == NULL) {
3113 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3114 return CAMERA_ERROR_INVALID_PARAMETER;
3117 int ret = MM_ERROR_NONE;
3118 camera_s *handle = (camera_s *)camera;
3119 MMCamAttrsInfo ainfo;
3121 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
3122 if (ret == MM_ERROR_NONE) {
3123 *min = ainfo.int_range.min;
3124 *max = ainfo.int_range.max;
3127 return __convert_camera_error_code(__func__, ret);
3131 int camera_attr_get_contrast(camera_h camera, int *level)
3133 if (camera == NULL || level == NULL) {
3134 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3135 return CAMERA_ERROR_INVALID_PARAMETER;
3138 int ret = MM_ERROR_NONE;
3139 camera_s *handle = (camera_s *)camera;
3141 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3142 MMCAM_FILTER_CONTRAST, level,
3145 return __convert_camera_error_code(__func__, ret);
3149 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
3151 if (camera == NULL || min == NULL || max == NULL) {
3152 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3153 return CAMERA_ERROR_INVALID_PARAMETER;
3156 int ret = MM_ERROR_NONE;
3157 camera_s *handle = (camera_s *)camera;
3158 MMCamAttrsInfo ainfo;
3160 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
3161 if (ret == MM_ERROR_NONE) {
3162 *min = ainfo.int_range.min;
3163 *max = ainfo.int_range.max;
3166 return __convert_camera_error_code(__func__, ret);
3170 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
3172 if (camera == NULL || wb == NULL) {
3173 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3174 return CAMERA_ERROR_INVALID_PARAMETER;
3177 int ret = MM_ERROR_NONE;
3178 camera_s *handle = (camera_s *)camera;
3180 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3181 MMCAM_FILTER_WB, wb,
3184 return __convert_camera_error_code(__func__, ret);
3188 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
3190 if (camera == NULL || effect == NULL) {
3191 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3192 return CAMERA_ERROR_INVALID_PARAMETER;
3195 int ret = MM_ERROR_NONE;
3196 camera_s *handle = (camera_s *)camera;
3198 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3199 MMCAM_FILTER_COLOR_TONE, effect,
3202 return __convert_camera_error_code(__func__, ret);
3206 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
3208 if (camera == NULL || mode == NULL) {
3209 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3210 return CAMERA_ERROR_INVALID_PARAMETER;
3213 int ret = MM_ERROR_NONE;
3214 camera_s *handle = (camera_s *)camera;
3216 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3217 MMCAM_FILTER_SCENE_MODE, mode,
3220 return __convert_camera_error_code(__func__, ret);
3224 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
3226 if (camera == NULL || enable == NULL) {
3227 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3228 return CAMERA_ERROR_INVALID_PARAMETER;
3231 int ret = MM_ERROR_NONE;
3232 camera_s *handle = (camera_s *)camera;
3234 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3235 MMCAM_TAG_ENABLE, enable,
3238 return __convert_camera_error_code(__func__, ret);
3242 int camera_attr_get_tag_image_description(camera_h camera, char **description)
3244 if (camera == NULL || description == NULL) {
3245 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3246 return CAMERA_ERROR_INVALID_PARAMETER;
3249 int ret = MM_ERROR_NONE;
3250 camera_s *handle = (camera_s *)camera;
3251 char *ndescription = NULL;
3254 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3255 MMCAM_TAG_IMAGE_DESCRIPTION, &ndescription, &desc_size,
3257 if (ret == MM_ERROR_NONE) {
3258 if (ndescription != NULL) {
3259 *description = strdup(ndescription);
3261 *description = strdup("");
3265 return __convert_camera_error_code(__func__, ret);
3269 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
3271 if (camera == NULL || orientation == NULL) {
3272 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3273 return CAMERA_ERROR_INVALID_PARAMETER;
3276 int ret = MM_ERROR_NONE;
3277 camera_s *handle = (camera_s *)camera;
3279 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3280 MMCAM_TAG_ORIENTATION, orientation,
3283 return __convert_camera_error_code(__func__, ret);
3287 int camera_attr_get_tag_software(camera_h camera, char **software)
3289 if (camera == NULL || software == NULL) {
3290 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3291 return CAMERA_ERROR_INVALID_PARAMETER;
3294 int ret = MM_ERROR_NONE;
3295 camera_s *handle = (camera_s *)camera;
3299 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3300 MMCAM_TAG_SOFTWARE, &soft, &soft_size,
3302 if (ret == MM_ERROR_NONE) {
3304 *software = strdup(soft);
3306 *software = strdup("");
3310 return __convert_camera_error_code(__func__, ret);
3314 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
3316 if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
3317 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3318 return CAMERA_ERROR_INVALID_PARAMETER;
3321 int ret = MM_ERROR_NONE;
3322 camera_s *handle = (camera_s *)camera;
3324 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3325 MMCAM_TAG_LATITUDE, latitude,
3326 MMCAM_TAG_LONGITUDE, longitude,
3327 MMCAM_TAG_ALTITUDE, altitude,
3330 return __convert_camera_error_code(__func__, ret);
3334 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
3336 if (camera == NULL || mode == NULL) {
3337 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3338 return CAMERA_ERROR_INVALID_PARAMETER;
3341 int ret = MM_ERROR_NONE;
3342 camera_s *handle = (camera_s *)camera;
3344 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3345 MMCAM_STROBE_MODE, mode,
3348 return __convert_camera_error_code(__func__, ret);
3352 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
3354 if (camera == NULL || foreach_cb == NULL) {
3355 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3356 return CAMERA_ERROR_INVALID_PARAMETER;
3359 int ret = MM_ERROR_NONE;
3361 camera_s *handle = (camera_s *)camera;
3362 MMCamAttrsInfo af_range;
3363 MMCamAttrsInfo focus_mode;
3365 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE, &af_range);
3366 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE, &focus_mode);
3367 if (ret != MM_ERROR_NONE) {
3368 return __convert_camera_error_code(__func__, ret);
3371 for (i = 0 ; i < af_range.int_array.count ; i++) {
3372 if (!foreach_cb(af_range.int_array.array[i], user_data)) {
3377 return CAMERA_ERROR_NONE;
3381 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
3383 if (camera == NULL || foreach_cb == NULL) {
3384 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3385 return CAMERA_ERROR_INVALID_PARAMETER;
3388 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3389 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3390 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3391 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3392 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3393 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3394 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3395 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3396 -1 /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3399 int ret = MM_ERROR_NONE;
3400 camera_s *handle = (camera_s *)camera;
3401 MMCamAttrsInfo info;
3403 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE, &info);
3404 if (ret != MM_ERROR_NONE) {
3405 return __convert_camera_error_code(__func__, ret);
3408 for (i = 0 ; i < info.int_array.count ; i++) {
3409 if (info.int_array.array[i] >= MM_CAMCORDER_AUTO_EXPOSURE_OFF &&
3410 info.int_array.array[i] <= MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2) {
3411 if (maptable[info.int_array.array[i]] != -1) {
3412 if (!foreach_cb(maptable[info.int_array.array[i]], user_data)) {
3417 LOGW("unknown value %d", info.int_array.array[i]);
3421 return CAMERA_ERROR_NONE;
3425 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
3427 if (camera == NULL || foreach_cb == NULL) {
3428 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3429 return CAMERA_ERROR_INVALID_PARAMETER;
3433 int ret = MM_ERROR_NONE;
3434 camera_s *handle = (camera_s *)camera;
3435 MMCamAttrsInfo info;
3437 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO, &info);
3438 if (ret != MM_ERROR_NONE) {
3439 return __convert_camera_error_code(__func__, ret);
3442 for (i = 0 ; i < info.int_array.count ; i++) {
3443 if (!foreach_cb(info.int_array.array[i], user_data)) {
3448 return CAMERA_ERROR_NONE;
3452 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
3454 if (camera == NULL || foreach_cb == NULL) {
3455 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3456 return CAMERA_ERROR_INVALID_PARAMETER;
3460 int ret = MM_ERROR_NONE;
3461 camera_s *handle = (camera_s *)camera;
3462 MMCamAttrsInfo info;
3464 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB, &info);
3465 if (ret != MM_ERROR_NONE) {
3466 return __convert_camera_error_code(__func__, ret);
3469 for (i = 0 ; i < info.int_array.count ; i++) {
3470 if (!foreach_cb(info.int_array.array[i], user_data)) {
3475 return CAMERA_ERROR_NONE;
3479 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
3481 if (camera == NULL || foreach_cb == NULL) {
3482 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3483 return CAMERA_ERROR_INVALID_PARAMETER;
3487 int ret = MM_ERROR_NONE;
3488 camera_s *handle = (camera_s *)camera;
3489 MMCamAttrsInfo info;
3491 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE, &info);
3492 if (ret != MM_ERROR_NONE) {
3493 return __convert_camera_error_code(__func__, ret);
3496 for (i = 0 ; i < info.int_array.count ; i++) {
3497 if (!foreach_cb(info.int_array.array[i], user_data)) {
3502 return CAMERA_ERROR_NONE;
3506 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
3508 if (camera == NULL || foreach_cb == NULL) {
3509 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3510 return CAMERA_ERROR_INVALID_PARAMETER;
3514 int ret = MM_ERROR_NONE;
3515 camera_s *handle = (camera_s *)camera;
3516 MMCamAttrsInfo info;
3518 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE, &info);
3519 if (ret != MM_ERROR_NONE) {
3520 return __convert_camera_error_code(__func__, ret);
3523 for (i = 0 ; i < info.int_array.count ; i++) {
3524 if (!foreach_cb(info.int_array.array[i], user_data)) {
3529 return CAMERA_ERROR_NONE;
3533 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
3535 if (camera == NULL || foreach_cb == NULL) {
3536 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3537 return CAMERA_ERROR_INVALID_PARAMETER;
3541 int ret = MM_ERROR_NONE;
3542 camera_s *handle = (camera_s *)camera;
3543 MMCamAttrsInfo info;
3545 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE, &info);
3546 if (ret != MM_ERROR_NONE) {
3547 return __convert_camera_error_code(__func__, ret);
3550 for (i = 0 ; i < info.int_array.count ; i++) {
3551 if (!foreach_cb(info.int_array.array[i], user_data)) {
3556 return CAMERA_ERROR_NONE;
3560 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
3562 if (camera == NULL || foreach_cb == NULL) {
3563 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3564 return CAMERA_ERROR_INVALID_PARAMETER;
3567 int ret = MM_ERROR_NONE;
3568 camera_s *handle = (camera_s *)camera;
3569 MMCamAttrsInfo info;
3574 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3575 MMCAM_CAMERA_WIDTH, &width,
3576 MMCAM_CAMERA_HEIGHT, &height,
3578 if (ret != MM_ERROR_NONE) {
3579 return __convert_camera_error_code(__func__, ret);
3582 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3583 if (ret != MM_ERROR_NONE) {
3584 return __convert_camera_error_code(__func__, ret);
3587 for (i = 0 ; i < info.int_array.count ; i++) {
3588 if (!foreach_cb(info.int_array.array[i], user_data)) {
3593 return CAMERA_ERROR_NONE;
3597 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)
3599 if (camera == NULL || foreach_cb == NULL) {
3600 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3601 return CAMERA_ERROR_INVALID_PARAMETER;
3604 int ret = MM_ERROR_NONE;
3605 camera_s *handle = (camera_s *)camera;
3606 MMCamAttrsInfo info;
3609 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3610 if (ret != MM_ERROR_NONE) {
3611 return __convert_camera_error_code(__func__, ret);
3614 for (i = 0 ; i < info.int_array.count ; i++) {
3615 if (!foreach_cb(info.int_array.array[i], user_data)) {
3620 return CAMERA_ERROR_NONE;
3624 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
3626 if (camera == NULL || foreach_cb == NULL) {
3627 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3628 return CAMERA_ERROR_INVALID_PARAMETER;
3632 int ret = MM_ERROR_NONE;
3633 camera_s *handle = (camera_s *)camera;
3634 MMCamAttrsInfo info;
3636 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FLIP, &info);
3637 if (ret != MM_ERROR_NONE) {
3638 return __convert_camera_error_code(__func__, ret);
3641 for (i = 0 ; i < info.int_array.count ; i++) {
3642 if (!foreach_cb(info.int_array.array[i], user_data)) {
3647 return CAMERA_ERROR_NONE;
3651 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
3653 if (camera == NULL || foreach_cb == NULL) {
3654 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3655 return CAMERA_ERROR_INVALID_PARAMETER;
3659 int ret = MM_ERROR_NONE;
3660 camera_s *handle = (camera_s *)camera;
3661 MMCamAttrsInfo info;
3663 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ROTATION, &info);
3664 if (ret != MM_ERROR_NONE) {
3665 return __convert_camera_error_code(__func__, ret);
3668 for (i = 0 ; i < info.int_array.count ; i++) {
3669 if (!foreach_cb(info.int_array.array[i], user_data)) {
3674 return CAMERA_ERROR_NONE;
3678 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
3680 if (camera == NULL) {
3681 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3682 return CAMERA_ERROR_INVALID_PARAMETER;
3685 if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
3686 LOGE("INVALID_PARAMETER - %d", rotation);
3687 return CAMERA_ERROR_INVALID_PARAMETER;
3690 int ret = MM_ERROR_NONE;
3691 camera_s *handle = (camera_s *)camera;
3693 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3694 MMCAM_CAMERA_ROTATION, rotation,
3697 return __convert_camera_error_code(__func__, ret);
3701 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
3703 if (camera == NULL || rotation == NULL) {
3704 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3705 return CAMERA_ERROR_INVALID_PARAMETER;
3708 int ret = MM_ERROR_NONE;
3709 camera_s *handle = (camera_s *)camera;
3711 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3712 MMCAM_CAMERA_ROTATION, rotation,
3715 return __convert_camera_error_code(__func__, ret);
3719 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
3721 if (camera == NULL) {
3722 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3723 return CAMERA_ERROR_INVALID_PARAMETER;
3726 if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
3727 LOGE("INVALID_PARAMETER - %d", flip);
3728 return CAMERA_ERROR_INVALID_PARAMETER;
3731 int ret = MM_ERROR_NONE;
3732 camera_s *handle = (camera_s *)camera;
3734 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3735 MMCAM_CAMERA_FLIP, flip,
3738 return __convert_camera_error_code(__func__, ret);
3742 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
3744 if (camera == NULL || flip == NULL) {
3745 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3746 return CAMERA_ERROR_INVALID_PARAMETER;
3749 int ret = MM_ERROR_NONE;
3750 camera_s *handle = (camera_s *)camera;
3752 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3753 MMCAM_CAMERA_FLIP, flip,
3756 return __convert_camera_error_code(__func__, ret);
3760 int _camera_set_use(camera_h camera, bool used)
3762 camera_s *handle = (camera_s *)camera;
3764 if (handle == NULL) {
3765 LOGE("handle is NULL");
3766 return CAMERA_ERROR_INVALID_PARAMETER;
3769 handle->is_used_in_recorder = used;
3771 return CAMERA_ERROR_NONE;
3775 bool _camera_is_used(camera_h camera)
3777 camera_s *handle = (camera_s *)camera;
3779 if (handle == NULL) {
3780 LOGE("handle is NULL");
3784 return handle->is_used_in_recorder;
3788 int _camera_get_mm_handle(camera_h camera, MMHandleType *handle)
3790 if (camera == NULL || handle == NULL) {
3791 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3792 return CAMERA_ERROR_INVALID_PARAMETER;
3795 camera_s *camera_handle = (camera_s*)camera;
3797 *handle = camera_handle->mm_handle;
3799 return CAMERA_ERROR_NONE;
3803 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data)
3805 if( camera == NULL ){
3806 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3807 return CAMERA_ERROR_INVALID_PARAMETER;
3810 camera_s *handle = (camera_s *)camera;
3811 handle->relay_message_callback = callback;
3812 handle->relay_user_data = user_data;
3814 return CAMERA_ERROR_NONE;
3818 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
3820 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3821 in_format >= MM_PIXEL_FORMAT_NUM ||
3822 out_format == NULL) {
3823 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
3824 return CAMERA_ERROR_INVALID_PARAMETER;
3827 switch (in_format) {
3828 case MM_PIXEL_FORMAT_NV12:
3829 case MM_PIXEL_FORMAT_NV12T:
3830 *out_format = TBM_FORMAT_NV12;
3832 case MM_PIXEL_FORMAT_NV16:
3833 *out_format = TBM_FORMAT_NV16;
3835 case MM_PIXEL_FORMAT_NV21:
3836 *out_format = TBM_FORMAT_NV21;
3838 case MM_PIXEL_FORMAT_YUYV:
3839 *out_format = TBM_FORMAT_YUYV;
3841 case MM_PIXEL_FORMAT_UYVY:
3842 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3843 *out_format = TBM_FORMAT_UYVY;
3845 case MM_PIXEL_FORMAT_422P:
3846 *out_format = TBM_FORMAT_YUV422;
3848 case MM_PIXEL_FORMAT_I420:
3849 *out_format = TBM_FORMAT_YUV420;
3851 case MM_PIXEL_FORMAT_YV12:
3852 *out_format = TBM_FORMAT_YVU420;
3854 case MM_PIXEL_FORMAT_RGB565:
3855 *out_format = TBM_FORMAT_RGB565;
3857 case MM_PIXEL_FORMAT_RGB888:
3858 *out_format = TBM_FORMAT_RGB888;
3860 case MM_PIXEL_FORMAT_RGBA:
3861 *out_format = TBM_FORMAT_RGBA8888;
3863 case MM_PIXEL_FORMAT_ARGB:
3864 *out_format = TBM_FORMAT_ARGB8888;
3867 LOGE("invalid in_format %d", in_format);
3868 return CAMERA_ERROR_INVALID_PARAMETER;
3871 return CAMERA_ERROR_NONE;
3875 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
3877 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3878 in_format >= MM_PIXEL_FORMAT_NUM ||
3880 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
3881 return CAMERA_ERROR_INVALID_PARAMETER;
3884 switch (in_format) {
3885 case MM_PIXEL_FORMAT_NV12:
3886 case MM_PIXEL_FORMAT_NV12T:
3887 *mimetype = MEDIA_FORMAT_NV12;
3889 case MM_PIXEL_FORMAT_NV16:
3890 *mimetype = MEDIA_FORMAT_NV16;
3892 case MM_PIXEL_FORMAT_NV21:
3893 *mimetype = MEDIA_FORMAT_NV21;
3895 case MM_PIXEL_FORMAT_YUYV:
3896 *mimetype = MEDIA_FORMAT_YUYV;
3898 case MM_PIXEL_FORMAT_UYVY:
3899 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3900 *mimetype = MEDIA_FORMAT_UYVY;
3902 case MM_PIXEL_FORMAT_422P:
3903 *mimetype = MEDIA_FORMAT_422P;
3905 case MM_PIXEL_FORMAT_I420:
3906 *mimetype = MEDIA_FORMAT_I420;
3908 case MM_PIXEL_FORMAT_YV12:
3909 *mimetype = MEDIA_FORMAT_YV12;
3911 case MM_PIXEL_FORMAT_RGB565:
3912 *mimetype = MEDIA_FORMAT_RGB565;
3914 case MM_PIXEL_FORMAT_RGB888:
3915 *mimetype = MEDIA_FORMAT_RGB888;
3917 case MM_PIXEL_FORMAT_RGBA:
3918 *mimetype = MEDIA_FORMAT_RGBA;
3920 case MM_PIXEL_FORMAT_ARGB:
3921 *mimetype = MEDIA_FORMAT_ARGB;
3924 LOGE("invalid in_format %d", in_format);
3925 return CAMERA_ERROR_INVALID_PARAMETER;
3928 return CAMERA_ERROR_NONE;
3932 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
3935 void *internal_buffer = NULL;
3936 tbm_surface_h tsurf = NULL;
3938 if (pkt == NULL || user_data == NULL) {
3939 LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
3940 return MEDIA_PACKET_FINALIZE;
3943 ret = media_packet_get_extra(pkt, &internal_buffer);
3944 if (ret != MEDIA_PACKET_ERROR_NONE) {
3945 LOGE("media_packet_get_extra failed 0x%x", ret);
3946 return MEDIA_PACKET_FINALIZE;
3949 /*LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret);*/
3951 if (internal_buffer) {
3952 gst_buffer_unref((GstBuffer *)internal_buffer);
3953 internal_buffer = NULL;
3956 ret = media_packet_get_tbm_surface(pkt, &tsurf);
3957 if (ret != MEDIA_PACKET_ERROR_NONE) {
3958 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
3959 return MEDIA_PACKET_FINALIZE;
3963 tbm_surface_destroy(tsurf);
3967 return MEDIA_PACKET_FINALIZE;
3971 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
3973 if (camera == NULL) {
3974 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3975 return CAMERA_ERROR_INVALID_PARAMETER;
3978 if (camera_attr_is_supported_hdr_capture(camera) == false) {
3979 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3980 return CAMERA_ERROR_NOT_SUPPORTED;
3983 int ret = MM_ERROR_NONE;
3984 camera_s *handle = (camera_s *)camera;
3986 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3987 MMCAM_CAMERA_HDR_CAPTURE, mode,
3990 if (ret == MM_ERROR_NONE) {
3991 if (mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL) {
3992 handle->hdr_keep_mode = true;
3994 handle->hdr_keep_mode = false;
3998 return __convert_camera_error_code(__func__, ret);
4002 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
4004 if (camera == NULL) {
4005 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4006 return CAMERA_ERROR_INVALID_PARAMETER;
4009 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4010 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4011 return CAMERA_ERROR_NOT_SUPPORTED;
4015 LOGE("INVALID_PARAMETER(0x%08x) - mode", CAMERA_ERROR_INVALID_PARAMETER);
4016 return CAMERA_ERROR_INVALID_PARAMETER;
4019 int ret = MM_ERROR_NONE;
4020 camera_s *handle = (camera_s *)camera;
4022 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4023 MMCAM_CAMERA_HDR_CAPTURE, mode,
4026 return __convert_camera_error_code(__func__, ret);
4030 bool camera_attr_is_supported_hdr_capture(camera_h camera)
4032 if (camera == NULL) {
4033 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4037 int ret = MM_ERROR_NONE;
4039 camera_s *handle = (camera_s *)camera;
4040 MMCamAttrsInfo hdr_info;
4042 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE, &hdr_info);
4043 set_last_result(__convert_camera_error_code(__func__, ret));
4044 if (ret != MM_ERROR_NONE) {
4045 LOGE("MMCAM_CAMERA_HDR_CAPTURE get attr info failed");
4049 for (i = 0; i < hdr_info.int_array.count ; i++) {
4050 if (hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON) {
4051 LOGD("HDR capture supported");
4056 LOGD("HDR capture NOT supported");
4062 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
4064 if (camera == NULL) {
4065 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4066 return CAMERA_ERROR_INVALID_PARAMETER;
4069 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4070 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4071 return CAMERA_ERROR_NOT_SUPPORTED;
4074 if (callback == NULL) {
4075 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
4076 return CAMERA_ERROR_INVALID_PARAMETER;
4079 camera_s *handle = (camera_s *)camera;
4081 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)callback;
4082 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)user_data;
4084 return CAMERA_ERROR_NONE;
4088 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
4090 if (camera == NULL) {
4091 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4092 return CAMERA_ERROR_INVALID_PARAMETER;
4095 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4096 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4097 return CAMERA_ERROR_NOT_SUPPORTED;
4100 camera_s *handle = (camera_s *)camera;
4102 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4103 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4105 return CAMERA_ERROR_NONE;
4109 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
4111 if (camera == NULL) {
4112 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4113 return CAMERA_ERROR_INVALID_PARAMETER;
4116 if (camera_attr_is_supported_anti_shake(camera) == false) {
4117 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4118 return CAMERA_ERROR_NOT_SUPPORTED;
4121 int ret = MM_ERROR_NONE;
4122 int mode = MM_CAMCORDER_AHS_OFF;
4123 camera_s *handle = (camera_s *)camera;
4126 mode = MM_CAMCORDER_AHS_ON;
4129 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4130 MMCAM_CAMERA_ANTI_HANDSHAKE, mode,
4133 return __convert_camera_error_code(__func__, ret);
4137 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
4139 if (camera == NULL) {
4140 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4141 return CAMERA_ERROR_INVALID_PARAMETER;
4144 if (camera_attr_is_supported_anti_shake(camera) == false) {
4145 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4146 return CAMERA_ERROR_NOT_SUPPORTED;
4149 if (enabled == NULL) {
4150 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4151 return CAMERA_ERROR_INVALID_PARAMETER;
4154 int ret = MM_ERROR_NONE;
4155 camera_s *handle = (camera_s *)camera;
4157 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4158 MMCAM_CAMERA_ANTI_HANDSHAKE, enabled,
4161 return __convert_camera_error_code(__func__, ret);
4165 bool camera_attr_is_supported_anti_shake(camera_h camera)
4167 if (camera == NULL) {
4168 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4173 int ret = MM_ERROR_NONE;
4174 camera_s *handle = (camera_s *)camera;
4175 MMCamAttrsInfo ash_info;
4177 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE, &ash_info);
4178 set_last_result(__convert_camera_error_code(__func__, ret));
4179 if (ret != MM_ERROR_NONE) {
4180 LOGE("MMCAM_CAMERA_ANTI_HANDSHAKE get attr info failed");
4184 for (i = 0 ; i < ash_info.int_array.count ; i++) {
4185 if (ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON) {
4194 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
4196 if (camera == NULL) {
4197 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4198 return CAMERA_ERROR_INVALID_PARAMETER;
4201 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4202 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4203 return CAMERA_ERROR_NOT_SUPPORTED;
4206 int ret = MM_ERROR_NONE;
4207 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4208 camera_s *handle = (camera_s*)camera;
4211 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
4214 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4215 MMCAM_CAMERA_VIDEO_STABILIZATION, mode,
4218 return __convert_camera_error_code(__func__, ret);
4222 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
4224 if (camera == NULL) {
4225 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4226 return CAMERA_ERROR_INVALID_PARAMETER;
4229 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4230 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4231 return CAMERA_ERROR_NOT_SUPPORTED;
4234 if (enabled == NULL) {
4235 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4236 return CAMERA_ERROR_INVALID_PARAMETER;
4239 int ret = MM_ERROR_NONE;
4240 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4241 camera_s *handle = (camera_s *)camera;
4243 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4244 MMCAM_CAMERA_VIDEO_STABILIZATION, &mode,
4246 if (ret == MM_ERROR_NONE) {
4247 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
4250 return __convert_camera_error_code(__func__, ret);
4254 bool camera_attr_is_supported_video_stabilization(camera_h camera)
4256 if (camera == NULL) {
4257 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4262 int ret = MM_ERROR_NONE;
4263 camera_s *handle = (camera_s *)camera;
4264 MMCamAttrsInfo vs_info;
4266 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION, &vs_info);
4267 set_last_result(__convert_camera_error_code(__func__, ret));
4268 if (ret != MM_ERROR_NONE) {
4269 LOGE("MMCAM_CAMERA_VIDEO_STABILIZATION get attr info failed");
4273 for (i = 0 ; i < vs_info.int_array.count ; i++) {
4274 if (vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
4283 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
4285 if (camera == NULL) {
4286 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4287 return CAMERA_ERROR_INVALID_PARAMETER;
4290 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4291 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4292 return CAMERA_ERROR_NOT_SUPPORTED;
4295 int ret = MM_ERROR_NONE;
4296 int mode = MM_CAMCORDER_WDR_OFF;
4297 camera_s *handle = (camera_s *)camera;
4300 mode = MM_CAMCORDER_WDR_ON;
4303 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4304 MMCAM_CAMERA_WDR, mode,
4307 return __convert_camera_error_code(__func__, ret);
4311 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
4313 if (camera == NULL) {
4314 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4315 return CAMERA_ERROR_INVALID_PARAMETER;
4318 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4319 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4320 return CAMERA_ERROR_NOT_SUPPORTED;
4323 if (enabled == NULL) {
4324 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4325 return CAMERA_ERROR_INVALID_PARAMETER;
4328 int ret = MM_ERROR_NONE;
4329 int mode = MM_CAMCORDER_WDR_OFF;
4330 camera_s *handle = (camera_s *)camera;
4332 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4333 MMCAM_CAMERA_WDR, &mode,
4336 if (ret == MM_ERROR_NONE) {
4340 return __convert_camera_error_code(__func__, ret);
4344 bool camera_attr_is_supported_auto_contrast(camera_h camera)
4346 if (camera == NULL) {
4347 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4352 int ret = MM_ERROR_NONE;
4353 camera_s *handle = (camera_s *)camera;
4354 MMCamAttrsInfo info;
4356 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WDR, &info);
4357 set_last_result(__convert_camera_error_code(__func__, ret));
4358 if (ret != MM_ERROR_NONE) {
4359 LOGE("MMCAM_CAMERA_WDR get attr info failed");
4363 for (i = 0 ; i < info.int_array.count ; i++) {
4364 if (info.int_array.array[i] == MM_CAMCORDER_WDR_ON) {
4373 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
4375 if (camera == NULL) {
4376 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4377 return CAMERA_ERROR_INVALID_PARAMETER;
4380 int ret = MM_ERROR_NONE;
4381 camera_s *handle = (camera_s *)camera;
4383 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4384 "capture-sound-enable", !disable,
4386 if (ret != MM_ERROR_NONE) {
4387 LOGE("CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound");
4388 return CAMERA_ERROR_INVALID_OPERATION;
4391 return CAMERA_ERROR_NONE;