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.
24 #include <mm_camcorder.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_client.h>
34 #define LOG_TAG "TIZEN_N_CAMERA"
35 #define MODULE_NAME "camera"
38 /* for device changed callback */
39 static GMutex g_cam_dev_state_changed_cb_lock;
40 static GList *g_cam_dev_state_changed_cb_list;
41 static int g_cam_dev_state_changed_cb_id;
42 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
43 static guint g_cam_dev_state_changed_cb_subscribe_id;
44 static GMutex g_cam_idle_event_lock;
47 static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO;
49 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
50 static void __camera_release_imported_bo(tbm_bo *bo);
52 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
53 camera_media_packet_data *mp_data, media_packet_h *packet);
54 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
55 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
56 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
58 static gboolean __camera_allocate_preview_buffer(camera_h camera);
59 static void __camera_release_preview_buffer(camera_h camera);
60 static void __camera_release_tfd(int tfd[MUSE_NUM_FD]);
62 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
63 int type, const char *thread_name, camera_cb_info_s *cb_info);
64 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info);
68 static gboolean __camera_allocate_preview_buffer(camera_h camera)
71 int ret = CAMERA_ERROR_NONE;
72 int format = CAMERA_PIXEL_FORMAT_INVALID;
76 camera_cli_s *pc = (camera_cli_s *)camera;
77 camera_cb_info_s *cb_info = NULL;
79 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, FALSE);
81 cb_info = pc->cb_info;
83 CAM_LOG_INFO("Enter");
85 /* get preview info and calculate size */
86 ret = camera_get_preview_format(camera, &format);
87 if (ret != CAMERA_ERROR_NONE) {
88 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
92 ret = camera_get_preview_resolution(camera, &width, &height);
93 if (ret != CAMERA_ERROR_NONE) {
94 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
98 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
101 case CAMERA_PIXEL_FORMAT_INVZ:
102 buffer_size = width * height;
104 case CAMERA_PIXEL_FORMAT_NV12:
105 case CAMERA_PIXEL_FORMAT_I420:
106 buffer_size = (width * height * 3) >> 1;
108 case CAMERA_PIXEL_FORMAT_YUYV:
109 case CAMERA_PIXEL_FORMAT_UYVY:
110 buffer_size = width * height * 2;
113 CAM_LOG_ERROR("unhandled format %d", format);
114 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
117 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
119 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
120 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
121 if (!cb_info->bos[i]) {
122 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
123 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
126 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
127 if (cb_info->fds[i] < 0) {
128 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
129 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
132 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
135 CAM_LOG_INFO("Done");
139 _ALLOCATE_PREVIEW_BUFFER_FAILED:
140 __camera_release_preview_buffer(camera);
145 static void __camera_release_preview_buffer(camera_h camera)
148 camera_cli_s *pc = (camera_cli_s *)camera;
149 camera_cb_info_s *cb_info = NULL;
151 CAMERA_CHECK_HANDLE_RETURN(pc);
153 CAM_LOG_INFO("Enter");
155 cb_info = pc->cb_info;
157 /* close exported fd and bos */
158 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
159 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
161 if (cb_info->bos[i]) {
162 tbm_bo_unref(cb_info->bos[i]);
163 cb_info->bos[i] = NULL;
168 if (CAMERA_IS_FD_VALID(cb_info->fds[i])) {
169 close(cb_info->fds[i]);
170 cb_info->fds[i] = CAMERA_FD_INIT;
174 CAM_LOG_INFO("Done");
178 static void __camera_release_tfd(int tfd[MUSE_NUM_FD])
183 CAM_LOG_WARNING("NULL tfd");
187 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
188 if (!CAMERA_IS_FD_VALID(tfd[i]))
192 tfd[i] = CAMERA_FD_INIT;
197 void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
200 api < 0 || api >= MUSE_CAMERA_API_MAX) {
201 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
205 g_mutex_lock(&(cb_info->api_mutex[api]));
206 cb_info->api_waiting[api] += value;
207 g_mutex_unlock(&(cb_info->api_mutex[api]));
209 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
210 api, value, cb_info->api_waiting[api]);
214 static void __camera_device_state_changed_cb(GDBusConnection *connection,
215 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
216 const gchar *signal_name, GVariant *param, gpointer user_data)
219 camera_device_e device = CAMERA_DEVICE_CAMERA0;
220 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
221 GList *tmp_list = NULL;
222 camera_cb_info *info = NULL;
224 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
226 if (!g_cam_dev_state_changed_cb_list || !param) {
227 CAM_LOG_WARNING("no callback or NULL param %p", param);
231 /* get device and state */
232 g_variant_get(param, "(i)", &value);
234 device = value >> 16;
235 state = 0x0000ffff & value;
237 CAM_LOG_INFO("device %d, state %d", device, state);
239 tmp_list = g_cam_dev_state_changed_cb_list;
242 info = (camera_cb_info *)tmp_list->data;
245 if (info->callback) {
246 CAM_LOG_INFO("start id[%d] callback", info->id);
247 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
248 CAM_LOG_INFO("returned id[%d] callback", info->id);
250 CAM_LOG_WARNING("NULL callback for id %d", info->id);
254 tmp_list = tmp_list->next;
258 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
262 static void __camera_preview_cb_monitoring_info_sub_reset(monitoring_info_sub_s *info_sub)
265 CAM_LOG_ERROR("NULL info_sub");
269 info_sub->frame_count = 0;
270 info_sub->elapsed_sec_accum = 0.0;
271 info_sub->elapsed_sec_peak = 0.0;
275 static void __camera_preview_cb_monitoring_info_reset(camera_preview_cb_monitoring_info_s *info)
278 CAM_LOG_ERROR("NULL info");
282 __camera_preview_cb_monitoring_info_sub_reset(info->total);
283 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
287 static void __camera_preview_cb_monitoring_info_start(camera_preview_cb_monitoring_info_s *info)
290 CAM_LOG_ERROR("NULL info");
294 g_timer_start(info->timer_calling);
296 if (info->interval->frame_count == 0)
297 g_timer_start(info->timer_interval);
301 static void __camera_preview_cb_monitoring_info_sub_update(monitoring_info_sub_s *info_sub, gdouble elapsed_sec)
304 CAM_LOG_ERROR("NULL info_sub");
308 info_sub->frame_count++;
309 info_sub->elapsed_sec_accum += elapsed_sec;
311 if (info_sub->elapsed_sec_peak < elapsed_sec)
312 info_sub->elapsed_sec_peak = elapsed_sec;
316 static void __camera_preview_cb_monitoring_info_end(camera_preview_cb_monitoring_info_s *info)
318 gdouble elapsed_sec = 0.0;
319 gdouble elapsed_sec_interval = 0.0;
322 CAM_LOG_ERROR("NULL info");
326 elapsed_sec = g_timer_elapsed(info->timer_calling, NULL);
327 elapsed_sec_interval = g_timer_elapsed(info->timer_interval, NULL);
329 __camera_preview_cb_monitoring_info_sub_update(info->total, elapsed_sec);
330 __camera_preview_cb_monitoring_info_sub_update(info->interval, elapsed_sec);
332 if (elapsed_sec_interval >= 1.0) {
333 CAM_LOG_INFO("id[%d], frame count[t:%llu,i:%llu], elapsed - avg[t:%dms,i:%dms], peak[t:%dms,i:%dms]",
334 info->stream_id, info->total->frame_count, info->interval->frame_count,
335 (int)((info->total->elapsed_sec_accum / (gdouble)info->total->frame_count) * 1000),
336 (int)((info->interval->elapsed_sec_accum / (gdouble)info->interval->frame_count) * 1000),
337 (int)(info->total->elapsed_sec_peak * 1000), (int)(info->interval->elapsed_sec_peak * 1000));
339 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
344 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
348 int ret_fd = CAMERA_FD_INIT;
349 int preview_fd = CAMERA_FD_INIT;
350 int num_buffer_fd = 0;
351 unsigned char *buf_pos = NULL;
354 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
355 tbm_bo_handle bo_handle = {.ptr = NULL};
356 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
357 tbm_bo data_bo = NULL;
358 tbm_bo_handle data_bo_handle = {.ptr = NULL};
360 camera_msg_param param;
361 camera_preview_data_s frame;
362 MMCamcorderVideoStreamDataType *stream = NULL;
363 camera_media_packet_data *mp_data = NULL;
364 media_packet_h pkt = NULL;
365 camera_preview_cb_monitoring_info_s *monitoring_info = NULL;
367 /* tfd[0]: MMCamcorderVideoStreamDataType
368 tfd[1]: data_bo or zero copy bo[0]
369 tfd[2]: zero copy bo[1]
370 tfd[3]: zero copy bo[2] */
372 if (!cb_info || !recv_msg || !tfd) {
373 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
377 muse_camera_msg_get(preview_fd, recv_msg);
378 muse_camera_msg_get(num_buffer_fd, recv_msg);
380 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
382 memset(&frame, 0x0, sizeof(camera_preview_data_s));
385 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
390 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
392 if (cb_info->invoke_preview_cb == FALSE) {
393 CAM_LOG_WARNING("Skip preview callback for fd[%d] due to preview stop.", ret_fd);
394 goto _PREVIEW_CB_HANDLER_DONE;
397 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
398 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
399 goto _PREVIEW_CB_HANDLER_DONE;
402 /* import tbm bo and get virtual address */
403 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
404 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
405 goto _PREVIEW_CB_HANDLER_DONE;
408 buf_pos = (unsigned char *)bo_handle.ptr;
410 /* get stream info */
411 stream = (MMCamcorderVideoStreamDataType *)buf_pos;
413 CAM_LOG_VERBOSE("meta ts: [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu]",
414 stream->ts_soe, stream->ts_eoe,
415 stream->ts_sof, stream->ts_eof,
416 stream->ts_hal, stream->ts_qmf,
417 stream->ts_gst, stream->td_exp,
418 stream->ts_aux, stream->td_aux);
420 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
421 /* import tbm data_bo and get virtual address */
422 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
423 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
424 goto _PREVIEW_CB_HANDLER_DONE;
427 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
428 stream->data.encoded.data = data_bo_handle.ptr;
430 for (i = 0 ; i < num_buffer_fd ; i++) {
431 /* import buffer bo and get virtual address */
432 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
433 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
434 goto _PREVIEW_CB_HANDLER_DONE;
438 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
439 stream->data.encoded.data = buffer_bo_handle[0].ptr;
442 /* preview callback */
443 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
444 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]) {
445 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
447 /* set stream data for camera_get_preview_frame_rotation() */
448 cb_info->stream_data = stream;
450 if (stream->extra_stream_id < 0) {
451 monitoring_info = cb_info->monitoring_info_preview;
452 __camera_preview_cb_monitoring_info_start(monitoring_info);
454 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
455 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
456 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
458 monitoring_info = cb_info->monitoring_info_preview_ex[stream->extra_stream_id];
459 __camera_preview_cb_monitoring_info_start(monitoring_info);
461 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
462 ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
463 stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
466 __camera_preview_cb_monitoring_info_end(monitoring_info);
468 cb_info->stream_data = NULL;
471 if (stream->extra_stream_id >= 0)
472 goto _PREVIEW_CB_HANDLER_DONE;
474 /* make media packet with below cases.
475 * 1. media_packet_preview_cb is set
476 * 2. EVAS display rendering
477 * 3. media bridge is set
479 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
480 cb_info->is_evas_render ||
482 ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
483 if (ret != CAMERA_ERROR_NONE) {
484 CAM_LOG_ERROR("__camera_create_media_packet_data failed[0x%x]", ret);
485 goto _PREVIEW_CB_HANDLER_DONE;
488 ret = __camera_create_media_packet(cb_info, stream, mp_data, &pkt);
489 if (ret != CAMERA_ERROR_NONE) {
490 CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
491 __camera_release_media_packet_data(mp_data, cb_info);
493 goto _PREVIEW_CB_HANDLER_DONE;
497 /* 1. media packet preview callback */
498 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
499 media_packet_ref(pkt);
501 monitoring_info = cb_info->monitoring_info_preview_mp;
502 __camera_preview_cb_monitoring_info_start(monitoring_info);
504 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
505 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
507 __camera_preview_cb_monitoring_info_end(monitoring_info);
510 /* 2. call evas renderer */
511 if (cb_info->is_evas_render) {
512 if (cb_info->run_evas_render) {
513 media_packet_ref(pkt);
514 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
515 if (ret != MM_ERROR_NONE) {
516 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
517 media_packet_unref(pkt);
520 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
525 /* 3. media bridge */
526 g_mutex_lock(&cb_info->bridge_lock);
528 if (cb_info->bridge) {
529 media_packet_ref(pkt);
530 ret = media_bridge_push_packet(cb_info->bridge, pkt);
531 if (ret != MEDIA_BRIDGE_ERROR_NONE) {
532 CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
533 media_packet_unref(pkt);
538 g_mutex_unlock(&cb_info->bridge_lock);
540 _PREVIEW_CB_HANDLER_DONE:
541 /* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
542 and preview callback(normal or media packet) is set. */
543 if (num_buffer_fd > 0 &&
544 (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
545 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]))
546 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
549 media_packet_unref(pkt);
554 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
556 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
558 /* release imported bo and fd */
559 __camera_release_imported_bo(&data_bo);
560 __camera_release_imported_bo(&bo);
562 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
563 __camera_release_imported_bo(&buffer_bo[i]);
565 __camera_release_tfd(tfd);
569 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
572 int capture_fd_main = 0;
573 int capture_fd_post = 0;
574 int capture_fd_thumb = 0;
575 unsigned char *buf_pos = NULL;
577 camera_image_data_s *rImage = NULL;
578 camera_image_data_s *rPostview = NULL;
579 camera_image_data_s *rThumbnail = NULL;
581 tbm_bo bo_main = NULL;
582 tbm_bo bo_post = NULL;
583 tbm_bo bo_thumb = NULL;
584 tbm_bo_handle bo_main_handle = {.ptr = NULL};
585 tbm_bo_handle bo_post_handle = {.ptr = NULL};
586 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
588 if (!cb_info || !recv_msg || !tfd) {
589 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
593 muse_camera_msg_get(capture_fd_main, recv_msg);
594 muse_camera_msg_get(capture_fd_post, recv_msg);
595 muse_camera_msg_get(capture_fd_thumb, recv_msg);
597 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
598 capture_fd_main, capture_fd_post, capture_fd_thumb,
599 tfd[0], tfd[1], tfd[2]);
601 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
602 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
603 goto _CAPTURE_CB_HANDLER_DONE;
606 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
607 CAM_LOG_WARNING("NULL callback");
608 goto _CAPTURE_CB_HANDLER_DONE;
611 /* import tbm bo and get virtual address */
612 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
613 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
614 goto _CAPTURE_CB_HANDLER_DONE;
617 buf_pos = (unsigned char *)bo_main_handle.ptr;
618 rImage = (camera_image_data_s *)buf_pos;
619 rImage->data = buf_pos + sizeof(camera_image_data_s);
620 if (rImage->exif && rImage->exif_size > 0) {
621 rImage->exif = rImage->data + rImage->size;
624 rImage->exif_size = 0;
627 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
628 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
631 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
632 /* import tbm bo and get virtual address */
634 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
635 buf_pos = (unsigned char *)bo_post_handle.ptr;
636 rPostview = (camera_image_data_s *)buf_pos;
637 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
638 rPostview->data = buf_pos + sizeof(camera_image_data_s);
640 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
644 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
645 /* import tbm bo and get virtual address */
647 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
648 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
649 rThumbnail = (camera_image_data_s *)buf_pos;
650 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
651 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
653 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
658 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
659 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
661 _CAPTURE_CB_HANDLER_DONE:
663 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
664 __camera_release_imported_bo(&bo_main);
665 _camera_msg_return_buffer(capture_fd_main, cb_info);
668 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
669 __camera_release_imported_bo(&bo_post);
670 _camera_msg_return_buffer(capture_fd_post, cb_info);
673 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
674 __camera_release_imported_bo(&bo_thumb);
675 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
678 __camera_release_tfd(tfd);
680 CAM_LOG_INFO("return buffer done");
685 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
688 int face_fd = CAMERA_FD_INIT;
689 camera_detected_face_s *faces = NULL;
692 tbm_bo_handle bo_handle = {.ptr = NULL};
694 if (!cb_info || !recv_msg || !tfd) {
695 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
699 muse_camera_msg_get(count, recv_msg);
700 muse_camera_msg_get(face_fd, recv_msg);
702 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
703 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
705 if (CAMERA_IS_FD_VALID(tfd[0])) {
706 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
708 faces = bo_handle.ptr;
712 tfd[0] = CAMERA_FD_INIT;
715 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
716 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
719 __camera_release_imported_bo(&bo);
721 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
722 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
726 _camera_msg_return_buffer(face_fd, cb_info);
731 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
733 tbm_bo tmp_bo = NULL;
734 tbm_bo_handle tmp_bo_handle = {NULL, };
736 if (!bufmgr || !bo || !bo_handle || fd < 0) {
737 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
738 bufmgr, bo, bo_handle, fd);
742 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
743 if (tmp_bo == NULL) {
744 CAM_LOG_ERROR("import failed - fd %d", fd);
748 tmp_bo_handle = tbm_bo_get_handle(tmp_bo, TBM_DEVICE_CPU);
749 if (tmp_bo_handle.ptr == NULL) {
750 CAM_LOG_ERROR("tbm_bo_get_handle() failed %p", tmp_bo);
751 tbm_bo_unref(tmp_bo);
756 /* set bo and bo_handle */
758 *bo_handle = tmp_bo_handle;
760 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
765 static void __camera_release_imported_bo(tbm_bo *bo)
768 CAM_LOG_DEBUG("NULL bo");
777 static bool __is_supported(camera_h camera, muse_camera_api_e api)
779 int ret = CAMERA_ERROR_NONE;
780 camera_cli_s *pc = (camera_cli_s *)camera;
782 if (!pc || !pc->cb_info) {
783 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
784 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
788 CAM_LOG_INFO("Enter - api[%d]", api);
790 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
792 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
798 static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
800 int ret = CAMERA_ERROR_NONE;
801 camera_cli_s *pc = (camera_cli_s *)camera;
802 camera_msg_param param;
804 if (!pc || !pc->cb_info) {
805 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
806 return CAMERA_ERROR_INVALID_PARAMETER;
809 CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
811 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
813 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
815 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
821 static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
823 int ret = CAMERA_ERROR_NONE;
824 camera_cli_s *pc = (camera_cli_s *)camera;
825 camera_msg_param param;
827 if (!pc || !pc->cb_info) {
828 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
829 return CAMERA_ERROR_INVALID_PARAMETER;
832 CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
834 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
836 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
838 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
844 void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
849 CAM_LOG_ERROR("api[%d] message failed", api);
851 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
856 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
857 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
859 CAM_LOG_DEBUG("api[%d], message[%s]", api, msg);
861 if (cb_info->is_server_connected) {
862 _camera_update_api_waiting(cb_info, api, 1);
864 g_mutex_lock(&cb_info->fd_lock);
865 send_ret = muse_core_msg_send(cb_info->fd, msg);
866 g_mutex_unlock(&cb_info->fd_lock);
870 CAM_LOG_ERROR("message send failed");
872 *ret = CAMERA_ERROR_INVALID_OPERATION;
875 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
878 _camera_update_api_waiting(cb_info, api, -1);
880 muse_core_msg_free(msg);
882 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
883 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
885 CAM_LOG_DEBUG("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
889 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
891 int ret = CAMERA_ERROR_NONE;
894 if (!cb_info->is_server_connected) {
895 CAM_LOG_ERROR("server is disconnected");
896 return CAMERA_ERROR_SERVICE_DISCONNECTED;
899 g_mutex_lock(&(cb_info->api_mutex[api]));
901 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
903 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
905 while (!cb_info->api_activating[api]) {
906 if (time_out == CAMERA_CB_NO_TIMEOUT) {
907 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
908 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
909 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
910 CAM_LOG_ERROR("api %d TIMED OUT!", api);
911 ret = CAMERA_ERROR_INVALID_OPERATION;
915 if (!cb_info->is_server_connected) {
916 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
920 if (!cb_info->api_activating[api])
921 CAM_LOG_WARNING("invalid signal received, wait again...");
924 ret = cb_info->api_ret[api];
925 cb_info->api_activating[api] = FALSE;
928 g_mutex_unlock(&(cb_info->api_mutex[api]));
930 if (ret != CAMERA_ERROR_NONE)
931 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
937 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
938 int *ret, int timeout)
943 CAM_LOG_ERROR("NULL info - api %d", api);
946 *ret = CAMERA_ERROR_INVALID_PARAMETER;
951 msg = muse_core_msg_new(api, NULL);
953 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
957 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
958 int *ret, camera_msg_param *param, int timeout)
963 if (!cb_info || !param) {
964 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
967 *ret = CAMERA_ERROR_INVALID_PARAMETER;
972 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
974 switch (param->type) {
976 msg = muse_core_msg_new(api,
977 param->type, param->name, param->value.value_INT,
980 case MUSE_TYPE_STRING:
981 msg = muse_core_msg_new(api,
982 param->type, param->name, param->value.value_STRING,
985 case MUSE_TYPE_ARRAY:
986 array_length = param->value_size / sizeof(int) + \
987 (param->value_size % sizeof(int) ? 1 : 0);
989 msg = muse_core_msg_new(api,
990 param->type, param->name, array_length, param->value.value_ARRAY,
994 CAM_LOG_ERROR("unknown type %d", param->type);
998 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1002 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
1003 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
1007 if (!cb_info || !param0 || !param1) {
1008 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
1009 cb_info, param0, param1, api);
1012 *ret = CAMERA_ERROR_INVALID_PARAMETER;
1017 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
1019 param0->name, param0->value.value_INT,
1020 param1->name, param1->value.value_INT);
1022 msg = muse_core_msg_new(api,
1023 param0->type, param0->name, param0->value.value_INT,
1024 param1->type, param1->name, param1->value.value_INT,
1027 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1031 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
1033 camera_msg_param param;
1036 CAM_LOG_WARNING("invalid fd %d", ret_fd);
1040 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
1042 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1046 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
1048 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1049 in_format >= MM_PIXEL_FORMAT_NUM ||
1050 out_format == NULL) {
1051 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
1052 return CAMERA_ERROR_INVALID_PARAMETER;
1055 switch (in_format) {
1056 case MM_PIXEL_FORMAT_NV12:
1057 case MM_PIXEL_FORMAT_NV12T:
1058 *out_format = TBM_FORMAT_NV12;
1061 case MM_PIXEL_FORMAT_NV16:
1062 *out_format = TBM_FORMAT_NV16;
1064 case MM_PIXEL_FORMAT_NV21:
1065 *out_format = TBM_FORMAT_NV21;
1067 case MM_PIXEL_FORMAT_YUYV:
1068 *out_format = TBM_FORMAT_YUYV;
1070 case MM_PIXEL_FORMAT_UYVY:
1071 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1072 *out_format = TBM_FORMAT_UYVY;
1074 case MM_PIXEL_FORMAT_422P:
1075 *out_format = TBM_FORMAT_YUV422;
1077 case MM_PIXEL_FORMAT_I420:
1078 *out_format = TBM_FORMAT_YUV420;
1080 case MM_PIXEL_FORMAT_YV12:
1081 *out_format = TBM_FORMAT_YVU420;
1083 case MM_PIXEL_FORMAT_RGB565:
1084 *out_format = TBM_FORMAT_RGB565;
1086 case MM_PIXEL_FORMAT_RGB888:
1087 *out_format = TBM_FORMAT_RGB888;
1089 case MM_PIXEL_FORMAT_RGBA:
1090 *out_format = TBM_FORMAT_RGBA8888;
1092 case MM_PIXEL_FORMAT_ARGB:
1093 *out_format = TBM_FORMAT_ARGB8888;
1096 CAM_LOG_ERROR("invalid in_format %d", in_format);
1097 return CAMERA_ERROR_INVALID_PARAMETER;
1101 return CAMERA_ERROR_NONE;
1105 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1107 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1108 in_format >= MM_PIXEL_FORMAT_NUM ||
1110 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1111 return CAMERA_ERROR_INVALID_PARAMETER;
1114 switch (in_format) {
1115 case MM_PIXEL_FORMAT_NV12:
1116 case MM_PIXEL_FORMAT_NV12T:
1117 *mimetype = MEDIA_FORMAT_NV12;
1120 case MM_PIXEL_FORMAT_NV16:
1121 *mimetype = MEDIA_FORMAT_NV16;
1123 case MM_PIXEL_FORMAT_NV21:
1124 *mimetype = MEDIA_FORMAT_NV21;
1126 case MM_PIXEL_FORMAT_YUYV:
1127 *mimetype = MEDIA_FORMAT_YUYV;
1129 case MM_PIXEL_FORMAT_UYVY:
1130 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1131 *mimetype = MEDIA_FORMAT_UYVY;
1133 case MM_PIXEL_FORMAT_422P:
1134 *mimetype = MEDIA_FORMAT_422P;
1136 case MM_PIXEL_FORMAT_I420:
1137 *mimetype = MEDIA_FORMAT_I420;
1139 case MM_PIXEL_FORMAT_YV12:
1140 *mimetype = MEDIA_FORMAT_YV12;
1142 case MM_PIXEL_FORMAT_RGB565:
1143 *mimetype = MEDIA_FORMAT_RGB565;
1145 case MM_PIXEL_FORMAT_RGB888:
1146 *mimetype = MEDIA_FORMAT_RGB888;
1148 case MM_PIXEL_FORMAT_RGBA:
1149 *mimetype = MEDIA_FORMAT_RGBA;
1151 case MM_PIXEL_FORMAT_ARGB:
1152 *mimetype = MEDIA_FORMAT_ARGB;
1154 case MM_PIXEL_FORMAT_ENCODED_H264:
1155 /* TODO: How can we determine the profile for H.264 format? */
1156 *mimetype = MEDIA_FORMAT_H264_SP;
1158 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1159 *mimetype = MEDIA_FORMAT_MJPEG;
1161 case MM_PIXEL_FORMAT_ENCODED_VP8:
1162 *mimetype = MEDIA_FORMAT_VP8;
1164 case MM_PIXEL_FORMAT_ENCODED_VP9:
1165 *mimetype = MEDIA_FORMAT_VP9;
1168 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1169 return CAMERA_ERROR_NOT_SUPPORTED;
1173 return CAMERA_ERROR_NONE;
1177 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1178 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1181 int ret = CAMERA_ERROR_NONE;
1182 camera_media_packet_data *new_mp_data = NULL;
1184 if (!tfd || !mp_data) {
1185 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1186 return CAMERA_ERROR_INVALID_PARAMETER;
1189 new_mp_data = g_new0(camera_media_packet_data, 1);
1191 new_mp_data->ret_fd = ret_fd;
1192 new_mp_data->fd = tfd[0];
1193 new_mp_data->num_buffer_fd = num_buffer_fd;
1194 new_mp_data->bo = bo;
1196 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1200 new_mp_data->data_bo = data_bo;
1201 new_mp_data->data_fd = tfd[1];
1203 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1204 new_mp_data->data_bo, new_mp_data->data_fd);
1207 for (i = 0 ; i < num_buffer_fd ; i++) {
1208 new_mp_data->buffer_bo[i] = buffer_bo[i];
1209 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1211 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1212 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1215 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1216 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1218 new_mp_data->data_fd = CAMERA_FD_INIT;
1221 *mp_data = new_mp_data;
1223 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1228 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1232 if (!mp_data || !cb_info) {
1233 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1237 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1239 /* release imported bo and close fd */
1240 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1241 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1242 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1244 tbm_bo_unref(mp_data->buffer_bo[i]);
1246 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1247 close(mp_data->buffer_fd[i]);
1249 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1252 if (mp_data->data_bo) {
1253 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1254 mp_data->data_fd, mp_data->data_bo);
1256 tbm_bo_unref(mp_data->data_bo);
1258 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1259 close(mp_data->data_fd);
1261 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1264 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1266 tbm_bo_unref(mp_data->bo);
1268 if (CAMERA_IS_FD_VALID(mp_data->fd))
1271 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1274 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1280 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1283 int ret = CAMERA_ERROR_NONE;
1284 uint32_t tbm_format = 0;
1285 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1286 tbm_surface_info_s tsurf_info;
1288 if (!stream || !mp_data) {
1289 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1293 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1294 CAM_LOG_ERROR("No valid data");
1298 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1299 if (ret != CAMERA_ERROR_NONE)
1302 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1304 if (mp_data->num_buffer_fd > 0) {
1305 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1306 bos[i] = mp_data->buffer_bo[i];
1308 bos[0] = mp_data->data_bo;
1311 tsurf_info.width = stream->width;
1312 tsurf_info.height = stream->height;
1313 tsurf_info.format = tbm_format;
1314 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1315 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1317 switch (tbm_format) {
1318 case TBM_FORMAT_NV12: /* fall through */
1319 case TBM_FORMAT_NV21: /* fall through */
1320 case TBM_FORMAT_YUV420: /* fall through */
1321 case TBM_FORMAT_YVU420: /* fall through */
1322 case TBM_FORMAT_UYVY: /* fall through */
1323 case TBM_FORMAT_YUYV:
1324 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1325 tsurf_info.planes[i].stride = stream->stride[i];
1326 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1327 if (i != 0 && mp_data->num_buffer_fd <= 1)
1328 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1329 tsurf_info.size += tsurf_info.planes[i].size;
1331 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1332 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1336 case TBM_FORMAT_RGB565: /* fall through */
1337 case TBM_FORMAT_RGB888: /* fall through */
1338 case TBM_FORMAT_RGBA8888: /* fall through */
1339 case TBM_FORMAT_ARGB8888:
1340 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1341 tsurf_info.planes[0].offset = 0;
1342 tsurf_info.size = stream->data.rgb.length_data;
1345 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1350 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1351 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1355 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1357 int ret = CAMERA_ERROR_NONE;
1358 int pkt_fmt_width = 0;
1359 int pkt_fmt_height = 0;
1360 bool make_pkt_fmt = false;
1361 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1362 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1364 if (!cb_info || !stream) {
1365 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1366 return CAMERA_ERROR_INVALID_PARAMETER;
1369 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1370 if (ret != CAMERA_ERROR_NONE)
1373 /* check media packet format */
1374 if (cb_info->pkt_fmt) {
1375 media_format_get_video_info(cb_info->pkt_fmt,
1376 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1378 CAM_LOG_DEBUG("pkt_fmt %dx%d - stream %dx%d",
1379 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1381 if (pkt_fmt_mimetype != mimetype ||
1382 pkt_fmt_width != stream->width ||
1383 pkt_fmt_height != stream->height) {
1384 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1385 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1387 media_format_unref(cb_info->pkt_fmt);
1388 cb_info->pkt_fmt = NULL;
1389 make_pkt_fmt = true;
1392 make_pkt_fmt = true;
1395 /* create packet format */
1397 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1398 mimetype, stream->width, stream->height);
1400 ret = media_format_create(&cb_info->pkt_fmt);
1401 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1402 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1403 return CAMERA_ERROR_INVALID_OPERATION;
1406 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1407 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1408 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1409 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1410 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1411 return CAMERA_ERROR_INVALID_OPERATION;
1415 return CAMERA_ERROR_NONE;
1419 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1420 camera_media_packet_data *mp_data, media_packet_h *packet)
1422 media_packet_h pkt = NULL;
1423 tbm_surface_h tsurf = NULL;
1424 int ret = CAMERA_ERROR_NONE;
1426 if (!cb_info || !stream || !mp_data || !packet) {
1427 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1428 cb_info, stream, mp_data, packet);
1429 return CAMERA_ERROR_INVALID_PARAMETER;
1432 ret = __camera_update_media_packet_format(cb_info, stream);
1433 if (ret != CAMERA_ERROR_NONE)
1436 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1437 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1438 stream->data.encoded.data, stream->data.encoded.length_data,
1439 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1443 if (!stream->data.encoded.is_delta_frame)
1444 media_packet_set_flags(pkt, MEDIA_PACKET_SYNC_FRAME);
1446 if (stream->data.encoded.is_header_included) {
1447 media_packet_set_flags(pkt, MEDIA_PACKET_CODEC_CONFIG);
1448 CAM_LOG_INFO("Codec config in buffer");
1452 tsurf = __camera_get_tbm_surface(stream, mp_data);
1454 CAM_LOG_ERROR("get tbm surface failed");
1455 ret = CAMERA_ERROR_INVALID_OPERATION;
1456 goto _PACKET_CREATE_FAILED;
1459 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1460 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1461 (void *)cb_info, &pkt);
1464 if (ret != MEDIA_PACKET_ERROR_NONE) {
1465 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1466 goto _PACKET_CREATE_FAILED;
1469 ret = media_packet_set_extra(pkt, (void *)mp_data);
1470 if (ret != MEDIA_PACKET_ERROR_NONE) {
1471 CAM_LOG_ERROR("media_packet_set_extra failed");
1472 goto _PACKET_CREATE_FAILED;
1475 if (media_packet_set_pts(pkt, stream->timestamp_nsec) != MEDIA_PACKET_ERROR_NONE)
1476 CAM_LOG_WARNING("media_packet_set_pts failed");
1478 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1479 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1481 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1485 return CAMERA_ERROR_NONE;
1487 _PACKET_CREATE_FAILED:
1489 tbm_surface_destroy(tsurf);
1491 media_packet_unref(pkt);
1493 return CAMERA_ERROR_INVALID_OPERATION;
1496 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1499 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1500 camera_media_packet_data *mp_data = NULL;
1501 tbm_surface_h tsurf = NULL;
1503 if (!pkt || !cb_info) {
1504 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1508 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1509 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1510 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1514 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1516 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1517 pkt, mp_data, tsurf);
1520 tbm_surface_destroy(tsurf);
1522 g_mutex_lock(&cb_info->mp_data_mutex);
1523 __camera_release_media_packet_data(mp_data, cb_info);
1524 g_mutex_unlock(&cb_info->mp_data_mutex);
1527 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1532 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1533 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1537 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1539 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1541 if (cb_info->user_cb[event] == NULL) {
1542 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1543 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1544 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1545 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1546 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1547 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1551 /* return buffer message should be sent for some events.
1552 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1553 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1554 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1555 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1560 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1566 muse_camera_msg_get(previous, recv_msg);
1567 muse_camera_msg_get(current, recv_msg);
1568 muse_camera_msg_get(by_policy, recv_msg);
1570 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1571 previous, current, by_policy);
1573 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1574 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1577 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1581 muse_camera_msg_get(state, recv_msg);
1583 CAM_LOG_INFO("FOCUS state - %d", state);
1585 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1588 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1589 CAM_LOG_INFO("CAPTURE_COMPLETED");
1590 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1592 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1593 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1594 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1597 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1601 muse_camera_msg_get(percent, recv_msg);
1603 CAM_LOG_INFO("HDR progress - %d %%", percent);
1605 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1608 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1614 muse_camera_msg_get(policy, recv_msg);
1615 muse_camera_msg_get(previous, recv_msg);
1616 muse_camera_msg_get(current, recv_msg);
1618 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1620 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1621 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1624 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1629 muse_camera_msg_get(policy, recv_msg);
1630 muse_camera_msg_get(state, recv_msg);
1632 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1634 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1635 (camera_state_e)state, cb_info->user_data[event]);
1638 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1639 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1641 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1644 int current_state = 0;
1646 muse_camera_msg_get(error, recv_msg);
1647 muse_camera_msg_get(current_state, recv_msg);
1649 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1651 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1652 (camera_state_e)current_state, cb_info->user_data[event]);
1656 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1658 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1659 muse_camera_msg_get(param1, recv_msg);
1660 muse_camera_msg_get(param2, recv_msg);
1662 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1664 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1665 cb_info->user_cb[event] = NULL;
1666 cb_info->user_data[event] = NULL;
1667 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1670 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1672 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1674 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1676 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1678 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1680 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1682 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1684 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1686 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1688 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1690 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1692 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1694 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1697 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1699 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1700 muse_camera_msg_get(param1, recv_msg);
1702 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1704 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1705 cb_info->user_cb[event] = NULL;
1706 cb_info->user_data[event] = NULL;
1707 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1711 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1712 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1715 CAM_LOG_WARNING("unhandled event %d", event);
1719 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1722 static gboolean __camera_idle_event_callback(gpointer data)
1724 camera_cb_info_s *cb_info = NULL;
1725 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1727 if (cam_idle_event == NULL) {
1728 CAM_LOG_ERROR("cam_idle_event is NULL");
1733 g_mutex_lock(&g_cam_idle_event_lock);
1735 cb_info = cam_idle_event->cb_info;
1736 if (cb_info == NULL) {
1737 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1738 g_mutex_unlock(&g_cam_idle_event_lock);
1739 goto IDLE_EVENT_CALLBACK_DONE;
1742 /* remove event from list */
1743 if (cb_info->idle_event_list)
1744 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1746 g_mutex_unlock(&g_cam_idle_event_lock);
1749 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1751 IDLE_EVENT_CALLBACK_DONE:
1753 g_free(cam_idle_event);
1754 cam_idle_event = NULL;
1759 static gpointer __camera_msg_handler_func(gpointer data)
1763 camera_message_s *cam_msg = NULL;
1764 camera_idle_event_s *cam_idle_event = NULL;
1765 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1766 camera_cb_info_s *cb_info = NULL;
1767 GThread *thread = NULL;
1769 if (!handler_info || !handler_info->cb_info) {
1770 CAM_LOG_ERROR("NULL handler %p", handler_info);
1774 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1775 type = handler_info->type;
1776 thread = handler_info->thread;
1778 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1780 g_mutex_lock(&handler_info->mutex);
1782 while (g_atomic_int_get(&handler_info->running)) {
1783 if (g_queue_is_empty(handler_info->queue)) {
1784 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1785 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1786 CAM_LOG_VERBOSE("t[%d] signal received", type);
1788 if (g_atomic_int_get(&handler_info->running) == 0) {
1789 CAM_LOG_INFO("t:%d stop event thread", type);
1794 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1796 g_mutex_unlock(&handler_info->mutex);
1798 if (cam_msg == NULL) {
1799 CAM_LOG_ERROR("t:%d NULL message", type);
1800 g_mutex_lock(&handler_info->mutex);
1806 if (api < MUSE_CAMERA_API_MAX) {
1809 g_mutex_lock(&cb_info->api_mutex[api]);
1811 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1812 if (cb_info->api_waiting[api] > 0) {
1813 cb_info->api_ret[api] = ret;
1814 cb_info->api_activating[api] = TRUE;
1816 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1818 g_cond_broadcast(&cb_info->api_cond[api]);
1820 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1823 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1826 g_mutex_unlock(&cb_info->api_mutex[api]);
1827 } else if (api == MUSE_CAMERA_CB_EVENT) {
1828 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1829 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1830 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1833 switch (cam_msg->event_class) {
1834 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1835 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1837 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1838 cam_idle_event = g_new0(camera_idle_event_s, 1);
1839 if (cam_idle_event == NULL) {
1840 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1844 cam_idle_event->event = cam_msg->event;
1845 cam_idle_event->cb_info = cb_info;
1847 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1848 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1850 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1851 type, cam_msg->event, cam_idle_event);
1853 g_mutex_lock(&g_cam_idle_event_lock);
1854 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1855 g_mutex_unlock(&g_cam_idle_event_lock);
1857 g_idle_add_full(G_PRIORITY_DEFAULT,
1858 (GSourceFunc)__camera_idle_event_callback,
1859 (gpointer)cam_idle_event,
1863 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1867 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1872 g_mutex_lock(&handler_info->mutex);
1875 /* remove remained event */
1876 while (!g_queue_is_empty(handler_info->queue)) {
1877 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1879 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1880 __camera_release_tfd(cam_msg->tfd);
1883 CAM_LOG_WARNING("t:%d NULL message", type);
1887 g_mutex_unlock(&handler_info->mutex);
1889 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1895 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1897 camera_idle_event_s *cam_idle_event = NULL;
1900 if (cb_info == NULL) {
1901 CAM_LOG_ERROR("cb_info is NULL");
1905 g_mutex_lock(&g_cam_idle_event_lock);
1907 if (cb_info->idle_event_list == NULL) {
1908 CAM_LOG_INFO("No remained idle event");
1909 g_mutex_unlock(&g_cam_idle_event_lock);
1913 list = cb_info->idle_event_list;
1916 cam_idle_event = list->data;
1917 list = g_list_next(list);
1919 if (!cam_idle_event) {
1920 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1924 if (g_idle_remove_by_data(cam_idle_event)) {
1925 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1927 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1929 g_free(cam_idle_event);
1934 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1935 cam_idle_event, cam_idle_event->event);
1937 cam_idle_event->cb_info = NULL;
1939 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1942 g_list_free(cb_info->idle_event_list);
1943 cb_info->idle_event_list = NULL;
1945 g_mutex_unlock(&g_cam_idle_event_lock);
1949 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1951 camera_message_s *cam_msg = NULL;
1953 if (!cb_info || !msg) {
1954 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1958 cam_msg = g_new0(camera_message_s, 1);
1960 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1965 cam_msg->event = event;
1966 cam_msg->event_class = event_class;
1969 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1971 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1973 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1974 api, event, event_class);
1976 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1977 if (!cb_info->preview_cb_info.thread) {
1978 LOGI("The thread for preview cb is not created yet, create it now");
1979 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1980 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1981 CAM_LOG_ERROR("failed to create thread for preview cb");
1987 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1988 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1989 g_cond_signal(&cb_info->preview_cb_info.cond);
1990 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1991 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1992 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1993 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1994 g_cond_signal(&cb_info->capture_cb_info.cond);
1995 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1997 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1998 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1999 g_cond_signal(&cb_info->msg_handler_info.cond);
2000 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
2007 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
2009 int ret = CAMERA_ERROR_NONE;
2013 int event_class = -1;
2017 if (!cb_info || !msg) {
2018 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
2022 CAM_LOG_DEBUG("msg[%s]", msg);
2024 if (!muse_camera_msg_get(api, msg)) {
2025 CAM_LOG_ERROR("failed to get camera api");
2029 if (api == MUSE_CAMERA_CB_EVENT) {
2030 if (!muse_camera_msg_get(event, msg) ||
2031 !muse_camera_msg_get(event_class, msg)) {
2032 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
2036 if (!muse_camera_msg_get(api_class, msg)) {
2037 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
2042 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
2043 if (api >= MUSE_CAMERA_API_MAX) {
2044 CAM_LOG_ERROR("invalid api %d", api);
2048 if (!muse_camera_msg_get(ret, msg)) {
2049 CAM_LOG_ERROR("failed to get camera ret");
2053 g_mutex_lock(&cb_info->api_mutex[api]);
2056 case MUSE_CAMERA_API_CREATE:
2057 if (ret != CAMERA_ERROR_NONE) {
2058 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2059 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
2062 case MUSE_CAMERA_API_DESTROY:
2063 if (ret == CAMERA_ERROR_NONE) {
2064 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2065 CAM_LOG_INFO("camera destroy done. close client cb handler");
2069 muse_camera_msg_get(get_type, msg);
2070 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
2071 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
2072 muse_camera_msg_get(get_index, msg);
2075 case MUSE_CAMERA_GET_TYPE_INT:
2076 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
2078 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
2079 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
2080 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
2082 case MUSE_CAMERA_GET_TYPE_ARRAY:
2084 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
2085 muse_core_msg_deserialize("get_value",
2086 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2087 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
2088 cb_info->get_display_roi_area[0],
2089 cb_info->get_display_roi_area[1],
2090 cb_info->get_display_roi_area[2],
2091 cb_info->get_display_roi_area[3]);
2093 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
2094 muse_core_msg_deserialize("get_value",
2095 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2096 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2097 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2099 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2100 muse_core_msg_deserialize("get_value",
2101 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2102 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2103 cb_info->get_extra_preview_stream_format[0],
2104 cb_info->get_extra_preview_stream_format[1],
2105 cb_info->get_extra_preview_stream_format[2],
2106 cb_info->get_extra_preview_stream_format[3]);
2109 CAM_LOG_WARNING("unknown api[%d]", api);
2113 case MUSE_CAMERA_GET_TYPE_STRING:
2114 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2117 CAM_LOG_WARNING("unknown type %d", get_type);
2124 if (cb_info->api_waiting[api] > 0) {
2125 cb_info->api_ret[api] = ret;
2126 cb_info->api_activating[api] = TRUE;
2128 g_cond_broadcast(&cb_info->api_cond[api]);
2130 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2133 g_mutex_unlock(&cb_info->api_mutex[api]);
2134 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2135 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2137 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2142 static gpointer __camera_msg_recv_func(gpointer data)
2145 int recv_length = 0;
2146 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2147 char *recv_msg = NULL;
2148 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2151 CAM_LOG_ERROR("cb_info NULL");
2155 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2157 recv_msg = cb_info->recv_msg;
2159 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2160 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2161 tfd[i] = CAMERA_FD_INIT;
2163 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2164 if (recv_length <= 0) {
2165 cb_info->is_server_connected = FALSE;
2166 CAM_LOG_ERROR("receive msg failed - server disconnected");
2170 if (CAMERA_IS_FD_VALID(tfd[0]))
2171 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2173 recv_msg[recv_length] = '\0';
2175 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2177 __camera_process_msg(cb_info, recv_msg, tfd);
2180 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2183 if (!cb_info->is_server_connected) {
2184 char *error_msg = NULL;
2186 if (cb_info->bufmgr == NULL) {
2187 CAM_LOG_ERROR("No need to send error(handle is not created)");
2191 if (cb_info->fd < 0) {
2192 CAM_LOG_ERROR("fd is closed in client side");
2196 /* send error msg for server disconnection */
2197 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2198 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2199 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2203 CAM_LOG_ERROR("error_msg failed");
2207 __camera_add_msg_to_queue(cb_info,
2208 MUSE_CAMERA_CB_EVENT,
2209 MUSE_CAMERA_EVENT_TYPE_ERROR,
2210 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2214 muse_core_msg_free(error_msg);
2217 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2218 if (cb_info->api_waiting[i])
2219 g_cond_broadcast(&cb_info->api_cond[i]);
2222 CAM_LOG_ERROR("add error msg for service disconnection done");
2230 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2231 int type, const char *thread_name, camera_cb_info_s *cb_info)
2233 if (!handler_info || !thread_name || !cb_info) {
2234 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2235 type, handler_info, thread_name, cb_info);
2239 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2241 if (handler_info->thread) {
2242 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2246 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2248 handler_info->type = type;
2249 handler_info->queue = g_queue_new();
2250 if (handler_info->queue == NULL) {
2251 CAM_LOG_ERROR("t:%d queue failed", type);
2255 handler_info->cb_info = (void *)cb_info;
2256 g_atomic_int_set(&handler_info->running, 1);
2258 handler_info->thread = g_thread_try_new(thread_name,
2259 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2260 if (handler_info->thread == NULL) {
2261 CAM_LOG_ERROR("t:%d thread failed", type);
2263 g_queue_free(handler_info->queue);
2264 handler_info->queue = NULL;
2269 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2275 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2277 GThread *thread = NULL;
2279 if (!handler_info) {
2280 CAM_LOG_ERROR("NULL handler");
2284 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2286 if (!handler_info->thread) {
2287 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2291 thread = handler_info->thread;
2292 handler_info->thread = NULL;
2294 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2296 g_atomic_int_set(&handler_info->running, 0);
2297 g_cond_signal(&handler_info->cond);
2299 g_clear_pointer(&locker, g_mutex_locker_free);
2301 g_thread_join(thread);
2303 g_queue_free(handler_info->queue);
2304 handler_info->queue = NULL;
2306 CAM_LOG_INFO("t:%d done", handler_info->type);
2310 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2315 CAM_LOG_ERROR("NULL cb_info");
2319 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2320 g_mutex_init(&cb_info->api_mutex[i]);
2321 g_cond_init(&cb_info->api_cond[i]);
2324 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2325 g_mutex_init(&cb_info->user_cb_mutex[i]);
2327 g_mutex_init(&cb_info->fd_lock);
2328 g_mutex_init(&cb_info->mp_data_mutex);
2329 g_mutex_init(&cb_info->bridge_lock);
2331 g_mutex_init(&cb_info->msg_handler_info.mutex);
2332 g_mutex_init(&cb_info->preview_cb_info.mutex);
2333 g_mutex_init(&cb_info->capture_cb_info.mutex);
2334 g_cond_init(&cb_info->msg_handler_info.cond);
2335 g_cond_init(&cb_info->preview_cb_info.cond);
2336 g_cond_init(&cb_info->capture_cb_info.cond);
2338 CAM_LOG_INFO("done");
2342 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2347 CAM_LOG_ERROR("NULL cb_info");
2351 g_mutex_clear(&cb_info->msg_handler_info.mutex);
2352 g_mutex_clear(&cb_info->preview_cb_info.mutex);
2353 g_mutex_clear(&cb_info->capture_cb_info.mutex);
2354 g_cond_clear(&cb_info->msg_handler_info.cond);
2355 g_cond_clear(&cb_info->preview_cb_info.cond);
2356 g_cond_clear(&cb_info->capture_cb_info.cond);
2358 g_mutex_clear(&cb_info->fd_lock);
2359 g_mutex_clear(&cb_info->mp_data_mutex);
2360 g_mutex_clear(&cb_info->bridge_lock);
2362 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2363 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2365 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2366 g_mutex_clear(&cb_info->api_mutex[i]);
2367 g_cond_clear(&cb_info->api_cond[i]);
2370 CAM_LOG_INFO("done");
2374 static camera_preview_cb_monitoring_info_s *__camera_preview_cb_monitoring_info_create(int stream_id)
2376 camera_preview_cb_monitoring_info_s *new_info = g_new0(camera_preview_cb_monitoring_info_s, 1);
2378 new_info->stream_id = stream_id;
2379 new_info->total = g_new0(monitoring_info_sub_s, 1);
2380 new_info->interval = g_new0(monitoring_info_sub_s, 1);
2381 new_info->timer_calling = g_timer_new();
2382 new_info->timer_interval = g_timer_new();
2384 CAM_LOG_INFO("create preview cb monitoring info[%p]", new_info);
2390 static void __camera_preview_cb_monitoring_info_destroy(camera_preview_cb_monitoring_info_s *info)
2395 g_timer_destroy(info->timer_calling);
2396 g_timer_destroy(info->timer_interval);
2397 g_free(info->total);
2398 g_free(info->interval);
2400 CAM_LOG_INFO("destroy preview cb monitoring info[%p]", info);
2406 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2409 camera_cb_info_s *cb_info = NULL;
2411 g_return_val_if_fail(sockfd > 0, NULL);
2413 cb_info = g_new0(camera_cb_info_s, 1);
2415 CAM_LOG_ERROR("cb_info failed");
2419 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2421 __camera_mutex_cond_init(cb_info);
2423 /* message handler thread */
2424 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2425 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2426 CAM_LOG_ERROR("msg_handler_info failed");
2430 /* message handler thread for capture callback */
2431 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2432 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2433 CAM_LOG_ERROR("capture_cb_info failed");
2437 cb_info->fd = sockfd;
2439 /* message receive thread */
2440 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2441 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2442 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2443 if (cb_info->msg_recv_thread == NULL) {
2444 CAM_LOG_ERROR("message receive thread creation failed");
2449 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2450 cb_info->fds[i] = CAMERA_FD_INIT;
2452 cb_info->is_server_connected = TRUE;
2454 cb_info->monitoring_info_preview = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW);
2455 cb_info->monitoring_info_preview_mp = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW_MP);
2456 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2457 cb_info->monitoring_info_preview_ex[i] = __camera_preview_cb_monitoring_info_create(i);
2463 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2464 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2466 __camera_mutex_cond_clear(cb_info);
2477 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2482 CAM_LOG_ERROR("NULL cb_info");
2486 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2488 g_thread_join(cb_info->msg_recv_thread);
2489 cb_info->msg_recv_thread = NULL;
2491 CAM_LOG_INFO("msg_recv thread removed");
2493 /* destroy msg handler threads */
2494 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2495 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2496 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2498 __camera_mutex_cond_clear(cb_info);
2500 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2501 muse_client_close(cb_info->fd);
2502 cb_info->fd = CAMERA_FD_INIT;
2505 if (cb_info->bufmgr) {
2506 tbm_bufmgr_deinit(cb_info->bufmgr);
2507 cb_info->bufmgr = NULL;
2509 if (cb_info->pkt_fmt) {
2510 media_format_unref(cb_info->pkt_fmt);
2511 cb_info->pkt_fmt = NULL;
2514 if (cb_info->dp_interface) {
2515 mm_display_interface_deinit(cb_info->dp_interface);
2516 cb_info->dp_interface = NULL;
2519 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview);
2520 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_mp);
2521 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2522 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_ex[i]);
2528 int _camera_start_evas_rendering(camera_h camera)
2530 camera_cli_s *pc = (camera_cli_s *)camera;
2532 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2534 CAM_LOG_INFO("start");
2536 if (!pc->cb_info->is_evas_render) {
2537 CAM_LOG_ERROR("EVAS surface is not set");
2538 return CAMERA_ERROR_NONE;
2541 /* set evas render flag as RUN */
2542 pc->cb_info->run_evas_render = true;
2544 return CAMERA_ERROR_NONE;
2548 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2550 int ret = CAMERA_ERROR_NONE;
2551 camera_cli_s *pc = (camera_cli_s *)camera;
2553 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2555 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2557 if (!pc->cb_info->is_evas_render) {
2558 CAM_LOG_ERROR("EVAS surface is not set");
2559 return CAMERA_ERROR_NONE;
2562 /* set evas render flag as STOP and release buffers */
2563 pc->cb_info->run_evas_render = false;
2565 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2566 if (ret == MM_ERROR_NONE) {
2567 ret = CAMERA_ERROR_NONE;
2569 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2570 ret = CAMERA_ERROR_INVALID_OPERATION;
2577 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2579 int ret = CAMERA_ERROR_NONE;
2580 int sock_fd = CAMERA_FD_INIT;
2581 int module_index = -1;
2583 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2585 /* create muse connection */
2586 if (!key || !value) {
2587 CAM_LOG_ERROR("NULL pointer");
2588 return CAMERA_ERROR_INVALID_PARAMETER;
2591 sock_fd = muse_client_new();
2593 CAM_LOG_ERROR("muse_client_new failed");
2594 return CAMERA_ERROR_INVALID_OPERATION;
2597 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2598 CAM_LOG_ERROR("muse client get module index failed");
2599 ret = CAMERA_ERROR_INVALID_OPERATION;
2603 msg = muse_core_msg_new(api,
2604 MUSE_TYPE_INT, "module", module_index,
2605 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2608 CAM_LOG_ERROR("msg failed");
2609 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2613 ret = muse_core_msg_send(sock_fd, msg);
2615 muse_core_msg_free(msg);
2619 CAM_LOG_ERROR("send msg failed");
2620 ret = CAMERA_ERROR_INVALID_OPERATION;
2624 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2626 CAM_LOG_ERROR("recv msg failed %d", errno);
2627 ret = CAMERA_ERROR_INVALID_OPERATION;
2631 if (!muse_camera_msg_get(ret, recv_msg)) {
2632 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2633 ret = CAMERA_ERROR_INVALID_OPERATION;
2637 if (ret == CAMERA_ERROR_NONE)
2638 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2640 CAM_LOG_INFO("api %d - value %d", api, *value);
2643 if (CAMERA_IS_FD_VALID(sock_fd)) {
2644 muse_client_close(sock_fd);
2645 sock_fd = CAMERA_FD_INIT;
2652 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2654 int sock_fd = CAMERA_FD_INIT;
2655 char *send_msg = NULL;
2657 int ret = CAMERA_ERROR_NONE;
2658 camera_cli_s *pc = NULL;
2659 tbm_bufmgr bufmgr = NULL;
2661 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2662 int module_index = -1;
2663 int device_type = (int)device;
2665 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2667 sock_fd = muse_client_new();
2669 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2670 ret = CAMERA_ERROR_INVALID_OPERATION;
2674 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2675 CAM_LOG_ERROR("muse client get module index failed");
2676 ret = CAMERA_ERROR_INVALID_OPERATION;
2680 send_msg = muse_core_msg_new(api,
2681 MUSE_TYPE_INT, "module", module_index,
2682 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2683 MUSE_TYPE_INT, "is_network", (int)is_network,
2687 CAM_LOG_ERROR("NULL msg");
2688 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2692 send_ret = muse_core_msg_send(sock_fd, send_msg);
2694 muse_core_msg_free(send_msg);
2698 CAM_LOG_ERROR("send msg failed %d", errno);
2699 ret = CAMERA_ERROR_INVALID_OPERATION;
2703 pc = g_new0(camera_cli_s, 1);
2705 CAM_LOG_ERROR("camera_cli_s alloc failed");
2706 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2710 bufmgr = tbm_bufmgr_init(-1);
2711 if (bufmgr == NULL) {
2712 CAM_LOG_ERROR("get tbm bufmgr failed");
2713 ret = CAMERA_ERROR_INVALID_OPERATION;
2717 pc->cb_info = __camera_client_callback_new(sock_fd);
2718 if (pc->cb_info == NULL) {
2719 CAM_LOG_ERROR("cb_info alloc failed");
2720 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2724 sock_fd = CAMERA_FD_INIT;
2726 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2728 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2730 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2732 if (ret == CAMERA_ERROR_NONE) {
2733 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2734 int user_buffer_supported = 0;
2735 int log_level = CAMERA_LOG_LEVEL_INFO;
2736 intptr_t handle = 0;
2738 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2740 CAM_LOG_ERROR("Receiving Handle Failed!!");
2741 ret = CAMERA_ERROR_INVALID_OPERATION;
2745 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2746 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2747 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2749 pc->remote_handle = handle;
2750 pc->cb_info->bufmgr = bufmgr;
2751 pc->cb_info->preview_format = preview_format;
2752 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2753 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2754 pc->cb_info->is_network = is_network;
2755 g_camera_log_level = log_level;
2757 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2758 preview_format, user_buffer_supported, g_camera_log_level);
2761 CAM_LOG_ERROR("NULL out handle");
2762 ret= CAMERA_ERROR_INVALID_PARAMETER;
2766 *camera = (camera_h)pc;
2768 /* get display interface handle */
2769 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2770 CAM_LOG_WARNING("display interface init failed");
2779 tbm_bufmgr_deinit(bufmgr);
2783 if (CAMERA_IS_FD_VALID(sock_fd)) {
2784 muse_client_close(sock_fd);
2785 sock_fd = CAMERA_FD_INIT;
2790 int temp_fd = pc->cb_info->fd;
2792 /* pc->cb_info->fd should be closed,
2793 because g_thread_join for msg_recv_thread is not returned
2794 in __camera_client_callback_destroy. */
2795 if (CAMERA_IS_FD_VALID(temp_fd)) {
2796 pc->cb_info->fd = CAMERA_FD_INIT;
2797 muse_client_close(temp_fd);
2800 __camera_client_callback_destroy(pc->cb_info);
2807 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2814 int camera_create(camera_device_e device, camera_h *camera)
2816 return _camera_create_private(device, false, camera);
2820 int camera_change_device(camera_h camera, camera_device_e device)
2823 int ret = CAMERA_ERROR_NONE;
2824 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2825 camera_cli_s *pc = (camera_cli_s *)camera;
2826 camera_msg_param param;
2828 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2830 CAMERA_MSG_PARAM_SET(param, INT, device);
2832 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2834 if (ret == CAMERA_ERROR_NONE) {
2835 /* reset callback and user data */
2836 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2837 pc->cb_info->user_cb[i] = NULL;
2838 pc->cb_info->user_data[i] = NULL;
2846 int camera_destroy(camera_h camera)
2848 int ret = CAMERA_ERROR_NONE;
2849 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2850 camera_cli_s *pc = (camera_cli_s *)camera;
2852 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2854 CAM_LOG_INFO("Enter");
2856 if (pc->cb_info->is_server_connected)
2857 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2859 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2861 if (ret == CAMERA_ERROR_NONE) {
2862 __camera_deactivate_idle_event_all(pc->cb_info);
2863 __camera_client_callback_destroy(pc->cb_info);
2870 CAM_LOG_INFO("ret : 0x%x", ret);
2875 int camera_start_preview(camera_h camera)
2878 int ret = CAMERA_ERROR_NONE;
2880 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2881 camera_cli_s *pc = (camera_cli_s *)camera;
2882 camera_state_e current_state = CAMERA_STATE_NONE;
2884 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2886 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2887 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2889 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2890 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2891 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2892 pc->cb_info->dp_info.type);
2893 return CAMERA_ERROR_INVALID_OPERATION;
2896 ret = camera_get_state(camera, ¤t_state);
2897 if (ret != CAMERA_ERROR_NONE) {
2898 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2902 if (current_state == CAMERA_STATE_CREATED) {
2903 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview);
2904 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_mp);
2905 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2906 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_ex[i]);
2908 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2909 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2910 CAM_LOG_ERROR("preview_cb_info failed");
2911 return CAMERA_ERROR_INVALID_OPERATION;
2914 if (pc->cb_info->user_buffer_supported) {
2915 if (!__camera_allocate_preview_buffer(camera)) {
2916 ret = CAMERA_ERROR_INVALID_OPERATION;
2920 fds = pc->cb_info->fds;
2924 pc->cb_info->invoke_preview_cb = TRUE;
2926 _camera_msg_send(api, fds, pc->cb_info, &ret,
2927 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2928 CAMERA_CB_NO_TIMEOUT);
2930 CAMERA_CB_TIMEOUT_FOR_PREVIEW);
2932 if (ret != CAMERA_ERROR_NONE)
2935 if (pc->cb_info->is_evas_render) {
2936 ret = _camera_start_evas_rendering(camera);
2937 if (ret != CAMERA_ERROR_NONE) {
2938 CAM_LOG_ERROR("stop preview because of error");
2939 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2944 CAM_LOG_INFO("done");
2946 return CAMERA_ERROR_NONE;
2949 if (current_state == CAMERA_STATE_CREATED) {
2950 if (pc->cb_info->user_buffer_supported)
2951 __camera_release_preview_buffer(camera);
2953 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2956 CAM_LOG_ERROR("failed : 0x%x", ret);
2962 int camera_stop_preview(camera_h camera)
2964 int ret = CAMERA_ERROR_NONE;
2965 camera_cli_s *pc = (camera_cli_s *)camera;
2966 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2967 camera_state_e current_state = CAMERA_STATE_NONE;
2969 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2971 CAM_LOG_INFO("Enter");
2974 if (pc->cb_info->is_evas_render) {
2975 ret = camera_get_state(camera, ¤t_state);
2976 if (ret != CAMERA_ERROR_NONE) {
2977 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2981 if (current_state == CAMERA_STATE_PREVIEW) {
2982 ret = _camera_stop_evas_rendering(camera, false);
2983 if (ret != CAMERA_ERROR_NONE)
2989 pc->cb_info->invoke_preview_cb = FALSE;
2991 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2993 if (ret == CAMERA_ERROR_NONE) {
2994 if (pc->cb_info->user_buffer_supported)
2995 __camera_release_preview_buffer(camera);
2997 /* release remained message for preview callback */
2998 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2999 } else if (current_state == CAMERA_STATE_PREVIEW) {
3000 CAM_LOG_WARNING("restart evas rendering");
3001 _camera_start_evas_rendering(camera);
3004 CAM_LOG_INFO("ret : 0x%x", ret);
3010 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
3012 int ret = CAMERA_ERROR_NONE;
3013 camera_cli_s *pc = (camera_cli_s *)camera;
3014 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
3016 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3018 CAM_LOG_INFO("Enter");
3020 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3021 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3023 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3024 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3026 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3028 CAM_LOG_INFO("ret : 0x%x", ret);
3034 bool camera_is_supported_continuous_capture(camera_h camera)
3036 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
3040 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)
3042 int ret = CAMERA_ERROR_NONE;
3043 camera_cli_s *pc = (camera_cli_s *)camera;
3044 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
3045 camera_msg_param param;
3048 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3050 CAM_LOG_INFO("Enter");
3052 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3053 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3055 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3056 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3058 value = (count << 16) | interval;
3059 CAMERA_MSG_PARAM_SET(param, INT, value);
3061 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3063 CAM_LOG_INFO("ret : 0x%x", ret);
3069 int camera_stop_continuous_capture(camera_h camera)
3071 int ret = CAMERA_ERROR_NONE;
3072 camera_cli_s *pc = (camera_cli_s *)camera;
3073 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
3075 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3077 CAM_LOG_INFO("Enter");
3079 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3081 CAM_LOG_INFO("ret : 0x%x", ret);
3087 bool camera_is_supported_face_detection(camera_h camera)
3089 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
3093 bool camera_is_supported_zero_shutter_lag(camera_h camera)
3095 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
3099 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
3101 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
3105 bool camera_is_supported_extra_preview(camera_h camera)
3107 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
3111 int camera_get_device_count(camera_h camera, int *device_count)
3113 int ret = CAMERA_ERROR_NONE;
3114 camera_cli_s *pc = (camera_cli_s *)camera;
3115 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
3117 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3119 CAM_LOG_INFO("Enter");
3121 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3123 if (ret == CAMERA_ERROR_NONE)
3124 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3126 CAM_LOG_INFO("ret : 0x%x", ret);
3131 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3133 int ret = CAMERA_ERROR_NONE;
3134 camera_cli_s *pc = (camera_cli_s *)camera;
3135 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3137 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3139 CAM_LOG_INFO("Enter");
3141 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3143 if (ret == CAMERA_ERROR_NONE) {
3144 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3146 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3147 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3149 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3152 CAM_LOG_INFO("ret : 0x%x", ret);
3157 int camera_stop_face_detection(camera_h camera)
3159 int ret = CAMERA_ERROR_NONE;
3160 camera_cli_s *pc = (camera_cli_s *)camera;
3161 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3163 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3165 CAM_LOG_INFO("Enter");
3167 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3169 if (ret == CAMERA_ERROR_NONE) {
3170 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3172 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3173 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3175 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3178 CAM_LOG_INFO("ret : 0x%x", ret);
3183 int camera_get_state(camera_h camera, camera_state_e *state)
3185 int ret = CAMERA_ERROR_NONE;
3186 camera_cli_s *pc = (camera_cli_s *)camera;
3187 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3189 if (!pc || !pc->cb_info || !state) {
3190 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3191 return CAMERA_ERROR_INVALID_PARAMETER;
3194 CAM_LOG_INFO("Enter");
3196 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3198 if (ret == CAMERA_ERROR_NONE)
3199 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3201 CAM_LOG_INFO("ret : 0x%x", ret);
3206 int camera_start_focusing(camera_h camera, bool continuous)
3208 int ret = CAMERA_ERROR_NONE;
3209 camera_cli_s *pc = (camera_cli_s *)camera;
3210 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3211 camera_msg_param param;
3212 int is_continuous = (int)continuous;
3214 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3216 CAM_LOG_INFO("Enter");
3218 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3220 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3222 CAM_LOG_INFO("ret : 0x%x", ret);
3227 int camera_cancel_focusing(camera_h camera)
3229 int ret = CAMERA_ERROR_NONE;
3230 camera_cli_s *pc = (camera_cli_s *)camera;
3231 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3233 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3235 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3237 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3239 CAM_LOG_INFO("ret : 0x%x", ret);
3245 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3247 int mm_ret = MM_ERROR_NONE;
3248 int ret = CAMERA_ERROR_NONE;
3249 camera_cli_s *pc = (camera_cli_s *)camera;
3250 camera_cb_info_s *cb_info = NULL;
3251 camera_state_e current_state = CAMERA_STATE_NONE;
3252 camera_msg_param param;
3253 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3254 muse_camera_display_info_s *dp_info = NULL;
3256 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3258 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3259 CAM_LOG_ERROR("invalid type %d", type);
3260 return CAMERA_ERROR_INVALID_PARAMETER;
3263 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3264 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3265 return CAMERA_ERROR_INVALID_PARAMETER;
3268 cb_info = (camera_cb_info_s *)pc->cb_info;
3269 dp_info = &cb_info->dp_info;
3271 ret = camera_get_state(camera, ¤t_state);
3272 if (ret != CAMERA_ERROR_NONE) {
3273 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3277 if (current_state != CAMERA_STATE_CREATED) {
3278 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3279 return CAMERA_ERROR_INVALID_STATE;
3282 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3284 if (type != MM_DISPLAY_TYPE_NONE) {
3285 /* check display interface handle */
3286 if (!cb_info->dp_interface) {
3287 CAM_LOG_ERROR("display interface not supported");
3288 return CAMERA_ERROR_NOT_SUPPORTED;
3291 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3292 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3293 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3294 return CAMERA_ERROR_NOT_SUPPORTED;
3295 } else if (mm_ret != MM_ERROR_NONE) {
3296 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3297 return CAMERA_ERROR_INVALID_OPERATION;
3300 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3301 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3303 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3304 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3305 dp_info->window_rect.width, dp_info->window_rect.height);
3306 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3308 camera_flip_e flip = CAMERA_FLIP_NONE;
3309 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3310 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3317 camera_get_display_flip(camera, &flip);
3318 camera_get_display_mode(camera, &mode);
3319 camera_get_display_rotation(camera, &rotation);
3320 camera_is_display_visible(camera, &visible);
3322 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3323 flip, mode, rotation, visible);
3325 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3326 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3327 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3328 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3330 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3331 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3332 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3333 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3339 if (mm_ret != MM_ERROR_NONE) {
3340 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3341 return CAMERA_ERROR_INVALID_OPERATION;
3344 dp_info->type = type;
3346 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3348 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3350 if (ret == CAMERA_ERROR_NONE)
3351 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3357 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3359 CAM_LOG_INFO("type %d, display %p", type, display);
3360 return _camera_set_display(camera, (mm_display_type_e)type, display);
3364 int camera_set_preview_resolution(camera_h camera, int width, int height)
3366 int ret = CAMERA_ERROR_NONE;
3367 camera_state_e current_state = CAMERA_STATE_NONE;
3368 camera_cli_s *pc = (camera_cli_s *)camera;
3369 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3370 camera_msg_param param;
3373 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3375 if (pc->cb_info->is_evas_render) {
3376 ret = camera_get_state(camera, ¤t_state);
3377 if (ret != CAMERA_ERROR_NONE) {
3378 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3382 if (current_state == CAMERA_STATE_PREVIEW) {
3383 ret = _camera_stop_evas_rendering(camera, true);
3384 if (ret != CAMERA_ERROR_NONE)
3389 value = (width << 16) | height;
3390 CAMERA_MSG_PARAM_SET(param, INT, value);
3392 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3394 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3396 CAM_LOG_INFO("ret : 0x%x", ret);
3398 if (current_state == CAMERA_STATE_PREVIEW) {
3399 CAM_LOG_WARNING("restart evas rendering");
3400 _camera_start_evas_rendering(camera);
3407 int camera_set_capture_resolution(camera_h camera, int width, int height)
3409 int ret = CAMERA_ERROR_NONE;
3410 camera_cli_s *pc = (camera_cli_s *)camera;
3411 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3412 camera_msg_param param;
3415 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3417 CAM_LOG_INFO("Enter");
3419 value = (width << 16) | height;
3420 CAMERA_MSG_PARAM_SET(param, INT, value);
3422 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3424 CAM_LOG_INFO("ret : 0x%x", ret);
3430 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3432 int ret = CAMERA_ERROR_NONE;
3433 int set_format = (int)format;
3434 camera_cli_s *pc = (camera_cli_s *)camera;
3435 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3436 camera_msg_param param;
3438 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3440 CAM_LOG_INFO("Enter - format %d", set_format);
3442 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3444 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3446 CAM_LOG_INFO("ret : 0x%x", ret);
3452 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3454 int ret = CAMERA_ERROR_NONE;
3455 int set_format = (int)format;
3456 camera_msg_param param;
3457 camera_cli_s *pc = (camera_cli_s *)camera;
3458 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3460 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3462 CAM_LOG_INFO("Enter - format %d", set_format);
3464 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3466 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3468 if (ret == CAMERA_ERROR_NONE)
3469 pc->cb_info->preview_format = set_format;
3471 CAM_LOG_INFO("ret : 0x%x", ret);
3477 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3479 int ret = CAMERA_ERROR_NONE;
3480 camera_cli_s *pc = (camera_cli_s *)camera;
3481 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3483 if (!pc || !pc->cb_info || !width || !height) {
3484 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3485 return CAMERA_ERROR_INVALID_PARAMETER;
3488 CAM_LOG_INFO("Enter");
3490 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3492 if (ret == CAMERA_ERROR_NONE) {
3493 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3494 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3497 CAM_LOG_INFO("ret : 0x%x", ret);
3503 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3505 int ret = CAMERA_ERROR_NONE;
3506 int set_rotation = (int)rotation;
3507 camera_cli_s *pc = (camera_cli_s *)camera;
3508 camera_msg_param param;
3510 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3512 if (pc->cb_info->is_evas_render) {
3513 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3514 if (ret != MM_ERROR_NONE) {
3515 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3516 return CAMERA_ERROR_INVALID_OPERATION;
3520 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3522 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3528 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3530 int ret = CAMERA_ERROR_NONE;
3531 camera_cli_s *pc = (camera_cli_s *)camera;
3533 if (!pc || !pc->cb_info || !rotation) {
3534 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3535 return CAMERA_ERROR_INVALID_PARAMETER;
3538 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3540 if (ret == CAMERA_ERROR_NONE)
3541 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3547 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3549 int ret = CAMERA_ERROR_NONE;
3550 int set_flip = (int)flip;
3551 camera_cli_s *pc = (camera_cli_s *)camera;
3552 camera_msg_param param;
3554 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3556 if (pc->cb_info->is_evas_render) {
3557 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3558 if (ret != MM_ERROR_NONE) {
3559 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3560 return CAMERA_ERROR_INVALID_OPERATION;
3564 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3566 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3572 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3574 int ret = CAMERA_ERROR_NONE;
3575 camera_cli_s *pc = (camera_cli_s *)camera;
3577 if (!pc || !pc->cb_info || !flip) {
3578 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3579 return CAMERA_ERROR_INVALID_PARAMETER;
3582 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3584 if (ret == CAMERA_ERROR_NONE)
3585 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3591 int camera_set_display_visible(camera_h camera, bool visible)
3593 int ret = CAMERA_ERROR_NONE;
3594 int set_visible = (int)visible;
3595 camera_cli_s *pc = (camera_cli_s *)camera;
3596 camera_msg_param param;
3598 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3600 if (pc->cb_info->is_evas_render) {
3601 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3602 if (ret != MM_ERROR_NONE) {
3603 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3604 return CAMERA_ERROR_INVALID_OPERATION;
3608 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3610 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3616 int camera_is_display_visible(camera_h camera, bool *visible)
3618 int ret = CAMERA_ERROR_NONE;
3619 camera_cli_s *pc = (camera_cli_s *)camera;
3621 if (!pc || !pc->cb_info || !visible) {
3622 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3623 return CAMERA_ERROR_INVALID_PARAMETER;
3626 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3628 if (ret == CAMERA_ERROR_NONE)
3629 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3635 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3637 int ret = CAMERA_ERROR_NONE;
3638 int set_mode = (int)mode;
3639 camera_cli_s *pc = (camera_cli_s *)camera;
3640 camera_msg_param param;
3642 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3644 if (pc->cb_info->is_evas_render) {
3645 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3646 if (ret != MM_ERROR_NONE) {
3647 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3648 return CAMERA_ERROR_INVALID_OPERATION;
3652 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3654 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3660 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3662 int ret = CAMERA_ERROR_NONE;
3663 camera_cli_s *pc = (camera_cli_s *)camera;
3665 if (!pc || !pc->cb_info || !mode) {
3666 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3667 return CAMERA_ERROR_INVALID_PARAMETER;
3670 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3672 if (ret == CAMERA_ERROR_NONE)
3673 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3679 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3681 int ret = CAMERA_ERROR_NONE;
3682 int set_hint = (int)hint;
3683 camera_cli_s *pc = (camera_cli_s *)camera;
3684 camera_msg_param param;
3686 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3688 CAM_LOG_INFO("Enter - hint %d", set_hint);
3690 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3692 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3698 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3700 int ret = CAMERA_ERROR_NONE;
3701 camera_cli_s *pc = (camera_cli_s *)camera;
3702 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3704 if (!pc || !pc->cb_info || !hint) {
3705 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3706 return CAMERA_ERROR_INVALID_PARAMETER;
3709 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3711 if (ret == CAMERA_ERROR_NONE) {
3712 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3713 CAM_LOG_INFO("display reuse hint %d", *hint);
3720 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3722 int ret = CAMERA_ERROR_NONE;
3723 camera_cli_s *pc = (camera_cli_s *)camera;
3724 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3726 if (!pc || !pc->cb_info || !width || !height) {
3727 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3728 return CAMERA_ERROR_INVALID_PARAMETER;
3731 CAM_LOG_INFO("Enter");
3733 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3735 if (ret == CAMERA_ERROR_NONE) {
3736 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3737 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3740 CAM_LOG_INFO("ret : 0x%x", ret);
3746 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3748 int ret = CAMERA_ERROR_NONE;
3749 camera_cli_s *pc = (camera_cli_s *)camera;
3750 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3752 if (!pc || !pc->cb_info || !format) {
3753 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3754 return CAMERA_ERROR_INVALID_PARAMETER;
3757 CAM_LOG_INFO("Enter");
3759 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3761 if (ret == CAMERA_ERROR_NONE)
3762 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3764 CAM_LOG_INFO("ret : 0x%x", ret);
3770 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3772 int ret = CAMERA_ERROR_NONE;
3773 camera_cli_s *pc = (camera_cli_s *)camera;
3774 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3776 if (!pc || !pc->cb_info || !format) {
3777 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3778 return CAMERA_ERROR_INVALID_PARAMETER;
3781 CAM_LOG_INFO("Enter");
3783 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3785 if (ret == CAMERA_ERROR_NONE)
3786 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3788 CAM_LOG_INFO("ret : 0x%x", ret);
3794 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3796 int ret = CAMERA_ERROR_NONE;
3797 camera_cli_s *pc = (camera_cli_s *)camera;
3798 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3800 if (!pc || !pc->cb_info || !facing_direction) {
3801 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3802 return CAMERA_ERROR_INVALID_PARAMETER;
3805 CAM_LOG_INFO("Enter");
3807 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3809 if (ret == CAMERA_ERROR_NONE)
3810 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3812 CAM_LOG_INFO("ret : 0x%x", ret);
3818 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3820 int ret = CAMERA_ERROR_NONE;
3821 camera_cli_s *pc = (camera_cli_s *)camera;
3822 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3824 if (!pc || !pc->cb_info || !callback) {
3825 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3826 return CAMERA_ERROR_INVALID_PARAMETER;
3829 CAM_LOG_INFO("Enter");
3831 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3833 if (ret == CAMERA_ERROR_NONE) {
3834 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3836 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3837 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3839 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3842 CAM_LOG_INFO("ret : 0x%x", ret);
3848 int camera_unset_preview_cb(camera_h camera)
3850 int ret = CAMERA_ERROR_NONE;
3851 camera_cli_s *pc = (camera_cli_s *)camera;
3852 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3854 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3856 CAM_LOG_INFO("Enter");
3858 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3860 if (ret == CAMERA_ERROR_NONE) {
3861 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3863 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3864 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3866 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3869 CAM_LOG_INFO("ret : 0x%x", ret);
3875 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3877 int ret = CAMERA_ERROR_NONE;
3878 camera_cli_s *pc = (camera_cli_s *)camera;
3879 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3881 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3883 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3884 CAM_LOG_ERROR("NOT SUPPORTED");
3885 return CAMERA_ERROR_NOT_SUPPORTED;
3888 if (callback == NULL) {
3889 CAM_LOG_ERROR("NULL callback");
3890 return CAMERA_ERROR_INVALID_PARAMETER;
3893 CAM_LOG_INFO("Enter");
3895 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3897 if (ret == CAMERA_ERROR_NONE) {
3898 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3900 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3901 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3903 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3906 CAM_LOG_INFO("ret : 0x%x", ret);
3912 int camera_unset_media_packet_preview_cb(camera_h camera)
3914 int ret = CAMERA_ERROR_NONE;
3915 camera_cli_s *pc = (camera_cli_s *)camera;
3916 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3918 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3920 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3921 CAM_LOG_ERROR("NOT SUPPORTED");
3922 return CAMERA_ERROR_NOT_SUPPORTED;
3925 CAM_LOG_INFO("Enter");
3927 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3929 if (ret == CAMERA_ERROR_NONE) {
3930 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3932 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3933 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3935 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3938 CAM_LOG_INFO("ret : 0x%x", ret);
3944 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3946 int ret = CAMERA_ERROR_NONE;
3947 camera_cli_s *pc = (camera_cli_s *)camera;
3948 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3950 if (!pc || !pc->cb_info || !callback) {
3951 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3952 return CAMERA_ERROR_INVALID_PARAMETER;
3955 CAM_LOG_INFO("Enter");
3957 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3959 if (ret == CAMERA_ERROR_NONE) {
3960 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3962 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3963 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3965 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3968 CAM_LOG_INFO("ret : 0x%x", ret);
3974 int camera_unset_state_changed_cb(camera_h camera)
3976 int ret = CAMERA_ERROR_NONE;
3977 camera_cli_s *pc = (camera_cli_s *)camera;
3978 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3980 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3982 CAM_LOG_INFO("Enter");
3984 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3986 if (ret == CAMERA_ERROR_NONE) {
3987 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3989 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3990 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3992 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3995 CAM_LOG_INFO("ret : 0x%x", ret);
4001 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4003 int ret = CAMERA_ERROR_NONE;
4004 camera_cli_s *pc = (camera_cli_s *)camera;
4005 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4007 if (!pc || !pc->cb_info || !callback) {
4008 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4009 return CAMERA_ERROR_INVALID_PARAMETER;
4012 CAM_LOG_INFO("Enter");
4014 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4016 if (ret == CAMERA_ERROR_NONE) {
4017 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4019 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4020 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4022 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4025 CAM_LOG_INFO("ret : 0x%x", ret);
4031 int camera_unset_interrupted_cb(camera_h camera)
4033 int ret = CAMERA_ERROR_NONE;
4034 camera_cli_s *pc = (camera_cli_s *)camera;
4035 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4037 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4039 CAM_LOG_INFO("Enter");
4041 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4043 if (ret == CAMERA_ERROR_NONE) {
4044 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4046 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4047 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4049 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4052 CAM_LOG_INFO("ret : 0x%x", ret);
4058 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4060 int ret = CAMERA_ERROR_NONE;
4061 camera_cli_s *pc = (camera_cli_s *)camera;
4062 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4064 if (!pc || !pc->cb_info || !callback) {
4065 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4066 return CAMERA_ERROR_INVALID_PARAMETER;
4069 CAM_LOG_INFO("Enter");
4071 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4073 if (ret == CAMERA_ERROR_NONE) {
4074 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4076 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4077 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4079 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4082 CAM_LOG_INFO("ret : 0x%x", ret);
4088 int camera_unset_interrupt_started_cb(camera_h camera)
4090 int ret = CAMERA_ERROR_NONE;
4091 camera_cli_s *pc = (camera_cli_s *)camera;
4092 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4094 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4096 CAM_LOG_INFO("Enter");
4098 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4100 if (ret == CAMERA_ERROR_NONE) {
4101 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4103 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4104 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4106 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4109 CAM_LOG_INFO("ret : 0x%x", ret);
4115 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4117 int ret = CAMERA_ERROR_NONE;
4118 camera_cli_s *pc = (camera_cli_s *)camera;
4119 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4121 if (!pc || !pc->cb_info || !callback) {
4122 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4123 return CAMERA_ERROR_INVALID_PARAMETER;
4126 CAM_LOG_INFO("Enter");
4128 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4130 if (ret == CAMERA_ERROR_NONE) {
4131 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4133 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4134 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4136 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4139 CAM_LOG_INFO("ret : 0x%x", ret);
4145 int camera_unset_focus_changed_cb(camera_h camera)
4147 int ret = CAMERA_ERROR_NONE;
4148 camera_cli_s *pc = (camera_cli_s *)camera;
4149 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4151 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4153 CAM_LOG_INFO("Enter");
4155 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4157 if (ret == CAMERA_ERROR_NONE) {
4158 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4160 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4161 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4163 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4166 CAM_LOG_INFO("ret : 0x%x", ret);
4172 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4174 int ret = CAMERA_ERROR_NONE;
4175 camera_cli_s *pc = (camera_cli_s *)camera;
4176 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4178 if (!pc || !pc->cb_info || !callback) {
4179 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4180 return CAMERA_ERROR_INVALID_PARAMETER;
4183 CAM_LOG_INFO("Enter");
4185 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4187 if (ret == CAMERA_ERROR_NONE) {
4188 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4190 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4191 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4193 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4196 CAM_LOG_INFO("ret : 0x%x", ret);
4202 int camera_unset_error_cb(camera_h camera)
4204 int ret = CAMERA_ERROR_NONE;
4205 camera_cli_s *pc = (camera_cli_s *)camera;
4206 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4208 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4210 CAM_LOG_INFO("Enter");
4212 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4214 if (ret == CAMERA_ERROR_NONE) {
4215 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4217 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4218 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4220 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4223 CAM_LOG_INFO("ret : 0x%x", ret);
4229 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4231 int ret = CAMERA_ERROR_NONE;
4232 camera_cli_s *pc = (camera_cli_s *)camera;
4233 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4235 if (!pc || !pc->cb_info || !foreach_cb) {
4236 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4237 return CAMERA_ERROR_INVALID_PARAMETER;
4240 CAM_LOG_INFO("Enter");
4242 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4243 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4245 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4247 CAM_LOG_INFO("ret : 0x%x", ret);
4253 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4255 int ret = CAMERA_ERROR_NONE;
4256 camera_cli_s *pc = (camera_cli_s *)camera;
4257 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4259 if (!pc || !pc->cb_info || !foreach_cb) {
4260 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4261 return CAMERA_ERROR_INVALID_PARAMETER;
4264 CAM_LOG_INFO("Enter");
4266 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4267 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4269 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4271 CAM_LOG_INFO("ret : 0x%x", ret);
4277 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4279 int ret = CAMERA_ERROR_NONE;
4280 camera_cli_s *pc = (camera_cli_s *)camera;
4281 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4283 if (!pc || !pc->cb_info || !foreach_cb) {
4284 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4285 return CAMERA_ERROR_INVALID_PARAMETER;
4288 CAM_LOG_INFO("Enter");
4290 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4291 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4293 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4295 CAM_LOG_INFO("ret : 0x%x", ret);
4301 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4303 int ret = CAMERA_ERROR_NONE;
4304 camera_cli_s *pc = (camera_cli_s *)camera;
4305 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4307 if (!pc || !pc->cb_info || !foreach_cb) {
4308 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4309 return CAMERA_ERROR_INVALID_PARAMETER;
4312 CAM_LOG_INFO("Enter");
4314 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4315 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4317 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4319 CAM_LOG_INFO("ret : 0x%x", ret);
4325 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4327 int ret = CAMERA_ERROR_NONE;
4328 camera_cli_s *pc = (camera_cli_s *)camera;
4329 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4331 if (!pc || !pc->cb_info || !width || !height) {
4332 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4333 return CAMERA_ERROR_INVALID_PARAMETER;
4336 CAM_LOG_INFO("Enter");
4337 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4339 if (ret == CAMERA_ERROR_NONE) {
4340 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4341 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4344 CAM_LOG_INFO("ret : 0x%x", ret);
4350 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4352 int ret = CAMERA_ERROR_NONE;
4353 camera_cli_s *pc = (camera_cli_s *)camera;
4354 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4356 if (!pc || !pc->cb_info || !angle) {
4357 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4358 return CAMERA_ERROR_INVALID_PARAMETER;
4361 CAM_LOG_INFO("Enter");
4363 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4365 if (ret == CAMERA_ERROR_NONE)
4366 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4368 CAM_LOG_INFO("ret : 0x%x", ret);
4374 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4376 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4380 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4382 int ret = CAMERA_ERROR_NONE;
4383 camera_cli_s *pc = (camera_cli_s *)camera;
4384 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4386 if (!pc || !pc->cb_info || !mode) {
4387 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4388 return CAMERA_ERROR_INVALID_PARAMETER;
4391 CAM_LOG_INFO("Enter");
4393 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4395 if (ret == CAMERA_ERROR_NONE)
4396 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4398 CAM_LOG_INFO("ret : 0x%x", ret);
4404 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4406 int ret = CAMERA_ERROR_NONE;
4407 camera_cli_s *pc = (camera_cli_s *)camera;
4408 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4410 if (!pc || !pc->cb_info || !foreach_cb) {
4411 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4412 return CAMERA_ERROR_INVALID_PARAMETER;
4415 CAM_LOG_INFO("Enter");
4417 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4418 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4420 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4422 CAM_LOG_INFO("Finish, return :%x", ret);
4428 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4430 int ret = CAMERA_ERROR_NONE;
4431 camera_cli_s *pc = (camera_cli_s *)camera;
4432 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4433 camera_msg_param param;
4434 int set_fps = (int)fps;
4436 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4438 CAM_LOG_INFO("Enter");
4440 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4442 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4444 CAM_LOG_INFO("ret : 0x%x", ret);
4450 int camera_attr_set_image_quality(camera_h camera, int quality)
4452 int ret = CAMERA_ERROR_NONE;
4453 camera_cli_s *pc = (camera_cli_s *)camera;
4454 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4455 camera_msg_param param;
4457 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4459 CAM_LOG_INFO("Enter");
4461 CAMERA_MSG_PARAM_SET(param, INT, quality);
4463 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4465 CAM_LOG_INFO("ret : 0x%x", ret);
4471 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4473 int ret = CAMERA_ERROR_NONE;
4474 camera_cli_s *pc = (camera_cli_s *)camera;
4475 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4477 if (!pc || !pc->cb_info || !fps) {
4478 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4479 return CAMERA_ERROR_INVALID_PARAMETER;
4482 CAM_LOG_INFO("Enter");
4484 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4486 if (ret == CAMERA_ERROR_NONE)
4487 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4489 CAM_LOG_INFO("ret : 0x%x", ret);
4495 int camera_attr_get_image_quality(camera_h camera, int *quality)
4497 int ret = CAMERA_ERROR_NONE;
4498 camera_cli_s *pc = (camera_cli_s *)camera;
4499 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4501 if (!pc || !pc->cb_info || !quality) {
4502 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4503 return CAMERA_ERROR_INVALID_PARAMETER;
4506 CAM_LOG_INFO("Enter");
4508 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4510 if (ret == CAMERA_ERROR_NONE)
4511 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4513 CAM_LOG_INFO("ret : 0x%x", ret);
4519 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4521 int ret = CAMERA_ERROR_NONE;
4522 camera_cli_s *pc = (camera_cli_s *)camera;
4523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4525 if (!pc || !pc->cb_info || !bitrate) {
4526 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4527 return CAMERA_ERROR_INVALID_PARAMETER;
4530 CAM_LOG_INFO("Enter");
4532 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4534 if (ret == CAMERA_ERROR_NONE)
4535 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4537 CAM_LOG_INFO("ret : 0x%x", ret);
4543 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4545 int ret = CAMERA_ERROR_NONE;
4546 camera_cli_s *pc = (camera_cli_s *)camera;
4547 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4548 camera_msg_param param;
4549 int set_bitrate = bitrate;
4551 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4553 CAM_LOG_INFO("Enter");
4555 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4557 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4559 CAM_LOG_INFO("ret : 0x%x", ret);
4565 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4567 int ret = CAMERA_ERROR_NONE;
4568 camera_cli_s *pc = (camera_cli_s *)camera;
4569 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4571 if (!pc || !pc->cb_info || !interval) {
4572 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4573 return CAMERA_ERROR_INVALID_PARAMETER;
4576 CAM_LOG_INFO("Enter");
4578 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4580 if (ret == CAMERA_ERROR_NONE)
4581 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4583 CAM_LOG_INFO("ret : 0x%x", ret);
4589 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4591 int ret = CAMERA_ERROR_NONE;
4592 camera_cli_s *pc = (camera_cli_s *)camera;
4593 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4594 camera_msg_param param;
4595 int set_gop_interval = interval;
4597 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4599 CAM_LOG_INFO("Enter");
4601 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4603 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4605 CAM_LOG_INFO("ret : 0x%x", ret);
4611 int camera_attr_set_zoom(camera_h camera, int zoom)
4613 int ret = CAMERA_ERROR_NONE;
4614 camera_cli_s *pc = (camera_cli_s *)camera;
4615 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4616 camera_msg_param param;
4618 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4620 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4622 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4624 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4626 CAM_LOG_INFO("ret : 0x%x", ret);
4632 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4634 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4638 int camera_attr_set_af_area(camera_h camera, int x, int y)
4640 int ret = CAMERA_ERROR_NONE;
4641 camera_cli_s *pc = (camera_cli_s *)camera;
4642 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4643 camera_msg_param param;
4646 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4648 CAM_LOG_INFO("Enter - %d,%d", x, y);
4650 value = (x << 16) | y;
4651 CAMERA_MSG_PARAM_SET(param, INT, value);
4653 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4655 CAM_LOG_INFO("ret : 0x%x", ret);
4661 int camera_attr_clear_af_area(camera_h camera)
4663 int ret = CAMERA_ERROR_NONE;
4664 camera_cli_s *pc = (camera_cli_s *)camera;
4665 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4667 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4669 CAM_LOG_INFO("Enter");
4671 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4673 CAM_LOG_INFO("ret : 0x%x", ret);
4679 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4681 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4685 int camera_attr_set_exposure(camera_h camera, int value)
4687 int ret = CAMERA_ERROR_NONE;
4688 camera_cli_s *pc = (camera_cli_s *)camera;
4689 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4690 camera_msg_param param;
4692 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4694 CAM_LOG_INFO("Enter");
4696 CAMERA_MSG_PARAM_SET(param, INT, value);
4698 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4700 CAM_LOG_INFO("ret : 0x%x", ret);
4706 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4708 int ret = CAMERA_ERROR_NONE;
4709 camera_cli_s *pc = (camera_cli_s *)camera;
4710 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4711 camera_msg_param param;
4712 int set_iso = (int)iso;
4714 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4716 CAM_LOG_INFO("Enter");
4718 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4720 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4722 CAM_LOG_INFO("ret : 0x%x", ret);
4728 int camera_attr_set_gain(camera_h camera, int level)
4730 int ret = CAMERA_ERROR_NONE;
4731 camera_cli_s *pc = (camera_cli_s *)camera;
4732 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GAIN;
4733 camera_msg_param param;
4735 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4737 CAM_LOG_INFO("Enter");
4739 CAMERA_MSG_PARAM_SET(param, INT, level);
4741 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4743 CAM_LOG_INFO("ret : 0x%x", ret);
4749 int camera_attr_set_brightness(camera_h camera, int level)
4751 int ret = CAMERA_ERROR_NONE;
4752 camera_cli_s *pc = (camera_cli_s *)camera;
4753 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4754 camera_msg_param param;
4756 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4758 CAM_LOG_INFO("Enter");
4760 CAMERA_MSG_PARAM_SET(param, INT, level);
4762 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4764 CAM_LOG_INFO("ret : 0x%x", ret);
4770 int camera_attr_set_contrast(camera_h camera, int level)
4772 int ret = CAMERA_ERROR_NONE;
4773 camera_cli_s *pc = (camera_cli_s *)camera;
4774 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4775 camera_msg_param param;
4777 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4779 CAM_LOG_INFO("Enter");
4781 CAMERA_MSG_PARAM_SET(param, INT, level);
4783 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4785 CAM_LOG_INFO("ret : 0x%x", ret);
4791 int camera_attr_set_hue(camera_h camera, int level)
4793 int ret = CAMERA_ERROR_NONE;
4794 camera_cli_s *pc = (camera_cli_s *)camera;
4795 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4796 camera_msg_param param;
4798 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4800 CAM_LOG_INFO("Enter");
4802 CAMERA_MSG_PARAM_SET(param, INT, level);
4804 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4806 CAM_LOG_INFO("ret : 0x%x", ret);
4812 int camera_attr_set_saturation(camera_h camera, int level)
4814 int ret = CAMERA_ERROR_NONE;
4815 camera_cli_s *pc = (camera_cli_s *)camera;
4816 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SATURATION;
4817 camera_msg_param param;
4819 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4821 CAM_LOG_INFO("Enter");
4823 CAMERA_MSG_PARAM_SET(param, INT, level);
4825 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4827 CAM_LOG_INFO("ret : 0x%x", ret);
4833 int camera_attr_set_sharpness(camera_h camera, int level)
4835 int ret = CAMERA_ERROR_NONE;
4836 camera_cli_s *pc = (camera_cli_s *)camera;
4837 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SHARPNESS;
4838 camera_msg_param param;
4840 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4842 CAM_LOG_INFO("Enter");
4844 CAMERA_MSG_PARAM_SET(param, INT, level);
4846 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4848 CAM_LOG_INFO("ret : 0x%x", ret);
4854 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4856 int ret = CAMERA_ERROR_NONE;
4857 camera_cli_s *pc = (camera_cli_s *)camera;
4858 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4859 camera_msg_param param;
4860 int set_whitebalance = (int)wb;
4862 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4864 CAM_LOG_INFO("Enter");
4866 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4868 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4870 CAM_LOG_INFO("ret : 0x%x", ret);
4876 int camera_attr_set_whitebalance_temperature(camera_h camera, int temperature)
4878 int ret = CAMERA_ERROR_NONE;
4879 camera_cli_s *pc = (camera_cli_s *)camera;
4880 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE_TEMPERATURE;
4881 camera_msg_param param;
4883 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4885 CAM_LOG_INFO("Enter");
4887 CAMERA_MSG_PARAM_SET(param, INT, temperature);
4889 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4891 CAM_LOG_INFO("ret : 0x%x", ret);
4897 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4899 int ret = CAMERA_ERROR_NONE;
4900 camera_cli_s *pc = (camera_cli_s *)camera;
4901 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4902 camera_msg_param param;
4903 int set_effect = (int)effect;
4905 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4907 CAM_LOG_INFO("Enter");
4909 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4911 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4913 CAM_LOG_INFO("ret : 0x%x", ret);
4919 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4921 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4925 int camera_attr_enable_tag(camera_h camera, bool enable)
4927 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4931 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4933 int ret = CAMERA_ERROR_NONE;
4934 camera_cli_s *pc = (camera_cli_s *)camera;
4935 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4936 camera_msg_param param;
4938 if (!pc || !pc->cb_info || !description) {
4939 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4940 return CAMERA_ERROR_INVALID_PARAMETER;
4943 CAM_LOG_INFO("Enter");
4945 CAMERA_MSG_PARAM_SET(param, STRING, description);
4947 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4949 CAM_LOG_INFO("ret : 0x%x", ret);
4955 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4957 int ret = CAMERA_ERROR_NONE;
4958 camera_cli_s *pc = (camera_cli_s *)camera;
4959 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4960 camera_msg_param param;
4961 int set_orientation = (int)orientation;
4963 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4965 CAM_LOG_INFO("Enter");
4967 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4969 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4971 CAM_LOG_INFO("ret : 0x%x", ret);
4977 int camera_attr_set_tag_software(camera_h camera, const char *software)
4979 int ret = CAMERA_ERROR_NONE;
4980 camera_cli_s *pc = (camera_cli_s *)camera;
4981 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4982 camera_msg_param param;
4984 if (!pc || !pc->cb_info || !software) {
4985 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4986 return CAMERA_ERROR_INVALID_PARAMETER;
4989 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4991 CAMERA_MSG_PARAM_SET(param, STRING, software);
4993 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4995 CAM_LOG_INFO("ret : 0x%x", ret);
5001 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
5003 int ret = CAMERA_ERROR_NONE;
5004 camera_cli_s *pc = (camera_cli_s *)camera;
5005 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
5006 double set_geotag[3] = {latitude, longitude, altitude};
5010 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5012 CAM_LOG_INFO("Enter");
5014 length = sizeof(set_geotag) / sizeof(int) + \
5015 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5017 msg = muse_core_msg_new(api,
5018 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5021 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
5027 int camera_attr_remove_geotag(camera_h camera)
5029 int ret = CAMERA_ERROR_NONE;
5030 camera_cli_s *pc = (camera_cli_s *)camera;
5031 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5033 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5035 CAM_LOG_INFO("Enter");
5037 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5039 CAM_LOG_INFO("ret : 0x%x", ret);
5045 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5047 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
5051 int camera_attr_get_zoom(camera_h camera, int *zoom)
5053 int ret = CAMERA_ERROR_NONE;
5054 camera_cli_s *pc = (camera_cli_s *)camera;
5055 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5057 if (!pc || !pc->cb_info || !zoom) {
5058 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
5059 return CAMERA_ERROR_INVALID_PARAMETER;
5062 CAM_LOG_INFO("Enter");
5064 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5066 if (ret == CAMERA_ERROR_NONE)
5067 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5069 CAM_LOG_INFO("ret : 0x%x", ret);
5075 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5077 int ret = CAMERA_ERROR_NONE;
5078 camera_cli_s *pc = (camera_cli_s *)camera;
5079 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5081 if (!pc || !pc->cb_info || !min || !max) {
5082 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5083 return CAMERA_ERROR_INVALID_PARAMETER;
5086 CAM_LOG_INFO("Enter");
5088 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5090 if (ret == CAMERA_ERROR_NONE) {
5091 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5092 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5095 CAM_LOG_INFO("ret : 0x%x", ret);
5101 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5103 int ret = CAMERA_ERROR_NONE;
5104 camera_cli_s *pc = (camera_cli_s *)camera;
5105 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5107 if (!pc || !pc->cb_info || !mode) {
5108 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5109 return CAMERA_ERROR_INVALID_PARAMETER;
5112 CAM_LOG_INFO("Enter");
5114 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5116 if (ret == CAMERA_ERROR_NONE)
5117 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5119 CAM_LOG_INFO("ret : 0x%x", ret);
5125 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5127 int ret = CAMERA_ERROR_NONE;
5128 camera_cli_s *pc = (camera_cli_s *)camera;
5129 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5131 if (!pc || !pc->cb_info || !mode) {
5132 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5133 return CAMERA_ERROR_INVALID_PARAMETER;
5136 CAM_LOG_INFO("Enter");
5138 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5140 if (ret == CAMERA_ERROR_NONE)
5141 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5143 CAM_LOG_INFO("ret : 0x%x", ret);
5149 int camera_attr_get_exposure(camera_h camera, int *value)
5151 int ret = CAMERA_ERROR_NONE;
5152 camera_cli_s *pc = (camera_cli_s *)camera;
5153 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5155 if (!pc || !pc->cb_info || !value) {
5156 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5157 return CAMERA_ERROR_INVALID_PARAMETER;
5160 CAM_LOG_INFO("Enter");
5162 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5164 if (ret == CAMERA_ERROR_NONE)
5165 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5167 CAM_LOG_INFO("ret : 0x%x", ret);
5173 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5175 int ret = CAMERA_ERROR_NONE;
5176 camera_cli_s *pc = (camera_cli_s *)camera;
5177 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5179 if (!pc || !pc->cb_info || !min || !max) {
5180 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5181 return CAMERA_ERROR_INVALID_PARAMETER;
5184 CAM_LOG_INFO("Enter");
5186 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5188 if (ret == CAMERA_ERROR_NONE) {
5189 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5190 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5193 CAM_LOG_INFO("ret : 0x%x", ret);
5199 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5201 int ret = CAMERA_ERROR_NONE;
5202 camera_cli_s *pc = (camera_cli_s *)camera;
5203 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5205 if (!pc || !pc->cb_info || !iso) {
5206 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5207 return CAMERA_ERROR_INVALID_PARAMETER;
5210 CAM_LOG_INFO("Enter");
5212 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5214 if (ret == CAMERA_ERROR_NONE)
5215 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5217 CAM_LOG_INFO("ret : 0x%x", ret);
5223 int camera_attr_get_gain(camera_h camera, int *level)
5225 int ret = CAMERA_ERROR_NONE;
5226 camera_cli_s *pc = (camera_cli_s *)camera;
5227 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN;
5229 if (!pc || !pc->cb_info || !level) {
5230 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5231 return CAMERA_ERROR_INVALID_PARAMETER;
5234 CAM_LOG_INFO("Enter");
5236 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5238 if (ret == CAMERA_ERROR_NONE)
5239 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_GAIN];
5241 CAM_LOG_INFO("ret : 0x%x", ret);
5247 int camera_attr_get_gain_range(camera_h camera, int *min, int *max)
5249 int ret = CAMERA_ERROR_NONE;
5250 camera_cli_s *pc = (camera_cli_s *)camera;
5251 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN_RANGE;
5253 if (!pc || !pc->cb_info || !min || !max) {
5254 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5255 return CAMERA_ERROR_INVALID_PARAMETER;
5258 CAM_LOG_INFO("Enter");
5260 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5262 if (ret == CAMERA_ERROR_NONE) {
5263 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_GAIN_RANGE][0];
5264 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_GAIN_RANGE][1];
5267 CAM_LOG_INFO("ret : 0x%x", ret);
5273 int camera_attr_get_gain_step(camera_h camera, int *step)
5275 int ret = CAMERA_ERROR_NONE;
5276 camera_cli_s *pc = (camera_cli_s *)camera;
5277 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN_STEP;
5279 if (!pc || !pc->cb_info || !step) {
5280 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5281 return CAMERA_ERROR_INVALID_PARAMETER;
5284 CAM_LOG_INFO("Enter");
5286 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5288 if (ret == CAMERA_ERROR_NONE)
5289 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_GAIN_STEP];
5291 CAM_LOG_INFO("ret : 0x%x", ret);
5297 int camera_attr_get_brightness(camera_h camera, int *level)
5299 int ret = CAMERA_ERROR_NONE;
5300 camera_cli_s *pc = (camera_cli_s *)camera;
5301 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5303 if (!pc || !pc->cb_info || !level) {
5304 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5305 return CAMERA_ERROR_INVALID_PARAMETER;
5308 CAM_LOG_INFO("Enter");
5310 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5312 if (ret == CAMERA_ERROR_NONE)
5313 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5315 CAM_LOG_INFO("ret : 0x%x", ret);
5321 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5323 int ret = CAMERA_ERROR_NONE;
5324 camera_cli_s *pc = (camera_cli_s *)camera;
5325 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5327 if (!pc || !pc->cb_info || !min || !max) {
5328 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5329 return CAMERA_ERROR_INVALID_PARAMETER;
5332 CAM_LOG_INFO("Enter");
5334 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5336 if (ret == CAMERA_ERROR_NONE) {
5337 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5338 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5341 CAM_LOG_INFO("ret : 0x%x", ret);
5347 int camera_attr_get_contrast(camera_h camera, int *level)
5349 int ret = CAMERA_ERROR_NONE;
5350 camera_cli_s *pc = (camera_cli_s *)camera;
5351 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5353 if (!pc || !pc->cb_info || !level) {
5354 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5355 return CAMERA_ERROR_INVALID_PARAMETER;
5358 CAM_LOG_INFO("Enter");
5360 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5362 if (ret == CAMERA_ERROR_NONE)
5363 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5365 CAM_LOG_INFO("ret : 0x%x", ret);
5371 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5373 int ret = CAMERA_ERROR_NONE;
5374 camera_cli_s *pc = (camera_cli_s *)camera;
5375 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5377 if (!pc || !pc->cb_info || !min || !max) {
5378 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5379 return CAMERA_ERROR_INVALID_PARAMETER;
5382 CAM_LOG_INFO("Enter");
5384 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5386 if (ret == CAMERA_ERROR_NONE) {
5387 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5388 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5389 CAM_LOG_INFO("min %d, max %d", *min, *max);
5392 CAM_LOG_INFO("ret : 0x%x", ret);
5398 int camera_attr_get_hue(camera_h camera, int *level)
5400 int ret = CAMERA_ERROR_NONE;
5401 camera_cli_s *pc = (camera_cli_s *)camera;
5402 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5404 if (!pc || !pc->cb_info || !level) {
5405 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5406 return CAMERA_ERROR_INVALID_PARAMETER;
5409 CAM_LOG_INFO("Enter");
5411 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5413 if (ret == CAMERA_ERROR_NONE)
5414 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5416 CAM_LOG_INFO("ret : 0x%x", ret);
5422 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5424 int ret = CAMERA_ERROR_NONE;
5425 camera_cli_s *pc = (camera_cli_s *)camera;
5426 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5428 if (!pc || !pc->cb_info || !min || !max) {
5429 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5430 return CAMERA_ERROR_INVALID_PARAMETER;
5433 CAM_LOG_INFO("Enter");
5435 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5437 if (ret == CAMERA_ERROR_NONE) {
5438 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5439 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5440 CAM_LOG_INFO("min %d, max %d", *min, *max);
5443 CAM_LOG_INFO("ret : 0x%x", ret);
5449 int camera_attr_get_saturation(camera_h camera, int *level)
5451 int ret = CAMERA_ERROR_NONE;
5452 camera_cli_s *pc = (camera_cli_s *)camera;
5453 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SATURATION;
5455 if (!pc || !pc->cb_info || !level) {
5456 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5457 return CAMERA_ERROR_INVALID_PARAMETER;
5460 CAM_LOG_INFO("Enter");
5462 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5464 if (ret == CAMERA_ERROR_NONE)
5465 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SATURATION];
5467 CAM_LOG_INFO("ret : 0x%x", ret);
5473 int camera_attr_get_saturation_range(camera_h camera, int *min, int *max)
5475 int ret = CAMERA_ERROR_NONE;
5476 camera_cli_s *pc = (camera_cli_s *)camera;
5477 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SATURATION_RANGE;
5479 if (!pc || !pc->cb_info || !min || !max) {
5480 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5481 return CAMERA_ERROR_INVALID_PARAMETER;
5484 CAM_LOG_INFO("Enter");
5486 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5488 if (ret == CAMERA_ERROR_NONE) {
5489 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SATURATION_RANGE][0];
5490 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SATURATION_RANGE][1];
5491 CAM_LOG_INFO("min %d, max %d", *min, *max);
5494 CAM_LOG_INFO("ret : 0x%x", ret);
5500 int camera_attr_get_sharpness(camera_h camera, int *level)
5502 int ret = CAMERA_ERROR_NONE;
5503 camera_cli_s *pc = (camera_cli_s *)camera;
5504 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SHARPNESS;
5506 if (!pc || !pc->cb_info || !level) {
5507 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5508 return CAMERA_ERROR_INVALID_PARAMETER;
5511 CAM_LOG_INFO("Enter");
5513 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5515 if (ret == CAMERA_ERROR_NONE)
5516 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SHARPNESS];
5518 CAM_LOG_INFO("ret : 0x%x", ret);
5524 int camera_attr_get_sharpness_range(camera_h camera, int *min, int *max)
5526 int ret = CAMERA_ERROR_NONE;
5527 camera_cli_s *pc = (camera_cli_s *)camera;
5528 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SHARPNESS_RANGE;
5530 if (!pc || !pc->cb_info || !min || !max) {
5531 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5532 return CAMERA_ERROR_INVALID_PARAMETER;
5535 CAM_LOG_INFO("Enter");
5537 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5539 if (ret == CAMERA_ERROR_NONE) {
5540 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SHARPNESS_RANGE][0];
5541 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SHARPNESS_RANGE][1];
5542 CAM_LOG_INFO("min %d, max %d", *min, *max);
5545 CAM_LOG_INFO("ret : 0x%x", ret);
5551 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5553 int ret = CAMERA_ERROR_NONE;
5554 camera_cli_s *pc = (camera_cli_s *)camera;
5555 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5557 if (!pc || !pc->cb_info || !wb) {
5558 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5559 return CAMERA_ERROR_INVALID_PARAMETER;
5562 CAM_LOG_INFO("Enter");
5564 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5566 if (ret == CAMERA_ERROR_NONE)
5567 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5569 CAM_LOG_INFO("ret : 0x%x", ret);
5575 int camera_attr_get_whitebalance_temperature(camera_h camera, int *temperature)
5577 int ret = CAMERA_ERROR_NONE;
5578 camera_cli_s *pc = (camera_cli_s *)camera;
5579 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE;
5581 if (!pc || !pc->cb_info || !temperature) {
5582 CAM_LOG_ERROR("NULL pointer %p %p", pc, temperature);
5583 return CAMERA_ERROR_INVALID_PARAMETER;
5586 CAM_LOG_INFO("Enter");
5588 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5590 if (ret == CAMERA_ERROR_NONE)
5591 *temperature = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE];
5593 CAM_LOG_INFO("ret : 0x%x", ret);
5599 int camera_attr_get_whitebalance_temperature_range(camera_h camera, int *min, int *max)
5601 int ret = CAMERA_ERROR_NONE;
5602 camera_cli_s *pc = (camera_cli_s *)camera;
5603 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_RANGE;
5605 if (!pc || !pc->cb_info || !min || !max) {
5606 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5607 return CAMERA_ERROR_INVALID_PARAMETER;
5610 CAM_LOG_INFO("Enter");
5612 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5614 if (ret == CAMERA_ERROR_NONE) {
5615 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_WHITE_BALANCE_TEMPERATURE_RANGE][0];
5616 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_WHITE_BALANCE_TEMPERATURE_RANGE][1];
5619 CAM_LOG_INFO("ret : 0x%x", ret);
5625 int camera_attr_get_whitebalance_temperature_step(camera_h camera, int *step)
5627 int ret = CAMERA_ERROR_NONE;
5628 camera_cli_s *pc = (camera_cli_s *)camera;
5629 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_STEP;
5631 if (!pc || !pc->cb_info || !step) {
5632 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5633 return CAMERA_ERROR_INVALID_PARAMETER;
5636 CAM_LOG_INFO("Enter");
5638 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5640 if (ret == CAMERA_ERROR_NONE)
5641 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE_STEP];
5643 CAM_LOG_INFO("ret : 0x%x", ret);
5649 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5651 int ret = CAMERA_ERROR_NONE;
5652 camera_cli_s *pc = (camera_cli_s *)camera;
5653 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5655 if (!pc || !pc->cb_info || !effect) {
5656 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5657 return CAMERA_ERROR_INVALID_PARAMETER;
5660 CAM_LOG_INFO("Enter");
5662 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5664 if (ret == CAMERA_ERROR_NONE)
5665 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5667 CAM_LOG_INFO("ret : 0x%x", ret);
5673 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5675 int ret = CAMERA_ERROR_NONE;
5676 camera_cli_s *pc = (camera_cli_s *)camera;
5677 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5679 if (!pc || !pc->cb_info || !mode) {
5680 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5681 return CAMERA_ERROR_INVALID_PARAMETER;
5684 CAM_LOG_INFO("Enter");
5686 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5688 if (ret == CAMERA_ERROR_NONE)
5689 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5691 CAM_LOG_INFO("ret : 0x%x", ret);
5697 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5699 int ret = CAMERA_ERROR_NONE;
5700 camera_cli_s *pc = (camera_cli_s *)camera;
5701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5703 if (!pc || !pc->cb_info || !enable) {
5704 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5705 return CAMERA_ERROR_INVALID_PARAMETER;
5708 CAM_LOG_INFO("Enter");
5710 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5712 if (ret == CAMERA_ERROR_NONE)
5713 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5715 CAM_LOG_INFO("ret : 0x%x", ret);
5721 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5723 int ret = CAMERA_ERROR_NONE;
5724 camera_cli_s *pc = (camera_cli_s *)camera;
5725 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5727 if (!pc || !pc->cb_info || !description) {
5728 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5729 return CAMERA_ERROR_INVALID_PARAMETER;
5732 CAM_LOG_INFO("Enter");
5734 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5736 if (ret == CAMERA_ERROR_NONE)
5737 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5739 CAM_LOG_INFO("ret : 0x%x", ret);
5745 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5747 int ret = CAMERA_ERROR_NONE;
5748 camera_cli_s *pc = (camera_cli_s *)camera;
5749 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5751 if (!pc || !pc->cb_info || !orientation) {
5752 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5753 return CAMERA_ERROR_INVALID_PARAMETER;
5756 CAM_LOG_INFO("Enter");
5758 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5760 if (ret == CAMERA_ERROR_NONE)
5761 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5763 CAM_LOG_INFO("ret : 0x%x", ret);
5769 int camera_attr_get_tag_software(camera_h camera, char **software)
5771 int ret = CAMERA_ERROR_NONE;
5772 camera_cli_s *pc = (camera_cli_s *)camera;
5773 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5775 if (!pc || !pc->cb_info || !software) {
5776 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5777 return CAMERA_ERROR_INVALID_PARAMETER;
5780 CAM_LOG_INFO("Enter");
5782 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5784 if (ret == CAMERA_ERROR_NONE)
5785 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5787 CAM_LOG_INFO("ret : 0x%x", ret);
5793 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5795 int ret = CAMERA_ERROR_NONE;
5796 camera_cli_s *pc = (camera_cli_s *)camera;
5797 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5799 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5800 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5801 return CAMERA_ERROR_INVALID_PARAMETER;
5804 CAM_LOG_INFO("Enter");
5806 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5808 if (ret == CAMERA_ERROR_NONE) {
5809 *latitude = pc->cb_info->get_geotag[0];
5810 *longitude = pc->cb_info->get_geotag[1];
5811 *altitude = pc->cb_info->get_geotag[2];
5814 CAM_LOG_INFO("ret : 0x%x", ret);
5820 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5822 int ret = CAMERA_ERROR_NONE;
5823 camera_cli_s *pc = (camera_cli_s *)camera;
5824 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5826 if (!pc || !pc->cb_info || !mode) {
5827 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5828 return CAMERA_ERROR_INVALID_PARAMETER;
5831 CAM_LOG_INFO("Enter");
5833 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5835 if (ret == CAMERA_ERROR_NONE)
5836 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5838 CAM_LOG_INFO("ret : 0x%x", ret);
5844 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5846 int ret = CAMERA_ERROR_NONE;
5847 int get_flash_state = 0;
5850 CAM_LOG_ERROR("NULL pointer");
5851 return CAMERA_ERROR_INVALID_PARAMETER;
5854 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5855 (int)device, "get_flash_state", &get_flash_state);
5857 if (ret == CAMERA_ERROR_NONE) {
5858 *state = (camera_flash_state_e)get_flash_state;
5859 CAM_LOG_INFO("flash state %d", *state);
5861 CAM_LOG_ERROR("failed 0x%x", ret);
5868 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5870 int ret = CAMERA_ERROR_NONE;
5871 camera_cli_s *pc = (camera_cli_s *)camera;
5872 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5874 if (!pc || !pc->cb_info || !foreach_cb) {
5875 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5876 return CAMERA_ERROR_INVALID_PARAMETER;
5879 CAM_LOG_INFO("Enter");
5881 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5882 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5884 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5886 CAM_LOG_INFO("ret : 0x%x", ret);
5892 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5894 int ret = CAMERA_ERROR_NONE;
5895 camera_cli_s *pc = (camera_cli_s *)camera;
5896 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5898 if (!pc || !pc->cb_info || !foreach_cb) {
5899 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5900 return CAMERA_ERROR_INVALID_PARAMETER;
5903 CAM_LOG_INFO("Enter");
5905 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5906 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5908 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5910 CAM_LOG_INFO("ret : 0x%x", ret);
5916 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5918 int ret = CAMERA_ERROR_NONE;
5919 camera_cli_s *pc = (camera_cli_s *)camera;
5920 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5922 if (!pc || !pc->cb_info || !foreach_cb) {
5923 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5924 return CAMERA_ERROR_INVALID_PARAMETER;
5927 CAM_LOG_INFO("Enter");
5929 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5930 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5932 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5934 CAM_LOG_INFO("ret : 0x%x", ret);
5940 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5942 int ret = CAMERA_ERROR_NONE;
5943 camera_cli_s *pc = (camera_cli_s *)camera;
5944 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5946 if (!pc || !pc->cb_info || !foreach_cb) {
5947 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5948 return CAMERA_ERROR_INVALID_PARAMETER;
5951 CAM_LOG_INFO("Enter");
5953 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5954 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5956 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5958 CAM_LOG_INFO("ret : 0x%x", ret);
5964 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5966 int ret = CAMERA_ERROR_NONE;
5967 camera_cli_s *pc = (camera_cli_s *)camera;
5968 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5970 if (!pc || !pc->cb_info || !foreach_cb) {
5971 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5972 return CAMERA_ERROR_INVALID_PARAMETER;
5975 CAM_LOG_INFO("Enter");
5977 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5978 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5980 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5982 CAM_LOG_INFO("ret : 0x%x", ret);
5988 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5990 int ret = CAMERA_ERROR_NONE;
5991 camera_cli_s *pc = (camera_cli_s *)camera;
5992 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5994 if (!pc || !pc->cb_info || !foreach_cb) {
5995 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5996 return CAMERA_ERROR_INVALID_PARAMETER;
5999 CAM_LOG_INFO("Enter");
6001 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
6002 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
6004 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6006 CAM_LOG_INFO("ret : 0x%x", ret);
6012 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
6014 int ret = CAMERA_ERROR_NONE;
6015 camera_cli_s *pc = (camera_cli_s *)camera;
6016 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
6018 if (!pc || !pc->cb_info || !foreach_cb) {
6019 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6020 return CAMERA_ERROR_INVALID_PARAMETER;
6023 CAM_LOG_INFO("Enter");
6025 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
6026 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
6028 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6030 CAM_LOG_INFO("ret : 0x%x", ret);
6036 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
6038 int ret = CAMERA_ERROR_NONE;
6039 camera_cli_s *pc = (camera_cli_s *)camera;
6040 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
6042 if (!pc || !pc->cb_info || !foreach_cb) {
6043 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6044 return CAMERA_ERROR_INVALID_PARAMETER;
6047 CAM_LOG_INFO("Enter");
6049 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
6050 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
6052 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6054 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
6060 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)
6062 int ret = CAMERA_ERROR_NONE;
6063 camera_cli_s *pc = (camera_cli_s *)camera;
6064 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
6065 camera_msg_param param;
6068 if (!pc || !pc->cb_info || !foreach_cb) {
6069 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6070 return CAMERA_ERROR_INVALID_PARAMETER;
6073 CAM_LOG_INFO("Enter");
6075 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
6076 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
6078 value = (width << 16) | height;
6079 CAMERA_MSG_PARAM_SET(param, INT, value);
6081 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6083 CAM_LOG_INFO("ret : 0x%x", ret);
6089 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
6091 int ret = CAMERA_ERROR_NONE;
6092 camera_cli_s *pc = (camera_cli_s *)camera;
6093 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
6095 if (!pc || !pc->cb_info || !foreach_cb) {
6096 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6097 return CAMERA_ERROR_INVALID_PARAMETER;
6100 CAM_LOG_INFO("Enter");
6102 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
6103 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
6105 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6107 CAM_LOG_INFO("ret : 0x%x", ret);
6113 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
6115 int ret = CAMERA_ERROR_NONE;
6116 camera_cli_s *pc = (camera_cli_s *)camera;
6117 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
6119 if (!pc || !pc->cb_info || !foreach_cb) {
6120 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6121 return CAMERA_ERROR_INVALID_PARAMETER;
6124 CAM_LOG_INFO("Enter");
6126 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
6127 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
6129 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6131 CAM_LOG_INFO("ret : 0x%x", ret);
6137 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
6139 int ret = CAMERA_ERROR_NONE;
6140 camera_cli_s *pc = (camera_cli_s *)camera;
6141 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
6142 camera_msg_param param;
6143 int set_rotation = (int)rotation;
6145 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6147 CAM_LOG_INFO("Enter");
6149 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
6151 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6153 CAM_LOG_INFO("ret : 0x%x", ret);
6159 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
6161 int ret = CAMERA_ERROR_NONE;
6162 camera_cli_s *pc = (camera_cli_s *)camera;
6163 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
6165 if (!pc || !pc->cb_info || !rotation) {
6166 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6167 return CAMERA_ERROR_INVALID_PARAMETER;
6170 CAM_LOG_INFO("Enter");
6172 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6174 if (ret == CAMERA_ERROR_NONE)
6175 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
6177 CAM_LOG_INFO("ret : 0x%x", ret);
6183 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
6185 int ret = CAMERA_ERROR_NONE;
6186 camera_cli_s *pc = (camera_cli_s *)camera;
6187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
6188 camera_msg_param param;
6189 int set_flip = (int)flip;
6191 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6193 CAM_LOG_INFO("Enter");
6195 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
6197 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6199 CAM_LOG_INFO("ret : 0x%x", ret);
6205 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
6207 int ret = CAMERA_ERROR_NONE;
6208 camera_cli_s *pc = (camera_cli_s *)camera;
6209 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6211 if (!pc || !pc->cb_info || !flip) {
6212 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
6213 return CAMERA_ERROR_INVALID_PARAMETER;
6216 CAM_LOG_INFO("Enter");
6218 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6220 if (ret == CAMERA_ERROR_NONE)
6221 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6223 CAM_LOG_INFO("ret : 0x%x", ret);
6228 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6230 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
6234 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6236 int ret = CAMERA_ERROR_NONE;
6237 camera_cli_s *pc = (camera_cli_s *)camera;
6238 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6240 if (!pc || !pc->cb_info || !mode) {
6241 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
6242 return CAMERA_ERROR_INVALID_PARAMETER;
6245 CAM_LOG_INFO("Enter");
6247 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6249 if (ret == CAMERA_ERROR_NONE)
6250 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6252 CAM_LOG_INFO("ret : 0x%x", ret);
6258 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6260 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
6264 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6266 int ret = CAMERA_ERROR_NONE;
6267 camera_cli_s *pc = (camera_cli_s *)camera;
6268 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6270 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6272 CAM_LOG_INFO("Enter");
6274 if (!camera_attr_is_supported_hdr_capture(camera)) {
6275 CAM_LOG_ERROR("HDR not supported");
6276 return CAMERA_ERROR_NOT_SUPPORTED;
6280 CAM_LOG_ERROR("NULL callback");
6281 return CAMERA_ERROR_INVALID_PARAMETER;
6284 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6286 if (ret == CAMERA_ERROR_NONE) {
6287 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6289 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6290 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6292 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6295 CAM_LOG_INFO("ret : 0x%x", ret);
6301 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6303 int ret = CAMERA_ERROR_NONE;
6304 camera_cli_s *pc = (camera_cli_s *)camera;
6305 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6307 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6309 CAM_LOG_INFO("Enter");
6311 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6313 if (ret == CAMERA_ERROR_NONE) {
6314 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6316 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6317 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6319 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6322 CAM_LOG_INFO("ret : 0x%x", ret);
6328 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6330 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
6334 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6336 int ret = CAMERA_ERROR_NONE;
6337 camera_cli_s *pc = (camera_cli_s *)camera;
6338 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6340 if (!pc || !pc->cb_info || !enabled) {
6341 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6342 return CAMERA_ERROR_INVALID_PARAMETER;
6345 CAM_LOG_INFO("Enter");
6347 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6349 if (ret == CAMERA_ERROR_NONE)
6350 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6352 CAM_LOG_INFO("ret : 0x%x", ret);
6358 bool camera_attr_is_supported_anti_shake(camera_h camera)
6360 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
6364 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6366 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
6370 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6372 int ret = CAMERA_ERROR_NONE;
6373 camera_cli_s *pc = (camera_cli_s *)camera;
6374 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6376 if (!pc || !pc->cb_info || !enabled) {
6377 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6378 return CAMERA_ERROR_INVALID_PARAMETER;
6381 CAM_LOG_INFO("Enter");
6383 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6385 if (ret == CAMERA_ERROR_NONE)
6386 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6388 CAM_LOG_INFO("ret : 0x%x", ret);
6394 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6396 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
6400 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6402 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
6406 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6408 int ret = CAMERA_ERROR_NONE;
6409 camera_cli_s *pc = (camera_cli_s *)camera;
6410 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6412 if (!pc || !pc->cb_info || !enabled) {
6413 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6414 return CAMERA_ERROR_INVALID_PARAMETER;
6417 CAM_LOG_INFO("Enter");
6419 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6421 if (ret == CAMERA_ERROR_NONE)
6422 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6424 CAM_LOG_INFO("ret : 0x%x", ret);
6430 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6432 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
6436 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6438 int ret = CAMERA_ERROR_NONE;
6439 camera_cli_s *pc = (camera_cli_s *)camera;
6440 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6441 camera_msg_param param;
6442 int set_disable = (int)disable;
6444 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6446 CAM_LOG_INFO("Enter");
6448 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6450 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6452 CAM_LOG_INFO("ret : 0x%x", ret);
6458 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6460 int ret = CAMERA_ERROR_NONE;
6461 camera_cli_s *pc = (camera_cli_s *)camera;
6462 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6463 camera_msg_param param0;
6464 camera_msg_param param1;
6466 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6468 CAM_LOG_INFO("Enter");
6470 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6471 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6473 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6474 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6476 CAM_LOG_INFO("ret : 0x%x", ret);
6482 int camera_attr_get_pan(camera_h camera, int *pan_step)
6484 int ret = CAMERA_ERROR_NONE;
6485 camera_cli_s *pc = (camera_cli_s *)camera;
6486 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6488 if (!pc || !pc->cb_info || !pan_step) {
6489 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6490 return CAMERA_ERROR_INVALID_PARAMETER;
6493 CAM_LOG_INFO("Enter");
6495 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6497 if (ret == CAMERA_ERROR_NONE)
6498 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6500 CAM_LOG_INFO("ret : 0x%x", ret);
6506 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6508 int ret = CAMERA_ERROR_NONE;
6509 camera_cli_s *pc = (camera_cli_s *)camera;
6510 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6512 if (!pc || !pc->cb_info || !min || !max) {
6513 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6514 return CAMERA_ERROR_INVALID_PARAMETER;
6517 CAM_LOG_INFO("Enter");
6519 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6521 if (ret == CAMERA_ERROR_NONE) {
6522 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6523 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6526 CAM_LOG_INFO("ret : 0x%x", ret);
6532 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6534 int ret = CAMERA_ERROR_NONE;
6535 camera_cli_s *pc = (camera_cli_s *)camera;
6536 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6537 camera_msg_param param0;
6538 camera_msg_param param1;
6540 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6542 CAM_LOG_INFO("Enter");
6544 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6545 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6547 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6548 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6550 CAM_LOG_INFO("ret : 0x%x", ret);
6556 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6558 int ret = CAMERA_ERROR_NONE;
6559 camera_cli_s *pc = (camera_cli_s *)camera;
6560 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6562 if (!pc || !pc->cb_info || !tilt_step) {
6563 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6564 return CAMERA_ERROR_INVALID_PARAMETER;
6567 CAM_LOG_INFO("Enter");
6569 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6571 if (ret == CAMERA_ERROR_NONE)
6572 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6574 CAM_LOG_INFO("ret : 0x%x", ret);
6580 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6582 int ret = CAMERA_ERROR_NONE;
6583 camera_cli_s *pc = (camera_cli_s *)camera;
6584 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6586 if (!pc || !pc->cb_info || !min || !max) {
6587 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6588 return CAMERA_ERROR_INVALID_PARAMETER;
6591 CAM_LOG_INFO("Enter");
6593 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6595 if (ret == CAMERA_ERROR_NONE) {
6596 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6597 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6600 CAM_LOG_INFO("ret : 0x%x", ret);
6606 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6608 int ret = CAMERA_ERROR_NONE;
6609 camera_cli_s *pc = (camera_cli_s *)camera;
6610 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6611 camera_msg_param param;
6612 int set_ptz_type = (int)ptz_type;
6614 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6616 CAM_LOG_INFO("Enter");
6618 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6620 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6622 CAM_LOG_INFO("ret : 0x%x", ret);
6628 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6630 int ret = CAMERA_ERROR_NONE;
6631 camera_cli_s *pc = (camera_cli_s *)camera;
6632 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6634 if (!pc || !pc->cb_info || !foreach_cb) {
6635 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6636 return CAMERA_ERROR_INVALID_PARAMETER;
6639 CAM_LOG_INFO("Enter");
6641 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6642 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6644 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6646 CAM_LOG_INFO("ret : 0x%x", ret);
6652 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6654 int ret = CAMERA_ERROR_NONE;
6655 camera_cli_s *pc = (camera_cli_s *)camera;
6656 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6657 int set_display_roi_area[4] = {x, y, width, height};
6661 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6663 CAM_LOG_INFO("Enter");
6665 if (pc->cb_info->is_evas_render) {
6666 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6667 if (ret != MM_ERROR_NONE) {
6668 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6669 return CAMERA_ERROR_INVALID_OPERATION;
6673 length = sizeof(set_display_roi_area) / sizeof(int) + \
6674 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6676 msg = muse_core_msg_new(api,
6677 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6680 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6686 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6688 camera_cli_s *pc = (camera_cli_s *)camera;
6689 int ret = CAMERA_ERROR_NONE;
6690 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6692 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6693 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6694 return CAMERA_ERROR_INVALID_PARAMETER;
6697 CAM_LOG_INFO("Enter");
6699 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6701 if (ret == CAMERA_ERROR_NONE) {
6702 *x = pc->cb_info->get_display_roi_area[0];
6703 *y = pc->cb_info->get_display_roi_area[1];
6704 *width = pc->cb_info->get_display_roi_area[2];
6705 *height = pc->cb_info->get_display_roi_area[3];
6708 CAM_LOG_INFO("ret : 0x%x", ret);
6714 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6716 int ret = CAMERA_ERROR_NONE;
6717 int get_device_state = 0;
6720 CAM_LOG_ERROR("NULL pointer");
6721 return CAMERA_ERROR_INVALID_PARAMETER;
6724 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6725 (int)device, "get_device_state", &get_device_state);
6727 if (ret == CAMERA_ERROR_NONE) {
6728 *state = (camera_device_state_e)get_device_state;
6729 CAM_LOG_INFO("device state %d", *state);
6731 CAM_LOG_ERROR("failed 0x%x", ret);
6738 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6740 int ret = CAMERA_ERROR_NONE;
6741 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6742 camera_cb_info *info = NULL;
6744 if (!callback || !cb_id) {
6745 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6746 return CAMERA_ERROR_INVALID_PARAMETER;
6749 /* check camera support */
6750 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6751 if (ret != CAMERA_ERROR_NONE) {
6752 CAM_LOG_ERROR("get device state failed");
6756 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6758 info = g_new0(camera_cb_info, 1);
6760 CAM_LOG_ERROR("info failed");
6761 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6765 info->id = ++g_cam_dev_state_changed_cb_id;
6766 info->callback = (void *)callback;
6767 info->user_data = user_data;
6771 /* subscribe dbus signal for camera state change */
6772 if (!g_cam_dev_state_changed_cb_conn) {
6773 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6774 if (!g_cam_dev_state_changed_cb_conn) {
6775 CAM_LOG_ERROR("failed to get gdbus connection");
6776 ret = CAMERA_ERROR_INVALID_OPERATION;
6780 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6781 MM_CAMCORDER_DBUS_OBJECT,
6782 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6783 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6785 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6786 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6787 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6788 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6789 CAM_LOG_ERROR("failed to get gdbus connection");
6790 ret = CAMERA_ERROR_INVALID_OPERATION;
6794 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6797 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6799 CAM_LOG_INFO("callback id %d", info->id);
6802 if (ret != CAMERA_ERROR_NONE) {
6808 if (g_cam_dev_state_changed_cb_conn) {
6809 g_object_unref(g_cam_dev_state_changed_cb_conn);
6810 g_cam_dev_state_changed_cb_conn = NULL;
6814 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6820 int camera_remove_device_state_changed_cb(int cb_id)
6822 int ret = CAMERA_ERROR_NONE;
6823 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6824 GList *tmp_list = NULL;
6825 camera_cb_info *info = NULL;
6827 /* check camera support */
6828 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6829 if (ret != CAMERA_ERROR_NONE) {
6830 CAM_LOG_ERROR("get device state failed");
6834 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6836 if (!g_cam_dev_state_changed_cb_list) {
6837 CAM_LOG_ERROR("there is no callback info");
6838 ret = CAMERA_ERROR_INVALID_OPERATION;
6842 tmp_list = g_cam_dev_state_changed_cb_list;
6845 info = tmp_list->data;
6846 tmp_list = tmp_list->next;
6849 CAM_LOG_WARNING("NULL info");
6853 if (info->id == cb_id) {
6854 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6859 if (!g_cam_dev_state_changed_cb_list) {
6860 /* no remained callback */
6861 if (g_cam_dev_state_changed_cb_conn) {
6862 /* unsubscribe signal */
6863 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6864 g_cam_dev_state_changed_cb_subscribe_id = 0;
6866 /* unref connection */
6867 g_object_unref(g_cam_dev_state_changed_cb_conn);
6868 g_cam_dev_state_changed_cb_conn = NULL;
6872 CAM_LOG_INFO("id %d callback removed", cb_id);
6873 ret = CAMERA_ERROR_NONE;
6879 CAM_LOG_ERROR("id %d callback not found", cb_id);
6880 ret = CAMERA_ERROR_INVALID_PARAMETER;
6883 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6890 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6892 int ret = CAMERA_ERROR_NONE;
6893 camera_cli_s *pc = (camera_cli_s *)camera;
6894 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6896 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6898 g_mutex_lock(&pc->cb_info->bridge_lock);
6900 if (pc->cb_info->bridge) {
6901 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6902 ret = CAMERA_ERROR_INVALID_OPERATION;
6903 goto _SET_MEDIA_BRIDGE_DONE;
6906 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6907 if (ret != CAMERA_ERROR_NONE) {
6908 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6909 goto _SET_MEDIA_BRIDGE_DONE;
6912 pc->cb_info->bridge = bridge;
6914 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6916 _SET_MEDIA_BRIDGE_DONE:
6917 g_mutex_unlock(&pc->cb_info->bridge_lock);
6923 int camera_media_bridge_unset_bridge(camera_h camera)
6925 int ret = CAMERA_ERROR_NONE;
6926 camera_cli_s *pc = (camera_cli_s *)camera;
6927 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6929 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6931 g_mutex_lock(&pc->cb_info->bridge_lock);
6933 if (!pc->cb_info->bridge) {
6934 CAM_LOG_ERROR("no media bridge");
6935 ret = CAMERA_ERROR_INVALID_OPERATION;
6936 goto _UNSET_MEDIA_BRIDGE_DONE;
6939 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6940 if (ret != CAMERA_ERROR_NONE) {
6941 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6942 goto _UNSET_MEDIA_BRIDGE_DONE;
6945 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6947 pc->cb_info->bridge = NULL;
6949 _UNSET_MEDIA_BRIDGE_DONE:
6950 g_mutex_unlock(&pc->cb_info->bridge_lock);
6957 int camera_create_network(camera_device_e device, camera_h *camera)
6959 return _camera_create_private(device, true, camera);
6963 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
6965 int ret = CAMERA_ERROR_NONE;
6966 camera_cli_s *pc = (camera_cli_s *)camera;
6967 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
6969 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6971 if (!camera_is_supported_extra_preview(camera)) {
6972 CAM_LOG_ERROR("extra preview is not supported");
6973 return CAMERA_ERROR_NOT_SUPPORTED;
6977 CAM_LOG_ERROR("NULL callback");
6978 return CAMERA_ERROR_INVALID_PARAMETER;
6981 CAM_LOG_INFO("Enter");
6983 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6985 if (ret == CAMERA_ERROR_NONE) {
6986 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6988 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
6989 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
6991 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6994 CAM_LOG_INFO("ret : 0x%x", ret);
7000 int camera_unset_extra_preview_cb(camera_h camera)
7002 int ret = CAMERA_ERROR_NONE;
7003 camera_cli_s *pc = (camera_cli_s *)camera;
7004 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
7006 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7008 if (!camera_is_supported_extra_preview(camera)) {
7009 CAM_LOG_ERROR("extra preview is not supported");
7010 return CAMERA_ERROR_NOT_SUPPORTED;
7013 CAM_LOG_INFO("Enter");
7015 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
7017 if (ret == CAMERA_ERROR_NONE) {
7018 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7020 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
7021 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
7023 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7026 CAM_LOG_INFO("ret : 0x%x", ret);
7032 int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e pixel_format, int width, int height, int fps)
7034 int ret = CAMERA_ERROR_NONE;
7035 int stream_format[4] = {pixel_format, width, height, fps};
7037 camera_cli_s *pc = (camera_cli_s *)camera;
7038 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
7040 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7042 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
7043 stream_id, pixel_format, width, height, fps);
7045 msg = muse_core_msg_new(api,
7046 MUSE_TYPE_INT, "stream_id", stream_id,
7047 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
7050 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
7056 int camera_get_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e *pixel_format, int *width, int *height, int *fps)
7058 int ret = CAMERA_ERROR_NONE;
7059 camera_cli_s *pc = (camera_cli_s *)camera;
7060 camera_msg_param param;
7061 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
7063 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
7064 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
7065 return CAMERA_ERROR_INVALID_PARAMETER;
7068 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7070 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7072 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7074 if (ret == CAMERA_ERROR_NONE) {
7075 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
7076 *width = pc->cb_info->get_extra_preview_stream_format[1];
7077 *height = pc->cb_info->get_extra_preview_stream_format[2];
7078 *fps = pc->cb_info->get_extra_preview_stream_format[3];
7081 CAM_LOG_INFO("ret : 0x%x", ret);
7087 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
7089 int ret = CAMERA_ERROR_NONE;
7090 camera_cli_s *pc = (camera_cli_s *)camera;
7091 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
7092 camera_msg_param param0;
7093 camera_msg_param param1;
7095 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7097 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
7099 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
7100 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
7102 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
7103 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
7105 CAM_LOG_INFO("ret : 0x%x", ret);
7111 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
7113 int ret = CAMERA_ERROR_NONE;
7114 camera_cli_s *pc = (camera_cli_s *)camera;
7115 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
7116 camera_msg_param param;
7118 if (!pc || !pc->cb_info || !bitrate) {
7119 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
7120 return CAMERA_ERROR_INVALID_PARAMETER;
7123 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7125 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7127 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7129 if (ret == CAMERA_ERROR_NONE) {
7130 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
7131 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
7133 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
7140 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
7142 int ret = CAMERA_ERROR_NONE;
7143 camera_cli_s *pc = (camera_cli_s *)camera;
7144 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
7145 camera_msg_param param0;
7146 camera_msg_param param1;
7148 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7150 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
7152 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
7153 CAMERA_MSG_PARAM_SET(param1, INT, interval);
7155 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
7156 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
7158 CAM_LOG_INFO("ret : 0x%x", ret);
7164 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
7166 int ret = CAMERA_ERROR_NONE;
7167 camera_cli_s *pc = (camera_cli_s *)camera;
7168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
7169 camera_msg_param param;
7171 if (!pc || !pc->cb_info || !interval) {
7172 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
7173 return CAMERA_ERROR_INVALID_PARAMETER;
7176 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7178 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7180 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7182 if (ret == CAMERA_ERROR_NONE) {
7183 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
7184 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
7186 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
7193 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
7195 camera_cli_s *pc = (camera_cli_s *)camera;
7197 if (!pc || !pc->cb_info || !rotation) {
7198 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
7199 return CAMERA_ERROR_INVALID_PARAMETER;
7202 if (!pc->cb_info->stream_data) {
7203 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
7204 return CAMERA_ERROR_INVALID_OPERATION;
7207 *rotation = pc->cb_info->stream_data->rotation;
7209 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
7211 return CAMERA_ERROR_NONE;
7215 int _camera_get_log_level(void)
7217 return g_camera_log_level;