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 <Ecore_Wayland.h>
36 #include <Elementary.h>
41 #define LOG_TAG "TIZEN_N_CAMERA"
43 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType *stream, void *user_data);
44 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data);
47 void _camera_remove_cb_message(camera_s *handle)
51 camera_cb_data *cb_data = NULL;
54 LOGE("handle is NULL");
60 g_mutex_lock(&handle->idle_cb_lock);
62 if (handle->cb_data_list) {
63 list = handle->cb_data_list;
67 list = g_list_next(list);
70 LOGW("cb_data is NULL");
72 ret = g_idle_remove_by_data (cb_data);
73 LOGW("Remove cb_data[%p]. ret[%d]", cb_data, ret);
75 handle->cb_data_list = g_list_remove(handle->cb_data_list, cb_data);
81 g_list_free(handle->cb_data_list);
82 handle->cb_data_list = NULL;
84 LOGW("There is no remained callback");
87 g_mutex_unlock(&handle->idle_cb_lock);
95 int __convert_camera_error_code(const char *func, int code)
97 int ret = CAMERA_ERROR_NONE;
98 const char *errorstr = NULL;
102 ret = CAMERA_ERROR_NONE;
103 errorstr = "ERROR_NONE";
105 case MM_ERROR_CAMCORDER_INVALID_ARGUMENT:
106 case MM_ERROR_COMMON_INVALID_ATTRTYPE:
107 ret = CAMERA_ERROR_INVALID_PARAMETER;
108 errorstr = "INVALID_PARAMETER";
110 case MM_ERROR_CAMCORDER_NOT_INITIALIZED:
111 case MM_ERROR_CAMCORDER_INVALID_STATE:
112 ret = CAMERA_ERROR_INVALID_STATE;
113 errorstr = "INVALID_STATE";
115 case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND:
116 ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
117 errorstr = "DEVICE_NOT_FOUND";
119 case MM_ERROR_CAMCORDER_DEVICE_BUSY:
120 case MM_ERROR_CAMCORDER_DEVICE_OPEN:
121 case MM_ERROR_CAMCORDER_CMD_IS_RUNNING:
122 ret = CAMERA_ERROR_DEVICE_BUSY;
123 errorstr = "DEVICE_BUSY";
125 case MM_ERROR_CAMCORDER_DEVICE:
126 case MM_ERROR_CAMCORDER_DEVICE_IO:
127 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
128 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
129 case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER:
130 ret = CAMERA_ERROR_DEVICE;
131 errorstr = "ERROR_DEVICE";
133 case MM_ERROR_CAMCORDER_GST_CORE:
134 case MM_ERROR_CAMCORDER_GST_LIBRARY:
135 case MM_ERROR_CAMCORDER_GST_RESOURCE:
136 case MM_ERROR_CAMCORDER_GST_STREAM:
137 case MM_ERROR_CAMCORDER_GST_STATECHANGE:
138 case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
139 case MM_ERROR_CAMCORDER_GST_LINK:
140 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
141 case MM_ERROR_CAMCORDER_ENCODER:
142 case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
143 case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE:
144 case MM_ERROR_CAMCORDER_ENCODER_WORKING:
145 case MM_ERROR_CAMCORDER_INTERNAL:
146 case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT:
147 case MM_ERROR_CAMCORDER_DSP_FAIL:
148 case MM_ERROR_CAMCORDER_AUDIO_EMPTY:
149 case MM_ERROR_CAMCORDER_CREATE_CONFIGURE:
150 case MM_ERROR_CAMCORDER_FILE_SIZE_OVER:
151 case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF:
152 case MM_ERROR_CAMCORDER_INVALID_CONDITION:
153 ret = CAMERA_ERROR_INVALID_OPERATION;
154 errorstr = "INVALID_OPERATION";
156 case MM_ERROR_CAMCORDER_RESOURCE_CREATION:
157 case MM_ERROR_COMMON_OUT_OF_MEMORY:
158 ret = CAMERA_ERROR_OUT_OF_MEMORY;
159 errorstr = "OUT_OF_MEMORY";
161 case MM_ERROR_POLICY_BLOCKED:
162 ret = CAMERA_ERROR_SOUND_POLICY;
163 errorstr = "ERROR_SOUND_POLICY";
165 case MM_ERROR_POLICY_BLOCKED_BY_CALL:
166 ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
167 errorstr = "ERROR_SOUND_POLICY_BY_CALL";
169 case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
170 ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
171 errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
173 case MM_ERROR_POLICY_RESTRICTED:
174 ret = CAMERA_ERROR_SECURITY_RESTRICTED;
175 errorstr = "ERROR_RESTRICTED";
177 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
178 ret = CAMERA_ERROR_ESD;
179 errorstr = "ERROR_ESD";
181 case MM_ERROR_COMMON_INVALID_PERMISSION:
182 ret = CAMERA_ERROR_PERMISSION_DENIED;
183 errorstr = "ERROR_PERMISSION_DENIED";
185 case MM_ERROR_COMMON_OUT_OF_ARRAY:
186 case MM_ERROR_COMMON_OUT_OF_RANGE:
187 case MM_ERROR_COMMON_ATTR_NOT_EXIST:
188 case MM_ERROR_CAMCORDER_NOT_SUPPORTED:
189 ret = CAMERA_ERROR_NOT_SUPPORTED;
190 errorstr = "ERROR_NOT_SUPPORTED";
193 ret = CAMERA_ERROR_INVALID_OPERATION;
194 errorstr = "INVALID_OPERATION";
197 if (code != MM_ERROR_NONE) {
198 LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func ? func : "NULL_FUNC", errorstr, ret, code);
205 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType *stream, void *user_data)
207 if (user_data == NULL || stream == NULL) {
211 camera_s *handle = (camera_s *)user_data;
213 if (handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW]) {
214 camera_preview_data_s frame;
216 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
217 frame.format = MM_PIXEL_FORMAT_UYVY;
219 frame.format = stream->format;
221 frame.width = stream->width;
222 frame.height = stream->height;
223 frame.timestamp = stream->timestamp;
224 frame.num_of_planes = stream->num_planes;
226 switch (stream->data_type) {
227 case MM_CAM_STREAM_DATA_YUV420:
228 frame.data.single_plane.yuv = stream->data.yuv420.yuv;
229 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
231 case MM_CAM_STREAM_DATA_YUV422:
232 frame.data.single_plane.yuv = stream->data.yuv422.yuv;
233 frame.data.single_plane.size = stream->data.yuv422.length_yuv;
235 case MM_CAM_STREAM_DATA_YUV420SP:
236 frame.data.double_plane.y = stream->data.yuv420sp.y;
237 frame.data.double_plane.uv = stream->data.yuv420sp.uv;
238 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
239 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
241 case MM_CAM_STREAM_DATA_YUV420P:
242 frame.data.triple_plane.y = stream->data.yuv420p.y;
243 frame.data.triple_plane.u = stream->data.yuv420p.u;
244 frame.data.triple_plane.v = stream->data.yuv420p.v;
245 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
246 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
247 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
249 case MM_CAM_STREAM_DATA_YUV422P:
250 frame.data.triple_plane.y = stream->data.yuv422p.y;
251 frame.data.triple_plane.u = stream->data.yuv422p.u;
252 frame.data.triple_plane.v = stream->data.yuv422p.v;
253 frame.data.triple_plane.y_size = stream->data.yuv422p.length_y;
254 frame.data.triple_plane.u_size = stream->data.yuv422p.length_u;
255 frame.data.triple_plane.v_size = stream->data.yuv422p.length_v;
261 ((camera_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW])(&frame, handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW]);
264 if (handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
265 media_packet_h pkt = NULL;
266 tbm_surface_h tsurf = NULL;
267 uint32_t bo_format = 0;
271 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
272 bool make_pkt_fmt = false;
273 tbm_surface_info_s tsurf_info;
275 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
277 /* create tbm surface */
278 for (i = 0, bo_num = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++) {
282 tsurf_info.planes[i].stride = stream->stride[i];
285 /* get tbm surface format */
286 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
287 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
289 if (bo_num > 0 && ret == CAMERA_ERROR_NONE) {
290 tsurf_info.width = stream->width;
291 tsurf_info.height = stream->height;
292 tsurf_info.format = bo_format;
293 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
294 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
297 case TBM_FORMAT_NV12:
298 case TBM_FORMAT_NV21:
299 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
300 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
301 tsurf_info.planes[0].offset = 0;
303 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
305 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
307 case TBM_FORMAT_YUV420:
308 case TBM_FORMAT_YVU420:
309 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
310 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
311 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
312 tsurf_info.planes[0].offset = 0;
314 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
315 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
317 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
319 case TBM_FORMAT_UYVY:
320 case TBM_FORMAT_YUYV:
321 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
322 tsurf_info.planes[0].offset = 0;
323 tsurf_info.size = tsurf_info.planes[0].size;
329 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, (tbm_bo *)stream->bo, bo_num);
330 /*LOGD("tbm surface %p", tsurf);*/
334 /* check media packet format */
335 if (handle->pkt_fmt) {
336 int pkt_fmt_width = 0;
337 int pkt_fmt_height = 0;
338 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
340 media_format_get_video_info(handle->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
341 if (pkt_fmt_mimetype != mimetype ||
342 pkt_fmt_width != stream->width ||
343 pkt_fmt_height != stream->height) {
344 LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
345 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
346 media_format_unref(handle->pkt_fmt);
347 handle->pkt_fmt = NULL;
354 /* create packet format */
356 LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
357 ret = media_format_create(&handle->pkt_fmt);
358 if (ret == MEDIA_FORMAT_ERROR_NONE) {
359 ret = media_format_set_video_mime(handle->pkt_fmt, mimetype);
360 ret |= media_format_set_video_width(handle->pkt_fmt, stream->width);
361 ret |= media_format_set_video_height(handle->pkt_fmt, stream->height);
362 LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
364 LOGW("media_format_create failed");
368 /* create media packet */
369 ret = media_packet_create_from_tbm_surface(handle->pkt_fmt, tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize, (void *)handle, &pkt);
370 if (ret != MEDIA_PACKET_ERROR_NONE) {
371 LOGE("media_packet_create_from_tbm_surface failed");
373 tbm_surface_destroy(tsurf);
377 LOGE("failed to create tbm surface %dx%d, format %d, bo_num %d", stream->width, stream->height, stream->format, bo_num);
381 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
383 /* set internal buffer */
384 ret = media_packet_set_extra(pkt, stream->internal_buffer);
385 if (ret != MEDIA_PACKET_ERROR_NONE) {
386 LOGE("media_packet_set_extra failed");
388 media_packet_destroy(pkt);
391 /* set timestamp : msec -> nsec */
392 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE) {
393 LOGW("media_packet_set_pts failed");
396 /* increase ref count of gst buffer */
397 gst_buffer_ref((GstBuffer *)stream->internal_buffer);
399 /* call media packet callback */
400 ((camera_media_packet_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt, handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
409 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data)
411 if (user_data == NULL || frame == NULL) {
415 camera_s *handle = (camera_s *)user_data;
416 int ret = MM_ERROR_NONE;
417 unsigned char *exif = NULL;
419 MMCamcorderCaptureDataType *scrnl = NULL;
422 handle->current_capture_count++;
424 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE]) {
425 camera_image_data_s image = { NULL, 0, 0, 0, 0, NULL, 0 };
426 camera_image_data_s thumb = { NULL, 0, 0, 0, 0, NULL, 0 };
427 camera_image_data_s postview = { NULL, 0, 0, 0, 0, NULL, 0 };
430 image.data = frame->data;
431 image.size = frame->length;
432 image.width = frame->width;
433 image.height = frame->height;
434 image.format = frame->format;
436 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
437 "captured-exif-raw-data", &exif, &exif_size,
439 if (ret == MM_ERROR_NONE) {
441 image.exif_size = exif_size;
446 thumb.data = thumbnail->data;
447 thumb.size = thumbnail->length;
448 thumb.width = thumbnail->width;
449 thumb.height = thumbnail->height;
450 thumb.format = thumbnail->format;
453 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
454 "captured-screennail", &scrnl, &scrnl_size,
456 if (ret == MM_ERROR_NONE && scrnl) {
457 postview.data = scrnl->data;
458 postview.size = scrnl->length;
459 postview.width = scrnl->width;
460 postview.height = scrnl->height;
461 postview.format = scrnl->format;
464 ((camera_capturing_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE])(&image,
465 scrnl ? &postview : NULL,
466 thumbnail ? &thumb : NULL,
467 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE]);
470 /* update captured state */
471 if (handle->capture_count == 1 && handle->hdr_keep_mode) {
472 if (handle->current_capture_count == 2) {
473 handle->is_capture_completed = true;
475 } else if (handle->capture_count == handle->current_capture_count ||
476 handle->is_continuous_shot_break) {
477 handle->is_capture_completed = true;
484 static camera_state_e __camera_state_convert(MMCamcorderStateType mm_state)
486 camera_state_e state = CAMERA_STATE_NONE;
489 case MM_CAMCORDER_STATE_NONE:
490 state = CAMERA_STATE_NONE;
492 case MM_CAMCORDER_STATE_NULL:
493 state = CAMERA_STATE_CREATED;
495 case MM_CAMCORDER_STATE_READY:
496 state = CAMERA_STATE_CREATED;
498 case MM_CAMCORDER_STATE_PREPARE:
499 state = CAMERA_STATE_PREVIEW;
501 case MM_CAMCORDER_STATE_CAPTURING:
502 state = CAMERA_STATE_CAPTURING;
504 case MM_CAMCORDER_STATE_RECORDING:
505 state = CAMERA_STATE_PREVIEW;
507 case MM_CAMCORDER_STATE_PAUSED:
508 state = CAMERA_STATE_PREVIEW;
511 state = CAMERA_STATE_NONE;
519 static int __mm_camera_message_callback(int message, void *param, void *user_data)
521 if (user_data == NULL || param == NULL) {
526 int camera_error = 0;
527 camera_s *handle = (camera_s *)user_data;
528 MMMessageParamType *m = (MMMessageParamType *)param;
529 camera_state_e previous_state;
530 camera_policy_e policy = CAMERA_POLICY_NONE;
531 MMCamRecordingReport *report = NULL;
532 MMCamFaceDetectInfo *cam_fd_info = NULL;
534 if (handle->relay_message_callback) {
535 handle->relay_message_callback(message, param, handle->relay_user_data);
539 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
540 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
541 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
542 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED &&
543 (m->state.previous < MM_CAMCORDER_STATE_NONE ||
544 m->state.previous > MM_CAMCORDER_STATE_PAUSED ||
545 m->state.code != 0)) {
546 LOGI( "Invalid state changed message");
550 previous_state = handle->state;
551 handle->state = __camera_state_convert(m->state.current );
553 if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
554 switch (m->state.code) {
555 case ASM_EVENT_SOURCE_CALL_START:
556 case ASM_EVENT_SOURCE_CALL_END:
557 policy = CAMERA_POLICY_SOUND_BY_CALL;
558 LOGW("CAMERA_POLICY_SOUND_BY_CALL");
560 case ASM_EVENT_SOURCE_ALARM_START:
561 case ASM_EVENT_SOURCE_ALARM_END:
562 policy = CAMERA_POLICY_SOUND_BY_ALARM;
563 LOGW("CAMERA_POLICY_SOUND_BY_ALARM");
566 policy = CAMERA_POLICY_SOUND;
567 LOGW("CAMERA_POLICY_SOUND");
570 } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
571 policy = CAMERA_POLICY_SECURITY;
572 LOGW("CAMERA_POLICY_SECURITY");
575 if (previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
576 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
579 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
582 /* should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state */
583 if (policy != CAMERA_POLICY_NONE &&
584 m->state.current == MM_CAMCORDER_STATE_NULL) {
585 if (handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED]) {
586 ((camera_interrupted_cb)handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED])(policy,
589 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED]);
591 LOGW("_CAMERA_EVENT_TYPE_INTERRUPTED cb is NULL");
595 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED :
596 if (handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]) {
597 ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])(m->code,
598 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
601 case MM_MESSAGE_CAMCORDER_CAPTURED:
602 handle->current_capture_complete_count = m->code;
603 if (handle->capture_count == 1 ||
604 m->code == handle->capture_count ||
605 (handle->is_continuous_shot_break &&
606 handle->state == CAMERA_STATE_CAPTURING)) {
607 /* pseudo state change */
608 previous_state = handle->state ;
609 handle->state = CAMERA_STATE_CAPTURED;
610 if (previous_state != handle->state &&
611 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
612 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
615 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
617 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
618 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
622 case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
623 case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
624 report = (MMCamRecordingReport *)m->data;
625 if (report != NULL && report->recording_filename) {
626 free(report->recording_filename);
627 report->recording_filename = NULL;
634 case MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED:
635 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
636 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
639 case MM_MESSAGE_CAMCORDER_ERROR:
641 case MM_ERROR_CAMCORDER_DEVICE :
642 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
643 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
644 camera_error = CAMERA_ERROR_DEVICE;
646 case MM_ERROR_CAMCORDER_GST_CORE:
647 case MM_ERROR_CAMCORDER_GST_LIBRARY:
648 case MM_ERROR_CAMCORDER_GST_RESOURCE:
649 case MM_ERROR_CAMCORDER_GST_STREAM:
650 case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
651 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
652 case MM_ERROR_CAMCORDER_ENCODER:
653 case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
654 case MM_ERROR_CAMCORDER_ENCODER_WORKING:
655 case MM_ERROR_CAMCORDER_MNOTE_CREATION:
656 case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY:
657 case MM_ERROR_CAMCORDER_INTERNAL:
658 case MM_ERROR_FILE_NOT_FOUND:
659 case MM_ERROR_FILE_READ:
660 camera_error = CAMERA_ERROR_INVALID_OPERATION;
662 case MM_ERROR_CAMCORDER_LOW_MEMORY:
663 case MM_ERROR_CAMCORDER_MNOTE_MALLOC:
664 camera_error = CAMERA_ERROR_OUT_OF_MEMORY;
666 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
667 camera_error = CAMERA_ERROR_ESD;
670 camera_error = CAMERA_ERROR_INVALID_OPERATION;
674 /* set capture completed flag as true to release camera handle */
675 handle->is_capture_completed = true;
677 if (camera_error != 0 && handle->user_cb[_CAMERA_EVENT_TYPE_ERROR]) {
678 ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(camera_error,
680 handle->user_data[_CAMERA_EVENT_TYPE_ERROR]);
684 case MM_MESSAGE_CAMCORDER_HDR_PROGRESS:
685 if (handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS]) {
686 ((camera_attr_hdr_progress_cb)handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS])(m->code,
687 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
690 case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
691 cam_fd_info = (MMCamFaceDetectInfo *)(m->data);
693 camera_detected_face_s faces[cam_fd_info->num_of_faces];
694 handle->num_of_faces = cam_fd_info->num_of_faces > MAX_DETECTED_FACE ? MAX_DETECTED_FACE : cam_fd_info->num_of_faces;
696 for (i = 0 ; i < handle->num_of_faces ; i++) {
697 faces[i].id = cam_fd_info->face_info[i].id;
698 faces[i].score = cam_fd_info->face_info[i].score;
699 faces[i].x = cam_fd_info->face_info[i].rect.x;
700 faces[i].y = cam_fd_info->face_info[i].rect.y;
701 faces[i].width = cam_fd_info->face_info[i].rect.width;
702 faces[i].height = cam_fd_info->face_info[i].rect.height;
703 handle->faceinfo[i] = faces[i]; //cache face coordinate
706 if (handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
707 ((camera_face_detected_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
708 handle->num_of_faces,
709 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION]);
712 handle->num_of_faces = 0;
723 static int __capture_completed_event_cb(void *data)
725 camera_s *handle = (camera_s *)data;
726 camera_state_e previous_state = CAMERA_STATE_NONE;
728 if (handle == NULL) {
729 LOGE("handle is NULL");
733 if (handle->current_capture_count > 0 &&
734 handle->current_capture_count == handle->current_capture_complete_count &&
735 handle->state == CAMERA_STATE_CAPTURING) {
736 /* pseudo state change */
737 previous_state = handle->state;
738 handle->state = CAMERA_STATE_CAPTURED;
740 if (previous_state != handle->state &&
741 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE]) {
742 ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state,
745 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
748 if (handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]) {
749 ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
756 int camera_create(camera_device_e device, camera_h* camera)
759 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
760 return CAMERA_ERROR_INVALID_PARAMETER;
763 int ret = MM_ERROR_NONE;;
767 camera_s *handle = NULL;
770 LOGW("device name = [%d]",device);
772 info.videodev_type = device;
774 handle = (camera_s*)malloc( sizeof(camera_s) );
775 if (handle == NULL) {
777 return CAMERA_ERROR_OUT_OF_MEMORY;
780 memset(handle, 0x0, sizeof(camera_s));
782 ret = mm_camcorder_create(&handle->mm_handle, &info);
783 if (ret != MM_ERROR_NONE) {
785 return __convert_camera_error_code(__func__,ret);
788 preview_format = MM_PIXEL_FORMAT_YUYV;
789 rotation = MM_DISPLAY_ROTATION_NONE;
790 ret = mm_camcorder_get_attributes(handle->mm_handle, &error,
791 MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
792 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
793 MMCAM_CAPTURE_WIDTH, &handle->capture_width,
794 MMCAM_CAPTURE_HEIGHT, &handle->capture_height,
796 if (ret != MM_ERROR_NONE) {
797 LOGE("mm_camcorder_get_attributes fail(%x)", ret);
799 LOGE("failed attribute name %s", error);
803 mm_camcorder_destroy(handle->mm_handle);
806 return __convert_camera_error_code(__func__, ret);
809 ret = mm_camcorder_set_attributes(handle->mm_handle, &error,
810 MMCAM_MODE, MM_CAMCORDER_MODE_VIDEO_CAPTURE,
811 MMCAM_CAMERA_FORMAT, preview_format,
812 MMCAM_IMAGE_ENCODER, MM_IMAGE_CODEC_JPEG,
813 MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
814 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL,
815 MMCAM_DISPLAY_ROTATION, rotation,
816 MMCAM_CAPTURE_COUNT, 1,
819 handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
821 if (ret != MM_ERROR_NONE) {
822 LOGE("mm_camcorder_set_attributes fail(%x)", ret);
824 LOGE("failed attribute name %s", error);
828 mm_camcorder_destroy(handle->mm_handle);
831 return __convert_camera_error_code(__func__, ret);
834 handle->state = CAMERA_STATE_CREATED;
835 handle->relay_message_callback = NULL;
836 handle->relay_user_data = NULL;
837 handle->capture_resolution_modified = false;
838 handle->hdr_keep_mode = false;
839 handle->focus_area_valid = false;
840 handle->is_used_in_recorder = false;
841 handle->on_continuous_focusing = false;
842 handle->cached_focus_mode = -1;
844 g_mutex_init(&handle->idle_cb_lock);
846 mm_camcorder_set_message_callback(handle->mm_handle,
847 __mm_camera_message_callback,
850 *camera = (camera_h)handle;
852 LOGW("camera handle %p", handle);
854 return __convert_camera_error_code(__func__, ret);
858 int camera_destroy(camera_h camera)
860 if (camera == NULL) {
861 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
862 return CAMERA_ERROR_INVALID_PARAMETER;
865 int ret = MM_ERROR_NONE;
866 camera_s *handle = (camera_s *)camera;
868 if (handle->is_used_in_recorder) {
869 LOGE("camera is using in another recorder.");
870 return CAMERA_ERROR_INVALID_OPERATION;
873 LOGW("camera handle %p", handle);
875 if (handle->pkt_fmt) {
876 media_format_unref(handle->pkt_fmt);
877 handle->pkt_fmt = NULL;
880 ret = mm_camcorder_destroy(handle->mm_handle);
881 if (ret == MM_ERROR_NONE) {
882 _camera_remove_cb_message(handle);
883 g_mutex_clear(&handle->idle_cb_lock);
885 if (handle->wl_info) {
886 free(handle->wl_info);
887 handle->wl_info = NULL;
889 #endif /* HAVE_WAYLAND */
893 return __convert_camera_error_code(__func__, ret);
897 int camera_start_preview(camera_h camera)
899 if (camera == NULL) {
900 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
901 return CAMERA_ERROR_INVALID_PARAMETER;
904 int ret = MM_ERROR_NONE;
905 camera_s *handle = (camera_s *)camera;
906 camera_state_e capi_state = CAMERA_STATE_NONE;
907 MMCamcorderStateType mm_state = MM_CAMCORDER_STATE_NONE;
909 camera_get_state(camera, &capi_state);
910 if (capi_state == CAMERA_STATE_CAPTURED) {
911 ret = mm_camcorder_capture_stop(handle->mm_handle);
912 return __convert_camera_error_code(__func__, ret);
915 /* for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback */
916 mm_camcorder_set_video_capture_callback(handle->mm_handle,
917 (mm_camcorder_video_capture_callback)__mm_capture_callback,
920 mm_camcorder_get_state(handle->mm_handle, &mm_state);
921 if (mm_state != MM_CAMCORDER_STATE_READY) {
922 ret = mm_camcorder_realize(handle->mm_handle);
923 if (ret != MM_ERROR_NONE) {
924 LOGE("mm_camcorder_realize failed 0x%x", ret);
925 return __convert_camera_error_code(__func__, ret);
929 ret = mm_camcorder_start(handle->mm_handle);
930 if (ret != MM_ERROR_NONE) {
931 LOGE("mm_camcorder_start failed 0x%x, call mm_camcorder_unrealize", ret);
932 mm_camcorder_unrealize(handle->mm_handle);
935 return __convert_camera_error_code(__func__, ret);
939 int camera_stop_preview(camera_h camera)
941 if (camera == NULL) {
942 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
943 return CAMERA_ERROR_INVALID_PARAMETER;
946 int ret = MM_ERROR_NONE;;
947 camera_s *handle = (camera_s *)camera;
948 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
950 mm_camcorder_get_state(handle->mm_handle, &state);
951 if (state == MM_CAMCORDER_STATE_PREPARE) {
952 ret = mm_camcorder_stop(handle->mm_handle);
953 if (ret != MM_ERROR_NONE) {
954 LOGE("mm_camcorder_stop failed 0x%x", ret);
955 return __convert_camera_error_code(__func__, ret);
959 camera_stop_face_detection(camera);
961 ret = mm_camcorder_unrealize(handle->mm_handle);
963 return __convert_camera_error_code(__func__, ret);
967 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
969 if (camera == NULL) {
970 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
971 return CAMERA_ERROR_INVALID_PARAMETER;
974 camera_s *handle = (camera_s *)camera;
975 int ret = MM_ERROR_NONE;
976 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
978 mm_camcorder_get_state(handle->mm_handle, &state);
979 if (state != MM_CAMCORDER_STATE_PREPARE &&
980 state != MM_CAMCORDER_STATE_RECORDING &&
981 state != MM_CAMCORDER_STATE_PAUSED) {
982 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
983 return CAMERA_ERROR_INVALID_STATE;
986 if (handle->capture_resolution_modified) {
987 mm_camcorder_set_attributes(handle->mm_handle, NULL,
988 MMCAM_CAPTURE_WIDTH, handle->capture_width,
989 MMCAM_CAPTURE_HEIGHT, handle->capture_height,
992 handle->capture_resolution_modified = false;
995 mm_camcorder_set_attributes(handle->mm_handle, NULL,
996 MMCAM_CAPTURE_COUNT, 1,
999 handle->capture_count = 1;
1000 handle->is_continuous_shot_break = false;
1001 handle->current_capture_count = 0;
1002 handle->current_capture_complete_count = 0;
1003 handle->is_capture_completed = false;
1005 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
1006 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
1007 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
1008 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
1010 ret = mm_camcorder_capture_start(handle->mm_handle);
1011 if (ret != MM_ERROR_NONE) {
1012 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1013 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1014 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1015 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1018 return __convert_camera_error_code(__func__, ret);
1022 bool camera_is_supported_continuous_capture(camera_h camera)
1024 if (camera == NULL) {
1025 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1029 int ret = MM_ERROR_NONE;
1030 camera_s *handle = (camera_s *)camera;
1031 MMCamAttrsInfo info;
1033 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_COUNT, &info);
1034 set_last_result(__convert_camera_error_code(__func__, ret));
1035 if (ret != MM_ERROR_NONE) {
1036 LOGE("MMCAM_CAPTURE_COUNT info get failed 0x%x", ret);
1040 if (info.int_range.max > 1) {
1048 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)
1050 if (camera == NULL) {
1051 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1052 return CAMERA_ERROR_INVALID_PARAMETER;
1055 if (camera_is_supported_continuous_capture(camera) == false) {
1056 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1057 return CAMERA_ERROR_NOT_SUPPORTED;
1060 if (count < 2 || interval < 0) {
1061 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1062 return CAMERA_ERROR_INVALID_PARAMETER;
1065 camera_s *handle = (camera_s *)camera;
1066 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
1067 int supported_zsl = FALSE;
1068 int ret = MM_ERROR_NONE;
1070 mm_camcorder_get_state(handle->mm_handle, &state);
1071 if (state != MM_CAMCORDER_STATE_PREPARE) {
1072 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1073 return CAMERA_ERROR_INVALID_STATE;
1076 supported_zsl = FALSE;
1078 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1079 MMCAM_CAPTURE_COUNT, count,
1080 MMCAM_CAPTURE_INTERVAL, interval,
1082 if (ret != MM_ERROR_NONE) {
1083 LOGE("error set continuous shot attribute 0x%x", ret);
1084 return __convert_camera_error_code(__func__, ret);
1087 handle->capture_count = count;
1088 handle->is_continuous_shot_break = false;
1089 handle->current_capture_count = 0;
1090 handle->current_capture_complete_count = 0;
1091 handle->is_capture_completed = false;
1093 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1094 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1096 if (ret != MM_ERROR_NONE) {
1097 LOGE("(%x) error get continuous shot attribute", ret);
1100 if (!supported_zsl) {
1106 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1107 MMCAM_CAMERA_WIDTH, &preview_width,
1108 MMCAM_CAMERA_HEIGHT, &preview_height,
1109 MMCAM_CAPTURE_WIDTH, &capture_width,
1110 MMCAM_CAPTURE_HEIGHT, &capture_height,
1113 if (preview_width != capture_width || preview_height != capture_height) {
1114 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1115 MMCAM_CAPTURE_WIDTH, preview_width,
1116 MMCAM_CAPTURE_HEIGHT, preview_height,
1119 handle->capture_resolution_modified = true;
1123 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)capturing_cb;
1124 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void *)user_data;
1125 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)completed_cb;
1126 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void *)user_data;
1128 ret = mm_camcorder_capture_start(handle->mm_handle);
1129 if(ret != MM_ERROR_NONE ){
1130 LOGE("mm_camcorder_capture_start failed 0x%x", ret);
1131 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1132 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
1133 handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1134 handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
1137 return __convert_camera_error_code(__func__, ret);
1142 int camera_stop_continuous_capture(camera_h camera)
1144 if (camera == NULL) {
1145 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1146 return CAMERA_ERROR_INVALID_PARAMETER;
1149 if (camera_is_supported_continuous_capture(camera) == false) {
1150 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1151 return CAMERA_ERROR_NOT_SUPPORTED;
1154 camera_s *handle = (camera_s *)camera;
1155 int ret = MM_ERROR_NONE;
1156 camera_state_e state = CAMERA_STATE_NONE;
1158 camera_get_state(camera, &state);
1159 if (state != CAMERA_STATE_CAPTURING && handle->capture_count > 1) {
1160 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1161 return CAMERA_ERROR_INVALID_STATE;
1164 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1165 "capture-break-cont-shot", 1,
1167 if (ret == MM_ERROR_NONE) {
1168 handle->is_continuous_shot_break = true;
1170 if (handle->current_capture_count > 0) {
1171 handle->is_capture_completed = true;
1174 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
1177 return __convert_camera_error_code(__func__, ret);
1181 bool camera_is_supported_face_detection(camera_h camera)
1183 if (camera == NULL) {
1184 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1189 int ret = MM_ERROR_NONE;
1190 camera_s *handle = (camera_s *)camera;
1191 MMCamAttrsInfo info;
1193 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
1194 set_last_result(__convert_camera_error_code(__func__, ret));
1195 if (ret != MM_ERROR_NONE) {
1196 LOGE("MMCAM_DETECT_MODE get attr info failed");
1200 if (info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY) {
1201 for (i = 0 ; i < info.int_array.count ; i++) {
1202 if (info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON) {
1203 LOGD("face detection supported");
1209 LOGD("face detection NOT supported");
1215 bool camera_is_supported_zero_shutter_lag(camera_h camera)
1217 int ret = MM_ERROR_NONE;
1218 int supported_zsl = false;
1219 camera_s *handle = (camera_s *)camera;
1221 if (camera == NULL) {
1222 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1226 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1227 MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl,
1229 set_last_result(__convert_camera_error_code(__func__, ret));
1230 if (ret != MM_ERROR_NONE) {
1231 LOGE("MMCAM_SUPPORT_ZSL_CAPTURE get failed");
1235 LOGD("support zero shutter lag : %d", supported_zsl);
1237 return supported_zsl;
1241 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
1243 int ret = MM_ERROR_NONE;
1244 int supported = false;
1245 camera_s *handle = (camera_s *)camera;
1247 if (camera == NULL) {
1248 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1252 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1253 MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, &supported,
1255 set_last_result(__convert_camera_error_code(__func__, ret));
1256 if (ret != MM_ERROR_NONE) {
1257 LOGE("MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB get failed");
1261 LOGD("support media packet preview callback : %d", supported);
1267 int camera_get_device_count(camera_h camera, int *device_count)
1269 int ret = MM_ERROR_NONE;
1270 camera_s *handle = (camera_s *)camera;
1272 if (camera == NULL || device_count == NULL) {
1273 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1274 return CAMERA_ERROR_INVALID_PARAMETER;
1277 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1278 MMCAM_CAMERA_DEVICE_COUNT, device_count,
1281 return __convert_camera_error_code(__func__, ret);
1285 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
1287 if (camera == NULL) {
1288 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1289 return CAMERA_ERROR_INVALID_PARAMETER;
1292 if (camera_is_supported_face_detection(camera) == false) {
1293 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1294 return CAMERA_ERROR_NOT_SUPPORTED;
1297 camera_s *handle = (camera_s *)camera;
1298 camera_state_e state = CAMERA_STATE_NONE;
1299 int ret = MM_ERROR_NONE;
1301 camera_get_state(camera, &state);
1302 if (state != CAMERA_STATE_PREVIEW) {
1303 LOGE("INVALID_STATE(0x%08x)", CAMERA_ERROR_INVALID_STATE);
1304 return CAMERA_ERROR_INVALID_STATE;
1307 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1308 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON,
1310 if (ret == MM_ERROR_NONE) {
1311 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)callback;
1312 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void *)user_data;
1313 handle->num_of_faces = 0;
1316 return __convert_camera_error_code(__func__,ret);
1320 int camera_stop_face_detection(camera_h camera)
1322 if (camera == NULL) {
1323 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1324 return CAMERA_ERROR_INVALID_PARAMETER;
1327 camera_s *handle = (camera_s *)camera;
1328 int ret = MM_ERROR_NONE;
1330 if (camera_is_supported_face_detection(camera) == false) {
1331 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
1332 return CAMERA_ERROR_NOT_SUPPORTED;
1335 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1336 MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF,
1338 if (ret == MM_ERROR_NONE) {
1339 handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1340 handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
1341 handle->num_of_faces = 0;
1344 return __convert_camera_error_code(__func__,ret);
1348 int camera_get_state(camera_h camera, camera_state_e *state)
1350 if (camera == NULL || state == NULL) {
1351 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1352 return CAMERA_ERROR_INVALID_PARAMETER;
1355 camera_s *handle = (camera_s *)camera;
1356 camera_state_e capi_state = CAMERA_STATE_NONE;
1357 MMCamcorderStateType mmstate = MM_CAMCORDER_STATE_NONE;
1359 mm_camcorder_get_state(handle->mm_handle, &mmstate);
1360 capi_state = __camera_state_convert(mmstate);
1362 if ((handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed) &&
1363 (handle->current_capture_count > 0 || handle->is_capture_completed) &&
1364 mmstate == MM_CAMCORDER_STATE_CAPTURING) {
1365 capi_state = CAMERA_STATE_CAPTURED;
1368 *state = capi_state;
1370 return CAMERA_ERROR_NONE;
1374 int camera_start_focusing(camera_h camera, bool continuous)
1376 if (camera == NULL) {
1377 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1378 return CAMERA_ERROR_INVALID_PARAMETER;
1381 camera_s *handle = (camera_s *)camera;
1383 if (handle->cached_focus_mode != -1) {
1384 LOGD("apply cached focus mode %d", handle->cached_focus_mode);
1386 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1387 MMCAM_CAMERA_AF_SCAN_RANGE, handle->cached_focus_mode,
1390 handle->cached_focus_mode = -1;
1394 return __camera_start_continuous_focusing(camera);
1396 mm_camcorder_set_attributes(handle->mm_handle, NULL,
1397 MMCAM_CAMERA_FOCUS_MODE, handle->focus_area_valid ? \
1398 MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO : MM_CAMCORDER_FOCUS_MODE_AUTO,
1401 return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s *)camera)->mm_handle));
1406 int __camera_start_continuous_focusing(camera_h camera)
1408 if (camera == NULL) {
1409 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1410 return CAMERA_ERROR_INVALID_PARAMETER;
1413 camera_s *handle = (camera_s *)camera;
1414 int ret = MM_ERROR_NONE;
1415 int mode = MM_CAMCORDER_FOCUS_MODE_NONE;
1417 handle->on_continuous_focusing = true;
1418 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1419 MMCAM_CAMERA_FOCUS_MODE, &mode,
1422 if (mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS) {
1423 ret = mm_camcorder_start_focusing(handle->mm_handle);
1425 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1426 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS,
1430 return __convert_camera_error_code(__func__, ret);
1434 int camera_cancel_focusing(camera_h camera)
1436 if (camera == NULL) {
1437 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1438 return CAMERA_ERROR_INVALID_PARAMETER;
1441 camera_s *handle = (camera_s *)camera;
1443 handle->on_continuous_focusing = false;
1445 return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
1449 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
1451 int ret = MM_ERROR_NONE;
1452 int set_surface = MM_DISPLAY_SURFACE_X;
1453 void *set_handle = NULL;
1454 camera_s *handle = NULL;
1456 Evas_Object *obj = NULL;
1457 const char *object_type = NULL;
1459 if (camera == NULL) {
1460 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1461 return CAMERA_ERROR_INVALID_PARAMETER;
1464 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
1465 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
1466 return CAMERA_ERROR_INVALID_PARAMETER;
1469 handle = (camera_s *)camera;
1470 handle->display_type = type;
1472 if (type == CAMERA_DISPLAY_TYPE_NONE) {
1474 set_surface = MM_DISPLAY_SURFACE_NULL;
1475 handle->display_handle = 0;
1477 LOGD("display type NONE");
1479 obj = (Evas_Object *)display;
1480 object_type = evas_object_type_get(obj);
1482 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
1484 MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)malloc(sizeof(MMCamWaylandInfo));
1486 if (wl_info == NULL) {
1487 LOGE("wl_info alloc failed : %d", sizeof(MMCamWaylandInfo));
1488 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_LOW_MEMORY);
1491 memset(wl_info, 0x0, sizeof(MMCamWaylandInfo));
1493 wl_info->evas_obj = (void *)obj;
1494 wl_info->window = (void *)elm_win_wl_window_get(obj);
1495 wl_info->surface = (void *)ecore_wl_window_surface_get(wl_info->window);
1496 wl_info->display = (void *)ecore_wl_display_get();
1498 if (wl_info->window == NULL || wl_info->surface == NULL || wl_info->display == NULL) {
1499 LOGE("something is NULL %p, %p, %p", wl_info->window, wl_info->surface, wl_info->display);
1501 return __convert_camera_error_code(__func__, MM_ERROR_CAMCORDER_INTERNAL);
1504 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
1505 &wl_info->window_width, &wl_info->window_height);
1507 if (handle->wl_info) {
1508 free(handle->wl_info);
1509 handle->wl_info = NULL;
1512 /* set wayland info */
1513 handle->wl_info = (void *)wl_info;
1514 set_surface = MM_DISPLAY_SURFACE_X;
1515 set_handle = (void *)wl_info;
1517 LOGD("wayland obj %p, window %p, surface %p, display %p, size %d,%d,%dx%d",
1518 wl_info->evas_obj, wl_info->window, wl_info->surface, wl_info->display,
1519 wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
1520 #else /* HAVE_WAYLAND */
1521 /* x window overlay surface */
1522 handle->display_handle = (void *)elm_win_xwindow_get(obj);
1523 set_surface = MM_DISPLAY_SURFACE_X;
1524 set_handle = &(handle->display_handle);
1526 LOGD("display type OVERLAY : handle %p, %d", set_handle, (int)handle->display_handle);
1527 #endif /* HAVE_WAYLAND */
1528 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
1529 /* evas object surface */
1530 handle->display_handle = display;
1531 set_surface = MM_DISPLAY_SURFACE_EVAS;
1532 set_handle = display;
1534 LOGD("display type EVAS : handle %p", set_handle);
1536 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
1537 return CAMERA_ERROR_INVALID_PARAMETER;
1540 LOGE("failed to get evas object type from %p", obj);
1541 return CAMERA_ERROR_INVALID_PARAMETER;
1545 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1546 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
1547 MMCAM_DISPLAY_SURFACE, set_surface,
1550 if (ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE) {
1551 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1552 MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *),
1556 return __convert_camera_error_code(__func__, ret);
1560 int camera_set_preview_resolution(camera_h camera, int width, int height)
1562 if( camera == NULL){
1563 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1564 return CAMERA_ERROR_INVALID_PARAMETER;
1567 int ret = MM_ERROR_NONE;
1568 camera_s *handle = (camera_s *)camera;
1569 MMCamAttrsInfo info;
1573 mm_camcorder_get_attributes(handle->mm_handle, NULL,
1574 MMCAM_CAMERA_FPS, &mm_fps,
1577 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
1578 if (ret != MM_ERROR_NONE) {
1579 return __convert_camera_error_code(__func__, ret);
1582 for (i = 0 ; i < info.int_array.count ; i++) {
1583 if (info.int_array.array[i] == mm_fps) {
1586 if (i == info.int_array.count - 1) {
1587 LOGE("Not supported resolution: Current set Resolution's FPS is not supported in wanted resolution.");
1588 return CAMERA_ERROR_NOT_SUPPORTED;
1592 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1593 MMCAM_CAMERA_WIDTH, width,
1594 MMCAM_CAMERA_HEIGHT, height,
1597 return __convert_camera_error_code(__func__, ret);
1601 int camera_set_capture_resolution(camera_h camera, int width, int height)
1603 if (camera == NULL) {
1604 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1605 return CAMERA_ERROR_INVALID_PARAMETER;
1608 int ret = MM_ERROR_NONE;
1609 camera_s *handle = (camera_s *)camera;
1611 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1612 MMCAM_CAPTURE_WIDTH, width,
1613 MMCAM_CAPTURE_HEIGHT, height,
1615 if (ret == MM_ERROR_NONE) {
1616 handle->capture_width = width;
1617 handle->capture_height = height;
1620 return __convert_camera_error_code(__func__, ret);
1624 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
1626 if (camera == NULL) {
1627 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1628 return CAMERA_ERROR_INVALID_PARAMETER;
1631 int ret = MM_ERROR_NONE;
1632 camera_s *handle = (camera_s *)camera;
1634 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1635 MMCAM_CAPTURE_FORMAT, format,
1638 return __convert_camera_error_code(__func__, ret);
1642 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
1644 if (camera == NULL) {
1645 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1646 return CAMERA_ERROR_INVALID_PARAMETER;
1650 int ret = MM_ERROR_NONE;
1651 camera_s *handle = (camera_s *)camera;
1653 if (format == CAMERA_PIXEL_FORMAT_UYVY) {
1654 bool supported_ITLV_UYVY = false;
1655 MMCamAttrsInfo supported_format;
1656 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
1657 for (i = 0 ; i < supported_format.int_array.count ; i++) {
1658 if (supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1659 supported_ITLV_UYVY = true;
1662 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1663 MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ? MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY,
1666 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1667 MMCAM_CAMERA_FORMAT, format,
1671 return __convert_camera_error_code(__func__, ret);
1675 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
1677 if (camera == NULL || width == NULL || height == NULL) {
1678 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1679 return CAMERA_ERROR_INVALID_PARAMETER;
1682 int ret = MM_ERROR_NONE;
1683 camera_s *handle = (camera_s *)camera;
1685 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1686 MMCAM_CAMERA_WIDTH, width,
1687 MMCAM_CAMERA_HEIGHT, height,
1690 return __convert_camera_error_code(__func__, ret);
1694 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
1696 if (camera == NULL) {
1697 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1698 return CAMERA_ERROR_INVALID_PARAMETER;
1701 if (rotation > CAMERA_ROTATION_270) {
1702 return CAMERA_ERROR_INVALID_PARAMETER;
1705 int ret = MM_ERROR_NONE;
1706 camera_s *handle = (camera_s *)camera;
1708 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1709 MMCAM_DISPLAY_ROTATION, rotation,
1712 return __convert_camera_error_code(__func__, ret);
1716 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
1718 if (camera == NULL || rotation == NULL) {
1719 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1720 return CAMERA_ERROR_INVALID_PARAMETER;
1723 int ret = MM_ERROR_NONE;
1724 camera_s *handle = (camera_s *)camera;
1726 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1727 MMCAM_DISPLAY_ROTATION, rotation,
1730 return __convert_camera_error_code(__func__, ret);
1734 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
1736 if (camera == NULL) {
1737 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1738 return CAMERA_ERROR_INVALID_PARAMETER;
1741 if (flip > CAMERA_FLIP_BOTH) {
1742 return CAMERA_ERROR_INVALID_PARAMETER;
1745 int ret = MM_ERROR_NONE;
1746 camera_s *handle = (camera_s *)camera;
1748 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1749 MMCAM_DISPLAY_FLIP, flip,
1752 return __convert_camera_error_code(__func__, ret);
1756 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
1758 if (camera == NULL || flip == NULL) {
1759 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1760 return CAMERA_ERROR_INVALID_PARAMETER;
1763 int ret = MM_ERROR_NONE;
1764 camera_s *handle = (camera_s *)camera;
1766 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1767 MMCAM_DISPLAY_FLIP, flip,
1770 return __convert_camera_error_code(__func__, ret);
1774 int camera_set_display_visible(camera_h camera, bool visible)
1776 if (camera == NULL) {
1777 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1778 return CAMERA_ERROR_INVALID_PARAMETER;
1781 int ret = MM_ERROR_NONE;
1782 camera_s *handle = (camera_s *)camera;
1784 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1785 MMCAM_DISPLAY_VISIBLE, visible,
1788 return __convert_camera_error_code(__func__, ret);
1792 int camera_is_display_visible(camera_h camera, bool* visible)
1794 if (camera == NULL || visible == NULL) {
1795 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1796 return CAMERA_ERROR_INVALID_PARAMETER;
1799 int ret = MM_ERROR_NONE;
1801 camera_s *handle = (camera_s *)camera;
1803 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1804 MMCAM_DISPLAY_VISIBLE, &result,
1807 if (ret == MM_ERROR_NONE) {
1811 return __convert_camera_error_code(__func__, ret);
1815 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
1817 if (camera == NULL) {
1818 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1819 return CAMERA_ERROR_INVALID_PARAMETER;
1822 if (mode > CAMERA_DISPLAY_MODE_CROPPED_FULL) {
1823 return CAMERA_ERROR_INVALID_PARAMETER;
1826 int ret = MM_ERROR_NONE;
1827 camera_s *handle = (camera_s *)camera;
1829 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
1830 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1833 return __convert_camera_error_code(__func__, ret);
1837 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
1839 if (camera == NULL || mode == NULL) {
1840 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1841 return CAMERA_ERROR_INVALID_PARAMETER;
1844 int ret = MM_ERROR_NONE;
1845 camera_s *handle = (camera_s *)camera;
1847 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1848 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
1851 return __convert_camera_error_code(__func__, ret);
1855 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
1857 if (camera == NULL || width == NULL || height == NULL) {
1858 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1859 return CAMERA_ERROR_INVALID_PARAMETER;
1862 camera_s *handle = (camera_s *)camera;
1864 *width = handle->capture_width;
1865 *height = handle->capture_height;
1867 return CAMERA_ERROR_NONE;
1871 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
1873 if (camera == NULL || format == NULL) {
1874 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1875 return CAMERA_ERROR_INVALID_PARAMETER;
1878 int ret = MM_ERROR_NONE;
1879 camera_s *handle = (camera_s *)camera;
1881 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1882 MMCAM_CAPTURE_FORMAT, format,
1885 return __convert_camera_error_code(__func__, ret);
1889 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
1891 if (camera == NULL || format == NULL) {
1892 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1893 return CAMERA_ERROR_INVALID_PARAMETER;
1896 int ret = MM_ERROR_NONE;
1897 camera_s *handle = (camera_s *)camera;
1899 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
1900 MMCAM_CAMERA_FORMAT, format,
1903 if ((MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
1904 *format = CAMERA_PIXEL_FORMAT_UYVY;
1907 return __convert_camera_error_code(__func__, ret);
1911 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
1913 if (camera == NULL || callback == NULL) {
1914 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1915 return CAMERA_ERROR_INVALID_PARAMETER;
1918 camera_s *handle = (camera_s *)camera;
1919 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)callback;
1920 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)user_data;
1922 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1923 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1926 return CAMERA_ERROR_NONE;
1930 int camera_unset_preview_cb(camera_h camera)
1932 if (camera == NULL) {
1933 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1934 return CAMERA_ERROR_INVALID_PARAMETER;
1937 camera_s *handle = (camera_s *)camera;
1939 if (handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1940 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1941 (mm_camcorder_video_stream_callback)NULL,
1945 handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1946 handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
1948 return CAMERA_ERROR_NONE;
1952 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
1954 if (camera == NULL) {
1955 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
1956 return CAMERA_ERROR_INVALID_PARAMETER;
1959 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1960 LOGE("NOT SUPPORTED");
1961 return CAMERA_ERROR_NOT_SUPPORTED;
1964 if (callback == NULL) {
1965 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
1966 return CAMERA_ERROR_INVALID_PARAMETER;
1969 camera_s *handle = (camera_s *)camera;
1970 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)callback;
1971 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)user_data;
1973 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1974 (mm_camcorder_video_stream_callback)__mm_videostream_callback,
1977 return CAMERA_ERROR_NONE;
1981 int camera_unset_media_packet_preview_cb(camera_h camera)
1983 if (camera == NULL) {
1984 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1985 return CAMERA_ERROR_INVALID_PARAMETER;
1988 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
1989 LOGE("NOT SUPPORTED");
1990 return CAMERA_ERROR_NOT_SUPPORTED;
1993 camera_s *handle = (camera_s *)camera;
1995 if (handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] == NULL) {
1996 mm_camcorder_set_video_stream_callback(handle->mm_handle,
1997 (mm_camcorder_video_stream_callback)NULL,
2001 handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
2002 handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
2004 return CAMERA_ERROR_NONE;
2008 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
2010 if (camera == NULL || callback == NULL) {
2011 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2012 return CAMERA_ERROR_INVALID_PARAMETER;
2015 camera_s *handle = (camera_s *)camera;
2016 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)callback;
2017 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)user_data;
2019 return CAMERA_ERROR_NONE;
2023 int camera_unset_state_changed_cb(camera_h camera)
2025 if (camera == NULL) {
2026 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2027 return CAMERA_ERROR_INVALID_PARAMETER;
2030 camera_s *handle = (camera_s *)camera;
2031 handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2032 handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
2034 return CAMERA_ERROR_NONE;
2038 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
2040 if (camera == NULL || callback == NULL) {
2041 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2042 return CAMERA_ERROR_INVALID_PARAMETER;
2045 camera_s *handle = (camera_s *)camera;
2046 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)callback;
2047 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)user_data;
2049 return CAMERA_ERROR_NONE;
2053 int camera_unset_interrupted_cb(camera_h camera)
2055 if (camera == NULL) {
2056 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2057 return CAMERA_ERROR_INVALID_PARAMETER;
2060 camera_s *handle = (camera_s *)camera;
2062 handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2063 handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
2065 return CAMERA_ERROR_NONE;
2069 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
2071 if (camera == NULL || callback == NULL) {
2072 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2073 return CAMERA_ERROR_INVALID_PARAMETER;
2076 camera_s *handle = (camera_s *)camera;
2078 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)callback;
2079 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)user_data;
2081 return CAMERA_ERROR_NONE;
2085 int camera_unset_focus_changed_cb(camera_h camera)
2087 if (camera == NULL) {
2088 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2089 return CAMERA_ERROR_INVALID_PARAMETER;
2092 camera_s *handle = (camera_s *)camera;
2094 handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2095 handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
2097 return CAMERA_ERROR_NONE;
2101 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
2103 if (camera == NULL || callback == NULL) {
2104 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2105 return CAMERA_ERROR_INVALID_PARAMETER;
2108 camera_s *handle = (camera_s *)camera;
2110 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)callback;
2111 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)user_data;
2113 return CAMERA_ERROR_NONE;
2117 int camera_unset_error_cb(camera_h camera)
2119 if (camera == NULL) {
2120 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2121 return CAMERA_ERROR_INVALID_PARAMETER;
2124 camera_s *handle = (camera_s *)camera;
2126 handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2127 handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
2129 return CAMERA_ERROR_NONE;
2133 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
2135 if (camera == NULL || foreach_cb == NULL) {
2136 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2137 return CAMERA_ERROR_INVALID_PARAMETER;
2141 int ret = MM_ERROR_NONE;
2142 camera_s *handle = (camera_s *)camera;
2143 MMCamAttrsInfo preview_width;
2144 MMCamAttrsInfo preview_height;
2146 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH, &preview_width);
2147 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT, &preview_height);
2148 if (ret != CAMERA_ERROR_NONE) {
2149 return __convert_camera_error_code(__func__, ret);
2152 for (i = 0 ; i < preview_width.int_array.count ; i++) {
2153 if (!foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i], user_data)) {
2158 return CAMERA_ERROR_NONE;
2162 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
2164 if (camera == NULL || foreach_cb == NULL) {
2165 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2166 return CAMERA_ERROR_INVALID_PARAMETER;
2170 int ret = MM_ERROR_NONE;
2171 camera_s *handle = (camera_s *)camera;
2172 MMCamAttrsInfo capture_width;
2173 MMCamAttrsInfo capture_height;
2175 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH, &capture_width);
2176 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT, &capture_height);
2177 if (ret != CAMERA_ERROR_NONE) {
2178 return __convert_camera_error_code(__func__, ret);
2181 for (i = 0 ; i < capture_width.int_array.count ; i++) {
2182 if (!foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i], user_data)) {
2187 return CAMERA_ERROR_NONE;
2191 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
2193 if (camera == NULL || foreach_cb == NULL) {
2194 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2195 return CAMERA_ERROR_INVALID_PARAMETER;
2199 int ret = MM_ERROR_NONE;
2200 camera_s *handle = (camera_s *)camera;
2201 MMCamAttrsInfo format;
2203 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT, &format);
2204 if (ret != CAMERA_ERROR_NONE) {
2205 return __convert_camera_error_code(__func__, ret);
2208 for (i = 0 ; i < format.int_array.count ; i++) {
2209 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2210 if (!foreach_cb(format.int_array.array[i], user_data)) {
2216 return CAMERA_ERROR_NONE;
2220 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
2222 if (camera == NULL || foreach_cb == NULL) {
2223 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2224 return CAMERA_ERROR_INVALID_PARAMETER;
2228 int ret = MM_ERROR_NONE;
2229 camera_s *handle = (camera_s *)camera;
2230 MMCamAttrsInfo format;
2232 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT, &format);
2233 if (ret != CAMERA_ERROR_NONE) {
2234 return __convert_camera_error_code(__func__, ret);
2237 for (i = 0 ; i < format.int_array.count ; i++) {
2238 if (format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
2239 if (!foreach_cb(format.int_array.array[i], user_data)) {
2245 return CAMERA_ERROR_NONE;
2249 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
2251 if (camera == NULL || width == NULL || height == NULL) {
2252 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2253 return CAMERA_ERROR_INVALID_PARAMETER;
2256 enum MMCamcorderPreviewType wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2260 int ret = MM_ERROR_NONE;
2261 camera_s *handle = (camera_s *)camera;
2262 MMCamAttrsInfo width_info;
2263 MMCamAttrsInfo height_info;
2265 camera_get_capture_resolution(camera, &capture_w, &capture_h);
2266 ratio = (double)capture_w / (double)capture_h;
2268 wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
2269 } else if (ratio == 1.0) {
2270 wide = MM_CAMCORDER_PREVIEW_TYPE_SQUARE;
2272 wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
2275 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH, &width_info);
2276 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
2277 if (ret != MM_ERROR_NONE) {
2278 return __convert_camera_error_code(__func__, ret);
2281 if (width && (unsigned int)width_info.int_array.count > wide) {
2282 *width = width_info.int_array.array[wide];
2284 LOGE("there is no width value for resolution %dx%d type %d", capture_w, capture_h, wide);
2285 return CAMERA_ERROR_INVALID_OPERATION;
2288 if (height && (unsigned int)height_info.int_array.count > wide) {
2289 *height = height_info.int_array.array[wide];
2291 LOGE("there is no height value for resolution %dx%d type %d", capture_w, capture_h, wide);
2292 return CAMERA_ERROR_INVALID_OPERATION;
2295 LOGI("recommend resolution %dx%d, type %d", *width, *height, wide);
2297 return CAMERA_ERROR_NONE;
2301 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
2303 if (camera == NULL || angle == NULL) {
2304 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2305 return CAMERA_ERROR_INVALID_PARAMETER;
2308 int ret = MM_ERROR_NONE;
2309 camera_s *handle = (camera_s *)camera;
2310 int rotation = MM_DISPLAY_ROTATION_NONE;
2312 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2313 MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
2316 if (ret == MM_ERROR_NONE) {
2318 case MM_DISPLAY_ROTATION_NONE:
2321 case MM_DISPLAY_ROTATION_90:
2324 case MM_DISPLAY_ROTATION_180:
2327 case MM_DISPLAY_ROTATION_270:
2336 return __convert_camera_error_code(__func__, ret);
2340 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
2342 if (camera == NULL) {
2343 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2344 return CAMERA_ERROR_INVALID_PARAMETER;
2347 int ret = MM_ERROR_NONE;
2348 camera_s *handle = (camera_s *)camera;
2350 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2351 MMCAM_DISPLAY_MODE, mode,
2354 return __convert_camera_error_code(__func__, ret);
2358 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
2360 if (camera == NULL || mode == NULL) {
2361 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2362 return CAMERA_ERROR_INVALID_PARAMETER;
2365 int ret = MM_ERROR_NONE;
2366 camera_s *handle = (camera_s *)camera;
2368 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2369 MMCAM_DISPLAY_MODE, mode,
2372 return __convert_camera_error_code(__func__, ret);
2376 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
2378 if (camera == NULL || foreach_cb == NULL) {
2379 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2380 return CAMERA_ERROR_INVALID_PARAMETER;
2384 int ret = MM_ERROR_NONE;
2385 camera_s *handle = (camera_s *)camera;
2386 MMCamAttrsInfo info;
2388 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DISPLAY_MODE, &info);
2389 if (ret != CAMERA_ERROR_NONE) {
2390 return __convert_camera_error_code(__func__, ret);
2393 for (i = 0 ; i < info.int_array.count ; i++) {
2394 if (!foreach_cb(info.int_array.array[i], user_data)) {
2399 return CAMERA_ERROR_NONE;
2403 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
2405 if (camera == NULL) {
2406 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2407 return CAMERA_ERROR_INVALID_PARAMETER;
2410 int ret = MM_ERROR_NONE;
2411 camera_s *handle = (camera_s *)camera;
2413 if (fps == CAMERA_ATTR_FPS_AUTO) {
2414 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2415 MMCAM_CAMERA_FPS_AUTO, true,
2418 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2419 MMCAM_CAMERA_FPS_AUTO, false,
2420 MMCAM_CAMERA_FPS, fps,
2424 return __convert_camera_error_code(__func__, ret);
2428 int camera_attr_set_image_quality(camera_h camera, int quality)
2430 if (camera == NULL) {
2431 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2432 return CAMERA_ERROR_INVALID_PARAMETER;
2435 int ret = MM_ERROR_NONE;
2436 camera_s *handle = (camera_s *)camera;
2438 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2439 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2442 return __convert_camera_error_code(__func__, ret);
2446 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
2448 if (camera == NULL || fps == NULL) {
2449 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2450 return CAMERA_ERROR_INVALID_PARAMETER;
2453 int ret = MM_ERROR_NONE;
2455 int is_auto = false;
2456 camera_s *handle = (camera_s *)camera;
2458 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2459 MMCAM_CAMERA_FPS, &mm_fps,
2460 MMCAM_CAMERA_FPS_AUTO, &is_auto,
2462 if (ret == MM_ERROR_NONE) {
2464 *fps = CAMERA_ATTR_FPS_AUTO;
2470 return __convert_camera_error_code(__func__, ret);
2474 int camera_attr_get_image_quality(camera_h camera, int *quality)
2476 if (camera == NULL || quality == NULL) {
2477 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2478 return CAMERA_ERROR_INVALID_PARAMETER;
2481 int ret = MM_ERROR_NONE;
2482 camera_s *handle = (camera_s *)camera;
2484 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2485 MMCAM_IMAGE_ENCODER_QUALITY, quality,
2488 return __convert_camera_error_code(__func__, ret);
2492 int camera_attr_set_zoom(camera_h camera, int zoom)
2494 if (camera == NULL) {
2495 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2496 return CAMERA_ERROR_INVALID_PARAMETER;
2499 int ret = MM_ERROR_NONE;
2500 camera_s *handle = (camera_s *)camera;
2502 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2503 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2506 return __convert_camera_error_code(__func__, ret);
2510 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
2512 if (camera == NULL) {
2513 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2514 return CAMERA_ERROR_INVALID_PARAMETER;
2517 int ret = MM_ERROR_NONE;
2518 camera_s *handle = (camera_s *)camera;
2520 bool should_change_focus_mode = false;
2522 mm_camcorder_get_attributes(handle->mm_handle, NULL,
2523 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2526 if (focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO &&
2527 focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2528 focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO) {
2529 should_change_focus_mode = true;
2532 if (mode != CAMERA_ATTR_AF_NONE &&
2533 focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS &&
2534 !handle->on_continuous_focusing) {
2535 handle->cached_focus_mode = mode;
2536 LOGD("af mode will be set actually start focusing");
2537 return __convert_camera_error_code(__func__, MM_ERROR_NONE);
2539 handle->cached_focus_mode = -1;
2542 if (mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode) {
2543 mm_camcorder_set_attributes(handle->mm_handle, NULL,
2544 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO,
2549 case CAMERA_ATTR_AF_NONE:
2550 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2551 MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
2552 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NONE,
2555 case CAMERA_ATTR_AF_NORMAL:
2556 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2557 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NORMAL,
2560 case CAMERA_ATTR_AF_MACRO:
2561 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2562 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_MACRO,
2565 case CAMERA_ATTR_AF_FULL:
2566 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2567 MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_FULL,
2571 LOGE("invalid mode %d", mode);
2572 return CAMERA_ERROR_INVALID_PARAMETER;
2575 return __convert_camera_error_code(__func__, ret);
2579 int camera_attr_set_af_area(camera_h camera, int x, int y)
2581 if (camera == NULL) {
2582 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2583 return CAMERA_ERROR_INVALID_PARAMETER;
2586 int ret = MM_ERROR_NONE;
2587 camera_s *handle = (camera_s *)camera;
2588 camera_attr_af_mode_e mode;
2590 camera_attr_get_af_mode(camera, &mode);
2591 if (mode == CAMERA_ATTR_AF_NONE) {
2592 LOGE("INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE", CAMERA_ERROR_INVALID_OPERATION);
2593 return CAMERA_ERROR_INVALID_OPERATION;
2596 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2597 MMCAM_CAMERA_AF_TOUCH_X, x,
2598 MMCAM_CAMERA_AF_TOUCH_Y, y,
2600 if (ret == MM_ERROR_NONE) {
2601 handle->focus_area_valid = true;
2604 return __convert_camera_error_code(__func__, ret);
2608 int camera_attr_clear_af_area(camera_h camera)
2610 if (camera == NULL) {
2611 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2612 return CAMERA_ERROR_INVALID_PARAMETER;
2615 camera_s *handle = (camera_s *)camera;
2617 handle->focus_area_valid = false;
2623 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
2625 if (camera == NULL) {
2626 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2627 return CAMERA_ERROR_INVALID_PARAMETER;
2630 int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, /* CAMERA_ATTR_EXPOSURE_MODE_OFF */
2631 MM_CAMCORDER_AUTO_EXPOSURE_ALL, /* CAMERA_ATTR_EXPOSURE_MODE_ALL */
2632 MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, /* CAMERA_ATTR_EXPOSURE_MODE_CENTER */
2633 MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, /* CAMERA_ATTR_EXPOSURE_MODE_SPOT */
2634 MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1, /* CAMERA_ATTR_EXPOSURE_MODE_CUSTOM */
2637 int ret = MM_ERROR_NONE;
2638 camera_s *handle = (camera_s *)camera;
2640 if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
2641 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2642 return CAMERA_ERROR_INVALID_PARAMETER;
2645 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2646 MMCAM_CAMERA_EXPOSURE_MODE, maptable[mode],
2649 return __convert_camera_error_code(__func__, ret);
2653 int camera_attr_set_exposure(camera_h camera, int value)
2655 if (camera == NULL) {
2656 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2657 return CAMERA_ERROR_INVALID_PARAMETER;
2660 int ret = MM_ERROR_NONE;
2661 camera_s *handle = (camera_s *)camera;
2663 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2664 MMCAM_CAMERA_EXPOSURE_VALUE, value,
2667 return __convert_camera_error_code(__func__, ret);
2671 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
2673 if (camera == NULL) {
2674 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2675 return CAMERA_ERROR_INVALID_PARAMETER;
2678 int ret = MM_ERROR_NONE;
2679 camera_s *handle = (camera_s*)camera;
2681 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2682 MMCAM_CAMERA_ISO, iso,
2685 return __convert_camera_error_code(__func__, ret);
2689 int camera_attr_set_brightness(camera_h camera, int level)
2691 if (camera == NULL) {
2692 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2693 return CAMERA_ERROR_INVALID_PARAMETER;
2696 int ret = MM_ERROR_NONE;
2697 camera_s *handle = (camera_s *)camera;
2699 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2700 MMCAM_FILTER_BRIGHTNESS, level,
2703 return __convert_camera_error_code(__func__, ret);
2707 int camera_attr_set_contrast(camera_h camera, int level)
2709 if (camera == NULL) {
2710 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2711 return CAMERA_ERROR_INVALID_PARAMETER;
2714 int ret = MM_ERROR_NONE;
2715 camera_s *handle = (camera_s *)camera;
2717 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2718 MMCAM_FILTER_CONTRAST, level,
2721 return __convert_camera_error_code(__func__, ret);
2725 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
2727 if (camera == NULL) {
2728 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2729 return CAMERA_ERROR_INVALID_PARAMETER;
2732 int ret = MM_ERROR_NONE;
2733 camera_s *handle = (camera_s *)camera;
2735 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2736 MMCAM_FILTER_WB, wb,
2739 return __convert_camera_error_code(__func__, ret);
2743 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
2745 if (camera == NULL) {
2746 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2747 return CAMERA_ERROR_INVALID_PARAMETER;
2750 int ret = MM_ERROR_NONE;
2751 camera_s *handle = (camera_s *)camera;
2753 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2754 MMCAM_FILTER_COLOR_TONE, effect,
2757 return __convert_camera_error_code(__func__, ret);
2761 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
2763 if (camera == NULL) {
2764 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2765 return CAMERA_ERROR_INVALID_PARAMETER;
2768 int ret = MM_ERROR_NONE;
2769 camera_s *handle = (camera_s *)camera;
2771 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2772 MMCAM_FILTER_SCENE_MODE, mode,
2775 return __convert_camera_error_code(__func__, ret);
2779 int camera_attr_enable_tag(camera_h camera, bool enable)
2781 if (camera == NULL) {
2782 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2783 return CAMERA_ERROR_INVALID_PARAMETER;
2786 int ret = MM_ERROR_NONE;
2787 camera_s *handle = (camera_s *)camera;
2789 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2790 MMCAM_TAG_ENABLE, enable,
2793 return __convert_camera_error_code(__func__, ret);
2797 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
2799 if (camera == NULL) {
2800 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2801 return CAMERA_ERROR_INVALID_PARAMETER;
2804 int ret = MM_ERROR_NONE;
2805 camera_s *handle = (camera_s *)camera;
2807 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2808 MMCAM_TAG_IMAGE_DESCRIPTION, description, strlen(description),
2811 return __convert_camera_error_code(__func__, ret);
2815 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
2817 if (camera == NULL) {
2818 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2819 return CAMERA_ERROR_INVALID_PARAMETER;
2822 int ret = MM_ERROR_NONE;
2823 camera_s *handle = (camera_s *)camera;
2825 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2826 MMCAM_TAG_ORIENTATION, orientation,
2829 return __convert_camera_error_code(__func__, ret);
2833 int camera_attr_set_tag_software(camera_h camera, const char *software)
2835 if (camera == NULL) {
2836 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2837 return CAMERA_ERROR_INVALID_PARAMETER;
2840 int ret = MM_ERROR_NONE;
2841 camera_s *handle = (camera_s *)camera;
2843 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2844 MMCAM_TAG_SOFTWARE, software, strlen(software),
2847 return __convert_camera_error_code(__func__, ret);
2851 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
2853 if (camera == NULL) {
2854 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2855 return CAMERA_ERROR_INVALID_PARAMETER;
2858 int ret = MM_ERROR_NONE;
2859 camera_s *handle = (camera_s *)camera;
2861 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2862 MMCAM_TAG_GPS_ENABLE, true,
2863 MMCAM_TAG_LATITUDE, latitude,
2864 MMCAM_TAG_LONGITUDE, longitude,
2865 MMCAM_TAG_ALTITUDE, altitude,
2868 return __convert_camera_error_code(__func__, ret);
2872 int camera_attr_remove_geotag(camera_h camera)
2874 if (camera == NULL) {
2875 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2876 return CAMERA_ERROR_INVALID_PARAMETER;
2879 int ret = MM_ERROR_NONE;
2880 camera_s *handle = (camera_s *)camera;
2882 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2883 MMCAM_TAG_GPS_ENABLE, false,
2886 return __convert_camera_error_code(__func__, ret);
2890 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
2892 if (camera == NULL) {
2893 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2894 return CAMERA_ERROR_INVALID_PARAMETER;
2897 int ret = MM_ERROR_NONE;
2898 camera_s *handle = (camera_s *)camera;
2900 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
2901 MMCAM_STROBE_MODE, mode,
2904 return __convert_camera_error_code(__func__, ret);
2908 int camera_attr_get_zoom(camera_h camera, int *zoom)
2910 if (camera == NULL || zoom == NULL) {
2911 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2912 return CAMERA_ERROR_INVALID_PARAMETER;
2915 int ret = MM_ERROR_NONE;
2916 camera_s *handle = (camera_s *)camera;
2918 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2919 MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
2922 return __convert_camera_error_code(__func__, ret);
2926 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
2928 if (camera == NULL || min == NULL || max == NULL) {
2929 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2930 return CAMERA_ERROR_INVALID_PARAMETER;
2933 int ret = MM_ERROR_NONE;
2934 camera_s *handle = (camera_s *)camera;
2935 MMCamAttrsInfo ainfo;
2937 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
2938 if (ret == MM_ERROR_NONE) {
2939 *min = ainfo.int_range.min;
2940 *max = ainfo.int_range.max;
2943 return __convert_camera_error_code(__func__, ret);
2947 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
2949 if (camera == NULL || mode == NULL) {
2950 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2951 return CAMERA_ERROR_INVALID_PARAMETER;
2954 int ret = MM_ERROR_NONE;
2958 camera_s *handle = (camera_s *)camera;
2960 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
2961 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2962 MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
2963 MMCAM_DETECT_MODE, &detect_mode,
2965 if (ret == MM_ERROR_NONE) {
2966 switch (focus_mode) {
2967 case MM_CAMCORDER_FOCUS_MODE_NONE:
2968 case MM_CAMCORDER_FOCUS_MODE_PAN:
2969 case MM_CAMCORDER_FOCUS_MODE_MANUAL:
2970 *mode = CAMERA_ATTR_AF_NONE;
2972 case MM_CAMCORDER_FOCUS_MODE_AUTO:
2973 case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
2974 case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
2976 case MM_CAMCORDER_AUTO_FOCUS_NONE:
2977 *mode = CAMERA_ATTR_AF_NORMAL;
2979 case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
2980 *mode = CAMERA_ATTR_AF_NORMAL;
2982 case MM_CAMCORDER_AUTO_FOCUS_MACRO:
2983 *mode = CAMERA_ATTR_AF_MACRO;
2985 case MM_CAMCORDER_AUTO_FOCUS_FULL:
2986 *mode = CAMERA_ATTR_AF_FULL;
2989 *mode = CAMERA_ATTR_AF_NORMAL;
2994 *mode = CAMERA_ATTR_AF_NONE;
2999 return __convert_camera_error_code(__func__, ret);
3003 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
3005 if (camera == NULL || mode == NULL) {
3006 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3007 return CAMERA_ERROR_INVALID_PARAMETER;
3010 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3011 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3012 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3013 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3014 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3015 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3016 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3017 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3018 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3020 int ret = MM_ERROR_NONE;
3022 camera_s *handle = (camera_s *)camera;
3024 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3025 MMCAM_CAMERA_EXPOSURE_MODE, &exposure_mode,
3028 if (ret == CAMERA_ERROR_NONE) {
3029 *mode = maptable[abs(exposure_mode%9)];
3032 return __convert_camera_error_code(__func__, ret);
3036 int camera_attr_get_exposure(camera_h camera, int *value)
3038 if (camera == NULL || value == NULL) {
3039 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3040 return CAMERA_ERROR_INVALID_PARAMETER;
3043 int ret = MM_ERROR_NONE;
3044 camera_s *handle = (camera_s *)camera;
3046 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3047 MMCAM_CAMERA_EXPOSURE_VALUE, value,
3050 return __convert_camera_error_code(__func__, ret);
3054 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
3056 if (camera == NULL || min == NULL || max == NULL) {
3057 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3058 return CAMERA_ERROR_INVALID_PARAMETER;
3061 int ret = MM_ERROR_NONE;
3062 camera_s *handle = (camera_s *)camera;
3063 MMCamAttrsInfo ainfo;
3065 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
3066 if (ret == MM_ERROR_NONE) {
3067 *min = ainfo.int_range.min;
3068 *max = ainfo.int_range.max;
3071 return __convert_camera_error_code(__func__, ret);
3075 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
3077 if (camera == NULL || iso == NULL) {
3078 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3079 return CAMERA_ERROR_INVALID_PARAMETER;
3082 int ret = MM_ERROR_NONE;
3083 camera_s *handle = (camera_s *)camera;
3085 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3086 MMCAM_CAMERA_ISO, iso,
3089 return __convert_camera_error_code(__func__, ret);
3093 int camera_attr_get_brightness(camera_h camera, int *level)
3095 if (camera == NULL || level == NULL) {
3096 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3097 return CAMERA_ERROR_INVALID_PARAMETER;
3100 int ret = MM_ERROR_NONE;
3101 camera_s *handle = (camera_s *)camera;
3103 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3104 MMCAM_FILTER_BRIGHTNESS, level,
3107 return __convert_camera_error_code(__func__, ret);
3111 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
3113 if (camera == NULL || min == NULL || max == NULL) {
3114 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3115 return CAMERA_ERROR_INVALID_PARAMETER;
3118 int ret = MM_ERROR_NONE;
3119 camera_s *handle = (camera_s *)camera;
3120 MMCamAttrsInfo ainfo;
3122 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
3123 if (ret == MM_ERROR_NONE) {
3124 *min = ainfo.int_range.min;
3125 *max = ainfo.int_range.max;
3128 return __convert_camera_error_code(__func__, ret);
3132 int camera_attr_get_contrast(camera_h camera, int *level)
3134 if (camera == NULL || level == NULL) {
3135 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3136 return CAMERA_ERROR_INVALID_PARAMETER;
3139 int ret = MM_ERROR_NONE;
3140 camera_s *handle = (camera_s *)camera;
3142 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3143 MMCAM_FILTER_CONTRAST, level,
3146 return __convert_camera_error_code(__func__, ret);
3150 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
3152 if (camera == NULL || min == NULL || max == NULL) {
3153 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3154 return CAMERA_ERROR_INVALID_PARAMETER;
3157 int ret = MM_ERROR_NONE;
3158 camera_s *handle = (camera_s *)camera;
3159 MMCamAttrsInfo ainfo;
3161 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
3162 if (ret == MM_ERROR_NONE) {
3163 *min = ainfo.int_range.min;
3164 *max = ainfo.int_range.max;
3167 return __convert_camera_error_code(__func__, ret);
3171 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
3173 if (camera == NULL || wb == NULL) {
3174 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3175 return CAMERA_ERROR_INVALID_PARAMETER;
3178 int ret = MM_ERROR_NONE;
3179 camera_s *handle = (camera_s *)camera;
3181 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3182 MMCAM_FILTER_WB, wb,
3185 return __convert_camera_error_code(__func__, ret);
3189 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
3191 if (camera == NULL || effect == NULL) {
3192 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3193 return CAMERA_ERROR_INVALID_PARAMETER;
3196 int ret = MM_ERROR_NONE;
3197 camera_s *handle = (camera_s *)camera;
3199 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3200 MMCAM_FILTER_COLOR_TONE, effect,
3203 return __convert_camera_error_code(__func__, ret);
3207 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
3209 if (camera == NULL || mode == NULL) {
3210 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3211 return CAMERA_ERROR_INVALID_PARAMETER;
3214 int ret = MM_ERROR_NONE;
3215 camera_s *handle = (camera_s *)camera;
3217 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3218 MMCAM_FILTER_SCENE_MODE, mode,
3221 return __convert_camera_error_code(__func__, ret);
3225 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
3227 if (camera == NULL || enable == NULL) {
3228 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3229 return CAMERA_ERROR_INVALID_PARAMETER;
3232 int ret = MM_ERROR_NONE;
3233 camera_s *handle = (camera_s *)camera;
3235 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3236 MMCAM_TAG_ENABLE, enable,
3239 return __convert_camera_error_code(__func__, ret);
3243 int camera_attr_get_tag_image_description(camera_h camera, char **description)
3245 if (camera == NULL || description == NULL) {
3246 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3247 return CAMERA_ERROR_INVALID_PARAMETER;
3250 int ret = MM_ERROR_NONE;
3251 camera_s *handle = (camera_s *)camera;
3252 char *ndescription = NULL;
3255 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3256 MMCAM_TAG_IMAGE_DESCRIPTION, &ndescription, &desc_size,
3258 if (ret == MM_ERROR_NONE) {
3259 if (ndescription != NULL) {
3260 *description = strdup(ndescription);
3262 *description = strdup("");
3266 return __convert_camera_error_code(__func__, ret);
3270 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
3272 if (camera == NULL || orientation == NULL) {
3273 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3274 return CAMERA_ERROR_INVALID_PARAMETER;
3277 int ret = MM_ERROR_NONE;
3278 camera_s *handle = (camera_s *)camera;
3280 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3281 MMCAM_TAG_ORIENTATION, orientation,
3284 return __convert_camera_error_code(__func__, ret);
3288 int camera_attr_get_tag_software(camera_h camera, char **software)
3290 if (camera == NULL || software == NULL) {
3291 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3292 return CAMERA_ERROR_INVALID_PARAMETER;
3295 int ret = MM_ERROR_NONE;
3296 camera_s *handle = (camera_s *)camera;
3300 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3301 MMCAM_TAG_SOFTWARE, &soft, &soft_size,
3303 if (ret == MM_ERROR_NONE) {
3305 *software = strdup(soft);
3307 *software = strdup("");
3311 return __convert_camera_error_code(__func__, ret);
3315 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
3317 if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
3318 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3319 return CAMERA_ERROR_INVALID_PARAMETER;
3322 int ret = MM_ERROR_NONE;
3323 camera_s *handle = (camera_s *)camera;
3325 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3326 MMCAM_TAG_LATITUDE, latitude,
3327 MMCAM_TAG_LONGITUDE, longitude,
3328 MMCAM_TAG_ALTITUDE, altitude,
3331 return __convert_camera_error_code(__func__, ret);
3335 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
3337 if (camera == NULL || mode == NULL) {
3338 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3339 return CAMERA_ERROR_INVALID_PARAMETER;
3342 int ret = MM_ERROR_NONE;
3343 camera_s *handle = (camera_s *)camera;
3345 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3346 MMCAM_STROBE_MODE, mode,
3349 return __convert_camera_error_code(__func__, ret);
3353 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
3355 if (camera == NULL || foreach_cb == NULL) {
3356 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3357 return CAMERA_ERROR_INVALID_PARAMETER;
3360 int ret = MM_ERROR_NONE;
3362 camera_s *handle = (camera_s *)camera;
3363 MMCamAttrsInfo af_range;
3364 MMCamAttrsInfo focus_mode;
3366 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE, &af_range);
3367 ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE, &focus_mode);
3368 if (ret != MM_ERROR_NONE) {
3369 return __convert_camera_error_code(__func__, ret);
3372 for (i = 0 ; i < af_range.int_array.count ; i++) {
3373 if (!foreach_cb(af_range.int_array.array[i], user_data)) {
3378 return CAMERA_ERROR_NONE;
3382 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
3384 if (camera == NULL || foreach_cb == NULL) {
3385 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3386 return CAMERA_ERROR_INVALID_PARAMETER;
3389 int maptable[] = {CAMERA_ATTR_EXPOSURE_MODE_OFF, /* MM_CAMCORDER_AUTO_EXPOSURE_OFF */
3390 CAMERA_ATTR_EXPOSURE_MODE_ALL, /* MM_CAMCORDER_AUTO_EXPOSURE_ALL */
3391 CAMERA_ATTR_EXPOSURE_MODE_CENTER, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 */
3392 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 */
3393 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 */
3394 CAMERA_ATTR_EXPOSURE_MODE_SPOT, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 */
3395 -1, /* MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 */
3396 CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 */
3397 -1 /* MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 */
3400 int ret = MM_ERROR_NONE;
3401 camera_s *handle = (camera_s *)camera;
3402 MMCamAttrsInfo info;
3404 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE, &info);
3405 if (ret != MM_ERROR_NONE) {
3406 return __convert_camera_error_code(__func__, ret);
3409 for (i = 0 ; i < info.int_array.count ; i++) {
3410 if (info.int_array.array[i] >= MM_CAMCORDER_AUTO_EXPOSURE_OFF &&
3411 info.int_array.array[i] <= MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2) {
3412 if (maptable[info.int_array.array[i]] != -1) {
3413 if (!foreach_cb(maptable[info.int_array.array[i]], user_data)) {
3418 LOGW("unknown value %d", info.int_array.array[i]);
3422 return CAMERA_ERROR_NONE;
3426 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
3428 if (camera == NULL || foreach_cb == NULL) {
3429 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3430 return CAMERA_ERROR_INVALID_PARAMETER;
3434 int ret = MM_ERROR_NONE;
3435 camera_s *handle = (camera_s *)camera;
3436 MMCamAttrsInfo info;
3438 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO, &info);
3439 if (ret != MM_ERROR_NONE) {
3440 return __convert_camera_error_code(__func__, ret);
3443 for (i = 0 ; i < info.int_array.count ; i++) {
3444 if (!foreach_cb(info.int_array.array[i], user_data)) {
3449 return CAMERA_ERROR_NONE;
3453 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
3455 if (camera == NULL || foreach_cb == NULL) {
3456 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3457 return CAMERA_ERROR_INVALID_PARAMETER;
3461 int ret = MM_ERROR_NONE;
3462 camera_s *handle = (camera_s *)camera;
3463 MMCamAttrsInfo info;
3465 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB, &info);
3466 if (ret != MM_ERROR_NONE) {
3467 return __convert_camera_error_code(__func__, ret);
3470 for (i = 0 ; i < info.int_array.count ; i++) {
3471 if (!foreach_cb(info.int_array.array[i], user_data)) {
3476 return CAMERA_ERROR_NONE;
3480 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
3482 if (camera == NULL || foreach_cb == NULL) {
3483 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3484 return CAMERA_ERROR_INVALID_PARAMETER;
3488 int ret = MM_ERROR_NONE;
3489 camera_s *handle = (camera_s *)camera;
3490 MMCamAttrsInfo info;
3492 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE, &info);
3493 if (ret != MM_ERROR_NONE) {
3494 return __convert_camera_error_code(__func__, ret);
3497 for (i = 0 ; i < info.int_array.count ; i++) {
3498 if (!foreach_cb(info.int_array.array[i], user_data)) {
3503 return CAMERA_ERROR_NONE;
3507 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
3509 if (camera == NULL || foreach_cb == NULL) {
3510 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3511 return CAMERA_ERROR_INVALID_PARAMETER;
3515 int ret = MM_ERROR_NONE;
3516 camera_s *handle = (camera_s *)camera;
3517 MMCamAttrsInfo info;
3519 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE, &info);
3520 if (ret != MM_ERROR_NONE) {
3521 return __convert_camera_error_code(__func__, ret);
3524 for (i = 0 ; i < info.int_array.count ; i++) {
3525 if (!foreach_cb(info.int_array.array[i], user_data)) {
3530 return CAMERA_ERROR_NONE;
3534 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
3536 if (camera == NULL || foreach_cb == NULL) {
3537 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3538 return CAMERA_ERROR_INVALID_PARAMETER;
3542 int ret = MM_ERROR_NONE;
3543 camera_s *handle = (camera_s *)camera;
3544 MMCamAttrsInfo info;
3546 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE, &info);
3547 if (ret != MM_ERROR_NONE) {
3548 return __convert_camera_error_code(__func__, ret);
3551 for (i = 0 ; i < info.int_array.count ; i++) {
3552 if (!foreach_cb(info.int_array.array[i], user_data)) {
3557 return CAMERA_ERROR_NONE;
3561 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
3563 if (camera == NULL || foreach_cb == NULL) {
3564 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3565 return CAMERA_ERROR_INVALID_PARAMETER;
3568 int ret = MM_ERROR_NONE;
3569 camera_s *handle = (camera_s *)camera;
3570 MMCamAttrsInfo info;
3575 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3576 MMCAM_CAMERA_WIDTH, &width,
3577 MMCAM_CAMERA_HEIGHT, &height,
3579 if (ret != MM_ERROR_NONE) {
3580 return __convert_camera_error_code(__func__, ret);
3583 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3584 if (ret != MM_ERROR_NONE) {
3585 return __convert_camera_error_code(__func__, ret);
3588 for (i = 0 ; i < info.int_array.count ; i++) {
3589 if (!foreach_cb(info.int_array.array[i], user_data)) {
3594 return CAMERA_ERROR_NONE;
3598 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)
3600 if (camera == NULL || foreach_cb == NULL) {
3601 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3602 return CAMERA_ERROR_INVALID_PARAMETER;
3605 int ret = MM_ERROR_NONE;
3606 camera_s *handle = (camera_s *)camera;
3607 MMCamAttrsInfo info;
3610 ret = mm_camcorder_get_fps_list_by_resolution(handle->mm_handle, width, height, &info);
3611 if (ret != MM_ERROR_NONE) {
3612 return __convert_camera_error_code(__func__, ret);
3615 for (i = 0 ; i < info.int_array.count ; i++) {
3616 if (!foreach_cb(info.int_array.array[i], user_data)) {
3621 return CAMERA_ERROR_NONE;
3625 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
3627 if (camera == NULL || foreach_cb == NULL) {
3628 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3629 return CAMERA_ERROR_INVALID_PARAMETER;
3633 int ret = MM_ERROR_NONE;
3634 camera_s *handle = (camera_s *)camera;
3635 MMCamAttrsInfo info;
3637 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FLIP, &info);
3638 if (ret != MM_ERROR_NONE) {
3639 return __convert_camera_error_code(__func__, ret);
3642 for (i = 0 ; i < info.int_array.count ; i++) {
3643 if (!foreach_cb(info.int_array.array[i], user_data)) {
3648 return CAMERA_ERROR_NONE;
3652 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
3654 if (camera == NULL || foreach_cb == NULL) {
3655 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3656 return CAMERA_ERROR_INVALID_PARAMETER;
3660 int ret = MM_ERROR_NONE;
3661 camera_s *handle = (camera_s *)camera;
3662 MMCamAttrsInfo info;
3664 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ROTATION, &info);
3665 if (ret != MM_ERROR_NONE) {
3666 return __convert_camera_error_code(__func__, ret);
3669 for (i = 0 ; i < info.int_array.count ; i++) {
3670 if (!foreach_cb(info.int_array.array[i], user_data)) {
3675 return CAMERA_ERROR_NONE;
3679 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
3681 if (camera == NULL) {
3682 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3683 return CAMERA_ERROR_INVALID_PARAMETER;
3686 if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
3687 LOGE("INVALID_PARAMETER - %d", rotation);
3688 return CAMERA_ERROR_INVALID_PARAMETER;
3691 int ret = MM_ERROR_NONE;
3692 camera_s *handle = (camera_s *)camera;
3694 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3695 MMCAM_CAMERA_ROTATION, rotation,
3698 return __convert_camera_error_code(__func__, ret);
3702 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
3704 if (camera == NULL || rotation == NULL) {
3705 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3706 return CAMERA_ERROR_INVALID_PARAMETER;
3709 int ret = MM_ERROR_NONE;
3710 camera_s *handle = (camera_s *)camera;
3712 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3713 MMCAM_CAMERA_ROTATION, rotation,
3716 return __convert_camera_error_code(__func__, ret);
3720 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
3722 if (camera == NULL) {
3723 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3724 return CAMERA_ERROR_INVALID_PARAMETER;
3727 if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
3728 LOGE("INVALID_PARAMETER - %d", flip);
3729 return CAMERA_ERROR_INVALID_PARAMETER;
3732 int ret = MM_ERROR_NONE;
3733 camera_s *handle = (camera_s *)camera;
3735 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3736 MMCAM_CAMERA_FLIP, flip,
3739 return __convert_camera_error_code(__func__, ret);
3743 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
3745 if (camera == NULL || flip == NULL) {
3746 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3747 return CAMERA_ERROR_INVALID_PARAMETER;
3750 int ret = MM_ERROR_NONE;
3751 camera_s *handle = (camera_s *)camera;
3753 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
3754 MMCAM_CAMERA_FLIP, flip,
3757 return __convert_camera_error_code(__func__, ret);
3761 int _camera_set_use(camera_h camera, bool used)
3763 camera_s *handle = (camera_s *)camera;
3765 if (handle == NULL) {
3766 LOGE("handle is NULL");
3767 return CAMERA_ERROR_INVALID_PARAMETER;
3770 handle->is_used_in_recorder = used;
3772 return CAMERA_ERROR_NONE;
3776 bool _camera_is_used(camera_h camera)
3778 camera_s *handle = (camera_s *)camera;
3780 if (handle == NULL) {
3781 LOGE("handle is NULL");
3785 return handle->is_used_in_recorder;
3789 int _camera_get_mm_handle(camera_h camera, MMHandleType *handle)
3791 if (camera == NULL || handle == NULL) {
3792 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3793 return CAMERA_ERROR_INVALID_PARAMETER;
3796 camera_s *camera_handle = (camera_s*)camera;
3798 *handle = camera_handle->mm_handle;
3800 return CAMERA_ERROR_NONE;
3804 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data)
3806 if( camera == NULL ){
3807 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3808 return CAMERA_ERROR_INVALID_PARAMETER;
3811 camera_s *handle = (camera_s *)camera;
3812 handle->relay_message_callback = callback;
3813 handle->relay_user_data = user_data;
3815 return CAMERA_ERROR_NONE;
3819 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
3821 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3822 in_format >= MM_PIXEL_FORMAT_NUM ||
3823 out_format == NULL) {
3824 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
3825 return CAMERA_ERROR_INVALID_PARAMETER;
3828 switch (in_format) {
3829 case MM_PIXEL_FORMAT_NV12:
3830 case MM_PIXEL_FORMAT_NV12T:
3831 *out_format = TBM_FORMAT_NV12;
3833 case MM_PIXEL_FORMAT_NV16:
3834 *out_format = TBM_FORMAT_NV16;
3836 case MM_PIXEL_FORMAT_NV21:
3837 *out_format = TBM_FORMAT_NV21;
3839 case MM_PIXEL_FORMAT_YUYV:
3840 *out_format = TBM_FORMAT_YUYV;
3842 case MM_PIXEL_FORMAT_UYVY:
3843 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3844 *out_format = TBM_FORMAT_UYVY;
3846 case MM_PIXEL_FORMAT_422P:
3847 *out_format = TBM_FORMAT_YUV422;
3849 case MM_PIXEL_FORMAT_I420:
3850 *out_format = TBM_FORMAT_YUV420;
3852 case MM_PIXEL_FORMAT_YV12:
3853 *out_format = TBM_FORMAT_YVU420;
3855 case MM_PIXEL_FORMAT_RGB565:
3856 *out_format = TBM_FORMAT_RGB565;
3858 case MM_PIXEL_FORMAT_RGB888:
3859 *out_format = TBM_FORMAT_RGB888;
3861 case MM_PIXEL_FORMAT_RGBA:
3862 *out_format = TBM_FORMAT_RGBA8888;
3864 case MM_PIXEL_FORMAT_ARGB:
3865 *out_format = TBM_FORMAT_ARGB8888;
3868 LOGE("invalid in_format %d", in_format);
3869 return CAMERA_ERROR_INVALID_PARAMETER;
3872 return CAMERA_ERROR_NONE;
3876 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
3878 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
3879 in_format >= MM_PIXEL_FORMAT_NUM ||
3881 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
3882 return CAMERA_ERROR_INVALID_PARAMETER;
3885 switch (in_format) {
3886 case MM_PIXEL_FORMAT_NV12:
3887 case MM_PIXEL_FORMAT_NV12T:
3888 *mimetype = MEDIA_FORMAT_NV12;
3890 case MM_PIXEL_FORMAT_NV16:
3891 *mimetype = MEDIA_FORMAT_NV16;
3893 case MM_PIXEL_FORMAT_NV21:
3894 *mimetype = MEDIA_FORMAT_NV21;
3896 case MM_PIXEL_FORMAT_YUYV:
3897 *mimetype = MEDIA_FORMAT_YUYV;
3899 case MM_PIXEL_FORMAT_UYVY:
3900 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
3901 *mimetype = MEDIA_FORMAT_UYVY;
3903 case MM_PIXEL_FORMAT_422P:
3904 *mimetype = MEDIA_FORMAT_422P;
3906 case MM_PIXEL_FORMAT_I420:
3907 *mimetype = MEDIA_FORMAT_I420;
3909 case MM_PIXEL_FORMAT_YV12:
3910 *mimetype = MEDIA_FORMAT_YV12;
3912 case MM_PIXEL_FORMAT_RGB565:
3913 *mimetype = MEDIA_FORMAT_RGB565;
3915 case MM_PIXEL_FORMAT_RGB888:
3916 *mimetype = MEDIA_FORMAT_RGB888;
3918 case MM_PIXEL_FORMAT_RGBA:
3919 *mimetype = MEDIA_FORMAT_RGBA;
3921 case MM_PIXEL_FORMAT_ARGB:
3922 *mimetype = MEDIA_FORMAT_ARGB;
3925 LOGE("invalid in_format %d", in_format);
3926 return CAMERA_ERROR_INVALID_PARAMETER;
3929 return CAMERA_ERROR_NONE;
3933 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
3936 void *internal_buffer = NULL;
3937 tbm_surface_h tsurf = NULL;
3939 if (pkt == NULL || user_data == NULL) {
3940 LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
3941 return MEDIA_PACKET_FINALIZE;
3944 ret = media_packet_get_extra(pkt, &internal_buffer);
3945 if (ret != MEDIA_PACKET_ERROR_NONE) {
3946 LOGE("media_packet_get_extra failed 0x%x", ret);
3947 return MEDIA_PACKET_FINALIZE;
3950 /*LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret);*/
3952 if (internal_buffer) {
3953 gst_buffer_unref((GstBuffer *)internal_buffer);
3954 internal_buffer = NULL;
3957 ret = media_packet_get_tbm_surface(pkt, &tsurf);
3958 if (ret != MEDIA_PACKET_ERROR_NONE) {
3959 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
3960 return MEDIA_PACKET_FINALIZE;
3964 tbm_surface_destroy(tsurf);
3968 return MEDIA_PACKET_FINALIZE;
3972 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
3974 if (camera == NULL) {
3975 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3976 return CAMERA_ERROR_INVALID_PARAMETER;
3979 if (camera_attr_is_supported_hdr_capture(camera) == false) {
3980 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3981 return CAMERA_ERROR_NOT_SUPPORTED;
3984 int ret = MM_ERROR_NONE;
3985 camera_s *handle = (camera_s *)camera;
3987 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
3988 MMCAM_CAMERA_HDR_CAPTURE, mode,
3991 if (ret == MM_ERROR_NONE) {
3992 if (mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL) {
3993 handle->hdr_keep_mode = true;
3995 handle->hdr_keep_mode = false;
3999 return __convert_camera_error_code(__func__, ret);
4003 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
4005 if (camera == NULL) {
4006 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4007 return CAMERA_ERROR_INVALID_PARAMETER;
4010 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4011 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4012 return CAMERA_ERROR_NOT_SUPPORTED;
4016 LOGE("INVALID_PARAMETER(0x%08x) - mode", CAMERA_ERROR_INVALID_PARAMETER);
4017 return CAMERA_ERROR_INVALID_PARAMETER;
4020 int ret = MM_ERROR_NONE;
4021 camera_s *handle = (camera_s *)camera;
4023 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4024 MMCAM_CAMERA_HDR_CAPTURE, mode,
4027 return __convert_camera_error_code(__func__, ret);
4031 bool camera_attr_is_supported_hdr_capture(camera_h camera)
4033 if (camera == NULL) {
4034 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4038 int ret = MM_ERROR_NONE;
4040 camera_s *handle = (camera_s *)camera;
4041 MMCamAttrsInfo hdr_info;
4043 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE, &hdr_info);
4044 set_last_result(__convert_camera_error_code(__func__, ret));
4045 if (ret != MM_ERROR_NONE) {
4046 LOGE("MMCAM_CAMERA_HDR_CAPTURE get attr info failed");
4050 for (i = 0; i < hdr_info.int_array.count ; i++) {
4051 if (hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON) {
4052 LOGD("HDR capture supported");
4057 LOGD("HDR capture NOT supported");
4063 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
4065 if (camera == NULL) {
4066 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4067 return CAMERA_ERROR_INVALID_PARAMETER;
4070 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4071 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4072 return CAMERA_ERROR_NOT_SUPPORTED;
4075 if (callback == NULL) {
4076 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
4077 return CAMERA_ERROR_INVALID_PARAMETER;
4080 camera_s *handle = (camera_s *)camera;
4082 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)callback;
4083 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)user_data;
4085 return CAMERA_ERROR_NONE;
4089 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
4091 if (camera == NULL) {
4092 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4093 return CAMERA_ERROR_INVALID_PARAMETER;
4096 if (camera_attr_is_supported_hdr_capture(camera) == false) {
4097 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4098 return CAMERA_ERROR_NOT_SUPPORTED;
4101 camera_s *handle = (camera_s *)camera;
4103 handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4104 handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
4106 return CAMERA_ERROR_NONE;
4110 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
4112 if (camera == NULL) {
4113 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4114 return CAMERA_ERROR_INVALID_PARAMETER;
4117 if (camera_attr_is_supported_anti_shake(camera) == false) {
4118 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4119 return CAMERA_ERROR_NOT_SUPPORTED;
4122 int ret = MM_ERROR_NONE;
4123 int mode = MM_CAMCORDER_AHS_OFF;
4124 camera_s *handle = (camera_s *)camera;
4127 mode = MM_CAMCORDER_AHS_ON;
4130 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4131 MMCAM_CAMERA_ANTI_HANDSHAKE, mode,
4134 return __convert_camera_error_code(__func__, ret);
4138 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
4140 if (camera == NULL) {
4141 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4142 return CAMERA_ERROR_INVALID_PARAMETER;
4145 if (camera_attr_is_supported_anti_shake(camera) == false) {
4146 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4147 return CAMERA_ERROR_NOT_SUPPORTED;
4150 if (enabled == NULL) {
4151 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4152 return CAMERA_ERROR_INVALID_PARAMETER;
4155 int ret = MM_ERROR_NONE;
4156 camera_s *handle = (camera_s *)camera;
4158 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4159 MMCAM_CAMERA_ANTI_HANDSHAKE, enabled,
4162 return __convert_camera_error_code(__func__, ret);
4166 bool camera_attr_is_supported_anti_shake(camera_h camera)
4168 if (camera == NULL) {
4169 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4174 int ret = MM_ERROR_NONE;
4175 camera_s *handle = (camera_s *)camera;
4176 MMCamAttrsInfo ash_info;
4178 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE, &ash_info);
4179 set_last_result(__convert_camera_error_code(__func__, ret));
4180 if (ret != MM_ERROR_NONE) {
4181 LOGE("MMCAM_CAMERA_ANTI_HANDSHAKE get attr info failed");
4185 for (i = 0 ; i < ash_info.int_array.count ; i++) {
4186 if (ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON) {
4195 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
4197 if (camera == NULL) {
4198 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4199 return CAMERA_ERROR_INVALID_PARAMETER;
4202 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4203 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4204 return CAMERA_ERROR_NOT_SUPPORTED;
4207 int ret = MM_ERROR_NONE;
4208 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4209 camera_s *handle = (camera_s*)camera;
4212 mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
4215 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4216 MMCAM_CAMERA_VIDEO_STABILIZATION, mode,
4219 return __convert_camera_error_code(__func__, ret);
4223 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
4225 if (camera == NULL) {
4226 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4227 return CAMERA_ERROR_INVALID_PARAMETER;
4230 if (camera_attr_is_supported_video_stabilization(camera) == false) {
4231 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4232 return CAMERA_ERROR_NOT_SUPPORTED;
4235 if (enabled == NULL) {
4236 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4237 return CAMERA_ERROR_INVALID_PARAMETER;
4240 int ret = MM_ERROR_NONE;
4241 int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
4242 camera_s *handle = (camera_s *)camera;
4244 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4245 MMCAM_CAMERA_VIDEO_STABILIZATION, &mode,
4247 if (ret == MM_ERROR_NONE) {
4248 *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
4251 return __convert_camera_error_code(__func__, ret);
4255 bool camera_attr_is_supported_video_stabilization(camera_h camera)
4257 if (camera == NULL) {
4258 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4263 int ret = MM_ERROR_NONE;
4264 camera_s *handle = (camera_s *)camera;
4265 MMCamAttrsInfo vs_info;
4267 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION, &vs_info);
4268 set_last_result(__convert_camera_error_code(__func__, ret));
4269 if (ret != MM_ERROR_NONE) {
4270 LOGE("MMCAM_CAMERA_VIDEO_STABILIZATION get attr info failed");
4274 for (i = 0 ; i < vs_info.int_array.count ; i++) {
4275 if (vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
4284 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
4286 if (camera == NULL) {
4287 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4288 return CAMERA_ERROR_INVALID_PARAMETER;
4291 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4292 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4293 return CAMERA_ERROR_NOT_SUPPORTED;
4296 int ret = MM_ERROR_NONE;
4297 int mode = MM_CAMCORDER_WDR_OFF;
4298 camera_s *handle = (camera_s *)camera;
4301 mode = MM_CAMCORDER_WDR_ON;
4304 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4305 MMCAM_CAMERA_WDR, mode,
4308 return __convert_camera_error_code(__func__, ret);
4312 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
4314 if (camera == NULL) {
4315 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
4316 return CAMERA_ERROR_INVALID_PARAMETER;
4319 if (camera_attr_is_supported_auto_contrast(camera) == false) {
4320 LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
4321 return CAMERA_ERROR_NOT_SUPPORTED;
4324 if (enabled == NULL) {
4325 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
4326 return CAMERA_ERROR_INVALID_PARAMETER;
4329 int ret = MM_ERROR_NONE;
4330 int mode = MM_CAMCORDER_WDR_OFF;
4331 camera_s *handle = (camera_s *)camera;
4333 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
4334 MMCAM_CAMERA_WDR, &mode,
4337 if (ret == MM_ERROR_NONE) {
4341 return __convert_camera_error_code(__func__, ret);
4345 bool camera_attr_is_supported_auto_contrast(camera_h camera)
4347 if (camera == NULL) {
4348 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4353 int ret = MM_ERROR_NONE;
4354 camera_s *handle = (camera_s *)camera;
4355 MMCamAttrsInfo info;
4357 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WDR, &info);
4358 set_last_result(__convert_camera_error_code(__func__, ret));
4359 if (ret != MM_ERROR_NONE) {
4360 LOGE("MMCAM_CAMERA_WDR get attr info failed");
4364 for (i = 0 ; i < info.int_array.count ; i++) {
4365 if (info.int_array.array[i] == MM_CAMCORDER_WDR_ON) {
4374 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
4376 if (camera == NULL) {
4377 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4378 return CAMERA_ERROR_INVALID_PARAMETER;
4381 int ret = MM_ERROR_NONE;
4382 camera_s *handle = (camera_s *)camera;
4384 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
4385 "capture-sound-enable", !disable,
4387 if (ret != MM_ERROR_NONE) {
4388 LOGE("CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound");
4389 return CAMERA_ERROR_INVALID_OPERATION;
4392 return CAMERA_ERROR_NONE;