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>
35 #define LOG_TAG "TIZEN_N_CAMERA"
36 #define MODULE_NAME "camera"
37 #define LIB_CAMERA_DEVICE_MANAGER PATH_LIBDIR"/libcamera_device_manager.so"
38 #define CAMERA_CHECK_DEVICE_MANAGER \
40 if (access(LIB_CAMERA_DEVICE_MANAGER, F_OK) != 0) {\
41 CAM_LOG_ERROR("no camera device maanger[errno:%d]", errno);\
42 return CAMERA_ERROR_NOT_SUPPORTED;\
47 /* for camera device manager */
48 typedef struct _cdm_symbol_table {
50 const char *func_name;
53 /* for device changed callback */
54 static GMutex g_cam_dev_state_changed_cb_lock;
55 static GList *g_cam_dev_state_changed_cb_list;
56 static int g_cam_dev_state_changed_cb_id;
57 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
58 static guint g_cam_dev_state_changed_cb_subscribe_id;
59 static GMutex g_cam_idle_event_lock;
62 static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO;
64 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
65 static void __camera_release_imported_bo(tbm_bo *bo);
67 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
68 camera_media_packet_data *mp_data, media_packet_h *packet);
69 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
70 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
71 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
73 static gboolean __camera_allocate_preview_buffer(camera_h camera);
74 static void __camera_release_preview_buffer(camera_h camera);
75 static void __camera_release_tfd(int tfd[MUSE_NUM_FD]);
77 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
78 int type, const char *thread_name, camera_cb_info_s *cb_info);
79 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info);
83 static gboolean __camera_allocate_preview_buffer(camera_h camera)
86 int ret = CAMERA_ERROR_NONE;
87 int format = CAMERA_PIXEL_FORMAT_INVALID;
91 camera_cli_s *pc = (camera_cli_s *)camera;
92 camera_cb_info_s *cb_info = NULL;
94 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, FALSE);
96 cb_info = pc->cb_info;
98 CAM_LOG_INFO("Enter");
100 /* get preview info and calculate size */
101 ret = camera_get_preview_format(camera, &format);
102 if (ret != CAMERA_ERROR_NONE) {
103 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
107 ret = camera_get_preview_resolution(camera, &width, &height);
108 if (ret != CAMERA_ERROR_NONE) {
109 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
113 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
116 case CAMERA_PIXEL_FORMAT_INVZ:
117 buffer_size = width * height;
119 case CAMERA_PIXEL_FORMAT_NV12:
120 case CAMERA_PIXEL_FORMAT_I420:
121 buffer_size = (width * height * 3) >> 1;
123 case CAMERA_PIXEL_FORMAT_YUYV:
124 case CAMERA_PIXEL_FORMAT_UYVY:
125 buffer_size = width * height * 2;
128 CAM_LOG_ERROR("unhandled format %d", format);
129 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
132 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
134 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
135 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
136 if (!cb_info->bos[i]) {
137 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
138 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
141 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
142 if (cb_info->fds[i] < 0) {
143 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
144 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
147 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
150 CAM_LOG_INFO("Done");
154 _ALLOCATE_PREVIEW_BUFFER_FAILED:
155 __camera_release_preview_buffer(camera);
160 static void __camera_release_preview_buffer(camera_h camera)
163 camera_cli_s *pc = (camera_cli_s *)camera;
164 camera_cb_info_s *cb_info = NULL;
166 CAMERA_CHECK_HANDLE_RETURN(pc);
168 CAM_LOG_INFO("Enter");
170 cb_info = pc->cb_info;
172 /* close exported fd and bos */
173 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
174 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
176 if (cb_info->bos[i]) {
177 tbm_bo_unref(cb_info->bos[i]);
178 cb_info->bos[i] = NULL;
183 if (CAMERA_IS_FD_VALID(cb_info->fds[i])) {
184 close(cb_info->fds[i]);
185 cb_info->fds[i] = CAMERA_FD_INIT;
189 CAM_LOG_INFO("Done");
193 static void __camera_release_tfd(int tfd[MUSE_NUM_FD])
198 CAM_LOG_WARNING("NULL tfd");
202 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
203 if (!CAMERA_IS_FD_VALID(tfd[i]))
207 tfd[i] = CAMERA_FD_INIT;
212 void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
215 api < 0 || api >= MUSE_CAMERA_API_MAX) {
216 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
220 g_mutex_lock(&(cb_info->api_mutex[api]));
221 cb_info->api_waiting[api] += value;
222 g_mutex_unlock(&(cb_info->api_mutex[api]));
224 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
225 api, value, cb_info->api_waiting[api]);
229 static void __camera_device_state_changed_cb(GDBusConnection *connection,
230 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
231 const gchar *signal_name, GVariant *param, gpointer user_data)
234 camera_device_e device = CAMERA_DEVICE_CAMERA0;
235 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
236 GList *tmp_list = NULL;
237 camera_cb_info *info = NULL;
239 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
241 if (!g_cam_dev_state_changed_cb_list || !param) {
242 CAM_LOG_WARNING("no callback or NULL param %p", param);
246 /* get device and state */
247 g_variant_get(param, "(i)", &value);
249 device = value >> 16;
250 state = 0x0000ffff & value;
252 CAM_LOG_INFO("device %d, state %d", device, state);
254 tmp_list = g_cam_dev_state_changed_cb_list;
257 info = (camera_cb_info *)tmp_list->data;
260 if (info->callback) {
261 CAM_LOG_INFO("start id[%d] callback", info->id);
262 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
263 CAM_LOG_INFO("returned id[%d] callback", info->id);
265 CAM_LOG_WARNING("NULL callback for id %d", info->id);
269 tmp_list = tmp_list->next;
273 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
277 static void __camera_preview_cb_monitoring_info_sub_reset(monitoring_info_sub_s *info_sub)
280 CAM_LOG_ERROR("NULL info_sub");
284 info_sub->frame_count = 0;
285 info_sub->elapsed_sec_accum = 0.0;
286 info_sub->elapsed_sec_peak = 0.0;
290 static void __camera_preview_cb_monitoring_info_reset(camera_preview_cb_monitoring_info_s *info)
293 CAM_LOG_ERROR("NULL info");
297 __camera_preview_cb_monitoring_info_sub_reset(info->total);
298 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
302 static void __camera_preview_cb_monitoring_info_start(camera_preview_cb_monitoring_info_s *info)
305 CAM_LOG_ERROR("NULL info");
309 g_timer_start(info->timer_calling);
311 if (info->interval->frame_count == 0)
312 g_timer_start(info->timer_interval);
316 static void __camera_preview_cb_monitoring_info_sub_update(monitoring_info_sub_s *info_sub, gdouble elapsed_sec)
319 CAM_LOG_ERROR("NULL info_sub");
323 info_sub->frame_count++;
324 info_sub->elapsed_sec_accum += elapsed_sec;
326 if (info_sub->elapsed_sec_peak < elapsed_sec)
327 info_sub->elapsed_sec_peak = elapsed_sec;
331 static void __camera_preview_cb_monitoring_info_end(camera_preview_cb_monitoring_info_s *info)
333 gdouble elapsed_sec = 0.0;
334 gdouble elapsed_sec_interval = 0.0;
337 CAM_LOG_ERROR("NULL info");
341 elapsed_sec = g_timer_elapsed(info->timer_calling, NULL);
342 elapsed_sec_interval = g_timer_elapsed(info->timer_interval, NULL);
344 __camera_preview_cb_monitoring_info_sub_update(info->total, elapsed_sec);
345 __camera_preview_cb_monitoring_info_sub_update(info->interval, elapsed_sec);
347 if (elapsed_sec_interval >= 1.0) {
348 CAM_LOG_INFO("id[%d], frame count[t:%llu,i:%llu], elapsed - avg[t:%dms,i:%dms], peak[t:%dms,i:%dms]",
349 info->stream_id, info->total->frame_count, info->interval->frame_count,
350 (int)((info->total->elapsed_sec_accum / (gdouble)info->total->frame_count) * 1000),
351 (int)((info->interval->elapsed_sec_accum / (gdouble)info->interval->frame_count) * 1000),
352 (int)(info->total->elapsed_sec_peak * 1000), (int)(info->interval->elapsed_sec_peak * 1000));
354 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
359 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
363 int ret_fd = CAMERA_FD_INIT;
364 int preview_fd = CAMERA_FD_INIT;
365 int num_buffer_fd = 0;
366 unsigned char *buf_pos = NULL;
369 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
370 tbm_bo_handle bo_handle = {.ptr = NULL};
371 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
372 tbm_bo data_bo = NULL;
373 tbm_bo_handle data_bo_handle = {.ptr = NULL};
375 camera_msg_param param;
376 camera_preview_data_s frame;
377 MMCamcorderVideoStreamDataType *stream = NULL;
378 camera_media_packet_data *mp_data = NULL;
379 media_packet_h pkt = NULL;
380 camera_preview_cb_monitoring_info_s *monitoring_info = NULL;
382 /* tfd[0]: MMCamcorderVideoStreamDataType
383 tfd[1]: data_bo or zero copy bo[0]
384 tfd[2]: zero copy bo[1]
385 tfd[3]: zero copy bo[2] */
387 if (!cb_info || !recv_msg || !tfd) {
388 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
392 muse_camera_msg_get(preview_fd, recv_msg);
393 muse_camera_msg_get(num_buffer_fd, recv_msg);
395 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
397 memset(&frame, 0x0, sizeof(camera_preview_data_s));
400 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
405 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
407 if (cb_info->invoke_preview_cb == FALSE) {
408 CAM_LOG_WARNING("Skip preview callback for fd[%d] due to preview stop.", ret_fd);
409 goto _PREVIEW_CB_HANDLER_DONE;
412 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
413 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
414 goto _PREVIEW_CB_HANDLER_DONE;
417 /* import tbm bo and get virtual address */
418 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
419 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
420 goto _PREVIEW_CB_HANDLER_DONE;
423 buf_pos = (unsigned char *)bo_handle.ptr;
425 /* get stream info */
426 stream = (MMCamcorderVideoStreamDataType *)buf_pos;
428 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
429 /* import tbm data_bo and get virtual address */
430 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
431 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
432 goto _PREVIEW_CB_HANDLER_DONE;
435 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
436 stream->data.encoded.data = data_bo_handle.ptr;
438 for (i = 0 ; i < num_buffer_fd ; i++) {
439 /* import buffer bo and get virtual address */
440 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
441 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
442 goto _PREVIEW_CB_HANDLER_DONE;
446 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
447 stream->data.encoded.data = buffer_bo_handle[0].ptr;
450 /* preview callback */
451 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
452 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]) {
453 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
455 /* set stream data for camera_get_preview_frame_rotation() */
456 cb_info->stream_data = stream;
458 if (stream->extra_stream_id < 0) {
459 monitoring_info = cb_info->monitoring_info_preview;
460 __camera_preview_cb_monitoring_info_start(monitoring_info);
462 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
463 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
464 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
466 monitoring_info = cb_info->monitoring_info_preview_ex[stream->extra_stream_id];
467 __camera_preview_cb_monitoring_info_start(monitoring_info);
469 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
470 ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
471 stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
474 __camera_preview_cb_monitoring_info_end(monitoring_info);
476 cb_info->stream_data = NULL;
479 if (stream->extra_stream_id >= 0)
480 goto _PREVIEW_CB_HANDLER_DONE;
482 /* make media packet with below cases.
483 * 1. media_packet_preview_cb is set
484 * 2. EVAS display rendering
485 * 3. media bridge is set
487 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
488 cb_info->is_evas_render ||
490 ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
491 if (ret != CAMERA_ERROR_NONE) {
492 CAM_LOG_ERROR("__camera_create_media_packet_data failed[0x%x]", ret);
493 goto _PREVIEW_CB_HANDLER_DONE;
496 ret = __camera_create_media_packet(cb_info, stream, mp_data, &pkt);
497 if (ret != CAMERA_ERROR_NONE) {
498 CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
499 __camera_release_media_packet_data(mp_data, cb_info);
501 goto _PREVIEW_CB_HANDLER_DONE;
505 /* 1. media packet preview callback */
506 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
507 media_packet_ref(pkt);
509 monitoring_info = cb_info->monitoring_info_preview_mp;
510 __camera_preview_cb_monitoring_info_start(monitoring_info);
512 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
513 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
515 __camera_preview_cb_monitoring_info_end(monitoring_info);
518 /* 2. call evas renderer */
519 if (cb_info->is_evas_render) {
520 if (cb_info->run_evas_render) {
521 media_packet_ref(pkt);
522 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
523 if (ret != MM_ERROR_NONE) {
524 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
525 media_packet_unref(pkt);
528 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
533 /* 3. media bridge */
534 g_mutex_lock(&cb_info->bridge_lock);
536 if (cb_info->bridge) {
537 media_packet_ref(pkt);
538 ret = media_bridge_push_packet(cb_info->bridge, pkt);
539 if (ret != MEDIA_BRIDGE_ERROR_NONE) {
540 CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
541 media_packet_unref(pkt);
546 g_mutex_unlock(&cb_info->bridge_lock);
548 _PREVIEW_CB_HANDLER_DONE:
549 /* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
550 and preview callback(normal or media packet) is set. */
551 if (num_buffer_fd > 0 &&
552 (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
553 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]))
554 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
557 media_packet_unref(pkt);
562 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
564 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
566 /* release imported bo and fd */
567 __camera_release_imported_bo(&data_bo);
568 __camera_release_imported_bo(&bo);
570 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
571 __camera_release_imported_bo(&buffer_bo[i]);
573 __camera_release_tfd(tfd);
577 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
580 int capture_fd_main = 0;
581 int capture_fd_post = 0;
582 int capture_fd_thumb = 0;
583 unsigned char *buf_pos = NULL;
585 camera_image_data_s *rImage = NULL;
586 camera_image_data_s *rPostview = NULL;
587 camera_image_data_s *rThumbnail = NULL;
589 tbm_bo bo_main = NULL;
590 tbm_bo bo_post = NULL;
591 tbm_bo bo_thumb = NULL;
592 tbm_bo_handle bo_main_handle = {.ptr = NULL};
593 tbm_bo_handle bo_post_handle = {.ptr = NULL};
594 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
596 if (!cb_info || !recv_msg || !tfd) {
597 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
601 muse_camera_msg_get(capture_fd_main, recv_msg);
602 muse_camera_msg_get(capture_fd_post, recv_msg);
603 muse_camera_msg_get(capture_fd_thumb, recv_msg);
605 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
606 capture_fd_main, capture_fd_post, capture_fd_thumb,
607 tfd[0], tfd[1], tfd[2]);
609 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
610 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
611 goto _CAPTURE_CB_HANDLER_DONE;
614 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
615 CAM_LOG_WARNING("NULL callback");
616 goto _CAPTURE_CB_HANDLER_DONE;
619 /* import tbm bo and get virtual address */
620 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
621 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
622 goto _CAPTURE_CB_HANDLER_DONE;
625 buf_pos = (unsigned char *)bo_main_handle.ptr;
626 rImage = (camera_image_data_s *)buf_pos;
627 rImage->data = buf_pos + sizeof(camera_image_data_s);
628 if (rImage->exif && rImage->exif_size > 0) {
629 rImage->exif = rImage->data + rImage->size;
632 rImage->exif_size = 0;
635 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
636 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
639 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
640 /* import tbm bo and get virtual address */
642 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
643 buf_pos = (unsigned char *)bo_post_handle.ptr;
644 rPostview = (camera_image_data_s *)buf_pos;
645 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
646 rPostview->data = buf_pos + sizeof(camera_image_data_s);
648 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
652 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
653 /* import tbm bo and get virtual address */
655 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
656 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
657 rThumbnail = (camera_image_data_s *)buf_pos;
658 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
659 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
661 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
666 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
667 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
669 _CAPTURE_CB_HANDLER_DONE:
671 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
672 __camera_release_imported_bo(&bo_main);
673 _camera_msg_return_buffer(capture_fd_main, cb_info);
676 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
677 __camera_release_imported_bo(&bo_post);
678 _camera_msg_return_buffer(capture_fd_post, cb_info);
681 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
682 __camera_release_imported_bo(&bo_thumb);
683 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
686 __camera_release_tfd(tfd);
688 CAM_LOG_INFO("return buffer done");
693 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
696 int face_fd = CAMERA_FD_INIT;
697 camera_detected_face_s *faces = NULL;
700 tbm_bo_handle bo_handle = {.ptr = NULL};
702 if (!cb_info || !recv_msg || !tfd) {
703 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
707 muse_camera_msg_get(count, recv_msg);
708 muse_camera_msg_get(face_fd, recv_msg);
710 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
711 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
713 if (CAMERA_IS_FD_VALID(tfd[0])) {
714 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
716 faces = bo_handle.ptr;
720 tfd[0] = CAMERA_FD_INIT;
723 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
724 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
727 __camera_release_imported_bo(&bo);
729 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
730 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
734 _camera_msg_return_buffer(face_fd, cb_info);
739 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
741 tbm_bo tmp_bo = NULL;
742 tbm_bo_handle tmp_bo_handle = {NULL, };
744 if (!bufmgr || !bo || !bo_handle || fd < 0) {
745 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
746 bufmgr, bo, bo_handle, fd);
750 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
751 if (tmp_bo == NULL) {
752 CAM_LOG_ERROR("import failed - fd %d", fd);
756 tmp_bo_handle = tbm_bo_get_handle(tmp_bo, TBM_DEVICE_CPU);
757 if (tmp_bo_handle.ptr == NULL) {
758 CAM_LOG_ERROR("tbm_bo_get_handle() failed %p", tmp_bo);
759 tbm_bo_unref(tmp_bo);
764 /* set bo and bo_handle */
766 *bo_handle = tmp_bo_handle;
768 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
773 static void __camera_release_imported_bo(tbm_bo *bo)
776 CAM_LOG_DEBUG("NULL bo");
785 static bool __is_supported(camera_h camera, muse_camera_api_e api)
787 int ret = CAMERA_ERROR_NONE;
788 camera_cli_s *pc = (camera_cli_s *)camera;
790 if (!pc || !pc->cb_info) {
791 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
792 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
796 CAM_LOG_INFO("Enter - api[%d]", api);
798 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
800 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
806 static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
808 int ret = CAMERA_ERROR_NONE;
809 camera_cli_s *pc = (camera_cli_s *)camera;
810 camera_msg_param param;
812 if (!pc || !pc->cb_info) {
813 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
814 return CAMERA_ERROR_INVALID_PARAMETER;
817 CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
819 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
821 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
823 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
829 static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
831 int ret = CAMERA_ERROR_NONE;
832 camera_cli_s *pc = (camera_cli_s *)camera;
833 camera_msg_param param;
835 if (!pc || !pc->cb_info) {
836 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
837 return CAMERA_ERROR_INVALID_PARAMETER;
840 CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
842 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
844 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
846 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
852 void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
857 CAM_LOG_ERROR("api[%d] message failed", api);
859 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
864 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
865 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
867 CAM_LOG_DEBUG("api[%d], message[%s]", api, msg);
869 if (cb_info->is_server_connected) {
870 _camera_update_api_waiting(cb_info, api, 1);
872 g_mutex_lock(&cb_info->fd_lock);
873 send_ret = muse_core_msg_send(cb_info->fd, msg);
874 g_mutex_unlock(&cb_info->fd_lock);
878 CAM_LOG_ERROR("message send failed");
880 *ret = CAMERA_ERROR_INVALID_OPERATION;
883 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
886 _camera_update_api_waiting(cb_info, api, -1);
888 muse_core_msg_free(msg);
890 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
891 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
893 CAM_LOG_DEBUG("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
897 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
899 int ret = CAMERA_ERROR_NONE;
902 if (!cb_info->is_server_connected) {
903 CAM_LOG_ERROR("server is disconnected");
904 return CAMERA_ERROR_SERVICE_DISCONNECTED;
907 g_mutex_lock(&(cb_info->api_mutex[api]));
909 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
911 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
913 while (!cb_info->api_activating[api]) {
914 if (time_out == CAMERA_CB_NO_TIMEOUT) {
915 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
916 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
917 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
918 CAM_LOG_ERROR("api %d TIMED OUT!", api);
919 ret = CAMERA_ERROR_INVALID_OPERATION;
923 if (!cb_info->is_server_connected) {
924 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
928 if (!cb_info->api_activating[api])
929 CAM_LOG_WARNING("invalid signal received, wait again...");
932 ret = cb_info->api_ret[api];
933 cb_info->api_activating[api] = FALSE;
936 g_mutex_unlock(&(cb_info->api_mutex[api]));
938 if (ret != CAMERA_ERROR_NONE)
939 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
945 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
946 int *ret, int timeout)
951 CAM_LOG_ERROR("NULL info - api %d", api);
954 *ret = CAMERA_ERROR_INVALID_PARAMETER;
959 msg = muse_core_msg_new(api, NULL);
961 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
965 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
966 int *ret, camera_msg_param *param, int timeout)
971 if (!cb_info || !param) {
972 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
975 *ret = CAMERA_ERROR_INVALID_PARAMETER;
980 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
982 switch (param->type) {
984 msg = muse_core_msg_new(api,
985 param->type, param->name, param->value.value_INT,
988 case MUSE_TYPE_STRING:
989 msg = muse_core_msg_new(api,
990 param->type, param->name, param->value.value_STRING,
993 case MUSE_TYPE_ARRAY:
994 array_length = param->value_size / sizeof(int) + \
995 (param->value_size % sizeof(int) ? 1 : 0);
997 msg = muse_core_msg_new(api,
998 param->type, param->name, array_length, param->value.value_ARRAY,
1002 CAM_LOG_ERROR("unknown type %d", param->type);
1006 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1010 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
1011 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
1015 if (!cb_info || !param0 || !param1) {
1016 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
1017 cb_info, param0, param1, api);
1020 *ret = CAMERA_ERROR_INVALID_PARAMETER;
1025 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
1027 param0->name, param0->value.value_INT,
1028 param1->name, param1->value.value_INT);
1030 msg = muse_core_msg_new(api,
1031 param0->type, param0->name, param0->value.value_INT,
1032 param1->type, param1->name, param1->value.value_INT,
1035 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1039 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
1041 camera_msg_param param;
1044 CAM_LOG_WARNING("invalid fd %d", ret_fd);
1048 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
1050 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1054 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
1056 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1057 in_format >= MM_PIXEL_FORMAT_NUM ||
1058 out_format == NULL) {
1059 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
1060 return CAMERA_ERROR_INVALID_PARAMETER;
1063 switch (in_format) {
1064 case MM_PIXEL_FORMAT_NV12:
1065 case MM_PIXEL_FORMAT_NV12T:
1066 *out_format = TBM_FORMAT_NV12;
1069 case MM_PIXEL_FORMAT_NV16:
1070 *out_format = TBM_FORMAT_NV16;
1072 case MM_PIXEL_FORMAT_NV21:
1073 *out_format = TBM_FORMAT_NV21;
1075 case MM_PIXEL_FORMAT_YUYV:
1076 *out_format = TBM_FORMAT_YUYV;
1078 case MM_PIXEL_FORMAT_UYVY:
1079 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1080 *out_format = TBM_FORMAT_UYVY;
1082 case MM_PIXEL_FORMAT_422P:
1083 *out_format = TBM_FORMAT_YUV422;
1085 case MM_PIXEL_FORMAT_I420:
1086 *out_format = TBM_FORMAT_YUV420;
1088 case MM_PIXEL_FORMAT_YV12:
1089 *out_format = TBM_FORMAT_YVU420;
1091 case MM_PIXEL_FORMAT_RGB565:
1092 *out_format = TBM_FORMAT_RGB565;
1094 case MM_PIXEL_FORMAT_RGB888:
1095 *out_format = TBM_FORMAT_RGB888;
1097 case MM_PIXEL_FORMAT_RGBA:
1098 *out_format = TBM_FORMAT_RGBA8888;
1100 case MM_PIXEL_FORMAT_ARGB:
1101 *out_format = TBM_FORMAT_ARGB8888;
1104 CAM_LOG_ERROR("invalid in_format %d", in_format);
1105 return CAMERA_ERROR_INVALID_PARAMETER;
1109 return CAMERA_ERROR_NONE;
1113 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1115 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1116 in_format >= MM_PIXEL_FORMAT_NUM ||
1118 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1119 return CAMERA_ERROR_INVALID_PARAMETER;
1122 switch (in_format) {
1123 case MM_PIXEL_FORMAT_NV12:
1124 case MM_PIXEL_FORMAT_NV12T:
1125 *mimetype = MEDIA_FORMAT_NV12;
1128 case MM_PIXEL_FORMAT_NV16:
1129 *mimetype = MEDIA_FORMAT_NV16;
1131 case MM_PIXEL_FORMAT_NV21:
1132 *mimetype = MEDIA_FORMAT_NV21;
1134 case MM_PIXEL_FORMAT_YUYV:
1135 *mimetype = MEDIA_FORMAT_YUYV;
1137 case MM_PIXEL_FORMAT_UYVY:
1138 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1139 *mimetype = MEDIA_FORMAT_UYVY;
1141 case MM_PIXEL_FORMAT_422P:
1142 *mimetype = MEDIA_FORMAT_422P;
1144 case MM_PIXEL_FORMAT_I420:
1145 *mimetype = MEDIA_FORMAT_I420;
1147 case MM_PIXEL_FORMAT_YV12:
1148 *mimetype = MEDIA_FORMAT_YV12;
1150 case MM_PIXEL_FORMAT_RGB565:
1151 *mimetype = MEDIA_FORMAT_RGB565;
1153 case MM_PIXEL_FORMAT_RGB888:
1154 *mimetype = MEDIA_FORMAT_RGB888;
1156 case MM_PIXEL_FORMAT_RGBA:
1157 *mimetype = MEDIA_FORMAT_RGBA;
1159 case MM_PIXEL_FORMAT_ARGB:
1160 *mimetype = MEDIA_FORMAT_ARGB;
1162 case MM_PIXEL_FORMAT_ENCODED_H264:
1163 /* TODO: How can we determine the profile for H.264 format? */
1164 *mimetype = MEDIA_FORMAT_H264_SP;
1166 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1167 *mimetype = MEDIA_FORMAT_MJPEG;
1169 case MM_PIXEL_FORMAT_ENCODED_VP8:
1170 *mimetype = MEDIA_FORMAT_VP8;
1172 case MM_PIXEL_FORMAT_ENCODED_VP9:
1173 *mimetype = MEDIA_FORMAT_VP9;
1176 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1177 return CAMERA_ERROR_NOT_SUPPORTED;
1181 return CAMERA_ERROR_NONE;
1185 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1186 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1189 int ret = CAMERA_ERROR_NONE;
1190 camera_media_packet_data *new_mp_data = NULL;
1192 if (!tfd || !mp_data) {
1193 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1194 return CAMERA_ERROR_INVALID_PARAMETER;
1197 new_mp_data = g_new0(camera_media_packet_data, 1);
1199 new_mp_data->ret_fd = ret_fd;
1200 new_mp_data->fd = tfd[0];
1201 new_mp_data->num_buffer_fd = num_buffer_fd;
1202 new_mp_data->bo = bo;
1204 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1208 new_mp_data->data_bo = data_bo;
1209 new_mp_data->data_fd = tfd[1];
1211 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1212 new_mp_data->data_bo, new_mp_data->data_fd);
1215 for (i = 0 ; i < num_buffer_fd ; i++) {
1216 new_mp_data->buffer_bo[i] = buffer_bo[i];
1217 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1219 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1220 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1223 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1224 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1226 new_mp_data->data_fd = CAMERA_FD_INIT;
1229 *mp_data = new_mp_data;
1231 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1236 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1240 if (!mp_data || !cb_info) {
1241 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1245 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1247 /* release imported bo and close fd */
1248 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1249 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1250 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1252 tbm_bo_unref(mp_data->buffer_bo[i]);
1254 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1255 close(mp_data->buffer_fd[i]);
1257 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1260 if (mp_data->data_bo) {
1261 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1262 mp_data->data_fd, mp_data->data_bo);
1264 tbm_bo_unref(mp_data->data_bo);
1266 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1267 close(mp_data->data_fd);
1269 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1272 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1274 tbm_bo_unref(mp_data->bo);
1276 if (CAMERA_IS_FD_VALID(mp_data->fd))
1279 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1282 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1288 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1291 int ret = CAMERA_ERROR_NONE;
1292 uint32_t tbm_format = 0;
1293 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1294 tbm_surface_info_s tsurf_info;
1296 if (!stream || !mp_data) {
1297 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1301 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1302 CAM_LOG_ERROR("No valid data");
1306 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1307 if (ret != CAMERA_ERROR_NONE)
1310 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1312 if (mp_data->num_buffer_fd > 0) {
1313 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1314 bos[i] = mp_data->buffer_bo[i];
1316 bos[0] = mp_data->data_bo;
1319 tsurf_info.width = stream->width;
1320 tsurf_info.height = stream->height;
1321 tsurf_info.format = tbm_format;
1322 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1323 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1325 switch (tbm_format) {
1326 case TBM_FORMAT_NV12: /* fall through */
1327 case TBM_FORMAT_NV21: /* fall through */
1328 case TBM_FORMAT_YUV420: /* fall through */
1329 case TBM_FORMAT_YVU420: /* fall through */
1330 case TBM_FORMAT_UYVY: /* fall through */
1331 case TBM_FORMAT_YUYV:
1332 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1333 tsurf_info.planes[i].stride = stream->stride[i];
1334 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1335 if (i != 0 && mp_data->num_buffer_fd <= 1)
1336 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1337 tsurf_info.size += tsurf_info.planes[i].size;
1339 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1340 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1344 case TBM_FORMAT_RGB565: /* fall through */
1345 case TBM_FORMAT_RGB888: /* fall through */
1346 case TBM_FORMAT_RGBA8888: /* fall through */
1347 case TBM_FORMAT_ARGB8888:
1348 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1349 tsurf_info.planes[0].offset = 0;
1350 tsurf_info.size = stream->data.rgb.length_data;
1353 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1358 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1359 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1363 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1365 int ret = CAMERA_ERROR_NONE;
1366 int pkt_fmt_width = 0;
1367 int pkt_fmt_height = 0;
1368 bool make_pkt_fmt = false;
1369 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1370 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1372 if (!cb_info || !stream) {
1373 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1374 return CAMERA_ERROR_INVALID_PARAMETER;
1377 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1378 if (ret != CAMERA_ERROR_NONE)
1381 /* check media packet format */
1382 if (cb_info->pkt_fmt) {
1383 media_format_get_video_info(cb_info->pkt_fmt,
1384 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1386 CAM_LOG_DEBUG("pkt_fmt %dx%d - stream %dx%d",
1387 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1389 if (pkt_fmt_mimetype != mimetype ||
1390 pkt_fmt_width != stream->width ||
1391 pkt_fmt_height != stream->height) {
1392 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1393 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1395 media_format_unref(cb_info->pkt_fmt);
1396 cb_info->pkt_fmt = NULL;
1397 make_pkt_fmt = true;
1400 make_pkt_fmt = true;
1403 /* create packet format */
1405 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1406 mimetype, stream->width, stream->height);
1408 ret = media_format_create(&cb_info->pkt_fmt);
1409 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1410 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1411 return CAMERA_ERROR_INVALID_OPERATION;
1414 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1415 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1416 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1417 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1418 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1419 return CAMERA_ERROR_INVALID_OPERATION;
1423 return CAMERA_ERROR_NONE;
1427 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1428 camera_media_packet_data *mp_data, media_packet_h *packet)
1430 media_packet_h pkt = NULL;
1431 tbm_surface_h tsurf = NULL;
1432 int ret = CAMERA_ERROR_NONE;
1434 if (!cb_info || !stream || !mp_data || !packet) {
1435 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1436 cb_info, stream, mp_data, packet);
1437 return CAMERA_ERROR_INVALID_PARAMETER;
1440 ret = __camera_update_media_packet_format(cb_info, stream);
1441 if (ret != CAMERA_ERROR_NONE)
1444 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1445 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1446 stream->data.encoded.data, stream->data.encoded.length_data,
1447 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1451 if (!stream->data.encoded.is_delta_frame)
1452 media_packet_set_flags(pkt, MEDIA_PACKET_SYNC_FRAME);
1454 if (stream->data.encoded.is_header_included) {
1455 media_packet_set_flags(pkt, MEDIA_PACKET_CODEC_CONFIG);
1456 CAM_LOG_INFO("Codec config in buffer");
1460 tsurf = __camera_get_tbm_surface(stream, mp_data);
1462 CAM_LOG_ERROR("get tbm surface failed");
1463 ret = CAMERA_ERROR_INVALID_OPERATION;
1464 goto _PACKET_CREATE_FAILED;
1467 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1468 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1469 (void *)cb_info, &pkt);
1472 if (ret != MEDIA_PACKET_ERROR_NONE) {
1473 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1474 goto _PACKET_CREATE_FAILED;
1477 ret = media_packet_set_extra(pkt, (void *)mp_data);
1478 if (ret != MEDIA_PACKET_ERROR_NONE) {
1479 CAM_LOG_ERROR("media_packet_set_extra failed");
1480 goto _PACKET_CREATE_FAILED;
1483 if (media_packet_set_pts(pkt, stream->timestamp_nsec) != MEDIA_PACKET_ERROR_NONE)
1484 CAM_LOG_WARNING("media_packet_set_pts failed");
1486 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1487 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1489 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1493 return CAMERA_ERROR_NONE;
1495 _PACKET_CREATE_FAILED:
1497 tbm_surface_destroy(tsurf);
1499 media_packet_unref(pkt);
1501 return CAMERA_ERROR_INVALID_OPERATION;
1504 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1507 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1508 camera_media_packet_data *mp_data = NULL;
1509 tbm_surface_h tsurf = NULL;
1511 if (!pkt || !cb_info) {
1512 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1516 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1517 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1518 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1522 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1524 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1525 pkt, mp_data, tsurf);
1528 tbm_surface_destroy(tsurf);
1530 g_mutex_lock(&cb_info->mp_data_mutex);
1531 __camera_release_media_packet_data(mp_data, cb_info);
1532 g_mutex_unlock(&cb_info->mp_data_mutex);
1535 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1540 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1541 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1545 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1547 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1549 if (cb_info->user_cb[event] == NULL) {
1550 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1551 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1552 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1553 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1554 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1555 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1559 /* return buffer message should be sent for some events.
1560 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1561 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1562 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1563 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1568 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1574 muse_camera_msg_get(previous, recv_msg);
1575 muse_camera_msg_get(current, recv_msg);
1576 muse_camera_msg_get(by_policy, recv_msg);
1578 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1579 previous, current, by_policy);
1581 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1582 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1585 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1589 muse_camera_msg_get(state, recv_msg);
1591 CAM_LOG_INFO("FOCUS state - %d", state);
1593 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1596 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1597 CAM_LOG_INFO("CAPTURE_COMPLETED");
1598 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1600 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1601 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1602 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1605 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1609 muse_camera_msg_get(percent, recv_msg);
1611 CAM_LOG_INFO("HDR progress - %d %%", percent);
1613 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1616 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1622 muse_camera_msg_get(policy, recv_msg);
1623 muse_camera_msg_get(previous, recv_msg);
1624 muse_camera_msg_get(current, recv_msg);
1626 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1628 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1629 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1632 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1637 muse_camera_msg_get(policy, recv_msg);
1638 muse_camera_msg_get(state, recv_msg);
1640 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1642 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1643 (camera_state_e)state, cb_info->user_data[event]);
1646 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1647 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1649 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1652 int current_state = 0;
1654 muse_camera_msg_get(error, recv_msg);
1655 muse_camera_msg_get(current_state, recv_msg);
1657 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1659 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1660 (camera_state_e)current_state, cb_info->user_data[event]);
1664 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1666 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1667 muse_camera_msg_get(param1, recv_msg);
1668 muse_camera_msg_get(param2, recv_msg);
1670 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1672 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1673 cb_info->user_cb[event] = NULL;
1674 cb_info->user_data[event] = NULL;
1675 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1678 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1680 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1682 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1684 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1686 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1688 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1690 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1692 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1694 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1696 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1698 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1700 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1702 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1705 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1707 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1708 muse_camera_msg_get(param1, recv_msg);
1710 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1712 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1713 cb_info->user_cb[event] = NULL;
1714 cb_info->user_data[event] = NULL;
1715 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1719 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1720 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1723 CAM_LOG_WARNING("unhandled event %d", event);
1727 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1730 static gboolean __camera_idle_event_callback(gpointer data)
1732 camera_cb_info_s *cb_info = NULL;
1733 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1735 if (cam_idle_event == NULL) {
1736 CAM_LOG_ERROR("cam_idle_event is NULL");
1741 g_mutex_lock(&g_cam_idle_event_lock);
1743 cb_info = cam_idle_event->cb_info;
1744 if (cb_info == NULL) {
1745 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1746 g_mutex_unlock(&g_cam_idle_event_lock);
1747 goto IDLE_EVENT_CALLBACK_DONE;
1750 /* remove event from list */
1751 if (cb_info->idle_event_list)
1752 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1754 g_mutex_unlock(&g_cam_idle_event_lock);
1757 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1759 IDLE_EVENT_CALLBACK_DONE:
1761 g_free(cam_idle_event);
1762 cam_idle_event = NULL;
1767 static gpointer __camera_msg_handler_func(gpointer data)
1771 camera_message_s *cam_msg = NULL;
1772 camera_idle_event_s *cam_idle_event = NULL;
1773 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1774 camera_cb_info_s *cb_info = NULL;
1775 GThread *thread = NULL;
1777 if (!handler_info || !handler_info->cb_info) {
1778 CAM_LOG_ERROR("NULL handler %p", handler_info);
1782 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1783 type = handler_info->type;
1784 thread = handler_info->thread;
1786 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1788 g_mutex_lock(&handler_info->mutex);
1790 while (g_atomic_int_get(&handler_info->running)) {
1791 if (g_queue_is_empty(handler_info->queue)) {
1792 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1793 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1794 CAM_LOG_VERBOSE("t[%d] signal received", type);
1796 if (g_atomic_int_get(&handler_info->running) == 0) {
1797 CAM_LOG_INFO("t:%d stop event thread", type);
1802 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1804 g_mutex_unlock(&handler_info->mutex);
1806 if (cam_msg == NULL) {
1807 CAM_LOG_ERROR("t:%d NULL message", type);
1808 g_mutex_lock(&handler_info->mutex);
1814 if (api < MUSE_CAMERA_API_MAX) {
1817 g_mutex_lock(&cb_info->api_mutex[api]);
1819 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1820 if (cb_info->api_waiting[api] > 0) {
1821 cb_info->api_ret[api] = ret;
1822 cb_info->api_activating[api] = TRUE;
1824 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1826 g_cond_broadcast(&cb_info->api_cond[api]);
1828 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1831 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1834 g_mutex_unlock(&cb_info->api_mutex[api]);
1835 } else if (api == MUSE_CAMERA_CB_EVENT) {
1836 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1837 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1838 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1841 switch (cam_msg->event_class) {
1842 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1843 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1845 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1846 cam_idle_event = g_new0(camera_idle_event_s, 1);
1847 if (cam_idle_event == NULL) {
1848 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1852 cam_idle_event->event = cam_msg->event;
1853 cam_idle_event->cb_info = cb_info;
1855 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1856 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1858 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1859 type, cam_msg->event, cam_idle_event);
1861 g_mutex_lock(&g_cam_idle_event_lock);
1862 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1863 g_mutex_unlock(&g_cam_idle_event_lock);
1865 g_idle_add_full(G_PRIORITY_DEFAULT,
1866 (GSourceFunc)__camera_idle_event_callback,
1867 (gpointer)cam_idle_event,
1871 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1875 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1881 g_mutex_lock(&handler_info->mutex);
1884 /* remove remained event */
1885 while (!g_queue_is_empty(handler_info->queue)) {
1886 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1888 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1889 __camera_release_tfd(cam_msg->tfd);
1892 CAM_LOG_WARNING("t:%d NULL message", type);
1896 g_mutex_unlock(&handler_info->mutex);
1898 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1904 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1906 camera_idle_event_s *cam_idle_event = NULL;
1909 if (cb_info == NULL) {
1910 CAM_LOG_ERROR("cb_info is NULL");
1914 g_mutex_lock(&g_cam_idle_event_lock);
1916 if (cb_info->idle_event_list == NULL) {
1917 CAM_LOG_INFO("No remained idle event");
1918 g_mutex_unlock(&g_cam_idle_event_lock);
1922 list = cb_info->idle_event_list;
1925 cam_idle_event = list->data;
1926 list = g_list_next(list);
1928 if (!cam_idle_event) {
1929 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1933 if (g_idle_remove_by_data(cam_idle_event)) {
1934 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1936 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1938 g_free(cam_idle_event);
1939 cam_idle_event = NULL;
1944 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1945 cam_idle_event, cam_idle_event->event);
1947 cam_idle_event->cb_info = NULL;
1949 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1952 g_list_free(cb_info->idle_event_list);
1953 cb_info->idle_event_list = NULL;
1955 g_mutex_unlock(&g_cam_idle_event_lock);
1959 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1961 camera_message_s *cam_msg = NULL;
1963 if (!cb_info || !msg) {
1964 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1968 cam_msg = g_new0(camera_message_s, 1);
1970 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1975 cam_msg->event = event;
1976 cam_msg->event_class = event_class;
1979 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1981 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1983 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1984 api, event, event_class);
1986 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1987 if (!cb_info->preview_cb_info.thread) {
1988 LOGI("The thread for preview cb is not created yet, create it now");
1989 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1990 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1991 CAM_LOG_ERROR("failed to create thread for preview cb");
1997 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1998 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1999 g_cond_signal(&cb_info->preview_cb_info.cond);
2000 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
2001 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
2002 g_mutex_lock(&cb_info->capture_cb_info.mutex);
2003 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
2004 g_cond_signal(&cb_info->capture_cb_info.cond);
2005 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
2007 g_mutex_lock(&cb_info->msg_handler_info.mutex);
2008 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
2009 g_cond_signal(&cb_info->msg_handler_info.cond);
2010 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
2017 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
2019 int ret = CAMERA_ERROR_NONE;
2023 int event_class = -1;
2027 if (!cb_info || !msg) {
2028 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
2032 CAM_LOG_DEBUG("msg[%s]", msg);
2034 if (!muse_camera_msg_get(api, msg)) {
2035 CAM_LOG_ERROR("failed to get camera api");
2039 if (api == MUSE_CAMERA_CB_EVENT) {
2040 if (!muse_camera_msg_get(event, msg) ||
2041 !muse_camera_msg_get(event_class, msg)) {
2042 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
2046 if (!muse_camera_msg_get(api_class, msg)) {
2047 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
2052 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
2053 if (api >= MUSE_CAMERA_API_MAX) {
2054 CAM_LOG_ERROR("invalid api %d", api);
2058 if (!muse_camera_msg_get(ret, msg)) {
2059 CAM_LOG_ERROR("failed to get camera ret");
2063 g_mutex_lock(&cb_info->api_mutex[api]);
2066 case MUSE_CAMERA_API_CREATE:
2067 if (ret != CAMERA_ERROR_NONE) {
2068 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2069 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
2072 case MUSE_CAMERA_API_DESTROY:
2073 if (ret == CAMERA_ERROR_NONE) {
2074 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2075 CAM_LOG_INFO("camera destroy done. close client cb handler");
2079 muse_camera_msg_get(get_type, msg);
2080 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
2081 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
2082 muse_camera_msg_get(get_index, msg);
2085 case MUSE_CAMERA_GET_TYPE_INT:
2086 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
2088 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
2089 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
2090 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
2092 case MUSE_CAMERA_GET_TYPE_ARRAY:
2094 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
2095 muse_core_msg_deserialize("get_value",
2096 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2097 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
2098 cb_info->get_display_roi_area[0],
2099 cb_info->get_display_roi_area[1],
2100 cb_info->get_display_roi_area[2],
2101 cb_info->get_display_roi_area[3]);
2103 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
2104 muse_core_msg_deserialize("get_value",
2105 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2106 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2107 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2109 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2110 muse_core_msg_deserialize("get_value",
2111 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2112 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2113 cb_info->get_extra_preview_stream_format[0],
2114 cb_info->get_extra_preview_stream_format[1],
2115 cb_info->get_extra_preview_stream_format[2],
2116 cb_info->get_extra_preview_stream_format[3]);
2119 CAM_LOG_WARNING("unknown api[%d]", api);
2123 case MUSE_CAMERA_GET_TYPE_STRING:
2124 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2127 CAM_LOG_WARNING("unknown type %d", get_type);
2134 if (cb_info->api_waiting[api] > 0) {
2135 cb_info->api_ret[api] = ret;
2136 cb_info->api_activating[api] = TRUE;
2138 g_cond_broadcast(&cb_info->api_cond[api]);
2140 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2143 g_mutex_unlock(&cb_info->api_mutex[api]);
2144 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2145 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2147 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2152 static gpointer __camera_msg_recv_func(gpointer data)
2155 int recv_length = 0;
2156 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2157 char *recv_msg = NULL;
2158 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2161 CAM_LOG_ERROR("cb_info NULL");
2165 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2167 recv_msg = cb_info->recv_msg;
2169 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2170 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2171 tfd[i] = CAMERA_FD_INIT;
2173 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2174 if (recv_length <= 0) {
2175 cb_info->is_server_connected = FALSE;
2176 CAM_LOG_ERROR("receive msg failed - server disconnected");
2180 if (CAMERA_IS_FD_VALID(tfd[0]))
2181 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2183 recv_msg[recv_length] = '\0';
2185 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2187 __camera_process_msg(cb_info, recv_msg, tfd);
2190 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2193 if (!cb_info->is_server_connected) {
2194 char *error_msg = NULL;
2196 if (cb_info->bufmgr == NULL) {
2197 CAM_LOG_ERROR("No need to send error(handle is not created)");
2201 if (cb_info->fd < 0) {
2202 CAM_LOG_ERROR("fd is closed in client side");
2206 /* send error msg for server disconnection */
2207 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2208 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2209 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2213 CAM_LOG_ERROR("error_msg failed");
2217 __camera_add_msg_to_queue(cb_info,
2218 MUSE_CAMERA_CB_EVENT,
2219 MUSE_CAMERA_EVENT_TYPE_ERROR,
2220 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2224 muse_core_msg_free(error_msg);
2227 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2228 if (cb_info->api_waiting[i])
2229 g_cond_broadcast(&cb_info->api_cond[i]);
2232 CAM_LOG_ERROR("add error msg for service disconnection done");
2240 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2241 int type, const char *thread_name, camera_cb_info_s *cb_info)
2243 if (!handler_info || !thread_name || !cb_info) {
2244 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2245 type, handler_info, thread_name, cb_info);
2249 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2251 if (handler_info->thread) {
2252 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2256 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2258 handler_info->type = type;
2259 handler_info->queue = g_queue_new();
2260 if (handler_info->queue == NULL) {
2261 CAM_LOG_ERROR("t:%d queue failed", type);
2265 handler_info->cb_info = (void *)cb_info;
2266 g_atomic_int_set(&handler_info->running, 1);
2268 handler_info->thread = g_thread_try_new(thread_name,
2269 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2270 if (handler_info->thread == NULL) {
2271 CAM_LOG_ERROR("t:%d thread failed", type);
2273 g_queue_free(handler_info->queue);
2274 handler_info->queue = NULL;
2279 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2285 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2287 GThread *thread = NULL;
2289 if (!handler_info) {
2290 CAM_LOG_ERROR("NULL handler");
2294 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2296 if (!handler_info->thread) {
2297 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2301 thread = handler_info->thread;
2302 handler_info->thread = NULL;
2304 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2306 g_atomic_int_set(&handler_info->running, 0);
2307 g_cond_signal(&handler_info->cond);
2309 g_clear_pointer(&locker, g_mutex_locker_free);
2311 g_thread_join(thread);
2313 g_queue_free(handler_info->queue);
2314 handler_info->queue = NULL;
2316 CAM_LOG_INFO("t:%d done", handler_info->type);
2320 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2325 CAM_LOG_ERROR("NULL cb_info");
2329 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2330 g_mutex_init(&cb_info->api_mutex[i]);
2331 g_cond_init(&cb_info->api_cond[i]);
2334 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2335 g_mutex_init(&cb_info->user_cb_mutex[i]);
2337 g_mutex_init(&cb_info->fd_lock);
2338 g_mutex_init(&cb_info->mp_data_mutex);
2339 g_mutex_init(&cb_info->bridge_lock);
2341 g_mutex_init(&cb_info->msg_handler_info.mutex);
2342 g_mutex_init(&cb_info->preview_cb_info.mutex);
2343 g_mutex_init(&cb_info->capture_cb_info.mutex);
2344 g_cond_init(&cb_info->msg_handler_info.cond);
2345 g_cond_init(&cb_info->preview_cb_info.cond);
2346 g_cond_init(&cb_info->capture_cb_info.cond);
2348 CAM_LOG_INFO("done");
2352 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2357 CAM_LOG_ERROR("NULL cb_info");
2361 g_mutex_clear(&cb_info->msg_handler_info.mutex);
2362 g_mutex_clear(&cb_info->preview_cb_info.mutex);
2363 g_mutex_clear(&cb_info->capture_cb_info.mutex);
2364 g_cond_clear(&cb_info->msg_handler_info.cond);
2365 g_cond_clear(&cb_info->preview_cb_info.cond);
2366 g_cond_clear(&cb_info->capture_cb_info.cond);
2368 g_mutex_clear(&cb_info->fd_lock);
2369 g_mutex_clear(&cb_info->mp_data_mutex);
2370 g_mutex_clear(&cb_info->bridge_lock);
2372 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2373 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2375 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2376 g_mutex_clear(&cb_info->api_mutex[i]);
2377 g_cond_clear(&cb_info->api_cond[i]);
2380 CAM_LOG_INFO("done");
2384 static camera_preview_cb_monitoring_info_s *__camera_preview_cb_monitoring_info_create(int stream_id)
2386 camera_preview_cb_monitoring_info_s *new_info = g_new0(camera_preview_cb_monitoring_info_s, 1);
2388 new_info->stream_id = stream_id;
2389 new_info->total = g_new0(monitoring_info_sub_s, 1);
2390 new_info->interval = g_new0(monitoring_info_sub_s, 1);
2391 new_info->timer_calling = g_timer_new();
2392 new_info->timer_interval = g_timer_new();
2394 CAM_LOG_INFO("create preview cb monitoring info[%p]", new_info);
2400 static void __camera_preview_cb_monitoring_info_destroy(camera_preview_cb_monitoring_info_s *info)
2405 g_timer_destroy(info->timer_calling);
2406 g_timer_destroy(info->timer_interval);
2407 g_free(info->total);
2408 g_free(info->interval);
2410 CAM_LOG_INFO("destroy preview cb monitoring info[%p]", info);
2416 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2419 camera_cb_info_s *cb_info = NULL;
2421 g_return_val_if_fail(sockfd > 0, NULL);
2423 cb_info = g_new0(camera_cb_info_s, 1);
2425 CAM_LOG_ERROR("cb_info failed");
2429 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2431 __camera_mutex_cond_init(cb_info);
2433 /* message handler thread */
2434 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2435 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2436 CAM_LOG_ERROR("msg_handler_info failed");
2440 /* message handler thread for capture callback */
2441 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2442 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2443 CAM_LOG_ERROR("capture_cb_info failed");
2447 cb_info->fd = sockfd;
2449 /* message receive thread */
2450 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2451 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2452 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2453 if (cb_info->msg_recv_thread == NULL) {
2454 CAM_LOG_ERROR("message receive thread creation failed");
2459 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2460 cb_info->fds[i] = CAMERA_FD_INIT;
2462 cb_info->is_server_connected = TRUE;
2464 cb_info->monitoring_info_preview = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW);
2465 cb_info->monitoring_info_preview_mp = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW_MP);
2466 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2467 cb_info->monitoring_info_preview_ex[i] = __camera_preview_cb_monitoring_info_create(i);
2473 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2474 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2476 __camera_mutex_cond_clear(cb_info);
2487 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2492 CAM_LOG_ERROR("NULL cb_info");
2496 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2498 g_thread_join(cb_info->msg_recv_thread);
2499 cb_info->msg_recv_thread = NULL;
2501 CAM_LOG_INFO("msg_recv thread removed");
2503 /* destroy msg handler threads */
2504 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2505 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2506 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2508 __camera_mutex_cond_clear(cb_info);
2510 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2511 muse_client_close(cb_info->fd);
2512 cb_info->fd = CAMERA_FD_INIT;
2515 if (cb_info->bufmgr) {
2516 tbm_bufmgr_deinit(cb_info->bufmgr);
2517 cb_info->bufmgr = NULL;
2519 if (cb_info->pkt_fmt) {
2520 media_format_unref(cb_info->pkt_fmt);
2521 cb_info->pkt_fmt = NULL;
2524 if (cb_info->dp_interface) {
2525 mm_display_interface_deinit(cb_info->dp_interface);
2526 cb_info->dp_interface = NULL;
2529 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview);
2530 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_mp);
2531 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2532 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_ex[i]);
2538 int _camera_start_evas_rendering(camera_h camera)
2540 camera_cli_s *pc = (camera_cli_s *)camera;
2542 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2544 CAM_LOG_INFO("start");
2546 if (!pc->cb_info->is_evas_render) {
2547 CAM_LOG_ERROR("EVAS surface is not set");
2548 return CAMERA_ERROR_NONE;
2551 /* set evas render flag as RUN */
2552 pc->cb_info->run_evas_render = true;
2554 return CAMERA_ERROR_NONE;
2558 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2560 int ret = CAMERA_ERROR_NONE;
2561 camera_cli_s *pc = (camera_cli_s *)camera;
2563 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2565 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2567 if (!pc->cb_info->is_evas_render) {
2568 CAM_LOG_ERROR("EVAS surface is not set");
2569 return CAMERA_ERROR_NONE;
2572 /* set evas render flag as STOP and release buffers */
2573 pc->cb_info->run_evas_render = false;
2575 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2576 if (ret == MM_ERROR_NONE) {
2577 ret = CAMERA_ERROR_NONE;
2579 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2580 ret = CAMERA_ERROR_INVALID_OPERATION;
2587 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2589 int ret = CAMERA_ERROR_NONE;
2590 int sock_fd = CAMERA_FD_INIT;
2591 int module_index = -1;
2593 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2595 /* create muse connection */
2596 if (!key || !value) {
2597 CAM_LOG_ERROR("NULL pointer");
2598 return CAMERA_ERROR_INVALID_PARAMETER;
2601 sock_fd = muse_client_new();
2603 CAM_LOG_ERROR("muse_client_new failed");
2604 return CAMERA_ERROR_INVALID_OPERATION;
2607 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2608 CAM_LOG_ERROR("muse client get module index failed");
2609 ret = CAMERA_ERROR_INVALID_OPERATION;
2613 msg = muse_core_msg_new(api,
2614 MUSE_TYPE_INT, "module", module_index,
2615 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2618 CAM_LOG_ERROR("msg failed");
2619 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2623 ret = muse_core_msg_send(sock_fd, msg);
2625 muse_core_msg_free(msg);
2629 CAM_LOG_ERROR("send msg failed");
2630 ret = CAMERA_ERROR_INVALID_OPERATION;
2634 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2636 CAM_LOG_ERROR("recv msg failed %d", errno);
2637 ret = CAMERA_ERROR_INVALID_OPERATION;
2641 if (!muse_camera_msg_get(ret, recv_msg)) {
2642 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2643 ret = CAMERA_ERROR_INVALID_OPERATION;
2647 if (ret == CAMERA_ERROR_NONE)
2648 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2650 CAM_LOG_INFO("api %d - value %d", api, *value);
2653 if (CAMERA_IS_FD_VALID(sock_fd)) {
2654 muse_client_close(sock_fd);
2655 sock_fd = CAMERA_FD_INIT;
2662 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2664 int sock_fd = CAMERA_FD_INIT;
2665 char *send_msg = NULL;
2667 int ret = CAMERA_ERROR_NONE;
2668 camera_cli_s *pc = NULL;
2669 tbm_bufmgr bufmgr = NULL;
2671 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2672 int module_index = -1;
2673 int device_type = (int)device;
2675 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2677 sock_fd = muse_client_new();
2679 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2680 ret = CAMERA_ERROR_INVALID_OPERATION;
2684 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2685 CAM_LOG_ERROR("muse client get module index failed");
2686 ret = CAMERA_ERROR_INVALID_OPERATION;
2690 send_msg = muse_core_msg_new(api,
2691 MUSE_TYPE_INT, "module", module_index,
2692 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2693 MUSE_TYPE_INT, "is_network", (int)is_network,
2697 CAM_LOG_ERROR("NULL msg");
2698 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2702 send_ret = muse_core_msg_send(sock_fd, send_msg);
2704 muse_core_msg_free(send_msg);
2708 CAM_LOG_ERROR("send msg failed %d", errno);
2709 ret = CAMERA_ERROR_INVALID_OPERATION;
2713 pc = g_new0(camera_cli_s, 1);
2715 CAM_LOG_ERROR("camera_cli_s alloc failed");
2716 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2720 bufmgr = tbm_bufmgr_init(-1);
2721 if (bufmgr == NULL) {
2722 CAM_LOG_ERROR("get tbm bufmgr failed");
2723 ret = CAMERA_ERROR_INVALID_OPERATION;
2727 pc->cb_info = __camera_client_callback_new(sock_fd);
2728 if (pc->cb_info == NULL) {
2729 CAM_LOG_ERROR("cb_info alloc failed");
2730 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2734 sock_fd = CAMERA_FD_INIT;
2736 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2738 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2740 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2742 if (ret == CAMERA_ERROR_NONE) {
2743 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2744 int user_buffer_supported = 0;
2745 int log_level = CAMERA_LOG_LEVEL_INFO;
2746 intptr_t handle = 0;
2748 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2750 CAM_LOG_ERROR("Receiving Handle Failed!!");
2751 ret = CAMERA_ERROR_INVALID_OPERATION;
2755 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2756 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2757 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2759 pc->remote_handle = handle;
2760 pc->cb_info->bufmgr = bufmgr;
2761 pc->cb_info->preview_format = preview_format;
2762 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2763 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2764 pc->cb_info->is_network = is_network;
2765 g_camera_log_level = log_level;
2767 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2768 preview_format, user_buffer_supported, g_camera_log_level);
2771 CAM_LOG_ERROR("NULL out handle");
2772 ret= CAMERA_ERROR_INVALID_PARAMETER;
2776 *camera = (camera_h)pc;
2778 /* get display interface handle */
2779 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2780 CAM_LOG_WARNING("display interface init failed");
2789 tbm_bufmgr_deinit(bufmgr);
2793 if (CAMERA_IS_FD_VALID(sock_fd)) {
2794 muse_client_close(sock_fd);
2795 sock_fd = CAMERA_FD_INIT;
2800 int temp_fd = pc->cb_info->fd;
2802 /* pc->cb_info->fd should be closed,
2803 because g_thread_join for msg_recv_thread is not returned
2804 in __camera_client_callback_destroy. */
2805 if (CAMERA_IS_FD_VALID(temp_fd)) {
2806 pc->cb_info->fd = CAMERA_FD_INIT;
2807 muse_client_close(temp_fd);
2810 __camera_client_callback_destroy(pc->cb_info);
2817 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2824 int camera_create(camera_device_e device, camera_h *camera)
2826 return _camera_create_private(device, false, camera);
2830 int camera_change_device(camera_h camera, camera_device_e device)
2833 int ret = CAMERA_ERROR_NONE;
2834 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2835 camera_cli_s *pc = (camera_cli_s *)camera;
2836 camera_msg_param param;
2838 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2840 CAMERA_MSG_PARAM_SET(param, INT, device);
2842 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2844 if (ret == CAMERA_ERROR_NONE) {
2845 /* reset callback and user data */
2846 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2847 pc->cb_info->user_cb[i] = NULL;
2848 pc->cb_info->user_data[i] = NULL;
2856 int camera_destroy(camera_h camera)
2858 int ret = CAMERA_ERROR_NONE;
2859 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2860 camera_cli_s *pc = (camera_cli_s *)camera;
2862 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2864 CAM_LOG_INFO("Enter");
2866 if (pc->cb_info->is_server_connected)
2867 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2869 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2871 if (ret == CAMERA_ERROR_NONE) {
2872 __camera_deactivate_idle_event_all(pc->cb_info);
2873 __camera_client_callback_destroy(pc->cb_info);
2880 CAM_LOG_INFO("ret : 0x%x", ret);
2885 int camera_start_preview(camera_h camera)
2888 int ret = CAMERA_ERROR_NONE;
2890 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2891 camera_cli_s *pc = (camera_cli_s *)camera;
2892 camera_state_e current_state = CAMERA_STATE_NONE;
2894 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2896 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2897 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2899 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2900 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2901 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2902 pc->cb_info->dp_info.type);
2903 return CAMERA_ERROR_INVALID_OPERATION;
2906 ret = camera_get_state(camera, ¤t_state);
2907 if (ret != CAMERA_ERROR_NONE) {
2908 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2912 if (current_state == CAMERA_STATE_CREATED) {
2913 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview);
2914 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_mp);
2915 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2916 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_ex[i]);
2918 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2919 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2920 CAM_LOG_ERROR("preview_cb_info failed");
2921 return CAMERA_ERROR_INVALID_OPERATION;
2924 if (pc->cb_info->user_buffer_supported) {
2925 if (!__camera_allocate_preview_buffer(camera)) {
2926 ret = CAMERA_ERROR_INVALID_OPERATION;
2930 fds = pc->cb_info->fds;
2934 pc->cb_info->invoke_preview_cb = TRUE;
2936 _camera_msg_send(api, fds, pc->cb_info, &ret,
2937 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2938 CAMERA_CB_NO_TIMEOUT);
2940 CAMERA_CB_TIMEOUT_FOR_PREVIEW);
2942 if (ret != CAMERA_ERROR_NONE)
2945 if (pc->cb_info->is_evas_render) {
2946 ret = _camera_start_evas_rendering(camera);
2947 if (ret != CAMERA_ERROR_NONE) {
2948 CAM_LOG_ERROR("stop preview because of error");
2949 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2954 CAM_LOG_INFO("done");
2956 return CAMERA_ERROR_NONE;
2959 if (current_state == CAMERA_STATE_CREATED) {
2960 if (pc->cb_info->user_buffer_supported)
2961 __camera_release_preview_buffer(camera);
2963 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2966 CAM_LOG_ERROR("failed : 0x%x", ret);
2972 int camera_stop_preview(camera_h camera)
2974 int ret = CAMERA_ERROR_NONE;
2975 camera_cli_s *pc = (camera_cli_s *)camera;
2976 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2977 camera_state_e current_state = CAMERA_STATE_NONE;
2979 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2981 CAM_LOG_INFO("Enter");
2984 if (pc->cb_info->is_evas_render) {
2985 ret = camera_get_state(camera, ¤t_state);
2986 if (ret != CAMERA_ERROR_NONE) {
2987 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2991 if (current_state == CAMERA_STATE_PREVIEW) {
2992 ret = _camera_stop_evas_rendering(camera, false);
2993 if (ret != CAMERA_ERROR_NONE)
2999 pc->cb_info->invoke_preview_cb = FALSE;
3001 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3003 if (ret == CAMERA_ERROR_NONE) {
3004 if (pc->cb_info->user_buffer_supported)
3005 __camera_release_preview_buffer(camera);
3007 /* release remained message for preview callback */
3008 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
3009 } else if (current_state == CAMERA_STATE_PREVIEW) {
3010 CAM_LOG_WARNING("restart evas rendering");
3011 _camera_start_evas_rendering(camera);
3014 CAM_LOG_INFO("ret : 0x%x", ret);
3020 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
3022 int ret = CAMERA_ERROR_NONE;
3023 camera_cli_s *pc = (camera_cli_s *)camera;
3024 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
3026 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3028 CAM_LOG_INFO("Enter");
3030 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3031 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3033 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3034 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3036 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3038 CAM_LOG_INFO("ret : 0x%x", ret);
3044 bool camera_is_supported_continuous_capture(camera_h camera)
3046 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
3050 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)
3052 int ret = CAMERA_ERROR_NONE;
3053 camera_cli_s *pc = (camera_cli_s *)camera;
3054 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
3055 camera_msg_param param;
3058 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3060 CAM_LOG_INFO("Enter");
3062 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3063 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3065 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3066 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3068 value = (count << 16) | interval;
3069 CAMERA_MSG_PARAM_SET(param, INT, value);
3071 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3073 CAM_LOG_INFO("ret : 0x%x", ret);
3079 int camera_stop_continuous_capture(camera_h camera)
3081 int ret = CAMERA_ERROR_NONE;
3082 camera_cli_s *pc = (camera_cli_s *)camera;
3083 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
3085 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3087 CAM_LOG_INFO("Enter");
3089 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3091 CAM_LOG_INFO("ret : 0x%x", ret);
3097 bool camera_is_supported_face_detection(camera_h camera)
3099 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
3103 bool camera_is_supported_zero_shutter_lag(camera_h camera)
3105 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
3109 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
3111 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
3115 bool camera_is_supported_extra_preview(camera_h camera)
3117 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
3121 int camera_get_device_count(camera_h camera, int *device_count)
3123 int ret = CAMERA_ERROR_NONE;
3124 camera_cli_s *pc = (camera_cli_s *)camera;
3125 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
3127 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3129 CAM_LOG_INFO("Enter");
3131 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3133 if (ret == CAMERA_ERROR_NONE)
3134 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3136 CAM_LOG_INFO("ret : 0x%x", ret);
3141 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3143 int ret = CAMERA_ERROR_NONE;
3144 camera_cli_s *pc = (camera_cli_s *)camera;
3145 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3147 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3149 CAM_LOG_INFO("Enter");
3151 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3153 if (ret == CAMERA_ERROR_NONE) {
3154 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3156 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3157 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3159 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3162 CAM_LOG_INFO("ret : 0x%x", ret);
3167 int camera_stop_face_detection(camera_h camera)
3169 int ret = CAMERA_ERROR_NONE;
3170 camera_cli_s *pc = (camera_cli_s *)camera;
3171 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3173 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3175 CAM_LOG_INFO("Enter");
3177 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3179 if (ret == CAMERA_ERROR_NONE) {
3180 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3182 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3183 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3185 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3188 CAM_LOG_INFO("ret : 0x%x", ret);
3193 int camera_get_state(camera_h camera, camera_state_e *state)
3195 int ret = CAMERA_ERROR_NONE;
3196 camera_cli_s *pc = (camera_cli_s *)camera;
3197 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3199 if (!pc || !pc->cb_info || !state) {
3200 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3201 return CAMERA_ERROR_INVALID_PARAMETER;
3204 CAM_LOG_INFO("Enter");
3206 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3208 if (ret == CAMERA_ERROR_NONE)
3209 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3211 CAM_LOG_INFO("ret : 0x%x", ret);
3216 int camera_start_focusing(camera_h camera, bool continuous)
3218 int ret = CAMERA_ERROR_NONE;
3219 camera_cli_s *pc = (camera_cli_s *)camera;
3220 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3221 camera_msg_param param;
3222 int is_continuous = (int)continuous;
3224 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3226 CAM_LOG_INFO("Enter");
3228 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3230 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3232 CAM_LOG_INFO("ret : 0x%x", ret);
3237 int camera_cancel_focusing(camera_h camera)
3239 int ret = CAMERA_ERROR_NONE;
3240 camera_cli_s *pc = (camera_cli_s *)camera;
3241 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3243 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3245 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3247 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3249 CAM_LOG_INFO("ret : 0x%x", ret);
3255 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3257 int mm_ret = MM_ERROR_NONE;
3258 int ret = CAMERA_ERROR_NONE;
3259 camera_cli_s *pc = (camera_cli_s *)camera;
3260 camera_cb_info_s *cb_info = NULL;
3261 camera_state_e current_state = CAMERA_STATE_NONE;
3262 camera_msg_param param;
3263 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3264 muse_camera_display_info_s *dp_info = NULL;
3266 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3268 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3269 CAM_LOG_ERROR("invalid type %d", type);
3270 return CAMERA_ERROR_INVALID_PARAMETER;
3273 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3274 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3275 return CAMERA_ERROR_INVALID_PARAMETER;
3278 cb_info = (camera_cb_info_s *)pc->cb_info;
3279 dp_info = &cb_info->dp_info;
3281 ret = camera_get_state(camera, ¤t_state);
3282 if (ret != CAMERA_ERROR_NONE) {
3283 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3287 if (current_state != CAMERA_STATE_CREATED) {
3288 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3289 return CAMERA_ERROR_INVALID_STATE;
3292 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3294 if (type != MM_DISPLAY_TYPE_NONE) {
3295 /* check display interface handle */
3296 if (!cb_info->dp_interface) {
3297 CAM_LOG_ERROR("display interface not supported");
3298 return CAMERA_ERROR_NOT_SUPPORTED;
3301 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3302 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3303 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3304 return CAMERA_ERROR_NOT_SUPPORTED;
3305 } else if (mm_ret != MM_ERROR_NONE) {
3306 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3307 return CAMERA_ERROR_INVALID_OPERATION;
3310 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3311 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3313 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3314 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3315 dp_info->window_rect.width, dp_info->window_rect.height);
3316 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3318 camera_flip_e flip = CAMERA_FLIP_NONE;
3319 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3320 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3327 camera_get_display_flip(camera, &flip);
3328 camera_get_display_mode(camera, &mode);
3329 camera_get_display_rotation(camera, &rotation);
3330 camera_is_display_visible(camera, &visible);
3332 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3333 flip, mode, rotation, visible);
3335 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3336 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3337 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3338 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3340 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3341 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3342 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3343 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3349 if (mm_ret != MM_ERROR_NONE) {
3350 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3351 return CAMERA_ERROR_INVALID_OPERATION;
3354 dp_info->type = type;
3356 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3358 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3360 if (ret == CAMERA_ERROR_NONE)
3361 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3367 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3369 CAM_LOG_INFO("type %d, display %p", type, display);
3370 return _camera_set_display(camera, (mm_display_type_e)type, display);
3374 int camera_set_preview_resolution(camera_h camera, int width, int height)
3376 int ret = CAMERA_ERROR_NONE;
3377 camera_state_e current_state = CAMERA_STATE_NONE;
3378 camera_cli_s *pc = (camera_cli_s *)camera;
3379 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3380 camera_msg_param param;
3383 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3385 if (pc->cb_info->is_evas_render) {
3386 ret = camera_get_state(camera, ¤t_state);
3387 if (ret != CAMERA_ERROR_NONE) {
3388 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3392 if (current_state == CAMERA_STATE_PREVIEW) {
3393 ret = _camera_stop_evas_rendering(camera, true);
3394 if (ret != CAMERA_ERROR_NONE)
3399 value = (width << 16) | height;
3400 CAMERA_MSG_PARAM_SET(param, INT, value);
3402 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3404 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3406 CAM_LOG_INFO("ret : 0x%x", ret);
3408 if (current_state == CAMERA_STATE_PREVIEW) {
3409 CAM_LOG_WARNING("restart evas rendering");
3410 _camera_start_evas_rendering(camera);
3417 int camera_set_capture_resolution(camera_h camera, int width, int height)
3419 int ret = CAMERA_ERROR_NONE;
3420 camera_cli_s *pc = (camera_cli_s *)camera;
3421 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3422 camera_msg_param param;
3425 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3427 CAM_LOG_INFO("Enter");
3429 value = (width << 16) | height;
3430 CAMERA_MSG_PARAM_SET(param, INT, value);
3432 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3434 CAM_LOG_INFO("ret : 0x%x", ret);
3440 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3442 int ret = CAMERA_ERROR_NONE;
3443 int set_format = (int)format;
3444 camera_cli_s *pc = (camera_cli_s *)camera;
3445 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3446 camera_msg_param param;
3448 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3450 CAM_LOG_INFO("Enter - format %d", set_format);
3452 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3454 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3456 CAM_LOG_INFO("ret : 0x%x", ret);
3462 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3464 int ret = CAMERA_ERROR_NONE;
3465 int set_format = (int)format;
3466 camera_msg_param param;
3467 camera_cli_s *pc = (camera_cli_s *)camera;
3468 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3470 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3472 CAM_LOG_INFO("Enter - format %d", set_format);
3474 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3476 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3478 if (ret == CAMERA_ERROR_NONE)
3479 pc->cb_info->preview_format = set_format;
3481 CAM_LOG_INFO("ret : 0x%x", ret);
3487 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3489 int ret = CAMERA_ERROR_NONE;
3490 camera_cli_s *pc = (camera_cli_s *)camera;
3491 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3493 if (!pc || !pc->cb_info || !width || !height) {
3494 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3495 return CAMERA_ERROR_INVALID_PARAMETER;
3498 CAM_LOG_INFO("Enter");
3500 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3502 if (ret == CAMERA_ERROR_NONE) {
3503 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3504 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3507 CAM_LOG_INFO("ret : 0x%x", ret);
3513 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3515 int ret = CAMERA_ERROR_NONE;
3516 int set_rotation = (int)rotation;
3517 camera_cli_s *pc = (camera_cli_s *)camera;
3518 camera_msg_param param;
3520 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3522 if (pc->cb_info->is_evas_render) {
3523 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3524 if (ret != MM_ERROR_NONE) {
3525 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3526 return CAMERA_ERROR_INVALID_OPERATION;
3530 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3532 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3538 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3540 int ret = CAMERA_ERROR_NONE;
3541 camera_cli_s *pc = (camera_cli_s *)camera;
3543 if (!pc || !pc->cb_info || !rotation) {
3544 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3545 return CAMERA_ERROR_INVALID_PARAMETER;
3548 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3550 if (ret == CAMERA_ERROR_NONE)
3551 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3557 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3559 int ret = CAMERA_ERROR_NONE;
3560 int set_flip = (int)flip;
3561 camera_cli_s *pc = (camera_cli_s *)camera;
3562 camera_msg_param param;
3564 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3566 if (pc->cb_info->is_evas_render) {
3567 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3568 if (ret != MM_ERROR_NONE) {
3569 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3570 return CAMERA_ERROR_INVALID_OPERATION;
3574 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3576 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3582 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3584 int ret = CAMERA_ERROR_NONE;
3585 camera_cli_s *pc = (camera_cli_s *)camera;
3587 if (!pc || !pc->cb_info || !flip) {
3588 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3589 return CAMERA_ERROR_INVALID_PARAMETER;
3592 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3594 if (ret == CAMERA_ERROR_NONE)
3595 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3601 int camera_set_display_visible(camera_h camera, bool visible)
3603 int ret = CAMERA_ERROR_NONE;
3604 int set_visible = (int)visible;
3605 camera_cli_s *pc = (camera_cli_s *)camera;
3606 camera_msg_param param;
3608 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3610 if (pc->cb_info->is_evas_render) {
3611 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3612 if (ret != MM_ERROR_NONE) {
3613 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3614 return CAMERA_ERROR_INVALID_OPERATION;
3618 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3620 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3626 int camera_is_display_visible(camera_h camera, bool *visible)
3628 int ret = CAMERA_ERROR_NONE;
3629 camera_cli_s *pc = (camera_cli_s *)camera;
3631 if (!pc || !pc->cb_info || !visible) {
3632 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3633 return CAMERA_ERROR_INVALID_PARAMETER;
3636 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3638 if (ret == CAMERA_ERROR_NONE)
3639 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3645 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3647 int ret = CAMERA_ERROR_NONE;
3648 int set_mode = (int)mode;
3649 camera_cli_s *pc = (camera_cli_s *)camera;
3650 camera_msg_param param;
3652 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3654 if (pc->cb_info->is_evas_render) {
3655 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3656 if (ret != MM_ERROR_NONE) {
3657 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3658 return CAMERA_ERROR_INVALID_OPERATION;
3662 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3664 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3670 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3672 int ret = CAMERA_ERROR_NONE;
3673 camera_cli_s *pc = (camera_cli_s *)camera;
3675 if (!pc || !pc->cb_info || !mode) {
3676 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3677 return CAMERA_ERROR_INVALID_PARAMETER;
3680 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3682 if (ret == CAMERA_ERROR_NONE)
3683 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3689 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3691 int ret = CAMERA_ERROR_NONE;
3692 int set_hint = (int)hint;
3693 camera_cli_s *pc = (camera_cli_s *)camera;
3694 camera_msg_param param;
3696 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3698 CAM_LOG_INFO("Enter - hint %d", set_hint);
3700 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3702 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3708 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3710 int ret = CAMERA_ERROR_NONE;
3711 camera_cli_s *pc = (camera_cli_s *)camera;
3712 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3714 if (!pc || !pc->cb_info || !hint) {
3715 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3716 return CAMERA_ERROR_INVALID_PARAMETER;
3719 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3721 if (ret == CAMERA_ERROR_NONE) {
3722 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3723 CAM_LOG_INFO("display reuse hint %d", *hint);
3730 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3732 int ret = CAMERA_ERROR_NONE;
3733 camera_cli_s *pc = (camera_cli_s *)camera;
3734 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3736 if (!pc || !pc->cb_info || !width || !height) {
3737 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3738 return CAMERA_ERROR_INVALID_PARAMETER;
3741 CAM_LOG_INFO("Enter");
3743 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3745 if (ret == CAMERA_ERROR_NONE) {
3746 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3747 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3750 CAM_LOG_INFO("ret : 0x%x", ret);
3756 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3758 int ret = CAMERA_ERROR_NONE;
3759 camera_cli_s *pc = (camera_cli_s *)camera;
3760 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3762 if (!pc || !pc->cb_info || !format) {
3763 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3764 return CAMERA_ERROR_INVALID_PARAMETER;
3767 CAM_LOG_INFO("Enter");
3769 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3771 if (ret == CAMERA_ERROR_NONE)
3772 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3774 CAM_LOG_INFO("ret : 0x%x", ret);
3780 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3782 int ret = CAMERA_ERROR_NONE;
3783 camera_cli_s *pc = (camera_cli_s *)camera;
3784 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3786 if (!pc || !pc->cb_info || !format) {
3787 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3788 return CAMERA_ERROR_INVALID_PARAMETER;
3791 CAM_LOG_INFO("Enter");
3793 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3795 if (ret == CAMERA_ERROR_NONE)
3796 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3798 CAM_LOG_INFO("ret : 0x%x", ret);
3804 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3806 int ret = CAMERA_ERROR_NONE;
3807 camera_cli_s *pc = (camera_cli_s *)camera;
3808 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3810 if (!pc || !pc->cb_info || !facing_direction) {
3811 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3812 return CAMERA_ERROR_INVALID_PARAMETER;
3815 CAM_LOG_INFO("Enter");
3817 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3819 if (ret == CAMERA_ERROR_NONE)
3820 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3822 CAM_LOG_INFO("ret : 0x%x", ret);
3828 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3830 int ret = CAMERA_ERROR_NONE;
3831 camera_cli_s *pc = (camera_cli_s *)camera;
3832 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3834 if (!pc || !pc->cb_info || !callback) {
3835 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3836 return CAMERA_ERROR_INVALID_PARAMETER;
3839 CAM_LOG_INFO("Enter");
3841 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3843 if (ret == CAMERA_ERROR_NONE) {
3844 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3846 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3847 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3849 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3852 CAM_LOG_INFO("ret : 0x%x", ret);
3858 int camera_unset_preview_cb(camera_h camera)
3860 int ret = CAMERA_ERROR_NONE;
3861 camera_cli_s *pc = (camera_cli_s *)camera;
3862 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3864 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3866 CAM_LOG_INFO("Enter");
3868 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3870 if (ret == CAMERA_ERROR_NONE) {
3871 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3873 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3874 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3876 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3879 CAM_LOG_INFO("ret : 0x%x", ret);
3885 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3887 int ret = CAMERA_ERROR_NONE;
3888 camera_cli_s *pc = (camera_cli_s *)camera;
3889 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3891 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3893 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3894 CAM_LOG_ERROR("NOT SUPPORTED");
3895 return CAMERA_ERROR_NOT_SUPPORTED;
3898 if (callback == NULL) {
3899 CAM_LOG_ERROR("NULL callback");
3900 return CAMERA_ERROR_INVALID_PARAMETER;
3903 CAM_LOG_INFO("Enter");
3905 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3907 if (ret == CAMERA_ERROR_NONE) {
3908 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3913 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3916 CAM_LOG_INFO("ret : 0x%x", ret);
3922 int camera_unset_media_packet_preview_cb(camera_h camera)
3924 int ret = CAMERA_ERROR_NONE;
3925 camera_cli_s *pc = (camera_cli_s *)camera;
3926 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3928 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3930 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3931 CAM_LOG_ERROR("NOT SUPPORTED");
3932 return CAMERA_ERROR_NOT_SUPPORTED;
3935 CAM_LOG_INFO("Enter");
3937 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3939 if (ret == CAMERA_ERROR_NONE) {
3940 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3942 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3943 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3945 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3948 CAM_LOG_INFO("ret : 0x%x", ret);
3954 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3956 int ret = CAMERA_ERROR_NONE;
3957 camera_cli_s *pc = (camera_cli_s *)camera;
3958 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3960 if (!pc || !pc->cb_info || !callback) {
3961 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3962 return CAMERA_ERROR_INVALID_PARAMETER;
3965 CAM_LOG_INFO("Enter");
3967 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3969 if (ret == CAMERA_ERROR_NONE) {
3970 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3972 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3973 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3975 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3978 CAM_LOG_INFO("ret : 0x%x", ret);
3984 int camera_unset_state_changed_cb(camera_h camera)
3986 int ret = CAMERA_ERROR_NONE;
3987 camera_cli_s *pc = (camera_cli_s *)camera;
3988 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3990 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3992 CAM_LOG_INFO("Enter");
3994 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3996 if (ret == CAMERA_ERROR_NONE) {
3997 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3999 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4000 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4002 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4005 CAM_LOG_INFO("ret : 0x%x", ret);
4011 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4013 int ret = CAMERA_ERROR_NONE;
4014 camera_cli_s *pc = (camera_cli_s *)camera;
4015 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4017 if (!pc || !pc->cb_info || !callback) {
4018 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4019 return CAMERA_ERROR_INVALID_PARAMETER;
4022 CAM_LOG_INFO("Enter");
4024 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4026 if (ret == CAMERA_ERROR_NONE) {
4027 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4029 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4030 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4032 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4035 CAM_LOG_INFO("ret : 0x%x", ret);
4041 int camera_unset_interrupted_cb(camera_h camera)
4043 int ret = CAMERA_ERROR_NONE;
4044 camera_cli_s *pc = (camera_cli_s *)camera;
4045 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4047 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4049 CAM_LOG_INFO("Enter");
4051 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4053 if (ret == CAMERA_ERROR_NONE) {
4054 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4056 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4057 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4059 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4062 CAM_LOG_INFO("ret : 0x%x", ret);
4068 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4070 int ret = CAMERA_ERROR_NONE;
4071 camera_cli_s *pc = (camera_cli_s *)camera;
4072 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4074 if (!pc || !pc->cb_info || !callback) {
4075 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4076 return CAMERA_ERROR_INVALID_PARAMETER;
4079 CAM_LOG_INFO("Enter");
4081 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4083 if (ret == CAMERA_ERROR_NONE) {
4084 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4086 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4087 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4089 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4092 CAM_LOG_INFO("ret : 0x%x", ret);
4098 int camera_unset_interrupt_started_cb(camera_h camera)
4100 int ret = CAMERA_ERROR_NONE;
4101 camera_cli_s *pc = (camera_cli_s *)camera;
4102 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4104 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4106 CAM_LOG_INFO("Enter");
4108 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4110 if (ret == CAMERA_ERROR_NONE) {
4111 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4113 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4114 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4116 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4119 CAM_LOG_INFO("ret : 0x%x", ret);
4125 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4127 int ret = CAMERA_ERROR_NONE;
4128 camera_cli_s *pc = (camera_cli_s *)camera;
4129 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4131 if (!pc || !pc->cb_info || !callback) {
4132 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4133 return CAMERA_ERROR_INVALID_PARAMETER;
4136 CAM_LOG_INFO("Enter");
4138 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4140 if (ret == CAMERA_ERROR_NONE) {
4141 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4143 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4144 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4146 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4149 CAM_LOG_INFO("ret : 0x%x", ret);
4155 int camera_unset_focus_changed_cb(camera_h camera)
4157 int ret = CAMERA_ERROR_NONE;
4158 camera_cli_s *pc = (camera_cli_s *)camera;
4159 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4161 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4163 CAM_LOG_INFO("Enter");
4165 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4167 if (ret == CAMERA_ERROR_NONE) {
4168 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4170 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4171 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4173 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4176 CAM_LOG_INFO("ret : 0x%x", ret);
4182 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4184 int ret = CAMERA_ERROR_NONE;
4185 camera_cli_s *pc = (camera_cli_s *)camera;
4186 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4188 if (!pc || !pc->cb_info || !callback) {
4189 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4190 return CAMERA_ERROR_INVALID_PARAMETER;
4193 CAM_LOG_INFO("Enter");
4195 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4197 if (ret == CAMERA_ERROR_NONE) {
4198 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4200 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4201 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4203 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4206 CAM_LOG_INFO("ret : 0x%x", ret);
4212 int camera_unset_error_cb(camera_h camera)
4214 int ret = CAMERA_ERROR_NONE;
4215 camera_cli_s *pc = (camera_cli_s *)camera;
4216 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4218 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4220 CAM_LOG_INFO("Enter");
4222 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4224 if (ret == CAMERA_ERROR_NONE) {
4225 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4227 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4228 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4230 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4233 CAM_LOG_INFO("ret : 0x%x", ret);
4239 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4241 int ret = CAMERA_ERROR_NONE;
4242 camera_cli_s *pc = (camera_cli_s *)camera;
4243 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4245 if (!pc || !pc->cb_info || !foreach_cb) {
4246 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4247 return CAMERA_ERROR_INVALID_PARAMETER;
4250 CAM_LOG_INFO("Enter");
4252 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4253 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4255 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4257 CAM_LOG_INFO("ret : 0x%x", ret);
4263 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4265 int ret = CAMERA_ERROR_NONE;
4266 camera_cli_s *pc = (camera_cli_s *)camera;
4267 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4269 if (!pc || !pc->cb_info || !foreach_cb) {
4270 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4271 return CAMERA_ERROR_INVALID_PARAMETER;
4274 CAM_LOG_INFO("Enter");
4276 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4277 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4279 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4281 CAM_LOG_INFO("ret : 0x%x", ret);
4287 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4289 int ret = CAMERA_ERROR_NONE;
4290 camera_cli_s *pc = (camera_cli_s *)camera;
4291 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4293 if (!pc || !pc->cb_info || !foreach_cb) {
4294 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4295 return CAMERA_ERROR_INVALID_PARAMETER;
4298 CAM_LOG_INFO("Enter");
4300 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4301 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4303 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4305 CAM_LOG_INFO("ret : 0x%x", ret);
4311 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4313 int ret = CAMERA_ERROR_NONE;
4314 camera_cli_s *pc = (camera_cli_s *)camera;
4315 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4317 if (!pc || !pc->cb_info || !foreach_cb) {
4318 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4319 return CAMERA_ERROR_INVALID_PARAMETER;
4322 CAM_LOG_INFO("Enter");
4324 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4325 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4327 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4329 CAM_LOG_INFO("ret : 0x%x", ret);
4335 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4337 int ret = CAMERA_ERROR_NONE;
4338 camera_cli_s *pc = (camera_cli_s *)camera;
4339 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4341 if (!pc || !pc->cb_info || !width || !height) {
4342 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4343 return CAMERA_ERROR_INVALID_PARAMETER;
4346 CAM_LOG_INFO("Enter");
4347 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4349 if (ret == CAMERA_ERROR_NONE) {
4350 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4351 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4354 CAM_LOG_INFO("ret : 0x%x", ret);
4360 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4362 int ret = CAMERA_ERROR_NONE;
4363 camera_cli_s *pc = (camera_cli_s *)camera;
4364 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4366 if (!pc || !pc->cb_info || !angle) {
4367 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4368 return CAMERA_ERROR_INVALID_PARAMETER;
4371 CAM_LOG_INFO("Enter");
4373 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4375 if (ret == CAMERA_ERROR_NONE)
4376 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4378 CAM_LOG_INFO("ret : 0x%x", ret);
4384 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4386 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4390 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4392 int ret = CAMERA_ERROR_NONE;
4393 camera_cli_s *pc = (camera_cli_s *)camera;
4394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4396 if (!pc || !pc->cb_info || !mode) {
4397 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4398 return CAMERA_ERROR_INVALID_PARAMETER;
4401 CAM_LOG_INFO("Enter");
4403 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4405 if (ret == CAMERA_ERROR_NONE)
4406 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4408 CAM_LOG_INFO("ret : 0x%x", ret);
4414 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4416 int ret = CAMERA_ERROR_NONE;
4417 camera_cli_s *pc = (camera_cli_s *)camera;
4418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4420 if (!pc || !pc->cb_info || !foreach_cb) {
4421 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4422 return CAMERA_ERROR_INVALID_PARAMETER;
4425 CAM_LOG_INFO("Enter");
4427 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4428 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4430 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4432 CAM_LOG_INFO("Finish, return :%x", ret);
4438 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4440 int ret = CAMERA_ERROR_NONE;
4441 camera_cli_s *pc = (camera_cli_s *)camera;
4442 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4443 camera_msg_param param;
4444 int set_fps = (int)fps;
4446 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4448 CAM_LOG_INFO("Enter");
4450 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4452 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4454 CAM_LOG_INFO("ret : 0x%x", ret);
4460 int camera_attr_set_image_quality(camera_h camera, int quality)
4462 int ret = CAMERA_ERROR_NONE;
4463 camera_cli_s *pc = (camera_cli_s *)camera;
4464 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4465 camera_msg_param param;
4467 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4469 CAM_LOG_INFO("Enter");
4471 CAMERA_MSG_PARAM_SET(param, INT, quality);
4473 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4475 CAM_LOG_INFO("ret : 0x%x", ret);
4481 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4483 int ret = CAMERA_ERROR_NONE;
4484 camera_cli_s *pc = (camera_cli_s *)camera;
4485 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4487 if (!pc || !pc->cb_info || !fps) {
4488 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4489 return CAMERA_ERROR_INVALID_PARAMETER;
4492 CAM_LOG_INFO("Enter");
4494 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4496 if (ret == CAMERA_ERROR_NONE)
4497 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4499 CAM_LOG_INFO("ret : 0x%x", ret);
4505 int camera_attr_get_image_quality(camera_h camera, int *quality)
4507 int ret = CAMERA_ERROR_NONE;
4508 camera_cli_s *pc = (camera_cli_s *)camera;
4509 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4511 if (!pc || !pc->cb_info || !quality) {
4512 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4513 return CAMERA_ERROR_INVALID_PARAMETER;
4516 CAM_LOG_INFO("Enter");
4518 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4520 if (ret == CAMERA_ERROR_NONE)
4521 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4523 CAM_LOG_INFO("ret : 0x%x", ret);
4529 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4531 int ret = CAMERA_ERROR_NONE;
4532 camera_cli_s *pc = (camera_cli_s *)camera;
4533 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4535 if (!pc || !pc->cb_info || !bitrate) {
4536 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4537 return CAMERA_ERROR_INVALID_PARAMETER;
4540 CAM_LOG_INFO("Enter");
4542 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4544 if (ret == CAMERA_ERROR_NONE)
4545 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4547 CAM_LOG_INFO("ret : 0x%x", ret);
4553 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4555 int ret = CAMERA_ERROR_NONE;
4556 camera_cli_s *pc = (camera_cli_s *)camera;
4557 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4558 camera_msg_param param;
4559 int set_bitrate = bitrate;
4561 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4563 CAM_LOG_INFO("Enter");
4565 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4567 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4569 CAM_LOG_INFO("ret : 0x%x", ret);
4575 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4577 int ret = CAMERA_ERROR_NONE;
4578 camera_cli_s *pc = (camera_cli_s *)camera;
4579 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4581 if (!pc || !pc->cb_info || !interval) {
4582 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4583 return CAMERA_ERROR_INVALID_PARAMETER;
4586 CAM_LOG_INFO("Enter");
4588 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4590 if (ret == CAMERA_ERROR_NONE)
4591 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4593 CAM_LOG_INFO("ret : 0x%x", ret);
4599 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4601 int ret = CAMERA_ERROR_NONE;
4602 camera_cli_s *pc = (camera_cli_s *)camera;
4603 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4604 camera_msg_param param;
4605 int set_gop_interval = interval;
4607 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4609 CAM_LOG_INFO("Enter");
4611 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4613 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4615 CAM_LOG_INFO("ret : 0x%x", ret);
4621 int camera_attr_set_zoom(camera_h camera, int zoom)
4623 int ret = CAMERA_ERROR_NONE;
4624 camera_cli_s *pc = (camera_cli_s *)camera;
4625 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4626 camera_msg_param param;
4628 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4630 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4632 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4634 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4636 CAM_LOG_INFO("ret : 0x%x", ret);
4642 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4644 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4648 int camera_attr_set_af_area(camera_h camera, int x, int y)
4650 int ret = CAMERA_ERROR_NONE;
4651 camera_cli_s *pc = (camera_cli_s *)camera;
4652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4653 camera_msg_param param;
4656 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4658 CAM_LOG_INFO("Enter - %d,%d", x, y);
4660 value = (x << 16) | y;
4661 CAMERA_MSG_PARAM_SET(param, INT, value);
4663 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4665 CAM_LOG_INFO("ret : 0x%x", ret);
4671 int camera_attr_clear_af_area(camera_h camera)
4673 int ret = CAMERA_ERROR_NONE;
4674 camera_cli_s *pc = (camera_cli_s *)camera;
4675 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4677 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4679 CAM_LOG_INFO("Enter");
4681 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4683 CAM_LOG_INFO("ret : 0x%x", ret);
4689 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4691 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4695 int camera_attr_set_exposure(camera_h camera, int value)
4697 int ret = CAMERA_ERROR_NONE;
4698 camera_cli_s *pc = (camera_cli_s *)camera;
4699 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4700 camera_msg_param param;
4702 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4704 CAM_LOG_INFO("Enter");
4706 CAMERA_MSG_PARAM_SET(param, INT, value);
4708 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4710 CAM_LOG_INFO("ret : 0x%x", ret);
4716 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4718 int ret = CAMERA_ERROR_NONE;
4719 camera_cli_s *pc = (camera_cli_s *)camera;
4720 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4721 camera_msg_param param;
4722 int set_iso = (int)iso;
4724 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4726 CAM_LOG_INFO("Enter");
4728 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4730 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4732 CAM_LOG_INFO("ret : 0x%x", ret);
4738 int camera_attr_set_gain(camera_h camera, int level)
4740 int ret = CAMERA_ERROR_NONE;
4741 camera_cli_s *pc = (camera_cli_s *)camera;
4742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GAIN;
4743 camera_msg_param param;
4745 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4747 CAM_LOG_INFO("Enter");
4749 CAMERA_MSG_PARAM_SET(param, INT, level);
4751 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4753 CAM_LOG_INFO("ret : 0x%x", ret);
4759 int camera_attr_set_brightness(camera_h camera, int level)
4761 int ret = CAMERA_ERROR_NONE;
4762 camera_cli_s *pc = (camera_cli_s *)camera;
4763 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4764 camera_msg_param param;
4766 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4768 CAM_LOG_INFO("Enter");
4770 CAMERA_MSG_PARAM_SET(param, INT, level);
4772 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4774 CAM_LOG_INFO("ret : 0x%x", ret);
4780 int camera_attr_set_contrast(camera_h camera, int level)
4782 int ret = CAMERA_ERROR_NONE;
4783 camera_cli_s *pc = (camera_cli_s *)camera;
4784 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4785 camera_msg_param param;
4787 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4789 CAM_LOG_INFO("Enter");
4791 CAMERA_MSG_PARAM_SET(param, INT, level);
4793 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4795 CAM_LOG_INFO("ret : 0x%x", ret);
4801 int camera_attr_set_hue(camera_h camera, int level)
4803 int ret = CAMERA_ERROR_NONE;
4804 camera_cli_s *pc = (camera_cli_s *)camera;
4805 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4806 camera_msg_param param;
4808 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4810 CAM_LOG_INFO("Enter");
4812 CAMERA_MSG_PARAM_SET(param, INT, level);
4814 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4816 CAM_LOG_INFO("ret : 0x%x", ret);
4822 int camera_attr_set_saturation(camera_h camera, int level)
4824 int ret = CAMERA_ERROR_NONE;
4825 camera_cli_s *pc = (camera_cli_s *)camera;
4826 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SATURATION;
4827 camera_msg_param param;
4829 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4831 CAM_LOG_INFO("Enter");
4833 CAMERA_MSG_PARAM_SET(param, INT, level);
4835 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4837 CAM_LOG_INFO("ret : 0x%x", ret);
4843 int camera_attr_set_sharpness(camera_h camera, int level)
4845 int ret = CAMERA_ERROR_NONE;
4846 camera_cli_s *pc = (camera_cli_s *)camera;
4847 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SHARPNESS;
4848 camera_msg_param param;
4850 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4852 CAM_LOG_INFO("Enter");
4854 CAMERA_MSG_PARAM_SET(param, INT, level);
4856 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4858 CAM_LOG_INFO("ret : 0x%x", ret);
4864 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4866 int ret = CAMERA_ERROR_NONE;
4867 camera_cli_s *pc = (camera_cli_s *)camera;
4868 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4869 camera_msg_param param;
4870 int set_whitebalance = (int)wb;
4872 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4874 CAM_LOG_INFO("Enter");
4876 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4878 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4880 CAM_LOG_INFO("ret : 0x%x", ret);
4886 int camera_attr_set_whitebalance_temperature(camera_h camera, int temperature)
4888 int ret = CAMERA_ERROR_NONE;
4889 camera_cli_s *pc = (camera_cli_s *)camera;
4890 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE_TEMPERATURE;
4891 camera_msg_param param;
4893 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4895 CAM_LOG_INFO("Enter");
4897 CAMERA_MSG_PARAM_SET(param, INT, temperature);
4899 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4901 CAM_LOG_INFO("ret : 0x%x", ret);
4907 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4909 int ret = CAMERA_ERROR_NONE;
4910 camera_cli_s *pc = (camera_cli_s *)camera;
4911 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4912 camera_msg_param param;
4913 int set_effect = (int)effect;
4915 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4917 CAM_LOG_INFO("Enter");
4919 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4921 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4923 CAM_LOG_INFO("ret : 0x%x", ret);
4929 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4931 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4935 int camera_attr_enable_tag(camera_h camera, bool enable)
4937 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4941 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4943 int ret = CAMERA_ERROR_NONE;
4944 camera_cli_s *pc = (camera_cli_s *)camera;
4945 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4946 camera_msg_param param;
4948 if (!pc || !pc->cb_info || !description) {
4949 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4950 return CAMERA_ERROR_INVALID_PARAMETER;
4953 CAM_LOG_INFO("Enter");
4955 CAMERA_MSG_PARAM_SET(param, STRING, description);
4957 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4959 CAM_LOG_INFO("ret : 0x%x", ret);
4965 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4967 int ret = CAMERA_ERROR_NONE;
4968 camera_cli_s *pc = (camera_cli_s *)camera;
4969 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4970 camera_msg_param param;
4971 int set_orientation = (int)orientation;
4973 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4975 CAM_LOG_INFO("Enter");
4977 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4979 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4981 CAM_LOG_INFO("ret : 0x%x", ret);
4987 int camera_attr_set_tag_software(camera_h camera, const char *software)
4989 int ret = CAMERA_ERROR_NONE;
4990 camera_cli_s *pc = (camera_cli_s *)camera;
4991 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4992 camera_msg_param param;
4994 if (!pc || !pc->cb_info || !software) {
4995 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4996 return CAMERA_ERROR_INVALID_PARAMETER;
4999 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
5001 CAMERA_MSG_PARAM_SET(param, STRING, software);
5003 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5005 CAM_LOG_INFO("ret : 0x%x", ret);
5011 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
5013 int ret = CAMERA_ERROR_NONE;
5014 camera_cli_s *pc = (camera_cli_s *)camera;
5015 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
5016 double set_geotag[3] = {latitude, longitude, altitude};
5020 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5022 CAM_LOG_INFO("Enter");
5024 length = sizeof(set_geotag) / sizeof(int) + \
5025 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5027 msg = muse_core_msg_new(api,
5028 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5031 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
5037 int camera_attr_remove_geotag(camera_h camera)
5039 int ret = CAMERA_ERROR_NONE;
5040 camera_cli_s *pc = (camera_cli_s *)camera;
5041 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5043 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5045 CAM_LOG_INFO("Enter");
5047 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5049 CAM_LOG_INFO("ret : 0x%x", ret);
5055 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5057 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
5061 int camera_attr_get_zoom(camera_h camera, int *zoom)
5063 int ret = CAMERA_ERROR_NONE;
5064 camera_cli_s *pc = (camera_cli_s *)camera;
5065 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5067 if (!pc || !pc->cb_info || !zoom) {
5068 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
5069 return CAMERA_ERROR_INVALID_PARAMETER;
5072 CAM_LOG_INFO("Enter");
5074 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5076 if (ret == CAMERA_ERROR_NONE)
5077 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5079 CAM_LOG_INFO("ret : 0x%x", ret);
5085 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5087 int ret = CAMERA_ERROR_NONE;
5088 camera_cli_s *pc = (camera_cli_s *)camera;
5089 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5091 if (!pc || !pc->cb_info || !min || !max) {
5092 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5093 return CAMERA_ERROR_INVALID_PARAMETER;
5096 CAM_LOG_INFO("Enter");
5098 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5100 if (ret == CAMERA_ERROR_NONE) {
5101 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5102 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5105 CAM_LOG_INFO("ret : 0x%x", ret);
5111 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5113 int ret = CAMERA_ERROR_NONE;
5114 camera_cli_s *pc = (camera_cli_s *)camera;
5115 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5117 if (!pc || !pc->cb_info || !mode) {
5118 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5119 return CAMERA_ERROR_INVALID_PARAMETER;
5122 CAM_LOG_INFO("Enter");
5124 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5126 if (ret == CAMERA_ERROR_NONE)
5127 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5129 CAM_LOG_INFO("ret : 0x%x", ret);
5135 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5137 int ret = CAMERA_ERROR_NONE;
5138 camera_cli_s *pc = (camera_cli_s *)camera;
5139 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5141 if (!pc || !pc->cb_info || !mode) {
5142 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5143 return CAMERA_ERROR_INVALID_PARAMETER;
5146 CAM_LOG_INFO("Enter");
5148 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5150 if (ret == CAMERA_ERROR_NONE)
5151 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5153 CAM_LOG_INFO("ret : 0x%x", ret);
5159 int camera_attr_get_exposure(camera_h camera, int *value)
5161 int ret = CAMERA_ERROR_NONE;
5162 camera_cli_s *pc = (camera_cli_s *)camera;
5163 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5165 if (!pc || !pc->cb_info || !value) {
5166 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5167 return CAMERA_ERROR_INVALID_PARAMETER;
5170 CAM_LOG_INFO("Enter");
5172 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5174 if (ret == CAMERA_ERROR_NONE)
5175 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5177 CAM_LOG_INFO("ret : 0x%x", ret);
5183 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5185 int ret = CAMERA_ERROR_NONE;
5186 camera_cli_s *pc = (camera_cli_s *)camera;
5187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5189 if (!pc || !pc->cb_info || !min || !max) {
5190 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5191 return CAMERA_ERROR_INVALID_PARAMETER;
5194 CAM_LOG_INFO("Enter");
5196 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5198 if (ret == CAMERA_ERROR_NONE) {
5199 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5200 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5203 CAM_LOG_INFO("ret : 0x%x", ret);
5209 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5211 int ret = CAMERA_ERROR_NONE;
5212 camera_cli_s *pc = (camera_cli_s *)camera;
5213 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5215 if (!pc || !pc->cb_info || !iso) {
5216 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5217 return CAMERA_ERROR_INVALID_PARAMETER;
5220 CAM_LOG_INFO("Enter");
5222 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5224 if (ret == CAMERA_ERROR_NONE)
5225 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5227 CAM_LOG_INFO("ret : 0x%x", ret);
5233 int camera_attr_get_gain(camera_h camera, int *level)
5235 int ret = CAMERA_ERROR_NONE;
5236 camera_cli_s *pc = (camera_cli_s *)camera;
5237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN;
5239 if (!pc || !pc->cb_info || !level) {
5240 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5241 return CAMERA_ERROR_INVALID_PARAMETER;
5244 CAM_LOG_INFO("Enter");
5246 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5248 if (ret == CAMERA_ERROR_NONE)
5249 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_GAIN];
5251 CAM_LOG_INFO("ret : 0x%x", ret);
5257 int camera_attr_get_gain_range(camera_h camera, int *min, int *max)
5259 int ret = CAMERA_ERROR_NONE;
5260 camera_cli_s *pc = (camera_cli_s *)camera;
5261 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN_RANGE;
5263 if (!pc || !pc->cb_info || !min || !max) {
5264 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5265 return CAMERA_ERROR_INVALID_PARAMETER;
5268 CAM_LOG_INFO("Enter");
5270 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5272 if (ret == CAMERA_ERROR_NONE) {
5273 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_GAIN_RANGE][0];
5274 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_GAIN_RANGE][1];
5277 CAM_LOG_INFO("ret : 0x%x", ret);
5283 int camera_attr_get_gain_step(camera_h camera, int *step)
5285 int ret = CAMERA_ERROR_NONE;
5286 camera_cli_s *pc = (camera_cli_s *)camera;
5287 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN_STEP;
5289 if (!pc || !pc->cb_info || !step) {
5290 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5291 return CAMERA_ERROR_INVALID_PARAMETER;
5294 CAM_LOG_INFO("Enter");
5296 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5298 if (ret == CAMERA_ERROR_NONE)
5299 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_GAIN_STEP];
5301 CAM_LOG_INFO("ret : 0x%x", ret);
5307 int camera_attr_get_brightness(camera_h camera, int *level)
5309 int ret = CAMERA_ERROR_NONE;
5310 camera_cli_s *pc = (camera_cli_s *)camera;
5311 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5313 if (!pc || !pc->cb_info || !level) {
5314 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5315 return CAMERA_ERROR_INVALID_PARAMETER;
5318 CAM_LOG_INFO("Enter");
5320 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5322 if (ret == CAMERA_ERROR_NONE)
5323 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5325 CAM_LOG_INFO("ret : 0x%x", ret);
5331 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5333 int ret = CAMERA_ERROR_NONE;
5334 camera_cli_s *pc = (camera_cli_s *)camera;
5335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5337 if (!pc || !pc->cb_info || !min || !max) {
5338 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5339 return CAMERA_ERROR_INVALID_PARAMETER;
5342 CAM_LOG_INFO("Enter");
5344 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5346 if (ret == CAMERA_ERROR_NONE) {
5347 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5348 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5351 CAM_LOG_INFO("ret : 0x%x", ret);
5357 int camera_attr_get_contrast(camera_h camera, int *level)
5359 int ret = CAMERA_ERROR_NONE;
5360 camera_cli_s *pc = (camera_cli_s *)camera;
5361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5363 if (!pc || !pc->cb_info || !level) {
5364 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5365 return CAMERA_ERROR_INVALID_PARAMETER;
5368 CAM_LOG_INFO("Enter");
5370 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5372 if (ret == CAMERA_ERROR_NONE)
5373 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5375 CAM_LOG_INFO("ret : 0x%x", ret);
5381 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5383 int ret = CAMERA_ERROR_NONE;
5384 camera_cli_s *pc = (camera_cli_s *)camera;
5385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5387 if (!pc || !pc->cb_info || !min || !max) {
5388 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5389 return CAMERA_ERROR_INVALID_PARAMETER;
5392 CAM_LOG_INFO("Enter");
5394 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5396 if (ret == CAMERA_ERROR_NONE) {
5397 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5398 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5399 CAM_LOG_INFO("min %d, max %d", *min, *max);
5402 CAM_LOG_INFO("ret : 0x%x", ret);
5408 int camera_attr_get_hue(camera_h camera, int *level)
5410 int ret = CAMERA_ERROR_NONE;
5411 camera_cli_s *pc = (camera_cli_s *)camera;
5412 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5414 if (!pc || !pc->cb_info || !level) {
5415 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5416 return CAMERA_ERROR_INVALID_PARAMETER;
5419 CAM_LOG_INFO("Enter");
5421 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5423 if (ret == CAMERA_ERROR_NONE)
5424 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5426 CAM_LOG_INFO("ret : 0x%x", ret);
5432 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5434 int ret = CAMERA_ERROR_NONE;
5435 camera_cli_s *pc = (camera_cli_s *)camera;
5436 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5438 if (!pc || !pc->cb_info || !min || !max) {
5439 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5440 return CAMERA_ERROR_INVALID_PARAMETER;
5443 CAM_LOG_INFO("Enter");
5445 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5447 if (ret == CAMERA_ERROR_NONE) {
5448 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5449 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5450 CAM_LOG_INFO("min %d, max %d", *min, *max);
5453 CAM_LOG_INFO("ret : 0x%x", ret);
5459 int camera_attr_get_saturation(camera_h camera, int *level)
5461 int ret = CAMERA_ERROR_NONE;
5462 camera_cli_s *pc = (camera_cli_s *)camera;
5463 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SATURATION;
5465 if (!pc || !pc->cb_info || !level) {
5466 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5467 return CAMERA_ERROR_INVALID_PARAMETER;
5470 CAM_LOG_INFO("Enter");
5472 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5474 if (ret == CAMERA_ERROR_NONE)
5475 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SATURATION];
5477 CAM_LOG_INFO("ret : 0x%x", ret);
5483 int camera_attr_get_saturation_range(camera_h camera, int *min, int *max)
5485 int ret = CAMERA_ERROR_NONE;
5486 camera_cli_s *pc = (camera_cli_s *)camera;
5487 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SATURATION_RANGE;
5489 if (!pc || !pc->cb_info || !min || !max) {
5490 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5491 return CAMERA_ERROR_INVALID_PARAMETER;
5494 CAM_LOG_INFO("Enter");
5496 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5498 if (ret == CAMERA_ERROR_NONE) {
5499 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SATURATION_RANGE][0];
5500 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SATURATION_RANGE][1];
5501 CAM_LOG_INFO("min %d, max %d", *min, *max);
5504 CAM_LOG_INFO("ret : 0x%x", ret);
5510 int camera_attr_get_sharpness(camera_h camera, int *level)
5512 int ret = CAMERA_ERROR_NONE;
5513 camera_cli_s *pc = (camera_cli_s *)camera;
5514 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SHARPNESS;
5516 if (!pc || !pc->cb_info || !level) {
5517 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5518 return CAMERA_ERROR_INVALID_PARAMETER;
5521 CAM_LOG_INFO("Enter");
5523 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5525 if (ret == CAMERA_ERROR_NONE)
5526 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SHARPNESS];
5528 CAM_LOG_INFO("ret : 0x%x", ret);
5534 int camera_attr_get_sharpness_range(camera_h camera, int *min, int *max)
5536 int ret = CAMERA_ERROR_NONE;
5537 camera_cli_s *pc = (camera_cli_s *)camera;
5538 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SHARPNESS_RANGE;
5540 if (!pc || !pc->cb_info || !min || !max) {
5541 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5542 return CAMERA_ERROR_INVALID_PARAMETER;
5545 CAM_LOG_INFO("Enter");
5547 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5549 if (ret == CAMERA_ERROR_NONE) {
5550 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SHARPNESS_RANGE][0];
5551 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SHARPNESS_RANGE][1];
5552 CAM_LOG_INFO("min %d, max %d", *min, *max);
5555 CAM_LOG_INFO("ret : 0x%x", ret);
5561 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5563 int ret = CAMERA_ERROR_NONE;
5564 camera_cli_s *pc = (camera_cli_s *)camera;
5565 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5567 if (!pc || !pc->cb_info || !wb) {
5568 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5569 return CAMERA_ERROR_INVALID_PARAMETER;
5572 CAM_LOG_INFO("Enter");
5574 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5576 if (ret == CAMERA_ERROR_NONE)
5577 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5579 CAM_LOG_INFO("ret : 0x%x", ret);
5585 int camera_attr_get_whitebalance_temperature(camera_h camera, int *temperature)
5587 int ret = CAMERA_ERROR_NONE;
5588 camera_cli_s *pc = (camera_cli_s *)camera;
5589 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE;
5591 if (!pc || !pc->cb_info || !temperature) {
5592 CAM_LOG_ERROR("NULL pointer %p %p", pc, temperature);
5593 return CAMERA_ERROR_INVALID_PARAMETER;
5596 CAM_LOG_INFO("Enter");
5598 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5600 if (ret == CAMERA_ERROR_NONE)
5601 *temperature = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE];
5603 CAM_LOG_INFO("ret : 0x%x", ret);
5609 int camera_attr_get_whitebalance_temperature_range(camera_h camera, int *min, int *max)
5611 int ret = CAMERA_ERROR_NONE;
5612 camera_cli_s *pc = (camera_cli_s *)camera;
5613 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_RANGE;
5615 if (!pc || !pc->cb_info || !min || !max) {
5616 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5617 return CAMERA_ERROR_INVALID_PARAMETER;
5620 CAM_LOG_INFO("Enter");
5622 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5624 if (ret == CAMERA_ERROR_NONE) {
5625 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_WHITE_BALANCE_TEMPERATURE_RANGE][0];
5626 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_WHITE_BALANCE_TEMPERATURE_RANGE][1];
5629 CAM_LOG_INFO("ret : 0x%x", ret);
5635 int camera_attr_get_whitebalance_temperature_step(camera_h camera, int *step)
5637 int ret = CAMERA_ERROR_NONE;
5638 camera_cli_s *pc = (camera_cli_s *)camera;
5639 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_STEP;
5641 if (!pc || !pc->cb_info || !step) {
5642 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5643 return CAMERA_ERROR_INVALID_PARAMETER;
5646 CAM_LOG_INFO("Enter");
5648 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5650 if (ret == CAMERA_ERROR_NONE)
5651 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE_STEP];
5653 CAM_LOG_INFO("ret : 0x%x", ret);
5659 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5661 int ret = CAMERA_ERROR_NONE;
5662 camera_cli_s *pc = (camera_cli_s *)camera;
5663 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5665 if (!pc || !pc->cb_info || !effect) {
5666 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5667 return CAMERA_ERROR_INVALID_PARAMETER;
5670 CAM_LOG_INFO("Enter");
5672 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5674 if (ret == CAMERA_ERROR_NONE)
5675 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5677 CAM_LOG_INFO("ret : 0x%x", ret);
5683 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5685 int ret = CAMERA_ERROR_NONE;
5686 camera_cli_s *pc = (camera_cli_s *)camera;
5687 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5689 if (!pc || !pc->cb_info || !mode) {
5690 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5691 return CAMERA_ERROR_INVALID_PARAMETER;
5694 CAM_LOG_INFO("Enter");
5696 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5698 if (ret == CAMERA_ERROR_NONE)
5699 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5701 CAM_LOG_INFO("ret : 0x%x", ret);
5707 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5709 int ret = CAMERA_ERROR_NONE;
5710 camera_cli_s *pc = (camera_cli_s *)camera;
5711 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5713 if (!pc || !pc->cb_info || !enable) {
5714 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5715 return CAMERA_ERROR_INVALID_PARAMETER;
5718 CAM_LOG_INFO("Enter");
5720 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5722 if (ret == CAMERA_ERROR_NONE)
5723 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5725 CAM_LOG_INFO("ret : 0x%x", ret);
5731 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5733 int ret = CAMERA_ERROR_NONE;
5734 camera_cli_s *pc = (camera_cli_s *)camera;
5735 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5737 if (!pc || !pc->cb_info || !description) {
5738 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5739 return CAMERA_ERROR_INVALID_PARAMETER;
5742 CAM_LOG_INFO("Enter");
5744 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5746 if (ret == CAMERA_ERROR_NONE)
5747 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5749 CAM_LOG_INFO("ret : 0x%x", ret);
5755 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5757 int ret = CAMERA_ERROR_NONE;
5758 camera_cli_s *pc = (camera_cli_s *)camera;
5759 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5761 if (!pc || !pc->cb_info || !orientation) {
5762 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5763 return CAMERA_ERROR_INVALID_PARAMETER;
5766 CAM_LOG_INFO("Enter");
5768 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5770 if (ret == CAMERA_ERROR_NONE)
5771 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5773 CAM_LOG_INFO("ret : 0x%x", ret);
5779 int camera_attr_get_tag_software(camera_h camera, char **software)
5781 int ret = CAMERA_ERROR_NONE;
5782 camera_cli_s *pc = (camera_cli_s *)camera;
5783 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5785 if (!pc || !pc->cb_info || !software) {
5786 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5787 return CAMERA_ERROR_INVALID_PARAMETER;
5790 CAM_LOG_INFO("Enter");
5792 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5794 if (ret == CAMERA_ERROR_NONE)
5795 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5797 CAM_LOG_INFO("ret : 0x%x", ret);
5803 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5805 int ret = CAMERA_ERROR_NONE;
5806 camera_cli_s *pc = (camera_cli_s *)camera;
5807 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5809 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5810 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5811 return CAMERA_ERROR_INVALID_PARAMETER;
5814 CAM_LOG_INFO("Enter");
5816 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5818 if (ret == CAMERA_ERROR_NONE) {
5819 *latitude = pc->cb_info->get_geotag[0];
5820 *longitude = pc->cb_info->get_geotag[1];
5821 *altitude = pc->cb_info->get_geotag[2];
5824 CAM_LOG_INFO("ret : 0x%x", ret);
5830 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5832 int ret = CAMERA_ERROR_NONE;
5833 camera_cli_s *pc = (camera_cli_s *)camera;
5834 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5836 if (!pc || !pc->cb_info || !mode) {
5837 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5838 return CAMERA_ERROR_INVALID_PARAMETER;
5841 CAM_LOG_INFO("Enter");
5843 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5845 if (ret == CAMERA_ERROR_NONE)
5846 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5848 CAM_LOG_INFO("ret : 0x%x", ret);
5854 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5856 int ret = CAMERA_ERROR_NONE;
5857 int get_flash_state = 0;
5860 CAM_LOG_ERROR("NULL pointer");
5861 return CAMERA_ERROR_INVALID_PARAMETER;
5864 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5865 (int)device, "get_flash_state", &get_flash_state);
5867 if (ret == CAMERA_ERROR_NONE) {
5868 *state = (camera_flash_state_e)get_flash_state;
5869 CAM_LOG_INFO("flash state %d", *state);
5871 CAM_LOG_ERROR("failed 0x%x", ret);
5878 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5880 int ret = CAMERA_ERROR_NONE;
5881 camera_cli_s *pc = (camera_cli_s *)camera;
5882 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5884 if (!pc || !pc->cb_info || !foreach_cb) {
5885 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5886 return CAMERA_ERROR_INVALID_PARAMETER;
5889 CAM_LOG_INFO("Enter");
5891 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5892 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5894 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5896 CAM_LOG_INFO("ret : 0x%x", ret);
5902 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5904 int ret = CAMERA_ERROR_NONE;
5905 camera_cli_s *pc = (camera_cli_s *)camera;
5906 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5908 if (!pc || !pc->cb_info || !foreach_cb) {
5909 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5910 return CAMERA_ERROR_INVALID_PARAMETER;
5913 CAM_LOG_INFO("Enter");
5915 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5916 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5918 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5920 CAM_LOG_INFO("ret : 0x%x", ret);
5926 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5928 int ret = CAMERA_ERROR_NONE;
5929 camera_cli_s *pc = (camera_cli_s *)camera;
5930 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5932 if (!pc || !pc->cb_info || !foreach_cb) {
5933 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5934 return CAMERA_ERROR_INVALID_PARAMETER;
5937 CAM_LOG_INFO("Enter");
5939 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5940 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5942 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5944 CAM_LOG_INFO("ret : 0x%x", ret);
5950 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5952 int ret = CAMERA_ERROR_NONE;
5953 camera_cli_s *pc = (camera_cli_s *)camera;
5954 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5956 if (!pc || !pc->cb_info || !foreach_cb) {
5957 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5958 return CAMERA_ERROR_INVALID_PARAMETER;
5961 CAM_LOG_INFO("Enter");
5963 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5964 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5966 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5968 CAM_LOG_INFO("ret : 0x%x", ret);
5974 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5976 int ret = CAMERA_ERROR_NONE;
5977 camera_cli_s *pc = (camera_cli_s *)camera;
5978 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5980 if (!pc || !pc->cb_info || !foreach_cb) {
5981 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5982 return CAMERA_ERROR_INVALID_PARAMETER;
5985 CAM_LOG_INFO("Enter");
5987 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5988 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5990 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5992 CAM_LOG_INFO("ret : 0x%x", ret);
5998 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
6000 int ret = CAMERA_ERROR_NONE;
6001 camera_cli_s *pc = (camera_cli_s *)camera;
6002 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
6004 if (!pc || !pc->cb_info || !foreach_cb) {
6005 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6006 return CAMERA_ERROR_INVALID_PARAMETER;
6009 CAM_LOG_INFO("Enter");
6011 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
6012 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
6014 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6016 CAM_LOG_INFO("ret : 0x%x", ret);
6022 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
6024 int ret = CAMERA_ERROR_NONE;
6025 camera_cli_s *pc = (camera_cli_s *)camera;
6026 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
6028 if (!pc || !pc->cb_info || !foreach_cb) {
6029 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6030 return CAMERA_ERROR_INVALID_PARAMETER;
6033 CAM_LOG_INFO("Enter");
6035 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
6036 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
6038 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6040 CAM_LOG_INFO("ret : 0x%x", ret);
6046 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
6048 int ret = CAMERA_ERROR_NONE;
6049 camera_cli_s *pc = (camera_cli_s *)camera;
6050 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
6052 if (!pc || !pc->cb_info || !foreach_cb) {
6053 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6054 return CAMERA_ERROR_INVALID_PARAMETER;
6057 CAM_LOG_INFO("Enter");
6059 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
6060 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
6062 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6064 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
6070 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)
6072 int ret = CAMERA_ERROR_NONE;
6073 camera_cli_s *pc = (camera_cli_s *)camera;
6074 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
6075 camera_msg_param param;
6078 if (!pc || !pc->cb_info || !foreach_cb) {
6079 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6080 return CAMERA_ERROR_INVALID_PARAMETER;
6083 CAM_LOG_INFO("Enter");
6085 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
6086 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
6088 value = (width << 16) | height;
6089 CAMERA_MSG_PARAM_SET(param, INT, value);
6091 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6093 CAM_LOG_INFO("ret : 0x%x", ret);
6099 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
6101 int ret = CAMERA_ERROR_NONE;
6102 camera_cli_s *pc = (camera_cli_s *)camera;
6103 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
6105 if (!pc || !pc->cb_info || !foreach_cb) {
6106 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6107 return CAMERA_ERROR_INVALID_PARAMETER;
6110 CAM_LOG_INFO("Enter");
6112 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
6113 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
6115 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6117 CAM_LOG_INFO("ret : 0x%x", ret);
6123 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
6125 int ret = CAMERA_ERROR_NONE;
6126 camera_cli_s *pc = (camera_cli_s *)camera;
6127 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
6129 if (!pc || !pc->cb_info || !foreach_cb) {
6130 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6131 return CAMERA_ERROR_INVALID_PARAMETER;
6134 CAM_LOG_INFO("Enter");
6136 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
6137 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
6139 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6141 CAM_LOG_INFO("ret : 0x%x", ret);
6147 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
6149 int ret = CAMERA_ERROR_NONE;
6150 camera_cli_s *pc = (camera_cli_s *)camera;
6151 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
6152 camera_msg_param param;
6153 int set_rotation = (int)rotation;
6155 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6157 CAM_LOG_INFO("Enter");
6159 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
6161 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6163 CAM_LOG_INFO("ret : 0x%x", ret);
6169 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
6171 int ret = CAMERA_ERROR_NONE;
6172 camera_cli_s *pc = (camera_cli_s *)camera;
6173 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
6175 if (!pc || !pc->cb_info || !rotation) {
6176 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6177 return CAMERA_ERROR_INVALID_PARAMETER;
6180 CAM_LOG_INFO("Enter");
6182 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6184 if (ret == CAMERA_ERROR_NONE)
6185 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
6187 CAM_LOG_INFO("ret : 0x%x", ret);
6193 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
6195 int ret = CAMERA_ERROR_NONE;
6196 camera_cli_s *pc = (camera_cli_s *)camera;
6197 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
6198 camera_msg_param param;
6199 int set_flip = (int)flip;
6201 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6203 CAM_LOG_INFO("Enter");
6205 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
6207 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6209 CAM_LOG_INFO("ret : 0x%x", ret);
6215 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
6217 int ret = CAMERA_ERROR_NONE;
6218 camera_cli_s *pc = (camera_cli_s *)camera;
6219 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6221 if (!pc || !pc->cb_info || !flip) {
6222 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
6223 return CAMERA_ERROR_INVALID_PARAMETER;
6226 CAM_LOG_INFO("Enter");
6228 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6230 if (ret == CAMERA_ERROR_NONE)
6231 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6233 CAM_LOG_INFO("ret : 0x%x", ret);
6238 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6240 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
6244 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6246 int ret = CAMERA_ERROR_NONE;
6247 camera_cli_s *pc = (camera_cli_s *)camera;
6248 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6250 if (!pc || !pc->cb_info || !mode) {
6251 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
6252 return CAMERA_ERROR_INVALID_PARAMETER;
6255 CAM_LOG_INFO("Enter");
6257 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6259 if (ret == CAMERA_ERROR_NONE)
6260 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6262 CAM_LOG_INFO("ret : 0x%x", ret);
6268 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6270 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
6274 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6276 int ret = CAMERA_ERROR_NONE;
6277 camera_cli_s *pc = (camera_cli_s *)camera;
6278 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6280 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6282 CAM_LOG_INFO("Enter");
6284 if (!camera_attr_is_supported_hdr_capture(camera)) {
6285 CAM_LOG_ERROR("HDR not supported");
6286 return CAMERA_ERROR_NOT_SUPPORTED;
6290 CAM_LOG_ERROR("NULL callback");
6291 return CAMERA_ERROR_INVALID_PARAMETER;
6294 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6296 if (ret == CAMERA_ERROR_NONE) {
6297 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6299 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6300 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6302 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6305 CAM_LOG_INFO("ret : 0x%x", ret);
6311 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6313 int ret = CAMERA_ERROR_NONE;
6314 camera_cli_s *pc = (camera_cli_s *)camera;
6315 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6317 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6319 CAM_LOG_INFO("Enter");
6321 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6323 if (ret == CAMERA_ERROR_NONE) {
6324 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6326 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6327 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6329 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6332 CAM_LOG_INFO("ret : 0x%x", ret);
6338 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6340 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
6344 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6346 int ret = CAMERA_ERROR_NONE;
6347 camera_cli_s *pc = (camera_cli_s *)camera;
6348 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6350 if (!pc || !pc->cb_info || !enabled) {
6351 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6352 return CAMERA_ERROR_INVALID_PARAMETER;
6355 CAM_LOG_INFO("Enter");
6357 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6359 if (ret == CAMERA_ERROR_NONE)
6360 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6362 CAM_LOG_INFO("ret : 0x%x", ret);
6368 bool camera_attr_is_supported_anti_shake(camera_h camera)
6370 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
6374 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6376 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
6380 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6382 int ret = CAMERA_ERROR_NONE;
6383 camera_cli_s *pc = (camera_cli_s *)camera;
6384 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6386 if (!pc || !pc->cb_info || !enabled) {
6387 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6388 return CAMERA_ERROR_INVALID_PARAMETER;
6391 CAM_LOG_INFO("Enter");
6393 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6395 if (ret == CAMERA_ERROR_NONE)
6396 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6398 CAM_LOG_INFO("ret : 0x%x", ret);
6404 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6406 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
6410 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6412 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
6416 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6418 int ret = CAMERA_ERROR_NONE;
6419 camera_cli_s *pc = (camera_cli_s *)camera;
6420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6422 if (!pc || !pc->cb_info || !enabled) {
6423 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6424 return CAMERA_ERROR_INVALID_PARAMETER;
6427 CAM_LOG_INFO("Enter");
6429 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6431 if (ret == CAMERA_ERROR_NONE)
6432 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6434 CAM_LOG_INFO("ret : 0x%x", ret);
6440 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6442 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
6446 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6448 int ret = CAMERA_ERROR_NONE;
6449 camera_cli_s *pc = (camera_cli_s *)camera;
6450 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6451 camera_msg_param param;
6452 int set_disable = (int)disable;
6454 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6456 CAM_LOG_INFO("Enter");
6458 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6460 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6462 CAM_LOG_INFO("ret : 0x%x", ret);
6468 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6470 int ret = CAMERA_ERROR_NONE;
6471 camera_cli_s *pc = (camera_cli_s *)camera;
6472 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6473 camera_msg_param param0;
6474 camera_msg_param param1;
6476 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6478 CAM_LOG_INFO("Enter");
6480 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6481 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6483 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6484 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6486 CAM_LOG_INFO("ret : 0x%x", ret);
6492 int camera_attr_get_pan(camera_h camera, int *pan_step)
6494 int ret = CAMERA_ERROR_NONE;
6495 camera_cli_s *pc = (camera_cli_s *)camera;
6496 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6498 if (!pc || !pc->cb_info || !pan_step) {
6499 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6500 return CAMERA_ERROR_INVALID_PARAMETER;
6503 CAM_LOG_INFO("Enter");
6505 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6507 if (ret == CAMERA_ERROR_NONE)
6508 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6510 CAM_LOG_INFO("ret : 0x%x", ret);
6516 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6518 int ret = CAMERA_ERROR_NONE;
6519 camera_cli_s *pc = (camera_cli_s *)camera;
6520 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6522 if (!pc || !pc->cb_info || !min || !max) {
6523 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6524 return CAMERA_ERROR_INVALID_PARAMETER;
6527 CAM_LOG_INFO("Enter");
6529 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6531 if (ret == CAMERA_ERROR_NONE) {
6532 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6533 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6536 CAM_LOG_INFO("ret : 0x%x", ret);
6542 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6544 int ret = CAMERA_ERROR_NONE;
6545 camera_cli_s *pc = (camera_cli_s *)camera;
6546 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6547 camera_msg_param param0;
6548 camera_msg_param param1;
6550 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6552 CAM_LOG_INFO("Enter");
6554 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6555 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6557 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6558 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6560 CAM_LOG_INFO("ret : 0x%x", ret);
6566 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6568 int ret = CAMERA_ERROR_NONE;
6569 camera_cli_s *pc = (camera_cli_s *)camera;
6570 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6572 if (!pc || !pc->cb_info || !tilt_step) {
6573 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6574 return CAMERA_ERROR_INVALID_PARAMETER;
6577 CAM_LOG_INFO("Enter");
6579 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6581 if (ret == CAMERA_ERROR_NONE)
6582 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6584 CAM_LOG_INFO("ret : 0x%x", ret);
6590 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6592 int ret = CAMERA_ERROR_NONE;
6593 camera_cli_s *pc = (camera_cli_s *)camera;
6594 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6596 if (!pc || !pc->cb_info || !min || !max) {
6597 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6598 return CAMERA_ERROR_INVALID_PARAMETER;
6601 CAM_LOG_INFO("Enter");
6603 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6605 if (ret == CAMERA_ERROR_NONE) {
6606 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6607 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6610 CAM_LOG_INFO("ret : 0x%x", ret);
6616 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6618 int ret = CAMERA_ERROR_NONE;
6619 camera_cli_s *pc = (camera_cli_s *)camera;
6620 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6621 camera_msg_param param;
6622 int set_ptz_type = (int)ptz_type;
6624 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6626 CAM_LOG_INFO("Enter");
6628 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6630 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6632 CAM_LOG_INFO("ret : 0x%x", ret);
6638 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6640 int ret = CAMERA_ERROR_NONE;
6641 camera_cli_s *pc = (camera_cli_s *)camera;
6642 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6644 if (!pc || !pc->cb_info || !foreach_cb) {
6645 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6646 return CAMERA_ERROR_INVALID_PARAMETER;
6649 CAM_LOG_INFO("Enter");
6651 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6652 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6654 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6656 CAM_LOG_INFO("ret : 0x%x", ret);
6662 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6664 int ret = CAMERA_ERROR_NONE;
6665 camera_cli_s *pc = (camera_cli_s *)camera;
6666 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6667 int set_display_roi_area[4] = {x, y, width, height};
6671 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6673 CAM_LOG_INFO("Enter");
6675 if (pc->cb_info->is_evas_render) {
6676 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6677 if (ret != MM_ERROR_NONE) {
6678 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6679 return CAMERA_ERROR_INVALID_OPERATION;
6683 length = sizeof(set_display_roi_area) / sizeof(int) + \
6684 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6686 msg = muse_core_msg_new(api,
6687 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6690 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6696 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6698 camera_cli_s *pc = (camera_cli_s *)camera;
6699 int ret = CAMERA_ERROR_NONE;
6700 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6702 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6703 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6704 return CAMERA_ERROR_INVALID_PARAMETER;
6707 CAM_LOG_INFO("Enter");
6709 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6711 if (ret == CAMERA_ERROR_NONE) {
6712 *x = pc->cb_info->get_display_roi_area[0];
6713 *y = pc->cb_info->get_display_roi_area[1];
6714 *width = pc->cb_info->get_display_roi_area[2];
6715 *height = pc->cb_info->get_display_roi_area[3];
6718 CAM_LOG_INFO("ret : 0x%x", ret);
6724 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6726 int ret = CAMERA_ERROR_NONE;
6727 int get_device_state = 0;
6730 CAM_LOG_ERROR("NULL pointer");
6731 return CAMERA_ERROR_INVALID_PARAMETER;
6734 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6735 (int)device, "get_device_state", &get_device_state);
6737 if (ret == CAMERA_ERROR_NONE) {
6738 *state = (camera_device_state_e)get_device_state;
6739 CAM_LOG_INFO("device state %d", *state);
6741 CAM_LOG_ERROR("failed 0x%x", ret);
6748 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6750 int ret = CAMERA_ERROR_NONE;
6751 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6752 camera_cb_info *info = NULL;
6754 if (!callback || !cb_id) {
6755 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6756 return CAMERA_ERROR_INVALID_PARAMETER;
6759 /* check camera support */
6760 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6761 if (ret != CAMERA_ERROR_NONE) {
6762 CAM_LOG_ERROR("get device state failed");
6766 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6768 info = g_new0(camera_cb_info, 1);
6770 CAM_LOG_ERROR("info failed");
6771 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6775 info->id = ++g_cam_dev_state_changed_cb_id;
6776 info->callback = (void *)callback;
6777 info->user_data = user_data;
6781 /* subscribe dbus signal for camera state change */
6782 if (!g_cam_dev_state_changed_cb_conn) {
6783 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6784 if (!g_cam_dev_state_changed_cb_conn) {
6785 CAM_LOG_ERROR("failed to get gdbus connection");
6786 ret = CAMERA_ERROR_INVALID_OPERATION;
6790 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6791 MM_CAMCORDER_DBUS_OBJECT,
6792 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6793 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6795 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6796 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6797 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6798 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6799 CAM_LOG_ERROR("failed to get gdbus connection");
6800 ret = CAMERA_ERROR_INVALID_OPERATION;
6804 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6807 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6809 CAM_LOG_INFO("callback id %d", info->id);
6812 if (ret != CAMERA_ERROR_NONE) {
6818 if (g_cam_dev_state_changed_cb_conn) {
6819 g_object_unref(g_cam_dev_state_changed_cb_conn);
6820 g_cam_dev_state_changed_cb_conn = NULL;
6824 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6830 int camera_remove_device_state_changed_cb(int cb_id)
6832 int ret = CAMERA_ERROR_NONE;
6833 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6834 GList *tmp_list = NULL;
6835 camera_cb_info *info = NULL;
6837 /* check camera support */
6838 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6839 if (ret != CAMERA_ERROR_NONE) {
6840 CAM_LOG_ERROR("get device state failed");
6844 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6846 if (!g_cam_dev_state_changed_cb_list) {
6847 CAM_LOG_ERROR("there is no callback info");
6848 ret = CAMERA_ERROR_INVALID_OPERATION;
6852 tmp_list = g_cam_dev_state_changed_cb_list;
6855 info = tmp_list->data;
6856 tmp_list = tmp_list->next;
6859 CAM_LOG_WARNING("NULL info");
6863 if (info->id == cb_id) {
6864 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6869 if (!g_cam_dev_state_changed_cb_list) {
6870 /* no remained callback */
6871 if (g_cam_dev_state_changed_cb_conn) {
6872 /* unsubscribe signal */
6873 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6874 g_cam_dev_state_changed_cb_subscribe_id = 0;
6876 /* unref connection */
6877 g_object_unref(g_cam_dev_state_changed_cb_conn);
6878 g_cam_dev_state_changed_cb_conn = NULL;
6882 CAM_LOG_INFO("id %d callback removed", cb_id);
6883 ret = CAMERA_ERROR_NONE;
6889 CAM_LOG_ERROR("id %d callback not found", cb_id);
6890 ret = CAMERA_ERROR_INVALID_PARAMETER;
6893 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6900 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6902 int ret = CAMERA_ERROR_NONE;
6903 camera_cli_s *pc = (camera_cli_s *)camera;
6904 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6906 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6908 g_mutex_lock(&pc->cb_info->bridge_lock);
6910 if (pc->cb_info->bridge) {
6911 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6912 ret = CAMERA_ERROR_INVALID_OPERATION;
6913 goto _SET_MEDIA_BRIDGE_DONE;
6916 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6917 if (ret != CAMERA_ERROR_NONE) {
6918 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6919 goto _SET_MEDIA_BRIDGE_DONE;
6922 pc->cb_info->bridge = bridge;
6924 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6926 _SET_MEDIA_BRIDGE_DONE:
6927 g_mutex_unlock(&pc->cb_info->bridge_lock);
6933 int camera_media_bridge_unset_bridge(camera_h camera)
6935 int ret = CAMERA_ERROR_NONE;
6936 camera_cli_s *pc = (camera_cli_s *)camera;
6937 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6939 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6941 g_mutex_lock(&pc->cb_info->bridge_lock);
6943 if (!pc->cb_info->bridge) {
6944 CAM_LOG_ERROR("no media bridge");
6945 ret = CAMERA_ERROR_INVALID_OPERATION;
6946 goto _UNSET_MEDIA_BRIDGE_DONE;
6949 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6950 if (ret != CAMERA_ERROR_NONE) {
6951 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6952 goto _UNSET_MEDIA_BRIDGE_DONE;
6955 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6957 pc->cb_info->bridge = NULL;
6959 _UNSET_MEDIA_BRIDGE_DONE:
6960 g_mutex_unlock(&pc->cb_info->bridge_lock);
6967 int camera_create_network(camera_device_e device, camera_h *camera)
6969 return _camera_create_private(device, true, camera);
6973 int camera_device_manager_initialize(camera_device_manager_h *manager)
6976 int ret = CAMERA_ERROR_NONE;
6977 void *dl_handle = NULL;
6978 g_autofree camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
6979 cdm_symbol_table sym_table[] = {
6980 {(void **)&new_manager->initialize, "cdm_initialize"},
6981 {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
6982 {(void **)&new_manager->get_device_list, "cdm_get_device_list"},
6983 {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"},
6984 {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"},
6987 CAMERA_CHECK_DEVICE_MANAGER;
6990 CAM_LOG_ERROR("NULL manager");
6991 ret = CAMERA_ERROR_INVALID_PARAMETER;
6992 goto _INITIALIZE_FAILED;
6995 dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
6997 CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
6998 ret = CAMERA_ERROR_INVALID_OPERATION;
6999 goto _INITIALIZE_FAILED;
7003 for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
7004 *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
7005 if (*sym_table[i].func_ptr == NULL) {
7006 CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
7007 ret = CAMERA_ERROR_INVALID_OPERATION;
7008 goto _INITIALIZE_FAILED;
7012 ret = new_manager->initialize();
7013 if (ret != CAMERA_ERROR_NONE) {
7014 CAM_LOG_ERROR("failed[0x%x]", ret);
7015 goto _INITIALIZE_FAILED;
7018 new_manager->dl_handle = dl_handle;
7019 *manager = (camera_device_manager_h)g_steal_pointer(&new_manager);
7021 CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
7022 *manager, dl_handle);
7024 return CAMERA_ERROR_NONE;
7035 int camera_device_manager_deinitialize(camera_device_manager_h manager)
7037 int ret = CAMERA_ERROR_NONE;
7038 camera_device_manager *m = (camera_device_manager *)manager;
7040 CAMERA_CHECK_DEVICE_MANAGER;
7043 CAM_LOG_ERROR("NULL manager");
7044 return CAMERA_ERROR_INVALID_PARAMETER;
7047 CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
7049 ret = m->deinitialize();
7050 if (ret != CAMERA_ERROR_NONE) {
7051 CAM_LOG_ERROR("failed[0x%x]", ret);
7055 CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
7057 dlclose(m->dl_handle);
7059 memset(m, 0x0, sizeof(camera_device_manager));
7062 return CAMERA_ERROR_NONE;
7066 int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
7068 int ret = CAMERA_ERROR_NONE;
7070 camera_device_list_s device_list;
7071 camera_device_s *device = NULL;
7072 camera_device_manager *m = (camera_device_manager *)manager;
7074 CAMERA_CHECK_DEVICE_MANAGER;
7076 if (!m || !callback) {
7077 CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
7078 return CAMERA_ERROR_INVALID_PARAMETER;
7081 CAM_LOG_INFO("enter");
7083 memset(&device_list, 0x0, sizeof(camera_device_list_s));
7085 ret = m->get_device_list(&device_list);
7086 if (ret != CAMERA_ERROR_NONE) {
7087 CAM_LOG_ERROR("failed[0x%x]", ret);
7091 CAM_LOG_INFO("device count[%d]", device_list.count);
7093 for (i = 0 ; i < device_list.count ; i++) {
7094 device = &device_list.device[i];
7096 CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
7097 i, device->type, device->index,
7098 device->name, device->id, device->extra_stream_num);
7100 if (!callback(device, user_data)) {
7101 CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
7102 i + 1, device_list.count);
7107 return CAMERA_ERROR_NONE;
7111 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
7112 camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
7114 int ret = CAMERA_ERROR_NONE;
7115 camera_device_manager *m = (camera_device_manager *)manager;
7117 CAMERA_CHECK_DEVICE_MANAGER;
7119 if (!m || !callback || !cb_id) {
7120 CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
7121 return CAMERA_ERROR_INVALID_PARAMETER;
7124 CAM_LOG_INFO("enter");
7126 ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
7127 if (ret != CAMERA_ERROR_NONE) {
7128 CAM_LOG_ERROR("failed[0x%x]", ret);
7132 CAM_LOG_INFO("cb_id[%d] added", *cb_id);
7134 return CAMERA_ERROR_NONE;
7138 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
7140 int ret = CAMERA_ERROR_NONE;
7141 camera_device_manager *m = (camera_device_manager *)manager;
7143 CAMERA_CHECK_DEVICE_MANAGER;
7146 CAM_LOG_ERROR("NULL manager");
7147 return CAMERA_ERROR_INVALID_PARAMETER;
7150 CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
7152 ret = m->remove_device_connection_changed_cb(cb_id);
7153 if (ret != CAMERA_ERROR_NONE) {
7154 CAM_LOG_ERROR("failed[0x%x]", ret);
7158 CAM_LOG_INFO("cb_id[%d] removed", cb_id);
7160 return CAMERA_ERROR_NONE;
7165 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
7167 int ret = CAMERA_ERROR_NONE;
7168 camera_cli_s *pc = (camera_cli_s *)camera;
7169 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
7171 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7173 if (!camera_is_supported_extra_preview(camera)) {
7174 CAM_LOG_ERROR("extra preview is not supported");
7175 return CAMERA_ERROR_NOT_SUPPORTED;
7179 CAM_LOG_ERROR("NULL callback");
7180 return CAMERA_ERROR_INVALID_PARAMETER;
7183 CAM_LOG_INFO("Enter");
7185 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
7187 if (ret == CAMERA_ERROR_NONE) {
7188 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7190 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
7191 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
7193 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7196 CAM_LOG_INFO("ret : 0x%x", ret);
7202 int camera_unset_extra_preview_cb(camera_h camera)
7204 int ret = CAMERA_ERROR_NONE;
7205 camera_cli_s *pc = (camera_cli_s *)camera;
7206 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
7208 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7210 if (!camera_is_supported_extra_preview(camera)) {
7211 CAM_LOG_ERROR("extra preview is not supported");
7212 return CAMERA_ERROR_NOT_SUPPORTED;
7215 CAM_LOG_INFO("Enter");
7217 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
7219 if (ret == CAMERA_ERROR_NONE) {
7220 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7222 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
7223 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
7225 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7228 CAM_LOG_INFO("ret : 0x%x", ret);
7234 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)
7236 int ret = CAMERA_ERROR_NONE;
7237 int stream_format[4] = {pixel_format, width, height, fps};
7239 camera_cli_s *pc = (camera_cli_s *)camera;
7240 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
7242 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7244 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
7245 stream_id, pixel_format, width, height, fps);
7247 msg = muse_core_msg_new(api,
7248 MUSE_TYPE_INT, "stream_id", stream_id,
7249 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
7252 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
7258 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)
7260 int ret = CAMERA_ERROR_NONE;
7261 camera_cli_s *pc = (camera_cli_s *)camera;
7262 camera_msg_param param;
7263 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
7265 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
7266 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
7267 return CAMERA_ERROR_INVALID_PARAMETER;
7270 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7272 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7274 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7276 if (ret == CAMERA_ERROR_NONE) {
7277 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
7278 *width = pc->cb_info->get_extra_preview_stream_format[1];
7279 *height = pc->cb_info->get_extra_preview_stream_format[2];
7280 *fps = pc->cb_info->get_extra_preview_stream_format[3];
7283 CAM_LOG_INFO("ret : 0x%x", ret);
7289 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
7291 int ret = CAMERA_ERROR_NONE;
7292 camera_cli_s *pc = (camera_cli_s *)camera;
7293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
7294 camera_msg_param param0;
7295 camera_msg_param param1;
7297 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7299 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
7301 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
7302 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
7304 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
7305 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
7307 CAM_LOG_INFO("ret : 0x%x", ret);
7313 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
7315 int ret = CAMERA_ERROR_NONE;
7316 camera_cli_s *pc = (camera_cli_s *)camera;
7317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
7318 camera_msg_param param;
7320 if (!pc || !pc->cb_info || !bitrate) {
7321 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
7322 return CAMERA_ERROR_INVALID_PARAMETER;
7325 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7327 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7329 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7331 if (ret == CAMERA_ERROR_NONE) {
7332 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
7333 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
7335 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
7342 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
7344 int ret = CAMERA_ERROR_NONE;
7345 camera_cli_s *pc = (camera_cli_s *)camera;
7346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
7347 camera_msg_param param0;
7348 camera_msg_param param1;
7350 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7352 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
7354 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
7355 CAMERA_MSG_PARAM_SET(param1, INT, interval);
7357 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
7358 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
7360 CAM_LOG_INFO("ret : 0x%x", ret);
7366 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
7368 int ret = CAMERA_ERROR_NONE;
7369 camera_cli_s *pc = (camera_cli_s *)camera;
7370 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
7371 camera_msg_param param;
7373 if (!pc || !pc->cb_info || !interval) {
7374 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
7375 return CAMERA_ERROR_INVALID_PARAMETER;
7378 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7380 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7382 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7384 if (ret == CAMERA_ERROR_NONE) {
7385 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
7386 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
7388 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
7395 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
7397 camera_cli_s *pc = (camera_cli_s *)camera;
7399 if (!pc || !pc->cb_info || !rotation) {
7400 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
7401 return CAMERA_ERROR_INVALID_PARAMETER;
7404 if (!pc->cb_info->stream_data) {
7405 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
7406 return CAMERA_ERROR_INVALID_OPERATION;
7409 *rotation = pc->cb_info->stream_data->rotation;
7411 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
7413 return CAMERA_ERROR_NONE;
7417 int _camera_get_log_level(void)
7419 return g_camera_log_level;