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 CAM_LOG_VERBOSE("meta ts: [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu]",
429 stream->ts_soe, stream->ts_eoe,
430 stream->ts_sof, stream->ts_eof,
431 stream->ts_hal, stream->ts_qmf,
432 stream->ts_gst, stream->td_exp,
433 stream->ts_aux, stream->td_aux);
435 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
436 /* import tbm data_bo and get virtual address */
437 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
438 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
439 goto _PREVIEW_CB_HANDLER_DONE;
442 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
443 stream->data.encoded.data = data_bo_handle.ptr;
445 for (i = 0 ; i < num_buffer_fd ; i++) {
446 /* import buffer bo and get virtual address */
447 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
448 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
449 goto _PREVIEW_CB_HANDLER_DONE;
453 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
454 stream->data.encoded.data = buffer_bo_handle[0].ptr;
457 /* preview callback */
458 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
459 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]) {
460 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
462 /* set stream data for camera_get_preview_frame_rotation() */
463 cb_info->stream_data = stream;
465 if (stream->extra_stream_id < 0) {
466 monitoring_info = cb_info->monitoring_info_preview;
467 __camera_preview_cb_monitoring_info_start(monitoring_info);
469 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
470 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
471 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
473 monitoring_info = cb_info->monitoring_info_preview_ex[stream->extra_stream_id];
474 __camera_preview_cb_monitoring_info_start(monitoring_info);
476 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
477 ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
478 stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
481 __camera_preview_cb_monitoring_info_end(monitoring_info);
483 cb_info->stream_data = NULL;
486 if (stream->extra_stream_id >= 0)
487 goto _PREVIEW_CB_HANDLER_DONE;
489 /* make media packet with below cases.
490 * 1. media_packet_preview_cb is set
491 * 2. EVAS display rendering
492 * 3. media bridge is set
494 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
495 cb_info->is_evas_render ||
497 ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
498 if (ret != CAMERA_ERROR_NONE) {
499 CAM_LOG_ERROR("__camera_create_media_packet_data failed[0x%x]", ret);
500 goto _PREVIEW_CB_HANDLER_DONE;
503 ret = __camera_create_media_packet(cb_info, stream, mp_data, &pkt);
504 if (ret != CAMERA_ERROR_NONE) {
505 CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
506 __camera_release_media_packet_data(mp_data, cb_info);
508 goto _PREVIEW_CB_HANDLER_DONE;
512 /* 1. media packet preview callback */
513 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
514 media_packet_ref(pkt);
516 monitoring_info = cb_info->monitoring_info_preview_mp;
517 __camera_preview_cb_monitoring_info_start(monitoring_info);
519 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
520 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
522 __camera_preview_cb_monitoring_info_end(monitoring_info);
525 /* 2. call evas renderer */
526 if (cb_info->is_evas_render) {
527 if (cb_info->run_evas_render) {
528 media_packet_ref(pkt);
529 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
530 if (ret != MM_ERROR_NONE) {
531 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
532 media_packet_unref(pkt);
535 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
540 /* 3. media bridge */
541 g_mutex_lock(&cb_info->bridge_lock);
543 if (cb_info->bridge) {
544 media_packet_ref(pkt);
545 ret = media_bridge_push_packet(cb_info->bridge, pkt);
546 if (ret != MEDIA_BRIDGE_ERROR_NONE) {
547 CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
548 media_packet_unref(pkt);
553 g_mutex_unlock(&cb_info->bridge_lock);
555 _PREVIEW_CB_HANDLER_DONE:
556 /* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
557 and preview callback(normal or media packet) is set. */
558 if (num_buffer_fd > 0 &&
559 (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
560 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]))
561 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
564 media_packet_unref(pkt);
569 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
571 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
573 /* release imported bo and fd */
574 __camera_release_imported_bo(&data_bo);
575 __camera_release_imported_bo(&bo);
577 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
578 __camera_release_imported_bo(&buffer_bo[i]);
580 __camera_release_tfd(tfd);
584 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
587 int capture_fd_main = 0;
588 int capture_fd_post = 0;
589 int capture_fd_thumb = 0;
590 unsigned char *buf_pos = NULL;
592 camera_image_data_s *rImage = NULL;
593 camera_image_data_s *rPostview = NULL;
594 camera_image_data_s *rThumbnail = NULL;
596 tbm_bo bo_main = NULL;
597 tbm_bo bo_post = NULL;
598 tbm_bo bo_thumb = NULL;
599 tbm_bo_handle bo_main_handle = {.ptr = NULL};
600 tbm_bo_handle bo_post_handle = {.ptr = NULL};
601 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
603 if (!cb_info || !recv_msg || !tfd) {
604 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
608 muse_camera_msg_get(capture_fd_main, recv_msg);
609 muse_camera_msg_get(capture_fd_post, recv_msg);
610 muse_camera_msg_get(capture_fd_thumb, recv_msg);
612 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
613 capture_fd_main, capture_fd_post, capture_fd_thumb,
614 tfd[0], tfd[1], tfd[2]);
616 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
617 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
618 goto _CAPTURE_CB_HANDLER_DONE;
621 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
622 CAM_LOG_WARNING("NULL callback");
623 goto _CAPTURE_CB_HANDLER_DONE;
626 /* import tbm bo and get virtual address */
627 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
628 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
629 goto _CAPTURE_CB_HANDLER_DONE;
632 buf_pos = (unsigned char *)bo_main_handle.ptr;
633 rImage = (camera_image_data_s *)buf_pos;
634 rImage->data = buf_pos + sizeof(camera_image_data_s);
635 if (rImage->exif && rImage->exif_size > 0) {
636 rImage->exif = rImage->data + rImage->size;
639 rImage->exif_size = 0;
642 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
643 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
646 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
647 /* import tbm bo and get virtual address */
649 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
650 buf_pos = (unsigned char *)bo_post_handle.ptr;
651 rPostview = (camera_image_data_s *)buf_pos;
652 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
653 rPostview->data = buf_pos + sizeof(camera_image_data_s);
655 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
659 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
660 /* import tbm bo and get virtual address */
662 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
663 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
664 rThumbnail = (camera_image_data_s *)buf_pos;
665 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
666 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
668 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
673 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
674 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
676 _CAPTURE_CB_HANDLER_DONE:
678 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
679 __camera_release_imported_bo(&bo_main);
680 _camera_msg_return_buffer(capture_fd_main, cb_info);
683 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
684 __camera_release_imported_bo(&bo_post);
685 _camera_msg_return_buffer(capture_fd_post, cb_info);
688 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
689 __camera_release_imported_bo(&bo_thumb);
690 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
693 __camera_release_tfd(tfd);
695 CAM_LOG_INFO("return buffer done");
700 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
703 int face_fd = CAMERA_FD_INIT;
704 camera_detected_face_s *faces = NULL;
707 tbm_bo_handle bo_handle = {.ptr = NULL};
709 if (!cb_info || !recv_msg || !tfd) {
710 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
714 muse_camera_msg_get(count, recv_msg);
715 muse_camera_msg_get(face_fd, recv_msg);
717 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
718 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
720 if (CAMERA_IS_FD_VALID(tfd[0])) {
721 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
723 faces = bo_handle.ptr;
727 tfd[0] = CAMERA_FD_INIT;
730 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
731 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
734 __camera_release_imported_bo(&bo);
736 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
737 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
741 _camera_msg_return_buffer(face_fd, cb_info);
746 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
748 tbm_bo tmp_bo = NULL;
749 tbm_bo_handle tmp_bo_handle = {NULL, };
751 if (!bufmgr || !bo || !bo_handle || fd < 0) {
752 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
753 bufmgr, bo, bo_handle, fd);
757 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
758 if (tmp_bo == NULL) {
759 CAM_LOG_ERROR("import failed - fd %d", fd);
763 tmp_bo_handle = tbm_bo_get_handle(tmp_bo, TBM_DEVICE_CPU);
764 if (tmp_bo_handle.ptr == NULL) {
765 CAM_LOG_ERROR("tbm_bo_get_handle() failed %p", tmp_bo);
766 tbm_bo_unref(tmp_bo);
771 /* set bo and bo_handle */
773 *bo_handle = tmp_bo_handle;
775 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
780 static void __camera_release_imported_bo(tbm_bo *bo)
783 CAM_LOG_DEBUG("NULL bo");
792 static bool __is_supported(camera_h camera, muse_camera_api_e api)
794 int ret = CAMERA_ERROR_NONE;
795 camera_cli_s *pc = (camera_cli_s *)camera;
797 if (!pc || !pc->cb_info) {
798 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
799 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
803 CAM_LOG_INFO("Enter - api[%d]", api);
805 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
807 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
813 static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
815 int ret = CAMERA_ERROR_NONE;
816 camera_cli_s *pc = (camera_cli_s *)camera;
817 camera_msg_param param;
819 if (!pc || !pc->cb_info) {
820 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
821 return CAMERA_ERROR_INVALID_PARAMETER;
824 CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
826 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
828 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
830 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
836 static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
838 int ret = CAMERA_ERROR_NONE;
839 camera_cli_s *pc = (camera_cli_s *)camera;
840 camera_msg_param param;
842 if (!pc || !pc->cb_info) {
843 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
844 return CAMERA_ERROR_INVALID_PARAMETER;
847 CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
849 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
851 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
853 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
859 void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
864 CAM_LOG_ERROR("api[%d] message failed", api);
866 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
871 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
872 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
874 CAM_LOG_DEBUG("api[%d], message[%s]", api, msg);
876 if (cb_info->is_server_connected) {
877 _camera_update_api_waiting(cb_info, api, 1);
879 g_mutex_lock(&cb_info->fd_lock);
880 send_ret = muse_core_msg_send(cb_info->fd, msg);
881 g_mutex_unlock(&cb_info->fd_lock);
885 CAM_LOG_ERROR("message send failed");
887 *ret = CAMERA_ERROR_INVALID_OPERATION;
890 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
893 _camera_update_api_waiting(cb_info, api, -1);
895 muse_core_msg_free(msg);
897 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
898 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
900 CAM_LOG_DEBUG("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
904 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
906 int ret = CAMERA_ERROR_NONE;
909 if (!cb_info->is_server_connected) {
910 CAM_LOG_ERROR("server is disconnected");
911 return CAMERA_ERROR_SERVICE_DISCONNECTED;
914 g_mutex_lock(&(cb_info->api_mutex[api]));
916 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
918 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
920 while (!cb_info->api_activating[api]) {
921 if (time_out == CAMERA_CB_NO_TIMEOUT) {
922 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
923 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
924 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
925 CAM_LOG_ERROR("api %d TIMED OUT!", api);
926 ret = CAMERA_ERROR_INVALID_OPERATION;
930 if (!cb_info->is_server_connected) {
931 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
935 if (!cb_info->api_activating[api])
936 CAM_LOG_WARNING("invalid signal received, wait again...");
939 ret = cb_info->api_ret[api];
940 cb_info->api_activating[api] = FALSE;
943 g_mutex_unlock(&(cb_info->api_mutex[api]));
945 if (ret != CAMERA_ERROR_NONE)
946 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
952 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
953 int *ret, int timeout)
958 CAM_LOG_ERROR("NULL info - api %d", api);
961 *ret = CAMERA_ERROR_INVALID_PARAMETER;
966 msg = muse_core_msg_new(api, NULL);
968 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
972 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
973 int *ret, camera_msg_param *param, int timeout)
978 if (!cb_info || !param) {
979 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
982 *ret = CAMERA_ERROR_INVALID_PARAMETER;
987 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
989 switch (param->type) {
991 msg = muse_core_msg_new(api,
992 param->type, param->name, param->value.value_INT,
995 case MUSE_TYPE_STRING:
996 msg = muse_core_msg_new(api,
997 param->type, param->name, param->value.value_STRING,
1000 case MUSE_TYPE_ARRAY:
1001 array_length = param->value_size / sizeof(int) + \
1002 (param->value_size % sizeof(int) ? 1 : 0);
1004 msg = muse_core_msg_new(api,
1005 param->type, param->name, array_length, param->value.value_ARRAY,
1009 CAM_LOG_ERROR("unknown type %d", param->type);
1013 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1017 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
1018 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
1022 if (!cb_info || !param0 || !param1) {
1023 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
1024 cb_info, param0, param1, api);
1027 *ret = CAMERA_ERROR_INVALID_PARAMETER;
1032 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
1034 param0->name, param0->value.value_INT,
1035 param1->name, param1->value.value_INT);
1037 msg = muse_core_msg_new(api,
1038 param0->type, param0->name, param0->value.value_INT,
1039 param1->type, param1->name, param1->value.value_INT,
1042 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1046 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
1048 camera_msg_param param;
1051 CAM_LOG_WARNING("invalid fd %d", ret_fd);
1055 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
1057 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1061 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
1063 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1064 in_format >= MM_PIXEL_FORMAT_NUM ||
1065 out_format == NULL) {
1066 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
1067 return CAMERA_ERROR_INVALID_PARAMETER;
1070 switch (in_format) {
1071 case MM_PIXEL_FORMAT_NV12:
1072 case MM_PIXEL_FORMAT_NV12T:
1073 *out_format = TBM_FORMAT_NV12;
1076 case MM_PIXEL_FORMAT_NV16:
1077 *out_format = TBM_FORMAT_NV16;
1079 case MM_PIXEL_FORMAT_NV21:
1080 *out_format = TBM_FORMAT_NV21;
1082 case MM_PIXEL_FORMAT_YUYV:
1083 *out_format = TBM_FORMAT_YUYV;
1085 case MM_PIXEL_FORMAT_UYVY:
1086 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1087 *out_format = TBM_FORMAT_UYVY;
1089 case MM_PIXEL_FORMAT_422P:
1090 *out_format = TBM_FORMAT_YUV422;
1092 case MM_PIXEL_FORMAT_I420:
1093 *out_format = TBM_FORMAT_YUV420;
1095 case MM_PIXEL_FORMAT_YV12:
1096 *out_format = TBM_FORMAT_YVU420;
1098 case MM_PIXEL_FORMAT_RGB565:
1099 *out_format = TBM_FORMAT_RGB565;
1101 case MM_PIXEL_FORMAT_RGB888:
1102 *out_format = TBM_FORMAT_RGB888;
1104 case MM_PIXEL_FORMAT_RGBA:
1105 *out_format = TBM_FORMAT_RGBA8888;
1107 case MM_PIXEL_FORMAT_ARGB:
1108 *out_format = TBM_FORMAT_ARGB8888;
1111 CAM_LOG_ERROR("invalid in_format %d", in_format);
1112 return CAMERA_ERROR_INVALID_PARAMETER;
1116 return CAMERA_ERROR_NONE;
1120 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1122 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1123 in_format >= MM_PIXEL_FORMAT_NUM ||
1125 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1126 return CAMERA_ERROR_INVALID_PARAMETER;
1129 switch (in_format) {
1130 case MM_PIXEL_FORMAT_NV12:
1131 case MM_PIXEL_FORMAT_NV12T:
1132 *mimetype = MEDIA_FORMAT_NV12;
1135 case MM_PIXEL_FORMAT_NV16:
1136 *mimetype = MEDIA_FORMAT_NV16;
1138 case MM_PIXEL_FORMAT_NV21:
1139 *mimetype = MEDIA_FORMAT_NV21;
1141 case MM_PIXEL_FORMAT_YUYV:
1142 *mimetype = MEDIA_FORMAT_YUYV;
1144 case MM_PIXEL_FORMAT_UYVY:
1145 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1146 *mimetype = MEDIA_FORMAT_UYVY;
1148 case MM_PIXEL_FORMAT_422P:
1149 *mimetype = MEDIA_FORMAT_422P;
1151 case MM_PIXEL_FORMAT_I420:
1152 *mimetype = MEDIA_FORMAT_I420;
1154 case MM_PIXEL_FORMAT_YV12:
1155 *mimetype = MEDIA_FORMAT_YV12;
1157 case MM_PIXEL_FORMAT_RGB565:
1158 *mimetype = MEDIA_FORMAT_RGB565;
1160 case MM_PIXEL_FORMAT_RGB888:
1161 *mimetype = MEDIA_FORMAT_RGB888;
1163 case MM_PIXEL_FORMAT_RGBA:
1164 *mimetype = MEDIA_FORMAT_RGBA;
1166 case MM_PIXEL_FORMAT_ARGB:
1167 *mimetype = MEDIA_FORMAT_ARGB;
1169 case MM_PIXEL_FORMAT_ENCODED_H264:
1170 /* TODO: How can we determine the profile for H.264 format? */
1171 *mimetype = MEDIA_FORMAT_H264_SP;
1173 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1174 *mimetype = MEDIA_FORMAT_MJPEG;
1176 case MM_PIXEL_FORMAT_ENCODED_VP8:
1177 *mimetype = MEDIA_FORMAT_VP8;
1179 case MM_PIXEL_FORMAT_ENCODED_VP9:
1180 *mimetype = MEDIA_FORMAT_VP9;
1183 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1184 return CAMERA_ERROR_NOT_SUPPORTED;
1188 return CAMERA_ERROR_NONE;
1192 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1193 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1196 int ret = CAMERA_ERROR_NONE;
1197 camera_media_packet_data *new_mp_data = NULL;
1199 if (!tfd || !mp_data) {
1200 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1201 return CAMERA_ERROR_INVALID_PARAMETER;
1204 new_mp_data = g_new0(camera_media_packet_data, 1);
1206 new_mp_data->ret_fd = ret_fd;
1207 new_mp_data->fd = tfd[0];
1208 new_mp_data->num_buffer_fd = num_buffer_fd;
1209 new_mp_data->bo = bo;
1211 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1215 new_mp_data->data_bo = data_bo;
1216 new_mp_data->data_fd = tfd[1];
1218 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1219 new_mp_data->data_bo, new_mp_data->data_fd);
1222 for (i = 0 ; i < num_buffer_fd ; i++) {
1223 new_mp_data->buffer_bo[i] = buffer_bo[i];
1224 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1226 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1227 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1230 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1231 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1233 new_mp_data->data_fd = CAMERA_FD_INIT;
1236 *mp_data = new_mp_data;
1238 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1243 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1247 if (!mp_data || !cb_info) {
1248 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1252 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1254 /* release imported bo and close fd */
1255 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1256 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1257 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1259 tbm_bo_unref(mp_data->buffer_bo[i]);
1261 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1262 close(mp_data->buffer_fd[i]);
1264 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1267 if (mp_data->data_bo) {
1268 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1269 mp_data->data_fd, mp_data->data_bo);
1271 tbm_bo_unref(mp_data->data_bo);
1273 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1274 close(mp_data->data_fd);
1276 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1279 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1281 tbm_bo_unref(mp_data->bo);
1283 if (CAMERA_IS_FD_VALID(mp_data->fd))
1286 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1289 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1295 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1298 int ret = CAMERA_ERROR_NONE;
1299 uint32_t tbm_format = 0;
1300 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1301 tbm_surface_info_s tsurf_info;
1303 if (!stream || !mp_data) {
1304 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1308 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1309 CAM_LOG_ERROR("No valid data");
1313 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1314 if (ret != CAMERA_ERROR_NONE)
1317 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1319 if (mp_data->num_buffer_fd > 0) {
1320 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1321 bos[i] = mp_data->buffer_bo[i];
1323 bos[0] = mp_data->data_bo;
1326 tsurf_info.width = stream->width;
1327 tsurf_info.height = stream->height;
1328 tsurf_info.format = tbm_format;
1329 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1330 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1332 switch (tbm_format) {
1333 case TBM_FORMAT_NV12: /* fall through */
1334 case TBM_FORMAT_NV21: /* fall through */
1335 case TBM_FORMAT_YUV420: /* fall through */
1336 case TBM_FORMAT_YVU420: /* fall through */
1337 case TBM_FORMAT_UYVY: /* fall through */
1338 case TBM_FORMAT_YUYV:
1339 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1340 tsurf_info.planes[i].stride = stream->stride[i];
1341 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1342 if (i != 0 && mp_data->num_buffer_fd <= 1)
1343 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1344 tsurf_info.size += tsurf_info.planes[i].size;
1346 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1347 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1351 case TBM_FORMAT_RGB565: /* fall through */
1352 case TBM_FORMAT_RGB888: /* fall through */
1353 case TBM_FORMAT_RGBA8888: /* fall through */
1354 case TBM_FORMAT_ARGB8888:
1355 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1356 tsurf_info.planes[0].offset = 0;
1357 tsurf_info.size = stream->data.rgb.length_data;
1360 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1365 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1366 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1370 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1372 int ret = CAMERA_ERROR_NONE;
1373 int pkt_fmt_width = 0;
1374 int pkt_fmt_height = 0;
1375 bool make_pkt_fmt = false;
1376 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1377 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1379 if (!cb_info || !stream) {
1380 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1381 return CAMERA_ERROR_INVALID_PARAMETER;
1384 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1385 if (ret != CAMERA_ERROR_NONE)
1388 /* check media packet format */
1389 if (cb_info->pkt_fmt) {
1390 media_format_get_video_info(cb_info->pkt_fmt,
1391 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1393 CAM_LOG_DEBUG("pkt_fmt %dx%d - stream %dx%d",
1394 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1396 if (pkt_fmt_mimetype != mimetype ||
1397 pkt_fmt_width != stream->width ||
1398 pkt_fmt_height != stream->height) {
1399 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1400 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1402 media_format_unref(cb_info->pkt_fmt);
1403 cb_info->pkt_fmt = NULL;
1404 make_pkt_fmt = true;
1407 make_pkt_fmt = true;
1410 /* create packet format */
1412 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1413 mimetype, stream->width, stream->height);
1415 ret = media_format_create(&cb_info->pkt_fmt);
1416 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1417 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1418 return CAMERA_ERROR_INVALID_OPERATION;
1421 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1422 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1423 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1424 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1425 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1426 return CAMERA_ERROR_INVALID_OPERATION;
1430 return CAMERA_ERROR_NONE;
1434 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1435 camera_media_packet_data *mp_data, media_packet_h *packet)
1437 media_packet_h pkt = NULL;
1438 tbm_surface_h tsurf = NULL;
1439 int ret = CAMERA_ERROR_NONE;
1441 if (!cb_info || !stream || !mp_data || !packet) {
1442 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1443 cb_info, stream, mp_data, packet);
1444 return CAMERA_ERROR_INVALID_PARAMETER;
1447 ret = __camera_update_media_packet_format(cb_info, stream);
1448 if (ret != CAMERA_ERROR_NONE)
1451 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1452 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1453 stream->data.encoded.data, stream->data.encoded.length_data,
1454 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1458 if (!stream->data.encoded.is_delta_frame)
1459 media_packet_set_flags(pkt, MEDIA_PACKET_SYNC_FRAME);
1461 if (stream->data.encoded.is_header_included) {
1462 media_packet_set_flags(pkt, MEDIA_PACKET_CODEC_CONFIG);
1463 CAM_LOG_INFO("Codec config in buffer");
1467 tsurf = __camera_get_tbm_surface(stream, mp_data);
1469 CAM_LOG_ERROR("get tbm surface failed");
1470 ret = CAMERA_ERROR_INVALID_OPERATION;
1471 goto _PACKET_CREATE_FAILED;
1474 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1475 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1476 (void *)cb_info, &pkt);
1479 if (ret != MEDIA_PACKET_ERROR_NONE) {
1480 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1481 goto _PACKET_CREATE_FAILED;
1484 ret = media_packet_set_extra(pkt, (void *)mp_data);
1485 if (ret != MEDIA_PACKET_ERROR_NONE) {
1486 CAM_LOG_ERROR("media_packet_set_extra failed");
1487 goto _PACKET_CREATE_FAILED;
1490 if (media_packet_set_pts(pkt, stream->timestamp_nsec) != MEDIA_PACKET_ERROR_NONE)
1491 CAM_LOG_WARNING("media_packet_set_pts failed");
1493 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1494 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1496 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1500 return CAMERA_ERROR_NONE;
1502 _PACKET_CREATE_FAILED:
1504 tbm_surface_destroy(tsurf);
1506 media_packet_unref(pkt);
1508 return CAMERA_ERROR_INVALID_OPERATION;
1511 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1514 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1515 camera_media_packet_data *mp_data = NULL;
1516 tbm_surface_h tsurf = NULL;
1518 if (!pkt || !cb_info) {
1519 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1523 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1524 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1525 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1529 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1531 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1532 pkt, mp_data, tsurf);
1535 tbm_surface_destroy(tsurf);
1537 g_mutex_lock(&cb_info->mp_data_mutex);
1538 __camera_release_media_packet_data(mp_data, cb_info);
1539 g_mutex_unlock(&cb_info->mp_data_mutex);
1542 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1547 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1548 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1552 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1554 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1556 if (cb_info->user_cb[event] == NULL) {
1557 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1558 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1559 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1560 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1561 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1562 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1566 /* return buffer message should be sent for some events.
1567 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1568 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1569 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1570 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1575 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1581 muse_camera_msg_get(previous, recv_msg);
1582 muse_camera_msg_get(current, recv_msg);
1583 muse_camera_msg_get(by_policy, recv_msg);
1585 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1586 previous, current, by_policy);
1588 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1589 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1592 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1596 muse_camera_msg_get(state, recv_msg);
1598 CAM_LOG_INFO("FOCUS state - %d", state);
1600 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1603 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1604 CAM_LOG_INFO("CAPTURE_COMPLETED");
1605 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1607 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1608 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1609 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1612 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1616 muse_camera_msg_get(percent, recv_msg);
1618 CAM_LOG_INFO("HDR progress - %d %%", percent);
1620 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1623 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1629 muse_camera_msg_get(policy, recv_msg);
1630 muse_camera_msg_get(previous, recv_msg);
1631 muse_camera_msg_get(current, recv_msg);
1633 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1635 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1636 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1639 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1644 muse_camera_msg_get(policy, recv_msg);
1645 muse_camera_msg_get(state, recv_msg);
1647 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1649 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1650 (camera_state_e)state, cb_info->user_data[event]);
1653 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1654 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1656 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1659 int current_state = 0;
1661 muse_camera_msg_get(error, recv_msg);
1662 muse_camera_msg_get(current_state, recv_msg);
1664 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1666 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1667 (camera_state_e)current_state, cb_info->user_data[event]);
1671 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1673 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1674 muse_camera_msg_get(param1, recv_msg);
1675 muse_camera_msg_get(param2, recv_msg);
1677 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1679 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1680 cb_info->user_cb[event] = NULL;
1681 cb_info->user_data[event] = NULL;
1682 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1685 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1687 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1689 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1691 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1693 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1695 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1697 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1699 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1701 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1703 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1705 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1707 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1709 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1712 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1714 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1715 muse_camera_msg_get(param1, recv_msg);
1717 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1719 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1720 cb_info->user_cb[event] = NULL;
1721 cb_info->user_data[event] = NULL;
1722 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1726 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1727 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1730 CAM_LOG_WARNING("unhandled event %d", event);
1734 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1737 static gboolean __camera_idle_event_callback(gpointer data)
1739 camera_cb_info_s *cb_info = NULL;
1740 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1742 if (cam_idle_event == NULL) {
1743 CAM_LOG_ERROR("cam_idle_event is NULL");
1748 g_mutex_lock(&g_cam_idle_event_lock);
1750 cb_info = cam_idle_event->cb_info;
1751 if (cb_info == NULL) {
1752 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1753 g_mutex_unlock(&g_cam_idle_event_lock);
1754 goto IDLE_EVENT_CALLBACK_DONE;
1757 /* remove event from list */
1758 if (cb_info->idle_event_list)
1759 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1761 g_mutex_unlock(&g_cam_idle_event_lock);
1764 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1766 IDLE_EVENT_CALLBACK_DONE:
1768 g_free(cam_idle_event);
1769 cam_idle_event = NULL;
1774 static gpointer __camera_msg_handler_func(gpointer data)
1778 camera_message_s *cam_msg = NULL;
1779 camera_idle_event_s *cam_idle_event = NULL;
1780 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1781 camera_cb_info_s *cb_info = NULL;
1782 GThread *thread = NULL;
1784 if (!handler_info || !handler_info->cb_info) {
1785 CAM_LOG_ERROR("NULL handler %p", handler_info);
1789 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1790 type = handler_info->type;
1791 thread = handler_info->thread;
1793 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1795 g_mutex_lock(&handler_info->mutex);
1797 while (g_atomic_int_get(&handler_info->running)) {
1798 if (g_queue_is_empty(handler_info->queue)) {
1799 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1800 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1801 CAM_LOG_VERBOSE("t[%d] signal received", type);
1803 if (g_atomic_int_get(&handler_info->running) == 0) {
1804 CAM_LOG_INFO("t:%d stop event thread", type);
1809 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1811 g_mutex_unlock(&handler_info->mutex);
1813 if (cam_msg == NULL) {
1814 CAM_LOG_ERROR("t:%d NULL message", type);
1815 g_mutex_lock(&handler_info->mutex);
1821 if (api < MUSE_CAMERA_API_MAX) {
1824 g_mutex_lock(&cb_info->api_mutex[api]);
1826 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1827 if (cb_info->api_waiting[api] > 0) {
1828 cb_info->api_ret[api] = ret;
1829 cb_info->api_activating[api] = TRUE;
1831 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1833 g_cond_broadcast(&cb_info->api_cond[api]);
1835 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1838 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1841 g_mutex_unlock(&cb_info->api_mutex[api]);
1842 } else if (api == MUSE_CAMERA_CB_EVENT) {
1843 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1844 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1845 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1848 switch (cam_msg->event_class) {
1849 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1850 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1852 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1853 cam_idle_event = g_new0(camera_idle_event_s, 1);
1854 if (cam_idle_event == NULL) {
1855 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1859 cam_idle_event->event = cam_msg->event;
1860 cam_idle_event->cb_info = cb_info;
1862 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1863 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1865 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1866 type, cam_msg->event, cam_idle_event);
1868 g_mutex_lock(&g_cam_idle_event_lock);
1869 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1870 g_mutex_unlock(&g_cam_idle_event_lock);
1872 g_idle_add_full(G_PRIORITY_DEFAULT,
1873 (GSourceFunc)__camera_idle_event_callback,
1874 (gpointer)cam_idle_event,
1878 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1882 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1887 g_mutex_lock(&handler_info->mutex);
1890 /* remove remained event */
1891 while (!g_queue_is_empty(handler_info->queue)) {
1892 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1894 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1895 __camera_release_tfd(cam_msg->tfd);
1898 CAM_LOG_WARNING("t:%d NULL message", type);
1902 g_mutex_unlock(&handler_info->mutex);
1904 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1910 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1912 camera_idle_event_s *cam_idle_event = NULL;
1915 if (cb_info == NULL) {
1916 CAM_LOG_ERROR("cb_info is NULL");
1920 g_mutex_lock(&g_cam_idle_event_lock);
1922 if (cb_info->idle_event_list == NULL) {
1923 CAM_LOG_INFO("No remained idle event");
1924 g_mutex_unlock(&g_cam_idle_event_lock);
1928 list = cb_info->idle_event_list;
1931 cam_idle_event = list->data;
1932 list = g_list_next(list);
1934 if (!cam_idle_event) {
1935 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1939 if (g_idle_remove_by_data(cam_idle_event)) {
1940 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1942 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1944 g_free(cam_idle_event);
1949 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1950 cam_idle_event, cam_idle_event->event);
1952 cam_idle_event->cb_info = NULL;
1954 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1957 g_list_free(cb_info->idle_event_list);
1958 cb_info->idle_event_list = NULL;
1960 g_mutex_unlock(&g_cam_idle_event_lock);
1964 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1966 camera_message_s *cam_msg = NULL;
1968 if (!cb_info || !msg) {
1969 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1973 cam_msg = g_new0(camera_message_s, 1);
1975 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1980 cam_msg->event = event;
1981 cam_msg->event_class = event_class;
1984 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1986 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1988 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1989 api, event, event_class);
1991 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1992 if (!cb_info->preview_cb_info.thread) {
1993 LOGI("The thread for preview cb is not created yet, create it now");
1994 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1995 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1996 CAM_LOG_ERROR("failed to create thread for preview cb");
2002 g_mutex_lock(&cb_info->preview_cb_info.mutex);
2003 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
2004 g_cond_signal(&cb_info->preview_cb_info.cond);
2005 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
2006 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
2007 g_mutex_lock(&cb_info->capture_cb_info.mutex);
2008 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
2009 g_cond_signal(&cb_info->capture_cb_info.cond);
2010 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
2012 g_mutex_lock(&cb_info->msg_handler_info.mutex);
2013 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
2014 g_cond_signal(&cb_info->msg_handler_info.cond);
2015 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
2022 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
2024 int ret = CAMERA_ERROR_NONE;
2028 int event_class = -1;
2032 if (!cb_info || !msg) {
2033 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
2037 CAM_LOG_DEBUG("msg[%s]", msg);
2039 if (!muse_camera_msg_get(api, msg)) {
2040 CAM_LOG_ERROR("failed to get camera api");
2044 if (api == MUSE_CAMERA_CB_EVENT) {
2045 if (!muse_camera_msg_get(event, msg) ||
2046 !muse_camera_msg_get(event_class, msg)) {
2047 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
2051 if (!muse_camera_msg_get(api_class, msg)) {
2052 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
2057 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
2058 if (api >= MUSE_CAMERA_API_MAX) {
2059 CAM_LOG_ERROR("invalid api %d", api);
2063 if (!muse_camera_msg_get(ret, msg)) {
2064 CAM_LOG_ERROR("failed to get camera ret");
2068 g_mutex_lock(&cb_info->api_mutex[api]);
2071 case MUSE_CAMERA_API_CREATE:
2072 if (ret != CAMERA_ERROR_NONE) {
2073 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2074 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
2077 case MUSE_CAMERA_API_DESTROY:
2078 if (ret == CAMERA_ERROR_NONE) {
2079 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2080 CAM_LOG_INFO("camera destroy done. close client cb handler");
2084 muse_camera_msg_get(get_type, msg);
2085 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
2086 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
2087 muse_camera_msg_get(get_index, msg);
2090 case MUSE_CAMERA_GET_TYPE_INT:
2091 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
2093 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
2094 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
2095 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
2097 case MUSE_CAMERA_GET_TYPE_ARRAY:
2099 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
2100 muse_core_msg_deserialize("get_value",
2101 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2102 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
2103 cb_info->get_display_roi_area[0],
2104 cb_info->get_display_roi_area[1],
2105 cb_info->get_display_roi_area[2],
2106 cb_info->get_display_roi_area[3]);
2108 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
2109 muse_core_msg_deserialize("get_value",
2110 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2111 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2112 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2114 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2115 muse_core_msg_deserialize("get_value",
2116 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2117 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2118 cb_info->get_extra_preview_stream_format[0],
2119 cb_info->get_extra_preview_stream_format[1],
2120 cb_info->get_extra_preview_stream_format[2],
2121 cb_info->get_extra_preview_stream_format[3]);
2124 CAM_LOG_WARNING("unknown api[%d]", api);
2128 case MUSE_CAMERA_GET_TYPE_STRING:
2129 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2132 CAM_LOG_WARNING("unknown type %d", get_type);
2139 if (cb_info->api_waiting[api] > 0) {
2140 cb_info->api_ret[api] = ret;
2141 cb_info->api_activating[api] = TRUE;
2143 g_cond_broadcast(&cb_info->api_cond[api]);
2145 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2148 g_mutex_unlock(&cb_info->api_mutex[api]);
2149 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2150 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2152 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2157 static gpointer __camera_msg_recv_func(gpointer data)
2160 int recv_length = 0;
2161 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2162 char *recv_msg = NULL;
2163 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2166 CAM_LOG_ERROR("cb_info NULL");
2170 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2172 recv_msg = cb_info->recv_msg;
2174 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2175 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2176 tfd[i] = CAMERA_FD_INIT;
2178 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2179 if (recv_length <= 0) {
2180 cb_info->is_server_connected = FALSE;
2181 CAM_LOG_ERROR("receive msg failed - server disconnected");
2185 if (CAMERA_IS_FD_VALID(tfd[0]))
2186 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2188 recv_msg[recv_length] = '\0';
2190 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2192 __camera_process_msg(cb_info, recv_msg, tfd);
2195 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2198 if (!cb_info->is_server_connected) {
2199 char *error_msg = NULL;
2201 if (cb_info->bufmgr == NULL) {
2202 CAM_LOG_ERROR("No need to send error(handle is not created)");
2206 if (cb_info->fd < 0) {
2207 CAM_LOG_ERROR("fd is closed in client side");
2211 /* send error msg for server disconnection */
2212 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2213 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2214 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2218 CAM_LOG_ERROR("error_msg failed");
2222 __camera_add_msg_to_queue(cb_info,
2223 MUSE_CAMERA_CB_EVENT,
2224 MUSE_CAMERA_EVENT_TYPE_ERROR,
2225 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2229 muse_core_msg_free(error_msg);
2232 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2233 if (cb_info->api_waiting[i])
2234 g_cond_broadcast(&cb_info->api_cond[i]);
2237 CAM_LOG_ERROR("add error msg for service disconnection done");
2245 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2246 int type, const char *thread_name, camera_cb_info_s *cb_info)
2248 if (!handler_info || !thread_name || !cb_info) {
2249 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2250 type, handler_info, thread_name, cb_info);
2254 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2256 if (handler_info->thread) {
2257 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2261 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2263 handler_info->type = type;
2264 handler_info->queue = g_queue_new();
2265 if (handler_info->queue == NULL) {
2266 CAM_LOG_ERROR("t:%d queue failed", type);
2270 handler_info->cb_info = (void *)cb_info;
2271 g_atomic_int_set(&handler_info->running, 1);
2273 handler_info->thread = g_thread_try_new(thread_name,
2274 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2275 if (handler_info->thread == NULL) {
2276 CAM_LOG_ERROR("t:%d thread failed", type);
2278 g_queue_free(handler_info->queue);
2279 handler_info->queue = NULL;
2284 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2290 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2292 GThread *thread = NULL;
2294 if (!handler_info) {
2295 CAM_LOG_ERROR("NULL handler");
2299 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2301 if (!handler_info->thread) {
2302 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2306 thread = handler_info->thread;
2307 handler_info->thread = NULL;
2309 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2311 g_atomic_int_set(&handler_info->running, 0);
2312 g_cond_signal(&handler_info->cond);
2314 g_clear_pointer(&locker, g_mutex_locker_free);
2316 g_thread_join(thread);
2318 g_queue_free(handler_info->queue);
2319 handler_info->queue = NULL;
2321 CAM_LOG_INFO("t:%d done", handler_info->type);
2325 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2330 CAM_LOG_ERROR("NULL cb_info");
2334 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2335 g_mutex_init(&cb_info->api_mutex[i]);
2336 g_cond_init(&cb_info->api_cond[i]);
2339 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2340 g_mutex_init(&cb_info->user_cb_mutex[i]);
2342 g_mutex_init(&cb_info->fd_lock);
2343 g_mutex_init(&cb_info->mp_data_mutex);
2344 g_mutex_init(&cb_info->bridge_lock);
2346 g_mutex_init(&cb_info->msg_handler_info.mutex);
2347 g_mutex_init(&cb_info->preview_cb_info.mutex);
2348 g_mutex_init(&cb_info->capture_cb_info.mutex);
2349 g_cond_init(&cb_info->msg_handler_info.cond);
2350 g_cond_init(&cb_info->preview_cb_info.cond);
2351 g_cond_init(&cb_info->capture_cb_info.cond);
2353 CAM_LOG_INFO("done");
2357 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2362 CAM_LOG_ERROR("NULL cb_info");
2366 g_mutex_clear(&cb_info->msg_handler_info.mutex);
2367 g_mutex_clear(&cb_info->preview_cb_info.mutex);
2368 g_mutex_clear(&cb_info->capture_cb_info.mutex);
2369 g_cond_clear(&cb_info->msg_handler_info.cond);
2370 g_cond_clear(&cb_info->preview_cb_info.cond);
2371 g_cond_clear(&cb_info->capture_cb_info.cond);
2373 g_mutex_clear(&cb_info->fd_lock);
2374 g_mutex_clear(&cb_info->mp_data_mutex);
2375 g_mutex_clear(&cb_info->bridge_lock);
2377 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2378 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2380 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2381 g_mutex_clear(&cb_info->api_mutex[i]);
2382 g_cond_clear(&cb_info->api_cond[i]);
2385 CAM_LOG_INFO("done");
2389 static camera_preview_cb_monitoring_info_s *__camera_preview_cb_monitoring_info_create(int stream_id)
2391 camera_preview_cb_monitoring_info_s *new_info = g_new0(camera_preview_cb_monitoring_info_s, 1);
2393 new_info->stream_id = stream_id;
2394 new_info->total = g_new0(monitoring_info_sub_s, 1);
2395 new_info->interval = g_new0(monitoring_info_sub_s, 1);
2396 new_info->timer_calling = g_timer_new();
2397 new_info->timer_interval = g_timer_new();
2399 CAM_LOG_INFO("create preview cb monitoring info[%p]", new_info);
2405 static void __camera_preview_cb_monitoring_info_destroy(camera_preview_cb_monitoring_info_s *info)
2410 g_timer_destroy(info->timer_calling);
2411 g_timer_destroy(info->timer_interval);
2412 g_free(info->total);
2413 g_free(info->interval);
2415 CAM_LOG_INFO("destroy preview cb monitoring info[%p]", info);
2421 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2424 camera_cb_info_s *cb_info = NULL;
2426 g_return_val_if_fail(sockfd > 0, NULL);
2428 cb_info = g_new0(camera_cb_info_s, 1);
2430 CAM_LOG_ERROR("cb_info failed");
2434 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2436 __camera_mutex_cond_init(cb_info);
2438 /* message handler thread */
2439 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2440 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2441 CAM_LOG_ERROR("msg_handler_info failed");
2445 /* message handler thread for capture callback */
2446 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2447 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2448 CAM_LOG_ERROR("capture_cb_info failed");
2452 cb_info->fd = sockfd;
2454 /* message receive thread */
2455 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2456 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2457 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2458 if (cb_info->msg_recv_thread == NULL) {
2459 CAM_LOG_ERROR("message receive thread creation failed");
2464 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2465 cb_info->fds[i] = CAMERA_FD_INIT;
2467 cb_info->is_server_connected = TRUE;
2469 cb_info->monitoring_info_preview = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW);
2470 cb_info->monitoring_info_preview_mp = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW_MP);
2471 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2472 cb_info->monitoring_info_preview_ex[i] = __camera_preview_cb_monitoring_info_create(i);
2478 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2479 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2481 __camera_mutex_cond_clear(cb_info);
2492 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2497 CAM_LOG_ERROR("NULL cb_info");
2501 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2503 g_thread_join(cb_info->msg_recv_thread);
2504 cb_info->msg_recv_thread = NULL;
2506 CAM_LOG_INFO("msg_recv thread removed");
2508 /* destroy msg handler threads */
2509 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2510 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2511 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2513 __camera_mutex_cond_clear(cb_info);
2515 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2516 muse_client_close(cb_info->fd);
2517 cb_info->fd = CAMERA_FD_INIT;
2520 if (cb_info->bufmgr) {
2521 tbm_bufmgr_deinit(cb_info->bufmgr);
2522 cb_info->bufmgr = NULL;
2524 if (cb_info->pkt_fmt) {
2525 media_format_unref(cb_info->pkt_fmt);
2526 cb_info->pkt_fmt = NULL;
2529 if (cb_info->dp_interface) {
2530 mm_display_interface_deinit(cb_info->dp_interface);
2531 cb_info->dp_interface = NULL;
2534 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview);
2535 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_mp);
2536 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2537 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_ex[i]);
2543 int _camera_start_evas_rendering(camera_h camera)
2545 camera_cli_s *pc = (camera_cli_s *)camera;
2547 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2549 CAM_LOG_INFO("start");
2551 if (!pc->cb_info->is_evas_render) {
2552 CAM_LOG_ERROR("EVAS surface is not set");
2553 return CAMERA_ERROR_NONE;
2556 /* set evas render flag as RUN */
2557 pc->cb_info->run_evas_render = true;
2559 return CAMERA_ERROR_NONE;
2563 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2565 int ret = CAMERA_ERROR_NONE;
2566 camera_cli_s *pc = (camera_cli_s *)camera;
2568 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2570 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2572 if (!pc->cb_info->is_evas_render) {
2573 CAM_LOG_ERROR("EVAS surface is not set");
2574 return CAMERA_ERROR_NONE;
2577 /* set evas render flag as STOP and release buffers */
2578 pc->cb_info->run_evas_render = false;
2580 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2581 if (ret == MM_ERROR_NONE) {
2582 ret = CAMERA_ERROR_NONE;
2584 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2585 ret = CAMERA_ERROR_INVALID_OPERATION;
2592 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2594 int ret = CAMERA_ERROR_NONE;
2595 int sock_fd = CAMERA_FD_INIT;
2596 int module_index = -1;
2598 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2600 /* create muse connection */
2601 if (!key || !value) {
2602 CAM_LOG_ERROR("NULL pointer");
2603 return CAMERA_ERROR_INVALID_PARAMETER;
2606 sock_fd = muse_client_new();
2608 CAM_LOG_ERROR("muse_client_new failed");
2609 return CAMERA_ERROR_INVALID_OPERATION;
2612 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2613 CAM_LOG_ERROR("muse client get module index failed");
2614 ret = CAMERA_ERROR_INVALID_OPERATION;
2618 msg = muse_core_msg_new(api,
2619 MUSE_TYPE_INT, "module", module_index,
2620 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2623 CAM_LOG_ERROR("msg failed");
2624 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2628 ret = muse_core_msg_send(sock_fd, msg);
2630 muse_core_msg_free(msg);
2634 CAM_LOG_ERROR("send msg failed");
2635 ret = CAMERA_ERROR_INVALID_OPERATION;
2639 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2641 CAM_LOG_ERROR("recv msg failed %d", errno);
2642 ret = CAMERA_ERROR_INVALID_OPERATION;
2646 if (!muse_camera_msg_get(ret, recv_msg)) {
2647 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2648 ret = CAMERA_ERROR_INVALID_OPERATION;
2652 if (ret == CAMERA_ERROR_NONE)
2653 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2655 CAM_LOG_INFO("api %d - value %d", api, *value);
2658 if (CAMERA_IS_FD_VALID(sock_fd)) {
2659 muse_client_close(sock_fd);
2660 sock_fd = CAMERA_FD_INIT;
2667 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2669 int sock_fd = CAMERA_FD_INIT;
2670 char *send_msg = NULL;
2672 int ret = CAMERA_ERROR_NONE;
2673 camera_cli_s *pc = NULL;
2674 tbm_bufmgr bufmgr = NULL;
2676 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2677 int module_index = -1;
2678 int device_type = (int)device;
2680 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2682 sock_fd = muse_client_new();
2684 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2685 ret = CAMERA_ERROR_INVALID_OPERATION;
2689 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2690 CAM_LOG_ERROR("muse client get module index failed");
2691 ret = CAMERA_ERROR_INVALID_OPERATION;
2695 send_msg = muse_core_msg_new(api,
2696 MUSE_TYPE_INT, "module", module_index,
2697 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2698 MUSE_TYPE_INT, "is_network", (int)is_network,
2702 CAM_LOG_ERROR("NULL msg");
2703 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2707 send_ret = muse_core_msg_send(sock_fd, send_msg);
2709 muse_core_msg_free(send_msg);
2713 CAM_LOG_ERROR("send msg failed %d", errno);
2714 ret = CAMERA_ERROR_INVALID_OPERATION;
2718 pc = g_new0(camera_cli_s, 1);
2720 CAM_LOG_ERROR("camera_cli_s alloc failed");
2721 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2725 bufmgr = tbm_bufmgr_init(-1);
2726 if (bufmgr == NULL) {
2727 CAM_LOG_ERROR("get tbm bufmgr failed");
2728 ret = CAMERA_ERROR_INVALID_OPERATION;
2732 pc->cb_info = __camera_client_callback_new(sock_fd);
2733 if (pc->cb_info == NULL) {
2734 CAM_LOG_ERROR("cb_info alloc failed");
2735 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2739 sock_fd = CAMERA_FD_INIT;
2741 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2743 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2745 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2747 if (ret == CAMERA_ERROR_NONE) {
2748 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2749 int user_buffer_supported = 0;
2750 int log_level = CAMERA_LOG_LEVEL_INFO;
2751 intptr_t handle = 0;
2753 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2755 CAM_LOG_ERROR("Receiving Handle Failed!!");
2756 ret = CAMERA_ERROR_INVALID_OPERATION;
2760 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2761 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2762 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2764 pc->remote_handle = handle;
2765 pc->cb_info->bufmgr = bufmgr;
2766 pc->cb_info->preview_format = preview_format;
2767 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2768 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2769 pc->cb_info->is_network = is_network;
2770 g_camera_log_level = log_level;
2772 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2773 preview_format, user_buffer_supported, g_camera_log_level);
2776 CAM_LOG_ERROR("NULL out handle");
2777 ret= CAMERA_ERROR_INVALID_PARAMETER;
2781 *camera = (camera_h)pc;
2783 /* get display interface handle */
2784 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2785 CAM_LOG_WARNING("display interface init failed");
2794 tbm_bufmgr_deinit(bufmgr);
2798 if (CAMERA_IS_FD_VALID(sock_fd)) {
2799 muse_client_close(sock_fd);
2800 sock_fd = CAMERA_FD_INIT;
2805 int temp_fd = pc->cb_info->fd;
2807 /* pc->cb_info->fd should be closed,
2808 because g_thread_join for msg_recv_thread is not returned
2809 in __camera_client_callback_destroy. */
2810 if (CAMERA_IS_FD_VALID(temp_fd)) {
2811 pc->cb_info->fd = CAMERA_FD_INIT;
2812 muse_client_close(temp_fd);
2815 __camera_client_callback_destroy(pc->cb_info);
2822 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2829 int camera_create(camera_device_e device, camera_h *camera)
2831 return _camera_create_private(device, false, camera);
2835 int camera_change_device(camera_h camera, camera_device_e device)
2838 int ret = CAMERA_ERROR_NONE;
2839 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2840 camera_cli_s *pc = (camera_cli_s *)camera;
2841 camera_msg_param param;
2843 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2845 CAMERA_MSG_PARAM_SET(param, INT, device);
2847 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2849 if (ret == CAMERA_ERROR_NONE) {
2850 /* reset callback and user data */
2851 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2852 pc->cb_info->user_cb[i] = NULL;
2853 pc->cb_info->user_data[i] = NULL;
2861 int camera_destroy(camera_h camera)
2863 int ret = CAMERA_ERROR_NONE;
2864 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2865 camera_cli_s *pc = (camera_cli_s *)camera;
2867 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2869 CAM_LOG_INFO("Enter");
2871 if (pc->cb_info->is_server_connected)
2872 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2874 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2876 if (ret == CAMERA_ERROR_NONE) {
2877 __camera_deactivate_idle_event_all(pc->cb_info);
2878 __camera_client_callback_destroy(pc->cb_info);
2885 CAM_LOG_INFO("ret : 0x%x", ret);
2890 int camera_start_preview(camera_h camera)
2893 int ret = CAMERA_ERROR_NONE;
2895 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2896 camera_cli_s *pc = (camera_cli_s *)camera;
2897 camera_state_e current_state = CAMERA_STATE_NONE;
2899 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2901 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2902 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2904 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2905 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2906 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2907 pc->cb_info->dp_info.type);
2908 return CAMERA_ERROR_INVALID_OPERATION;
2911 ret = camera_get_state(camera, ¤t_state);
2912 if (ret != CAMERA_ERROR_NONE) {
2913 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2917 if (current_state == CAMERA_STATE_CREATED) {
2918 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview);
2919 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_mp);
2920 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2921 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_ex[i]);
2923 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2924 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2925 CAM_LOG_ERROR("preview_cb_info failed");
2926 return CAMERA_ERROR_INVALID_OPERATION;
2929 if (pc->cb_info->user_buffer_supported) {
2930 if (!__camera_allocate_preview_buffer(camera)) {
2931 ret = CAMERA_ERROR_INVALID_OPERATION;
2935 fds = pc->cb_info->fds;
2939 pc->cb_info->invoke_preview_cb = TRUE;
2941 _camera_msg_send(api, fds, pc->cb_info, &ret,
2942 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2943 CAMERA_CB_NO_TIMEOUT);
2945 CAMERA_CB_TIMEOUT_FOR_PREVIEW);
2947 if (ret != CAMERA_ERROR_NONE)
2950 if (pc->cb_info->is_evas_render) {
2951 ret = _camera_start_evas_rendering(camera);
2952 if (ret != CAMERA_ERROR_NONE) {
2953 CAM_LOG_ERROR("stop preview because of error");
2954 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2959 CAM_LOG_INFO("done");
2961 return CAMERA_ERROR_NONE;
2964 if (current_state == CAMERA_STATE_CREATED) {
2965 if (pc->cb_info->user_buffer_supported)
2966 __camera_release_preview_buffer(camera);
2968 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2971 CAM_LOG_ERROR("failed : 0x%x", ret);
2977 int camera_stop_preview(camera_h camera)
2979 int ret = CAMERA_ERROR_NONE;
2980 camera_cli_s *pc = (camera_cli_s *)camera;
2981 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2982 camera_state_e current_state = CAMERA_STATE_NONE;
2984 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2986 CAM_LOG_INFO("Enter");
2989 if (pc->cb_info->is_evas_render) {
2990 ret = camera_get_state(camera, ¤t_state);
2991 if (ret != CAMERA_ERROR_NONE) {
2992 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2996 if (current_state == CAMERA_STATE_PREVIEW) {
2997 ret = _camera_stop_evas_rendering(camera, false);
2998 if (ret != CAMERA_ERROR_NONE)
3004 pc->cb_info->invoke_preview_cb = FALSE;
3006 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3008 if (ret == CAMERA_ERROR_NONE) {
3009 if (pc->cb_info->user_buffer_supported)
3010 __camera_release_preview_buffer(camera);
3012 /* release remained message for preview callback */
3013 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
3014 } else if (current_state == CAMERA_STATE_PREVIEW) {
3015 CAM_LOG_WARNING("restart evas rendering");
3016 _camera_start_evas_rendering(camera);
3019 CAM_LOG_INFO("ret : 0x%x", ret);
3025 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
3027 int ret = CAMERA_ERROR_NONE;
3028 camera_cli_s *pc = (camera_cli_s *)camera;
3029 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
3031 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3033 CAM_LOG_INFO("Enter");
3035 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3036 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3038 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3039 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3041 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3043 CAM_LOG_INFO("ret : 0x%x", ret);
3049 bool camera_is_supported_continuous_capture(camera_h camera)
3051 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
3055 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)
3057 int ret = CAMERA_ERROR_NONE;
3058 camera_cli_s *pc = (camera_cli_s *)camera;
3059 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
3060 camera_msg_param param;
3063 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3065 CAM_LOG_INFO("Enter");
3067 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3068 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3070 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3071 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3073 value = (count << 16) | interval;
3074 CAMERA_MSG_PARAM_SET(param, INT, value);
3076 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3078 CAM_LOG_INFO("ret : 0x%x", ret);
3084 int camera_stop_continuous_capture(camera_h camera)
3086 int ret = CAMERA_ERROR_NONE;
3087 camera_cli_s *pc = (camera_cli_s *)camera;
3088 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
3090 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3092 CAM_LOG_INFO("Enter");
3094 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3096 CAM_LOG_INFO("ret : 0x%x", ret);
3102 bool camera_is_supported_face_detection(camera_h camera)
3104 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
3108 bool camera_is_supported_zero_shutter_lag(camera_h camera)
3110 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
3114 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
3116 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
3120 bool camera_is_supported_extra_preview(camera_h camera)
3122 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
3126 int camera_get_device_count(camera_h camera, int *device_count)
3128 int ret = CAMERA_ERROR_NONE;
3129 camera_cli_s *pc = (camera_cli_s *)camera;
3130 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
3132 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3134 CAM_LOG_INFO("Enter");
3136 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3138 if (ret == CAMERA_ERROR_NONE)
3139 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3141 CAM_LOG_INFO("ret : 0x%x", ret);
3146 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3148 int ret = CAMERA_ERROR_NONE;
3149 camera_cli_s *pc = (camera_cli_s *)camera;
3150 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3152 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3154 CAM_LOG_INFO("Enter");
3156 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3158 if (ret == CAMERA_ERROR_NONE) {
3159 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3161 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3162 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3164 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3167 CAM_LOG_INFO("ret : 0x%x", ret);
3172 int camera_stop_face_detection(camera_h camera)
3174 int ret = CAMERA_ERROR_NONE;
3175 camera_cli_s *pc = (camera_cli_s *)camera;
3176 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3178 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3180 CAM_LOG_INFO("Enter");
3182 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3184 if (ret == CAMERA_ERROR_NONE) {
3185 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3187 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3188 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3190 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3193 CAM_LOG_INFO("ret : 0x%x", ret);
3198 int camera_get_state(camera_h camera, camera_state_e *state)
3200 int ret = CAMERA_ERROR_NONE;
3201 camera_cli_s *pc = (camera_cli_s *)camera;
3202 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3204 if (!pc || !pc->cb_info || !state) {
3205 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3206 return CAMERA_ERROR_INVALID_PARAMETER;
3209 CAM_LOG_INFO("Enter");
3211 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3213 if (ret == CAMERA_ERROR_NONE)
3214 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3216 CAM_LOG_INFO("ret : 0x%x", ret);
3221 int camera_start_focusing(camera_h camera, bool continuous)
3223 int ret = CAMERA_ERROR_NONE;
3224 camera_cli_s *pc = (camera_cli_s *)camera;
3225 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3226 camera_msg_param param;
3227 int is_continuous = (int)continuous;
3229 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3231 CAM_LOG_INFO("Enter");
3233 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3235 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3237 CAM_LOG_INFO("ret : 0x%x", ret);
3242 int camera_cancel_focusing(camera_h camera)
3244 int ret = CAMERA_ERROR_NONE;
3245 camera_cli_s *pc = (camera_cli_s *)camera;
3246 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3248 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3250 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3252 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3254 CAM_LOG_INFO("ret : 0x%x", ret);
3260 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3262 int mm_ret = MM_ERROR_NONE;
3263 int ret = CAMERA_ERROR_NONE;
3264 camera_cli_s *pc = (camera_cli_s *)camera;
3265 camera_cb_info_s *cb_info = NULL;
3266 camera_state_e current_state = CAMERA_STATE_NONE;
3267 camera_msg_param param;
3268 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3269 muse_camera_display_info_s *dp_info = NULL;
3271 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3273 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3274 CAM_LOG_ERROR("invalid type %d", type);
3275 return CAMERA_ERROR_INVALID_PARAMETER;
3278 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3279 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3280 return CAMERA_ERROR_INVALID_PARAMETER;
3283 cb_info = (camera_cb_info_s *)pc->cb_info;
3284 dp_info = &cb_info->dp_info;
3286 ret = camera_get_state(camera, ¤t_state);
3287 if (ret != CAMERA_ERROR_NONE) {
3288 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3292 if (current_state != CAMERA_STATE_CREATED) {
3293 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3294 return CAMERA_ERROR_INVALID_STATE;
3297 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3299 if (type != MM_DISPLAY_TYPE_NONE) {
3300 /* check display interface handle */
3301 if (!cb_info->dp_interface) {
3302 CAM_LOG_ERROR("display interface not supported");
3303 return CAMERA_ERROR_NOT_SUPPORTED;
3306 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3307 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3308 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3309 return CAMERA_ERROR_NOT_SUPPORTED;
3310 } else if (mm_ret != MM_ERROR_NONE) {
3311 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3312 return CAMERA_ERROR_INVALID_OPERATION;
3315 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3316 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3318 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3319 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3320 dp_info->window_rect.width, dp_info->window_rect.height);
3321 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3323 camera_flip_e flip = CAMERA_FLIP_NONE;
3324 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3325 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3332 camera_get_display_flip(camera, &flip);
3333 camera_get_display_mode(camera, &mode);
3334 camera_get_display_rotation(camera, &rotation);
3335 camera_is_display_visible(camera, &visible);
3337 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3338 flip, mode, rotation, visible);
3340 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3341 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3342 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3343 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3345 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3346 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3347 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3348 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3354 if (mm_ret != MM_ERROR_NONE) {
3355 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3356 return CAMERA_ERROR_INVALID_OPERATION;
3359 dp_info->type = type;
3361 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3363 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3365 if (ret == CAMERA_ERROR_NONE)
3366 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3372 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3374 CAM_LOG_INFO("type %d, display %p", type, display);
3375 return _camera_set_display(camera, (mm_display_type_e)type, display);
3379 int camera_set_preview_resolution(camera_h camera, int width, int height)
3381 int ret = CAMERA_ERROR_NONE;
3382 camera_state_e current_state = CAMERA_STATE_NONE;
3383 camera_cli_s *pc = (camera_cli_s *)camera;
3384 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3385 camera_msg_param param;
3388 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3390 if (pc->cb_info->is_evas_render) {
3391 ret = camera_get_state(camera, ¤t_state);
3392 if (ret != CAMERA_ERROR_NONE) {
3393 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3397 if (current_state == CAMERA_STATE_PREVIEW) {
3398 ret = _camera_stop_evas_rendering(camera, true);
3399 if (ret != CAMERA_ERROR_NONE)
3404 value = (width << 16) | height;
3405 CAMERA_MSG_PARAM_SET(param, INT, value);
3407 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3409 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3411 CAM_LOG_INFO("ret : 0x%x", ret);
3413 if (current_state == CAMERA_STATE_PREVIEW) {
3414 CAM_LOG_WARNING("restart evas rendering");
3415 _camera_start_evas_rendering(camera);
3422 int camera_set_capture_resolution(camera_h camera, int width, int height)
3424 int ret = CAMERA_ERROR_NONE;
3425 camera_cli_s *pc = (camera_cli_s *)camera;
3426 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3427 camera_msg_param param;
3430 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3432 CAM_LOG_INFO("Enter");
3434 value = (width << 16) | height;
3435 CAMERA_MSG_PARAM_SET(param, INT, value);
3437 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3439 CAM_LOG_INFO("ret : 0x%x", ret);
3445 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3447 int ret = CAMERA_ERROR_NONE;
3448 int set_format = (int)format;
3449 camera_cli_s *pc = (camera_cli_s *)camera;
3450 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3451 camera_msg_param param;
3453 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3455 CAM_LOG_INFO("Enter - format %d", set_format);
3457 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3459 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3461 CAM_LOG_INFO("ret : 0x%x", ret);
3467 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3469 int ret = CAMERA_ERROR_NONE;
3470 int set_format = (int)format;
3471 camera_msg_param param;
3472 camera_cli_s *pc = (camera_cli_s *)camera;
3473 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3475 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3477 CAM_LOG_INFO("Enter - format %d", set_format);
3479 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3481 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3483 if (ret == CAMERA_ERROR_NONE)
3484 pc->cb_info->preview_format = set_format;
3486 CAM_LOG_INFO("ret : 0x%x", ret);
3492 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3494 int ret = CAMERA_ERROR_NONE;
3495 camera_cli_s *pc = (camera_cli_s *)camera;
3496 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3498 if (!pc || !pc->cb_info || !width || !height) {
3499 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3500 return CAMERA_ERROR_INVALID_PARAMETER;
3503 CAM_LOG_INFO("Enter");
3505 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3507 if (ret == CAMERA_ERROR_NONE) {
3508 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3509 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3512 CAM_LOG_INFO("ret : 0x%x", ret);
3518 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3520 int ret = CAMERA_ERROR_NONE;
3521 int set_rotation = (int)rotation;
3522 camera_cli_s *pc = (camera_cli_s *)camera;
3523 camera_msg_param param;
3525 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3527 if (pc->cb_info->is_evas_render) {
3528 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3529 if (ret != MM_ERROR_NONE) {
3530 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3531 return CAMERA_ERROR_INVALID_OPERATION;
3535 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3537 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3543 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3545 int ret = CAMERA_ERROR_NONE;
3546 camera_cli_s *pc = (camera_cli_s *)camera;
3548 if (!pc || !pc->cb_info || !rotation) {
3549 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3550 return CAMERA_ERROR_INVALID_PARAMETER;
3553 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3555 if (ret == CAMERA_ERROR_NONE)
3556 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3562 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3564 int ret = CAMERA_ERROR_NONE;
3565 int set_flip = (int)flip;
3566 camera_cli_s *pc = (camera_cli_s *)camera;
3567 camera_msg_param param;
3569 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3571 if (pc->cb_info->is_evas_render) {
3572 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3573 if (ret != MM_ERROR_NONE) {
3574 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3575 return CAMERA_ERROR_INVALID_OPERATION;
3579 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3581 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3587 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3589 int ret = CAMERA_ERROR_NONE;
3590 camera_cli_s *pc = (camera_cli_s *)camera;
3592 if (!pc || !pc->cb_info || !flip) {
3593 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3594 return CAMERA_ERROR_INVALID_PARAMETER;
3597 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3599 if (ret == CAMERA_ERROR_NONE)
3600 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3606 int camera_set_display_visible(camera_h camera, bool visible)
3608 int ret = CAMERA_ERROR_NONE;
3609 int set_visible = (int)visible;
3610 camera_cli_s *pc = (camera_cli_s *)camera;
3611 camera_msg_param param;
3613 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3615 if (pc->cb_info->is_evas_render) {
3616 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3617 if (ret != MM_ERROR_NONE) {
3618 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3619 return CAMERA_ERROR_INVALID_OPERATION;
3623 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3625 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3631 int camera_is_display_visible(camera_h camera, bool *visible)
3633 int ret = CAMERA_ERROR_NONE;
3634 camera_cli_s *pc = (camera_cli_s *)camera;
3636 if (!pc || !pc->cb_info || !visible) {
3637 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3638 return CAMERA_ERROR_INVALID_PARAMETER;
3641 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3643 if (ret == CAMERA_ERROR_NONE)
3644 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3650 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3652 int ret = CAMERA_ERROR_NONE;
3653 int set_mode = (int)mode;
3654 camera_cli_s *pc = (camera_cli_s *)camera;
3655 camera_msg_param param;
3657 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3659 if (pc->cb_info->is_evas_render) {
3660 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3661 if (ret != MM_ERROR_NONE) {
3662 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3663 return CAMERA_ERROR_INVALID_OPERATION;
3667 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3669 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3675 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3677 int ret = CAMERA_ERROR_NONE;
3678 camera_cli_s *pc = (camera_cli_s *)camera;
3680 if (!pc || !pc->cb_info || !mode) {
3681 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3682 return CAMERA_ERROR_INVALID_PARAMETER;
3685 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3687 if (ret == CAMERA_ERROR_NONE)
3688 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3694 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3696 int ret = CAMERA_ERROR_NONE;
3697 int set_hint = (int)hint;
3698 camera_cli_s *pc = (camera_cli_s *)camera;
3699 camera_msg_param param;
3701 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3703 CAM_LOG_INFO("Enter - hint %d", set_hint);
3705 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3707 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3713 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3715 int ret = CAMERA_ERROR_NONE;
3716 camera_cli_s *pc = (camera_cli_s *)camera;
3717 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3719 if (!pc || !pc->cb_info || !hint) {
3720 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3721 return CAMERA_ERROR_INVALID_PARAMETER;
3724 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3726 if (ret == CAMERA_ERROR_NONE) {
3727 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3728 CAM_LOG_INFO("display reuse hint %d", *hint);
3735 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3737 int ret = CAMERA_ERROR_NONE;
3738 camera_cli_s *pc = (camera_cli_s *)camera;
3739 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3741 if (!pc || !pc->cb_info || !width || !height) {
3742 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3743 return CAMERA_ERROR_INVALID_PARAMETER;
3746 CAM_LOG_INFO("Enter");
3748 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3750 if (ret == CAMERA_ERROR_NONE) {
3751 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3752 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3755 CAM_LOG_INFO("ret : 0x%x", ret);
3761 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3763 int ret = CAMERA_ERROR_NONE;
3764 camera_cli_s *pc = (camera_cli_s *)camera;
3765 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3767 if (!pc || !pc->cb_info || !format) {
3768 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3769 return CAMERA_ERROR_INVALID_PARAMETER;
3772 CAM_LOG_INFO("Enter");
3774 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3776 if (ret == CAMERA_ERROR_NONE)
3777 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3779 CAM_LOG_INFO("ret : 0x%x", ret);
3785 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3787 int ret = CAMERA_ERROR_NONE;
3788 camera_cli_s *pc = (camera_cli_s *)camera;
3789 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3791 if (!pc || !pc->cb_info || !format) {
3792 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3793 return CAMERA_ERROR_INVALID_PARAMETER;
3796 CAM_LOG_INFO("Enter");
3798 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3800 if (ret == CAMERA_ERROR_NONE)
3801 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3803 CAM_LOG_INFO("ret : 0x%x", ret);
3809 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3811 int ret = CAMERA_ERROR_NONE;
3812 camera_cli_s *pc = (camera_cli_s *)camera;
3813 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3815 if (!pc || !pc->cb_info || !facing_direction) {
3816 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3817 return CAMERA_ERROR_INVALID_PARAMETER;
3820 CAM_LOG_INFO("Enter");
3822 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3824 if (ret == CAMERA_ERROR_NONE)
3825 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3827 CAM_LOG_INFO("ret : 0x%x", ret);
3833 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3835 int ret = CAMERA_ERROR_NONE;
3836 camera_cli_s *pc = (camera_cli_s *)camera;
3837 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3839 if (!pc || !pc->cb_info || !callback) {
3840 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3841 return CAMERA_ERROR_INVALID_PARAMETER;
3844 CAM_LOG_INFO("Enter");
3846 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3848 if (ret == CAMERA_ERROR_NONE) {
3849 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3851 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3852 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3854 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3857 CAM_LOG_INFO("ret : 0x%x", ret);
3863 int camera_unset_preview_cb(camera_h camera)
3865 int ret = CAMERA_ERROR_NONE;
3866 camera_cli_s *pc = (camera_cli_s *)camera;
3867 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3869 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3871 CAM_LOG_INFO("Enter");
3873 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3875 if (ret == CAMERA_ERROR_NONE) {
3876 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3878 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3879 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3881 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3884 CAM_LOG_INFO("ret : 0x%x", ret);
3890 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3892 int ret = CAMERA_ERROR_NONE;
3893 camera_cli_s *pc = (camera_cli_s *)camera;
3894 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3896 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3898 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3899 CAM_LOG_ERROR("NOT SUPPORTED");
3900 return CAMERA_ERROR_NOT_SUPPORTED;
3903 if (callback == NULL) {
3904 CAM_LOG_ERROR("NULL callback");
3905 return CAMERA_ERROR_INVALID_PARAMETER;
3908 CAM_LOG_INFO("Enter");
3910 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3912 if (ret == CAMERA_ERROR_NONE) {
3913 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3915 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3916 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3918 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3921 CAM_LOG_INFO("ret : 0x%x", ret);
3927 int camera_unset_media_packet_preview_cb(camera_h camera)
3929 int ret = CAMERA_ERROR_NONE;
3930 camera_cli_s *pc = (camera_cli_s *)camera;
3931 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3933 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3935 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3936 CAM_LOG_ERROR("NOT SUPPORTED");
3937 return CAMERA_ERROR_NOT_SUPPORTED;
3940 CAM_LOG_INFO("Enter");
3942 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3944 if (ret == CAMERA_ERROR_NONE) {
3945 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3947 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3948 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3950 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3953 CAM_LOG_INFO("ret : 0x%x", ret);
3959 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3961 int ret = CAMERA_ERROR_NONE;
3962 camera_cli_s *pc = (camera_cli_s *)camera;
3963 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3965 if (!pc || !pc->cb_info || !callback) {
3966 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3967 return CAMERA_ERROR_INVALID_PARAMETER;
3970 CAM_LOG_INFO("Enter");
3972 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3974 if (ret == CAMERA_ERROR_NONE) {
3975 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3977 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3978 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3980 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3983 CAM_LOG_INFO("ret : 0x%x", ret);
3989 int camera_unset_state_changed_cb(camera_h camera)
3991 int ret = CAMERA_ERROR_NONE;
3992 camera_cli_s *pc = (camera_cli_s *)camera;
3993 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3995 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3997 CAM_LOG_INFO("Enter");
3999 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4001 if (ret == CAMERA_ERROR_NONE) {
4002 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4004 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4005 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4007 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4010 CAM_LOG_INFO("ret : 0x%x", ret);
4016 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4018 int ret = CAMERA_ERROR_NONE;
4019 camera_cli_s *pc = (camera_cli_s *)camera;
4020 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4022 if (!pc || !pc->cb_info || !callback) {
4023 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4024 return CAMERA_ERROR_INVALID_PARAMETER;
4027 CAM_LOG_INFO("Enter");
4029 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4031 if (ret == CAMERA_ERROR_NONE) {
4032 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4034 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4035 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4037 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4040 CAM_LOG_INFO("ret : 0x%x", ret);
4046 int camera_unset_interrupted_cb(camera_h camera)
4048 int ret = CAMERA_ERROR_NONE;
4049 camera_cli_s *pc = (camera_cli_s *)camera;
4050 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4052 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4054 CAM_LOG_INFO("Enter");
4056 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4058 if (ret == CAMERA_ERROR_NONE) {
4059 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4061 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4062 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4064 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4067 CAM_LOG_INFO("ret : 0x%x", ret);
4073 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4075 int ret = CAMERA_ERROR_NONE;
4076 camera_cli_s *pc = (camera_cli_s *)camera;
4077 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4079 if (!pc || !pc->cb_info || !callback) {
4080 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4081 return CAMERA_ERROR_INVALID_PARAMETER;
4084 CAM_LOG_INFO("Enter");
4086 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4088 if (ret == CAMERA_ERROR_NONE) {
4089 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4091 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4092 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4094 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4097 CAM_LOG_INFO("ret : 0x%x", ret);
4103 int camera_unset_interrupt_started_cb(camera_h camera)
4105 int ret = CAMERA_ERROR_NONE;
4106 camera_cli_s *pc = (camera_cli_s *)camera;
4107 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4109 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4111 CAM_LOG_INFO("Enter");
4113 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4115 if (ret == CAMERA_ERROR_NONE) {
4116 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4118 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4119 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4121 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4124 CAM_LOG_INFO("ret : 0x%x", ret);
4130 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4132 int ret = CAMERA_ERROR_NONE;
4133 camera_cli_s *pc = (camera_cli_s *)camera;
4134 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4136 if (!pc || !pc->cb_info || !callback) {
4137 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4138 return CAMERA_ERROR_INVALID_PARAMETER;
4141 CAM_LOG_INFO("Enter");
4143 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4145 if (ret == CAMERA_ERROR_NONE) {
4146 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4148 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4149 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4151 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4154 CAM_LOG_INFO("ret : 0x%x", ret);
4160 int camera_unset_focus_changed_cb(camera_h camera)
4162 int ret = CAMERA_ERROR_NONE;
4163 camera_cli_s *pc = (camera_cli_s *)camera;
4164 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4166 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4168 CAM_LOG_INFO("Enter");
4170 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4172 if (ret == CAMERA_ERROR_NONE) {
4173 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4175 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4176 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4178 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4181 CAM_LOG_INFO("ret : 0x%x", ret);
4187 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4189 int ret = CAMERA_ERROR_NONE;
4190 camera_cli_s *pc = (camera_cli_s *)camera;
4191 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4193 if (!pc || !pc->cb_info || !callback) {
4194 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4195 return CAMERA_ERROR_INVALID_PARAMETER;
4198 CAM_LOG_INFO("Enter");
4200 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4202 if (ret == CAMERA_ERROR_NONE) {
4203 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4205 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4206 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4208 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4211 CAM_LOG_INFO("ret : 0x%x", ret);
4217 int camera_unset_error_cb(camera_h camera)
4219 int ret = CAMERA_ERROR_NONE;
4220 camera_cli_s *pc = (camera_cli_s *)camera;
4221 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4223 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4225 CAM_LOG_INFO("Enter");
4227 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4229 if (ret == CAMERA_ERROR_NONE) {
4230 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4232 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4233 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4235 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4238 CAM_LOG_INFO("ret : 0x%x", ret);
4244 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4246 int ret = CAMERA_ERROR_NONE;
4247 camera_cli_s *pc = (camera_cli_s *)camera;
4248 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4250 if (!pc || !pc->cb_info || !foreach_cb) {
4251 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4252 return CAMERA_ERROR_INVALID_PARAMETER;
4255 CAM_LOG_INFO("Enter");
4257 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4258 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4260 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4262 CAM_LOG_INFO("ret : 0x%x", ret);
4268 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4270 int ret = CAMERA_ERROR_NONE;
4271 camera_cli_s *pc = (camera_cli_s *)camera;
4272 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4274 if (!pc || !pc->cb_info || !foreach_cb) {
4275 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4276 return CAMERA_ERROR_INVALID_PARAMETER;
4279 CAM_LOG_INFO("Enter");
4281 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4282 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4284 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4286 CAM_LOG_INFO("ret : 0x%x", ret);
4292 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4294 int ret = CAMERA_ERROR_NONE;
4295 camera_cli_s *pc = (camera_cli_s *)camera;
4296 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4298 if (!pc || !pc->cb_info || !foreach_cb) {
4299 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4300 return CAMERA_ERROR_INVALID_PARAMETER;
4303 CAM_LOG_INFO("Enter");
4305 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4306 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4308 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4310 CAM_LOG_INFO("ret : 0x%x", ret);
4316 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4318 int ret = CAMERA_ERROR_NONE;
4319 camera_cli_s *pc = (camera_cli_s *)camera;
4320 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4322 if (!pc || !pc->cb_info || !foreach_cb) {
4323 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4324 return CAMERA_ERROR_INVALID_PARAMETER;
4327 CAM_LOG_INFO("Enter");
4329 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4330 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4332 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4334 CAM_LOG_INFO("ret : 0x%x", ret);
4340 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4342 int ret = CAMERA_ERROR_NONE;
4343 camera_cli_s *pc = (camera_cli_s *)camera;
4344 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4346 if (!pc || !pc->cb_info || !width || !height) {
4347 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4348 return CAMERA_ERROR_INVALID_PARAMETER;
4351 CAM_LOG_INFO("Enter");
4352 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4354 if (ret == CAMERA_ERROR_NONE) {
4355 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4356 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4359 CAM_LOG_INFO("ret : 0x%x", ret);
4365 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4367 int ret = CAMERA_ERROR_NONE;
4368 camera_cli_s *pc = (camera_cli_s *)camera;
4369 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4371 if (!pc || !pc->cb_info || !angle) {
4372 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4373 return CAMERA_ERROR_INVALID_PARAMETER;
4376 CAM_LOG_INFO("Enter");
4378 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4380 if (ret == CAMERA_ERROR_NONE)
4381 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4383 CAM_LOG_INFO("ret : 0x%x", ret);
4389 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4391 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4395 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4397 int ret = CAMERA_ERROR_NONE;
4398 camera_cli_s *pc = (camera_cli_s *)camera;
4399 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4401 if (!pc || !pc->cb_info || !mode) {
4402 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4403 return CAMERA_ERROR_INVALID_PARAMETER;
4406 CAM_LOG_INFO("Enter");
4408 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4410 if (ret == CAMERA_ERROR_NONE)
4411 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4413 CAM_LOG_INFO("ret : 0x%x", ret);
4419 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4421 int ret = CAMERA_ERROR_NONE;
4422 camera_cli_s *pc = (camera_cli_s *)camera;
4423 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4425 if (!pc || !pc->cb_info || !foreach_cb) {
4426 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4427 return CAMERA_ERROR_INVALID_PARAMETER;
4430 CAM_LOG_INFO("Enter");
4432 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4433 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4435 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4437 CAM_LOG_INFO("Finish, return :%x", ret);
4443 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4445 int ret = CAMERA_ERROR_NONE;
4446 camera_cli_s *pc = (camera_cli_s *)camera;
4447 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4448 camera_msg_param param;
4449 int set_fps = (int)fps;
4451 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4453 CAM_LOG_INFO("Enter");
4455 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4457 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4459 CAM_LOG_INFO("ret : 0x%x", ret);
4465 int camera_attr_set_image_quality(camera_h camera, int quality)
4467 int ret = CAMERA_ERROR_NONE;
4468 camera_cli_s *pc = (camera_cli_s *)camera;
4469 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4470 camera_msg_param param;
4472 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4474 CAM_LOG_INFO("Enter");
4476 CAMERA_MSG_PARAM_SET(param, INT, quality);
4478 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4480 CAM_LOG_INFO("ret : 0x%x", ret);
4486 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4488 int ret = CAMERA_ERROR_NONE;
4489 camera_cli_s *pc = (camera_cli_s *)camera;
4490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4492 if (!pc || !pc->cb_info || !fps) {
4493 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4494 return CAMERA_ERROR_INVALID_PARAMETER;
4497 CAM_LOG_INFO("Enter");
4499 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4501 if (ret == CAMERA_ERROR_NONE)
4502 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4504 CAM_LOG_INFO("ret : 0x%x", ret);
4510 int camera_attr_get_image_quality(camera_h camera, int *quality)
4512 int ret = CAMERA_ERROR_NONE;
4513 camera_cli_s *pc = (camera_cli_s *)camera;
4514 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4516 if (!pc || !pc->cb_info || !quality) {
4517 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4518 return CAMERA_ERROR_INVALID_PARAMETER;
4521 CAM_LOG_INFO("Enter");
4523 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4525 if (ret == CAMERA_ERROR_NONE)
4526 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4528 CAM_LOG_INFO("ret : 0x%x", ret);
4534 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4536 int ret = CAMERA_ERROR_NONE;
4537 camera_cli_s *pc = (camera_cli_s *)camera;
4538 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4540 if (!pc || !pc->cb_info || !bitrate) {
4541 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4542 return CAMERA_ERROR_INVALID_PARAMETER;
4545 CAM_LOG_INFO("Enter");
4547 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4549 if (ret == CAMERA_ERROR_NONE)
4550 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4552 CAM_LOG_INFO("ret : 0x%x", ret);
4558 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4560 int ret = CAMERA_ERROR_NONE;
4561 camera_cli_s *pc = (camera_cli_s *)camera;
4562 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4563 camera_msg_param param;
4564 int set_bitrate = bitrate;
4566 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4568 CAM_LOG_INFO("Enter");
4570 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4572 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4574 CAM_LOG_INFO("ret : 0x%x", ret);
4580 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4582 int ret = CAMERA_ERROR_NONE;
4583 camera_cli_s *pc = (camera_cli_s *)camera;
4584 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4586 if (!pc || !pc->cb_info || !interval) {
4587 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4588 return CAMERA_ERROR_INVALID_PARAMETER;
4591 CAM_LOG_INFO("Enter");
4593 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4595 if (ret == CAMERA_ERROR_NONE)
4596 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4598 CAM_LOG_INFO("ret : 0x%x", ret);
4604 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4606 int ret = CAMERA_ERROR_NONE;
4607 camera_cli_s *pc = (camera_cli_s *)camera;
4608 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4609 camera_msg_param param;
4610 int set_gop_interval = interval;
4612 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4614 CAM_LOG_INFO("Enter");
4616 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4618 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4620 CAM_LOG_INFO("ret : 0x%x", ret);
4626 int camera_attr_set_zoom(camera_h camera, int zoom)
4628 int ret = CAMERA_ERROR_NONE;
4629 camera_cli_s *pc = (camera_cli_s *)camera;
4630 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4631 camera_msg_param param;
4633 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4635 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4637 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4639 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4641 CAM_LOG_INFO("ret : 0x%x", ret);
4647 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4649 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4653 int camera_attr_set_af_area(camera_h camera, int x, int y)
4655 int ret = CAMERA_ERROR_NONE;
4656 camera_cli_s *pc = (camera_cli_s *)camera;
4657 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4658 camera_msg_param param;
4661 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4663 CAM_LOG_INFO("Enter - %d,%d", x, y);
4665 value = (x << 16) | y;
4666 CAMERA_MSG_PARAM_SET(param, INT, value);
4668 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4670 CAM_LOG_INFO("ret : 0x%x", ret);
4676 int camera_attr_clear_af_area(camera_h camera)
4678 int ret = CAMERA_ERROR_NONE;
4679 camera_cli_s *pc = (camera_cli_s *)camera;
4680 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4682 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4684 CAM_LOG_INFO("Enter");
4686 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4688 CAM_LOG_INFO("ret : 0x%x", ret);
4694 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4696 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4700 int camera_attr_set_exposure(camera_h camera, int value)
4702 int ret = CAMERA_ERROR_NONE;
4703 camera_cli_s *pc = (camera_cli_s *)camera;
4704 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4705 camera_msg_param param;
4707 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4709 CAM_LOG_INFO("Enter");
4711 CAMERA_MSG_PARAM_SET(param, INT, value);
4713 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4715 CAM_LOG_INFO("ret : 0x%x", ret);
4721 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4723 int ret = CAMERA_ERROR_NONE;
4724 camera_cli_s *pc = (camera_cli_s *)camera;
4725 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4726 camera_msg_param param;
4727 int set_iso = (int)iso;
4729 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4731 CAM_LOG_INFO("Enter");
4733 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4735 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4737 CAM_LOG_INFO("ret : 0x%x", ret);
4743 int camera_attr_set_gain(camera_h camera, int level)
4745 int ret = CAMERA_ERROR_NONE;
4746 camera_cli_s *pc = (camera_cli_s *)camera;
4747 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GAIN;
4748 camera_msg_param param;
4750 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4752 CAM_LOG_INFO("Enter");
4754 CAMERA_MSG_PARAM_SET(param, INT, level);
4756 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4758 CAM_LOG_INFO("ret : 0x%x", ret);
4764 int camera_attr_set_brightness(camera_h camera, int level)
4766 int ret = CAMERA_ERROR_NONE;
4767 camera_cli_s *pc = (camera_cli_s *)camera;
4768 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4769 camera_msg_param param;
4771 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4773 CAM_LOG_INFO("Enter");
4775 CAMERA_MSG_PARAM_SET(param, INT, level);
4777 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4779 CAM_LOG_INFO("ret : 0x%x", ret);
4785 int camera_attr_set_contrast(camera_h camera, int level)
4787 int ret = CAMERA_ERROR_NONE;
4788 camera_cli_s *pc = (camera_cli_s *)camera;
4789 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4790 camera_msg_param param;
4792 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4794 CAM_LOG_INFO("Enter");
4796 CAMERA_MSG_PARAM_SET(param, INT, level);
4798 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4800 CAM_LOG_INFO("ret : 0x%x", ret);
4806 int camera_attr_set_hue(camera_h camera, int level)
4808 int ret = CAMERA_ERROR_NONE;
4809 camera_cli_s *pc = (camera_cli_s *)camera;
4810 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4811 camera_msg_param param;
4813 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4815 CAM_LOG_INFO("Enter");
4817 CAMERA_MSG_PARAM_SET(param, INT, level);
4819 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4821 CAM_LOG_INFO("ret : 0x%x", ret);
4827 int camera_attr_set_saturation(camera_h camera, int level)
4829 int ret = CAMERA_ERROR_NONE;
4830 camera_cli_s *pc = (camera_cli_s *)camera;
4831 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SATURATION;
4832 camera_msg_param param;
4834 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4836 CAM_LOG_INFO("Enter");
4838 CAMERA_MSG_PARAM_SET(param, INT, level);
4840 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4842 CAM_LOG_INFO("ret : 0x%x", ret);
4848 int camera_attr_set_sharpness(camera_h camera, int level)
4850 int ret = CAMERA_ERROR_NONE;
4851 camera_cli_s *pc = (camera_cli_s *)camera;
4852 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SHARPNESS;
4853 camera_msg_param param;
4855 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4857 CAM_LOG_INFO("Enter");
4859 CAMERA_MSG_PARAM_SET(param, INT, level);
4861 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4863 CAM_LOG_INFO("ret : 0x%x", ret);
4869 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4871 int ret = CAMERA_ERROR_NONE;
4872 camera_cli_s *pc = (camera_cli_s *)camera;
4873 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4874 camera_msg_param param;
4875 int set_whitebalance = (int)wb;
4877 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4879 CAM_LOG_INFO("Enter");
4881 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4883 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4885 CAM_LOG_INFO("ret : 0x%x", ret);
4891 int camera_attr_set_whitebalance_temperature(camera_h camera, int temperature)
4893 int ret = CAMERA_ERROR_NONE;
4894 camera_cli_s *pc = (camera_cli_s *)camera;
4895 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE_TEMPERATURE;
4896 camera_msg_param param;
4898 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4900 CAM_LOG_INFO("Enter");
4902 CAMERA_MSG_PARAM_SET(param, INT, temperature);
4904 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4906 CAM_LOG_INFO("ret : 0x%x", ret);
4912 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4914 int ret = CAMERA_ERROR_NONE;
4915 camera_cli_s *pc = (camera_cli_s *)camera;
4916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4917 camera_msg_param param;
4918 int set_effect = (int)effect;
4920 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4922 CAM_LOG_INFO("Enter");
4924 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4926 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4928 CAM_LOG_INFO("ret : 0x%x", ret);
4934 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4936 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4940 int camera_attr_enable_tag(camera_h camera, bool enable)
4942 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4946 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4948 int ret = CAMERA_ERROR_NONE;
4949 camera_cli_s *pc = (camera_cli_s *)camera;
4950 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4951 camera_msg_param param;
4953 if (!pc || !pc->cb_info || !description) {
4954 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4955 return CAMERA_ERROR_INVALID_PARAMETER;
4958 CAM_LOG_INFO("Enter");
4960 CAMERA_MSG_PARAM_SET(param, STRING, description);
4962 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4964 CAM_LOG_INFO("ret : 0x%x", ret);
4970 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4972 int ret = CAMERA_ERROR_NONE;
4973 camera_cli_s *pc = (camera_cli_s *)camera;
4974 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4975 camera_msg_param param;
4976 int set_orientation = (int)orientation;
4978 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4980 CAM_LOG_INFO("Enter");
4982 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4984 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4986 CAM_LOG_INFO("ret : 0x%x", ret);
4992 int camera_attr_set_tag_software(camera_h camera, const char *software)
4994 int ret = CAMERA_ERROR_NONE;
4995 camera_cli_s *pc = (camera_cli_s *)camera;
4996 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4997 camera_msg_param param;
4999 if (!pc || !pc->cb_info || !software) {
5000 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5001 return CAMERA_ERROR_INVALID_PARAMETER;
5004 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
5006 CAMERA_MSG_PARAM_SET(param, STRING, software);
5008 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5010 CAM_LOG_INFO("ret : 0x%x", ret);
5016 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
5018 int ret = CAMERA_ERROR_NONE;
5019 camera_cli_s *pc = (camera_cli_s *)camera;
5020 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
5021 double set_geotag[3] = {latitude, longitude, altitude};
5025 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5027 CAM_LOG_INFO("Enter");
5029 length = sizeof(set_geotag) / sizeof(int) + \
5030 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5032 msg = muse_core_msg_new(api,
5033 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5036 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
5042 int camera_attr_remove_geotag(camera_h camera)
5044 int ret = CAMERA_ERROR_NONE;
5045 camera_cli_s *pc = (camera_cli_s *)camera;
5046 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5048 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5050 CAM_LOG_INFO("Enter");
5052 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5054 CAM_LOG_INFO("ret : 0x%x", ret);
5060 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5062 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
5066 int camera_attr_get_zoom(camera_h camera, int *zoom)
5068 int ret = CAMERA_ERROR_NONE;
5069 camera_cli_s *pc = (camera_cli_s *)camera;
5070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5072 if (!pc || !pc->cb_info || !zoom) {
5073 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
5074 return CAMERA_ERROR_INVALID_PARAMETER;
5077 CAM_LOG_INFO("Enter");
5079 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5081 if (ret == CAMERA_ERROR_NONE)
5082 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5084 CAM_LOG_INFO("ret : 0x%x", ret);
5090 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5092 int ret = CAMERA_ERROR_NONE;
5093 camera_cli_s *pc = (camera_cli_s *)camera;
5094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5096 if (!pc || !pc->cb_info || !min || !max) {
5097 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5098 return CAMERA_ERROR_INVALID_PARAMETER;
5101 CAM_LOG_INFO("Enter");
5103 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5105 if (ret == CAMERA_ERROR_NONE) {
5106 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5107 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5110 CAM_LOG_INFO("ret : 0x%x", ret);
5116 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5118 int ret = CAMERA_ERROR_NONE;
5119 camera_cli_s *pc = (camera_cli_s *)camera;
5120 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5122 if (!pc || !pc->cb_info || !mode) {
5123 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5124 return CAMERA_ERROR_INVALID_PARAMETER;
5127 CAM_LOG_INFO("Enter");
5129 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5131 if (ret == CAMERA_ERROR_NONE)
5132 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5134 CAM_LOG_INFO("ret : 0x%x", ret);
5140 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5142 int ret = CAMERA_ERROR_NONE;
5143 camera_cli_s *pc = (camera_cli_s *)camera;
5144 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5146 if (!pc || !pc->cb_info || !mode) {
5147 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5148 return CAMERA_ERROR_INVALID_PARAMETER;
5151 CAM_LOG_INFO("Enter");
5153 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5155 if (ret == CAMERA_ERROR_NONE)
5156 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5158 CAM_LOG_INFO("ret : 0x%x", ret);
5164 int camera_attr_get_exposure(camera_h camera, int *value)
5166 int ret = CAMERA_ERROR_NONE;
5167 camera_cli_s *pc = (camera_cli_s *)camera;
5168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5170 if (!pc || !pc->cb_info || !value) {
5171 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5172 return CAMERA_ERROR_INVALID_PARAMETER;
5175 CAM_LOG_INFO("Enter");
5177 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5179 if (ret == CAMERA_ERROR_NONE)
5180 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5182 CAM_LOG_INFO("ret : 0x%x", ret);
5188 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5190 int ret = CAMERA_ERROR_NONE;
5191 camera_cli_s *pc = (camera_cli_s *)camera;
5192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5194 if (!pc || !pc->cb_info || !min || !max) {
5195 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5196 return CAMERA_ERROR_INVALID_PARAMETER;
5199 CAM_LOG_INFO("Enter");
5201 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5203 if (ret == CAMERA_ERROR_NONE) {
5204 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5205 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5208 CAM_LOG_INFO("ret : 0x%x", ret);
5214 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5216 int ret = CAMERA_ERROR_NONE;
5217 camera_cli_s *pc = (camera_cli_s *)camera;
5218 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5220 if (!pc || !pc->cb_info || !iso) {
5221 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5222 return CAMERA_ERROR_INVALID_PARAMETER;
5225 CAM_LOG_INFO("Enter");
5227 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5229 if (ret == CAMERA_ERROR_NONE)
5230 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5232 CAM_LOG_INFO("ret : 0x%x", ret);
5238 int camera_attr_get_gain(camera_h camera, int *level)
5240 int ret = CAMERA_ERROR_NONE;
5241 camera_cli_s *pc = (camera_cli_s *)camera;
5242 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN;
5244 if (!pc || !pc->cb_info || !level) {
5245 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5246 return CAMERA_ERROR_INVALID_PARAMETER;
5249 CAM_LOG_INFO("Enter");
5251 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5253 if (ret == CAMERA_ERROR_NONE)
5254 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_GAIN];
5256 CAM_LOG_INFO("ret : 0x%x", ret);
5262 int camera_attr_get_gain_range(camera_h camera, int *min, int *max)
5264 int ret = CAMERA_ERROR_NONE;
5265 camera_cli_s *pc = (camera_cli_s *)camera;
5266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN_RANGE;
5268 if (!pc || !pc->cb_info || !min || !max) {
5269 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5270 return CAMERA_ERROR_INVALID_PARAMETER;
5273 CAM_LOG_INFO("Enter");
5275 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5277 if (ret == CAMERA_ERROR_NONE) {
5278 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_GAIN_RANGE][0];
5279 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_GAIN_RANGE][1];
5282 CAM_LOG_INFO("ret : 0x%x", ret);
5288 int camera_attr_get_gain_step(camera_h camera, int *step)
5290 int ret = CAMERA_ERROR_NONE;
5291 camera_cli_s *pc = (camera_cli_s *)camera;
5292 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN_STEP;
5294 if (!pc || !pc->cb_info || !step) {
5295 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5296 return CAMERA_ERROR_INVALID_PARAMETER;
5299 CAM_LOG_INFO("Enter");
5301 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5303 if (ret == CAMERA_ERROR_NONE)
5304 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_GAIN_STEP];
5306 CAM_LOG_INFO("ret : 0x%x", ret);
5312 int camera_attr_get_brightness(camera_h camera, int *level)
5314 int ret = CAMERA_ERROR_NONE;
5315 camera_cli_s *pc = (camera_cli_s *)camera;
5316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5318 if (!pc || !pc->cb_info || !level) {
5319 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5320 return CAMERA_ERROR_INVALID_PARAMETER;
5323 CAM_LOG_INFO("Enter");
5325 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5327 if (ret == CAMERA_ERROR_NONE)
5328 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5330 CAM_LOG_INFO("ret : 0x%x", ret);
5336 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5338 int ret = CAMERA_ERROR_NONE;
5339 camera_cli_s *pc = (camera_cli_s *)camera;
5340 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5342 if (!pc || !pc->cb_info || !min || !max) {
5343 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5344 return CAMERA_ERROR_INVALID_PARAMETER;
5347 CAM_LOG_INFO("Enter");
5349 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5351 if (ret == CAMERA_ERROR_NONE) {
5352 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5353 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5356 CAM_LOG_INFO("ret : 0x%x", ret);
5362 int camera_attr_get_contrast(camera_h camera, int *level)
5364 int ret = CAMERA_ERROR_NONE;
5365 camera_cli_s *pc = (camera_cli_s *)camera;
5366 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5368 if (!pc || !pc->cb_info || !level) {
5369 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5370 return CAMERA_ERROR_INVALID_PARAMETER;
5373 CAM_LOG_INFO("Enter");
5375 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5377 if (ret == CAMERA_ERROR_NONE)
5378 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5380 CAM_LOG_INFO("ret : 0x%x", ret);
5386 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5388 int ret = CAMERA_ERROR_NONE;
5389 camera_cli_s *pc = (camera_cli_s *)camera;
5390 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5392 if (!pc || !pc->cb_info || !min || !max) {
5393 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5394 return CAMERA_ERROR_INVALID_PARAMETER;
5397 CAM_LOG_INFO("Enter");
5399 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5401 if (ret == CAMERA_ERROR_NONE) {
5402 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5403 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5404 CAM_LOG_INFO("min %d, max %d", *min, *max);
5407 CAM_LOG_INFO("ret : 0x%x", ret);
5413 int camera_attr_get_hue(camera_h camera, int *level)
5415 int ret = CAMERA_ERROR_NONE;
5416 camera_cli_s *pc = (camera_cli_s *)camera;
5417 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5419 if (!pc || !pc->cb_info || !level) {
5420 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5421 return CAMERA_ERROR_INVALID_PARAMETER;
5424 CAM_LOG_INFO("Enter");
5426 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5428 if (ret == CAMERA_ERROR_NONE)
5429 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5431 CAM_LOG_INFO("ret : 0x%x", ret);
5437 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5439 int ret = CAMERA_ERROR_NONE;
5440 camera_cli_s *pc = (camera_cli_s *)camera;
5441 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5443 if (!pc || !pc->cb_info || !min || !max) {
5444 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5445 return CAMERA_ERROR_INVALID_PARAMETER;
5448 CAM_LOG_INFO("Enter");
5450 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5452 if (ret == CAMERA_ERROR_NONE) {
5453 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5454 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5455 CAM_LOG_INFO("min %d, max %d", *min, *max);
5458 CAM_LOG_INFO("ret : 0x%x", ret);
5464 int camera_attr_get_saturation(camera_h camera, int *level)
5466 int ret = CAMERA_ERROR_NONE;
5467 camera_cli_s *pc = (camera_cli_s *)camera;
5468 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SATURATION;
5470 if (!pc || !pc->cb_info || !level) {
5471 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5472 return CAMERA_ERROR_INVALID_PARAMETER;
5475 CAM_LOG_INFO("Enter");
5477 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5479 if (ret == CAMERA_ERROR_NONE)
5480 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SATURATION];
5482 CAM_LOG_INFO("ret : 0x%x", ret);
5488 int camera_attr_get_saturation_range(camera_h camera, int *min, int *max)
5490 int ret = CAMERA_ERROR_NONE;
5491 camera_cli_s *pc = (camera_cli_s *)camera;
5492 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SATURATION_RANGE;
5494 if (!pc || !pc->cb_info || !min || !max) {
5495 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5496 return CAMERA_ERROR_INVALID_PARAMETER;
5499 CAM_LOG_INFO("Enter");
5501 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5503 if (ret == CAMERA_ERROR_NONE) {
5504 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SATURATION_RANGE][0];
5505 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SATURATION_RANGE][1];
5506 CAM_LOG_INFO("min %d, max %d", *min, *max);
5509 CAM_LOG_INFO("ret : 0x%x", ret);
5515 int camera_attr_get_sharpness(camera_h camera, int *level)
5517 int ret = CAMERA_ERROR_NONE;
5518 camera_cli_s *pc = (camera_cli_s *)camera;
5519 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SHARPNESS;
5521 if (!pc || !pc->cb_info || !level) {
5522 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5523 return CAMERA_ERROR_INVALID_PARAMETER;
5526 CAM_LOG_INFO("Enter");
5528 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5530 if (ret == CAMERA_ERROR_NONE)
5531 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SHARPNESS];
5533 CAM_LOG_INFO("ret : 0x%x", ret);
5539 int camera_attr_get_sharpness_range(camera_h camera, int *min, int *max)
5541 int ret = CAMERA_ERROR_NONE;
5542 camera_cli_s *pc = (camera_cli_s *)camera;
5543 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SHARPNESS_RANGE;
5545 if (!pc || !pc->cb_info || !min || !max) {
5546 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5547 return CAMERA_ERROR_INVALID_PARAMETER;
5550 CAM_LOG_INFO("Enter");
5552 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5554 if (ret == CAMERA_ERROR_NONE) {
5555 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SHARPNESS_RANGE][0];
5556 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_SHARPNESS_RANGE][1];
5557 CAM_LOG_INFO("min %d, max %d", *min, *max);
5560 CAM_LOG_INFO("ret : 0x%x", ret);
5566 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5568 int ret = CAMERA_ERROR_NONE;
5569 camera_cli_s *pc = (camera_cli_s *)camera;
5570 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5572 if (!pc || !pc->cb_info || !wb) {
5573 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5574 return CAMERA_ERROR_INVALID_PARAMETER;
5577 CAM_LOG_INFO("Enter");
5579 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5581 if (ret == CAMERA_ERROR_NONE)
5582 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5584 CAM_LOG_INFO("ret : 0x%x", ret);
5590 int camera_attr_get_whitebalance_temperature(camera_h camera, int *temperature)
5592 int ret = CAMERA_ERROR_NONE;
5593 camera_cli_s *pc = (camera_cli_s *)camera;
5594 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE;
5596 if (!pc || !pc->cb_info || !temperature) {
5597 CAM_LOG_ERROR("NULL pointer %p %p", pc, temperature);
5598 return CAMERA_ERROR_INVALID_PARAMETER;
5601 CAM_LOG_INFO("Enter");
5603 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5605 if (ret == CAMERA_ERROR_NONE)
5606 *temperature = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE];
5608 CAM_LOG_INFO("ret : 0x%x", ret);
5614 int camera_attr_get_whitebalance_temperature_range(camera_h camera, int *min, int *max)
5616 int ret = CAMERA_ERROR_NONE;
5617 camera_cli_s *pc = (camera_cli_s *)camera;
5618 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_RANGE;
5620 if (!pc || !pc->cb_info || !min || !max) {
5621 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5622 return CAMERA_ERROR_INVALID_PARAMETER;
5625 CAM_LOG_INFO("Enter");
5627 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5629 if (ret == CAMERA_ERROR_NONE) {
5630 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_WHITE_BALANCE_TEMPERATURE_RANGE][0];
5631 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_WHITE_BALANCE_TEMPERATURE_RANGE][1];
5634 CAM_LOG_INFO("ret : 0x%x", ret);
5640 int camera_attr_get_whitebalance_temperature_step(camera_h camera, int *step)
5642 int ret = CAMERA_ERROR_NONE;
5643 camera_cli_s *pc = (camera_cli_s *)camera;
5644 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_STEP;
5646 if (!pc || !pc->cb_info || !step) {
5647 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5648 return CAMERA_ERROR_INVALID_PARAMETER;
5651 CAM_LOG_INFO("Enter");
5653 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5655 if (ret == CAMERA_ERROR_NONE)
5656 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE_STEP];
5658 CAM_LOG_INFO("ret : 0x%x", ret);
5664 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5666 int ret = CAMERA_ERROR_NONE;
5667 camera_cli_s *pc = (camera_cli_s *)camera;
5668 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5670 if (!pc || !pc->cb_info || !effect) {
5671 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5672 return CAMERA_ERROR_INVALID_PARAMETER;
5675 CAM_LOG_INFO("Enter");
5677 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5679 if (ret == CAMERA_ERROR_NONE)
5680 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5682 CAM_LOG_INFO("ret : 0x%x", ret);
5688 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5690 int ret = CAMERA_ERROR_NONE;
5691 camera_cli_s *pc = (camera_cli_s *)camera;
5692 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5694 if (!pc || !pc->cb_info || !mode) {
5695 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5696 return CAMERA_ERROR_INVALID_PARAMETER;
5699 CAM_LOG_INFO("Enter");
5701 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5703 if (ret == CAMERA_ERROR_NONE)
5704 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5706 CAM_LOG_INFO("ret : 0x%x", ret);
5712 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5714 int ret = CAMERA_ERROR_NONE;
5715 camera_cli_s *pc = (camera_cli_s *)camera;
5716 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5718 if (!pc || !pc->cb_info || !enable) {
5719 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5720 return CAMERA_ERROR_INVALID_PARAMETER;
5723 CAM_LOG_INFO("Enter");
5725 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5727 if (ret == CAMERA_ERROR_NONE)
5728 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5730 CAM_LOG_INFO("ret : 0x%x", ret);
5736 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5738 int ret = CAMERA_ERROR_NONE;
5739 camera_cli_s *pc = (camera_cli_s *)camera;
5740 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5742 if (!pc || !pc->cb_info || !description) {
5743 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5744 return CAMERA_ERROR_INVALID_PARAMETER;
5747 CAM_LOG_INFO("Enter");
5749 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5751 if (ret == CAMERA_ERROR_NONE)
5752 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5754 CAM_LOG_INFO("ret : 0x%x", ret);
5760 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5762 int ret = CAMERA_ERROR_NONE;
5763 camera_cli_s *pc = (camera_cli_s *)camera;
5764 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5766 if (!pc || !pc->cb_info || !orientation) {
5767 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5768 return CAMERA_ERROR_INVALID_PARAMETER;
5771 CAM_LOG_INFO("Enter");
5773 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5775 if (ret == CAMERA_ERROR_NONE)
5776 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5778 CAM_LOG_INFO("ret : 0x%x", ret);
5784 int camera_attr_get_tag_software(camera_h camera, char **software)
5786 int ret = CAMERA_ERROR_NONE;
5787 camera_cli_s *pc = (camera_cli_s *)camera;
5788 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5790 if (!pc || !pc->cb_info || !software) {
5791 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5792 return CAMERA_ERROR_INVALID_PARAMETER;
5795 CAM_LOG_INFO("Enter");
5797 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5799 if (ret == CAMERA_ERROR_NONE)
5800 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5802 CAM_LOG_INFO("ret : 0x%x", ret);
5808 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5810 int ret = CAMERA_ERROR_NONE;
5811 camera_cli_s *pc = (camera_cli_s *)camera;
5812 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5814 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5815 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5816 return CAMERA_ERROR_INVALID_PARAMETER;
5819 CAM_LOG_INFO("Enter");
5821 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5823 if (ret == CAMERA_ERROR_NONE) {
5824 *latitude = pc->cb_info->get_geotag[0];
5825 *longitude = pc->cb_info->get_geotag[1];
5826 *altitude = pc->cb_info->get_geotag[2];
5829 CAM_LOG_INFO("ret : 0x%x", ret);
5835 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5837 int ret = CAMERA_ERROR_NONE;
5838 camera_cli_s *pc = (camera_cli_s *)camera;
5839 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5841 if (!pc || !pc->cb_info || !mode) {
5842 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5843 return CAMERA_ERROR_INVALID_PARAMETER;
5846 CAM_LOG_INFO("Enter");
5848 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5850 if (ret == CAMERA_ERROR_NONE)
5851 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5853 CAM_LOG_INFO("ret : 0x%x", ret);
5859 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5861 int ret = CAMERA_ERROR_NONE;
5862 int get_flash_state = 0;
5865 CAM_LOG_ERROR("NULL pointer");
5866 return CAMERA_ERROR_INVALID_PARAMETER;
5869 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5870 (int)device, "get_flash_state", &get_flash_state);
5872 if (ret == CAMERA_ERROR_NONE) {
5873 *state = (camera_flash_state_e)get_flash_state;
5874 CAM_LOG_INFO("flash state %d", *state);
5876 CAM_LOG_ERROR("failed 0x%x", ret);
5883 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5885 int ret = CAMERA_ERROR_NONE;
5886 camera_cli_s *pc = (camera_cli_s *)camera;
5887 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5889 if (!pc || !pc->cb_info || !foreach_cb) {
5890 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5891 return CAMERA_ERROR_INVALID_PARAMETER;
5894 CAM_LOG_INFO("Enter");
5896 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5897 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5899 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5901 CAM_LOG_INFO("ret : 0x%x", ret);
5907 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5909 int ret = CAMERA_ERROR_NONE;
5910 camera_cli_s *pc = (camera_cli_s *)camera;
5911 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5913 if (!pc || !pc->cb_info || !foreach_cb) {
5914 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5915 return CAMERA_ERROR_INVALID_PARAMETER;
5918 CAM_LOG_INFO("Enter");
5920 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5921 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5923 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5925 CAM_LOG_INFO("ret : 0x%x", ret);
5931 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5933 int ret = CAMERA_ERROR_NONE;
5934 camera_cli_s *pc = (camera_cli_s *)camera;
5935 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5937 if (!pc || !pc->cb_info || !foreach_cb) {
5938 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5939 return CAMERA_ERROR_INVALID_PARAMETER;
5942 CAM_LOG_INFO("Enter");
5944 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5945 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5947 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5949 CAM_LOG_INFO("ret : 0x%x", ret);
5955 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5957 int ret = CAMERA_ERROR_NONE;
5958 camera_cli_s *pc = (camera_cli_s *)camera;
5959 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5961 if (!pc || !pc->cb_info || !foreach_cb) {
5962 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5963 return CAMERA_ERROR_INVALID_PARAMETER;
5966 CAM_LOG_INFO("Enter");
5968 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5969 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5971 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5973 CAM_LOG_INFO("ret : 0x%x", ret);
5979 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5981 int ret = CAMERA_ERROR_NONE;
5982 camera_cli_s *pc = (camera_cli_s *)camera;
5983 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5985 if (!pc || !pc->cb_info || !foreach_cb) {
5986 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5987 return CAMERA_ERROR_INVALID_PARAMETER;
5990 CAM_LOG_INFO("Enter");
5992 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5993 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5995 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5997 CAM_LOG_INFO("ret : 0x%x", ret);
6003 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
6005 int ret = CAMERA_ERROR_NONE;
6006 camera_cli_s *pc = (camera_cli_s *)camera;
6007 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
6009 if (!pc || !pc->cb_info || !foreach_cb) {
6010 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6011 return CAMERA_ERROR_INVALID_PARAMETER;
6014 CAM_LOG_INFO("Enter");
6016 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
6017 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
6019 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6021 CAM_LOG_INFO("ret : 0x%x", ret);
6027 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
6029 int ret = CAMERA_ERROR_NONE;
6030 camera_cli_s *pc = (camera_cli_s *)camera;
6031 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
6033 if (!pc || !pc->cb_info || !foreach_cb) {
6034 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6035 return CAMERA_ERROR_INVALID_PARAMETER;
6038 CAM_LOG_INFO("Enter");
6040 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
6041 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
6043 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6045 CAM_LOG_INFO("ret : 0x%x", ret);
6051 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
6053 int ret = CAMERA_ERROR_NONE;
6054 camera_cli_s *pc = (camera_cli_s *)camera;
6055 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
6057 if (!pc || !pc->cb_info || !foreach_cb) {
6058 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6059 return CAMERA_ERROR_INVALID_PARAMETER;
6062 CAM_LOG_INFO("Enter");
6064 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
6065 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
6067 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6069 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
6075 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)
6077 int ret = CAMERA_ERROR_NONE;
6078 camera_cli_s *pc = (camera_cli_s *)camera;
6079 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
6080 camera_msg_param param;
6083 if (!pc || !pc->cb_info || !foreach_cb) {
6084 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6085 return CAMERA_ERROR_INVALID_PARAMETER;
6088 CAM_LOG_INFO("Enter");
6090 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
6091 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
6093 value = (width << 16) | height;
6094 CAMERA_MSG_PARAM_SET(param, INT, value);
6096 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6098 CAM_LOG_INFO("ret : 0x%x", ret);
6104 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
6106 int ret = CAMERA_ERROR_NONE;
6107 camera_cli_s *pc = (camera_cli_s *)camera;
6108 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
6110 if (!pc || !pc->cb_info || !foreach_cb) {
6111 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6112 return CAMERA_ERROR_INVALID_PARAMETER;
6115 CAM_LOG_INFO("Enter");
6117 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
6118 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
6120 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6122 CAM_LOG_INFO("ret : 0x%x", ret);
6128 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
6130 int ret = CAMERA_ERROR_NONE;
6131 camera_cli_s *pc = (camera_cli_s *)camera;
6132 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
6134 if (!pc || !pc->cb_info || !foreach_cb) {
6135 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6136 return CAMERA_ERROR_INVALID_PARAMETER;
6139 CAM_LOG_INFO("Enter");
6141 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
6142 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
6144 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6146 CAM_LOG_INFO("ret : 0x%x", ret);
6152 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
6154 int ret = CAMERA_ERROR_NONE;
6155 camera_cli_s *pc = (camera_cli_s *)camera;
6156 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
6157 camera_msg_param param;
6158 int set_rotation = (int)rotation;
6160 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6162 CAM_LOG_INFO("Enter");
6164 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
6166 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6168 CAM_LOG_INFO("ret : 0x%x", ret);
6174 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
6176 int ret = CAMERA_ERROR_NONE;
6177 camera_cli_s *pc = (camera_cli_s *)camera;
6178 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
6180 if (!pc || !pc->cb_info || !rotation) {
6181 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6182 return CAMERA_ERROR_INVALID_PARAMETER;
6185 CAM_LOG_INFO("Enter");
6187 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6189 if (ret == CAMERA_ERROR_NONE)
6190 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
6192 CAM_LOG_INFO("ret : 0x%x", ret);
6198 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
6200 int ret = CAMERA_ERROR_NONE;
6201 camera_cli_s *pc = (camera_cli_s *)camera;
6202 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
6203 camera_msg_param param;
6204 int set_flip = (int)flip;
6206 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6208 CAM_LOG_INFO("Enter");
6210 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
6212 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6214 CAM_LOG_INFO("ret : 0x%x", ret);
6220 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
6222 int ret = CAMERA_ERROR_NONE;
6223 camera_cli_s *pc = (camera_cli_s *)camera;
6224 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6226 if (!pc || !pc->cb_info || !flip) {
6227 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
6228 return CAMERA_ERROR_INVALID_PARAMETER;
6231 CAM_LOG_INFO("Enter");
6233 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6235 if (ret == CAMERA_ERROR_NONE)
6236 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6238 CAM_LOG_INFO("ret : 0x%x", ret);
6243 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6245 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
6249 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6251 int ret = CAMERA_ERROR_NONE;
6252 camera_cli_s *pc = (camera_cli_s *)camera;
6253 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6255 if (!pc || !pc->cb_info || !mode) {
6256 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
6257 return CAMERA_ERROR_INVALID_PARAMETER;
6260 CAM_LOG_INFO("Enter");
6262 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6264 if (ret == CAMERA_ERROR_NONE)
6265 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6267 CAM_LOG_INFO("ret : 0x%x", ret);
6273 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6275 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
6279 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6281 int ret = CAMERA_ERROR_NONE;
6282 camera_cli_s *pc = (camera_cli_s *)camera;
6283 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6285 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6287 CAM_LOG_INFO("Enter");
6289 if (!camera_attr_is_supported_hdr_capture(camera)) {
6290 CAM_LOG_ERROR("HDR not supported");
6291 return CAMERA_ERROR_NOT_SUPPORTED;
6295 CAM_LOG_ERROR("NULL callback");
6296 return CAMERA_ERROR_INVALID_PARAMETER;
6299 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6301 if (ret == CAMERA_ERROR_NONE) {
6302 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6304 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6305 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6307 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6310 CAM_LOG_INFO("ret : 0x%x", ret);
6316 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6318 int ret = CAMERA_ERROR_NONE;
6319 camera_cli_s *pc = (camera_cli_s *)camera;
6320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6322 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6324 CAM_LOG_INFO("Enter");
6326 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6328 if (ret == CAMERA_ERROR_NONE) {
6329 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6331 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6332 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6334 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6337 CAM_LOG_INFO("ret : 0x%x", ret);
6343 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6345 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
6349 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6351 int ret = CAMERA_ERROR_NONE;
6352 camera_cli_s *pc = (camera_cli_s *)camera;
6353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6355 if (!pc || !pc->cb_info || !enabled) {
6356 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6357 return CAMERA_ERROR_INVALID_PARAMETER;
6360 CAM_LOG_INFO("Enter");
6362 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6364 if (ret == CAMERA_ERROR_NONE)
6365 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6367 CAM_LOG_INFO("ret : 0x%x", ret);
6373 bool camera_attr_is_supported_anti_shake(camera_h camera)
6375 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
6379 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6381 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
6385 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6387 int ret = CAMERA_ERROR_NONE;
6388 camera_cli_s *pc = (camera_cli_s *)camera;
6389 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6391 if (!pc || !pc->cb_info || !enabled) {
6392 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6393 return CAMERA_ERROR_INVALID_PARAMETER;
6396 CAM_LOG_INFO("Enter");
6398 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6400 if (ret == CAMERA_ERROR_NONE)
6401 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6403 CAM_LOG_INFO("ret : 0x%x", ret);
6409 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6411 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
6415 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6417 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
6421 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6423 int ret = CAMERA_ERROR_NONE;
6424 camera_cli_s *pc = (camera_cli_s *)camera;
6425 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6427 if (!pc || !pc->cb_info || !enabled) {
6428 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6429 return CAMERA_ERROR_INVALID_PARAMETER;
6432 CAM_LOG_INFO("Enter");
6434 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6436 if (ret == CAMERA_ERROR_NONE)
6437 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6439 CAM_LOG_INFO("ret : 0x%x", ret);
6445 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6447 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
6451 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6453 int ret = CAMERA_ERROR_NONE;
6454 camera_cli_s *pc = (camera_cli_s *)camera;
6455 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6456 camera_msg_param param;
6457 int set_disable = (int)disable;
6459 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6461 CAM_LOG_INFO("Enter");
6463 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6465 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6467 CAM_LOG_INFO("ret : 0x%x", ret);
6473 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6475 int ret = CAMERA_ERROR_NONE;
6476 camera_cli_s *pc = (camera_cli_s *)camera;
6477 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6478 camera_msg_param param0;
6479 camera_msg_param param1;
6481 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6483 CAM_LOG_INFO("Enter");
6485 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6486 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6488 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6489 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6491 CAM_LOG_INFO("ret : 0x%x", ret);
6497 int camera_attr_get_pan(camera_h camera, int *pan_step)
6499 int ret = CAMERA_ERROR_NONE;
6500 camera_cli_s *pc = (camera_cli_s *)camera;
6501 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6503 if (!pc || !pc->cb_info || !pan_step) {
6504 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6505 return CAMERA_ERROR_INVALID_PARAMETER;
6508 CAM_LOG_INFO("Enter");
6510 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6512 if (ret == CAMERA_ERROR_NONE)
6513 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6515 CAM_LOG_INFO("ret : 0x%x", ret);
6521 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6523 int ret = CAMERA_ERROR_NONE;
6524 camera_cli_s *pc = (camera_cli_s *)camera;
6525 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6527 if (!pc || !pc->cb_info || !min || !max) {
6528 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6529 return CAMERA_ERROR_INVALID_PARAMETER;
6532 CAM_LOG_INFO("Enter");
6534 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6536 if (ret == CAMERA_ERROR_NONE) {
6537 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6538 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6541 CAM_LOG_INFO("ret : 0x%x", ret);
6547 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6549 int ret = CAMERA_ERROR_NONE;
6550 camera_cli_s *pc = (camera_cli_s *)camera;
6551 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6552 camera_msg_param param0;
6553 camera_msg_param param1;
6555 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6557 CAM_LOG_INFO("Enter");
6559 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6560 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6562 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6563 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6565 CAM_LOG_INFO("ret : 0x%x", ret);
6571 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6573 int ret = CAMERA_ERROR_NONE;
6574 camera_cli_s *pc = (camera_cli_s *)camera;
6575 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6577 if (!pc || !pc->cb_info || !tilt_step) {
6578 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6579 return CAMERA_ERROR_INVALID_PARAMETER;
6582 CAM_LOG_INFO("Enter");
6584 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6586 if (ret == CAMERA_ERROR_NONE)
6587 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6589 CAM_LOG_INFO("ret : 0x%x", ret);
6595 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6597 int ret = CAMERA_ERROR_NONE;
6598 camera_cli_s *pc = (camera_cli_s *)camera;
6599 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6601 if (!pc || !pc->cb_info || !min || !max) {
6602 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6603 return CAMERA_ERROR_INVALID_PARAMETER;
6606 CAM_LOG_INFO("Enter");
6608 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6610 if (ret == CAMERA_ERROR_NONE) {
6611 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6612 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6615 CAM_LOG_INFO("ret : 0x%x", ret);
6621 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6623 int ret = CAMERA_ERROR_NONE;
6624 camera_cli_s *pc = (camera_cli_s *)camera;
6625 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6626 camera_msg_param param;
6627 int set_ptz_type = (int)ptz_type;
6629 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6631 CAM_LOG_INFO("Enter");
6633 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6635 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6637 CAM_LOG_INFO("ret : 0x%x", ret);
6643 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6645 int ret = CAMERA_ERROR_NONE;
6646 camera_cli_s *pc = (camera_cli_s *)camera;
6647 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6649 if (!pc || !pc->cb_info || !foreach_cb) {
6650 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6651 return CAMERA_ERROR_INVALID_PARAMETER;
6654 CAM_LOG_INFO("Enter");
6656 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6657 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6659 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6661 CAM_LOG_INFO("ret : 0x%x", ret);
6667 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6669 int ret = CAMERA_ERROR_NONE;
6670 camera_cli_s *pc = (camera_cli_s *)camera;
6671 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6672 int set_display_roi_area[4] = {x, y, width, height};
6676 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6678 CAM_LOG_INFO("Enter");
6680 if (pc->cb_info->is_evas_render) {
6681 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6682 if (ret != MM_ERROR_NONE) {
6683 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6684 return CAMERA_ERROR_INVALID_OPERATION;
6688 length = sizeof(set_display_roi_area) / sizeof(int) + \
6689 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6691 msg = muse_core_msg_new(api,
6692 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6695 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6701 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6703 camera_cli_s *pc = (camera_cli_s *)camera;
6704 int ret = CAMERA_ERROR_NONE;
6705 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6707 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6708 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6709 return CAMERA_ERROR_INVALID_PARAMETER;
6712 CAM_LOG_INFO("Enter");
6714 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6716 if (ret == CAMERA_ERROR_NONE) {
6717 *x = pc->cb_info->get_display_roi_area[0];
6718 *y = pc->cb_info->get_display_roi_area[1];
6719 *width = pc->cb_info->get_display_roi_area[2];
6720 *height = pc->cb_info->get_display_roi_area[3];
6723 CAM_LOG_INFO("ret : 0x%x", ret);
6729 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6731 int ret = CAMERA_ERROR_NONE;
6732 int get_device_state = 0;
6735 CAM_LOG_ERROR("NULL pointer");
6736 return CAMERA_ERROR_INVALID_PARAMETER;
6739 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6740 (int)device, "get_device_state", &get_device_state);
6742 if (ret == CAMERA_ERROR_NONE) {
6743 *state = (camera_device_state_e)get_device_state;
6744 CAM_LOG_INFO("device state %d", *state);
6746 CAM_LOG_ERROR("failed 0x%x", ret);
6753 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6755 int ret = CAMERA_ERROR_NONE;
6756 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6757 camera_cb_info *info = NULL;
6759 if (!callback || !cb_id) {
6760 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6761 return CAMERA_ERROR_INVALID_PARAMETER;
6764 /* check camera support */
6765 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6766 if (ret != CAMERA_ERROR_NONE) {
6767 CAM_LOG_ERROR("get device state failed");
6771 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6773 info = g_new0(camera_cb_info, 1);
6775 CAM_LOG_ERROR("info failed");
6776 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6780 info->id = ++g_cam_dev_state_changed_cb_id;
6781 info->callback = (void *)callback;
6782 info->user_data = user_data;
6786 /* subscribe dbus signal for camera state change */
6787 if (!g_cam_dev_state_changed_cb_conn) {
6788 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6789 if (!g_cam_dev_state_changed_cb_conn) {
6790 CAM_LOG_ERROR("failed to get gdbus connection");
6791 ret = CAMERA_ERROR_INVALID_OPERATION;
6795 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6796 MM_CAMCORDER_DBUS_OBJECT,
6797 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6798 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6800 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6801 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6802 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6803 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6804 CAM_LOG_ERROR("failed to get gdbus connection");
6805 ret = CAMERA_ERROR_INVALID_OPERATION;
6809 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6812 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6814 CAM_LOG_INFO("callback id %d", info->id);
6817 if (ret != CAMERA_ERROR_NONE) {
6823 if (g_cam_dev_state_changed_cb_conn) {
6824 g_object_unref(g_cam_dev_state_changed_cb_conn);
6825 g_cam_dev_state_changed_cb_conn = NULL;
6829 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6835 int camera_remove_device_state_changed_cb(int cb_id)
6837 int ret = CAMERA_ERROR_NONE;
6838 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6839 GList *tmp_list = NULL;
6840 camera_cb_info *info = NULL;
6842 /* check camera support */
6843 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6844 if (ret != CAMERA_ERROR_NONE) {
6845 CAM_LOG_ERROR("get device state failed");
6849 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6851 if (!g_cam_dev_state_changed_cb_list) {
6852 CAM_LOG_ERROR("there is no callback info");
6853 ret = CAMERA_ERROR_INVALID_OPERATION;
6857 tmp_list = g_cam_dev_state_changed_cb_list;
6860 info = tmp_list->data;
6861 tmp_list = tmp_list->next;
6864 CAM_LOG_WARNING("NULL info");
6868 if (info->id == cb_id) {
6869 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6874 if (!g_cam_dev_state_changed_cb_list) {
6875 /* no remained callback */
6876 if (g_cam_dev_state_changed_cb_conn) {
6877 /* unsubscribe signal */
6878 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6879 g_cam_dev_state_changed_cb_subscribe_id = 0;
6881 /* unref connection */
6882 g_object_unref(g_cam_dev_state_changed_cb_conn);
6883 g_cam_dev_state_changed_cb_conn = NULL;
6887 CAM_LOG_INFO("id %d callback removed", cb_id);
6888 ret = CAMERA_ERROR_NONE;
6894 CAM_LOG_ERROR("id %d callback not found", cb_id);
6895 ret = CAMERA_ERROR_INVALID_PARAMETER;
6898 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6905 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6907 int ret = CAMERA_ERROR_NONE;
6908 camera_cli_s *pc = (camera_cli_s *)camera;
6909 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6911 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6913 g_mutex_lock(&pc->cb_info->bridge_lock);
6915 if (pc->cb_info->bridge) {
6916 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6917 ret = CAMERA_ERROR_INVALID_OPERATION;
6918 goto _SET_MEDIA_BRIDGE_DONE;
6921 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6922 if (ret != CAMERA_ERROR_NONE) {
6923 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6924 goto _SET_MEDIA_BRIDGE_DONE;
6927 pc->cb_info->bridge = bridge;
6929 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6931 _SET_MEDIA_BRIDGE_DONE:
6932 g_mutex_unlock(&pc->cb_info->bridge_lock);
6938 int camera_media_bridge_unset_bridge(camera_h camera)
6940 int ret = CAMERA_ERROR_NONE;
6941 camera_cli_s *pc = (camera_cli_s *)camera;
6942 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6944 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6946 g_mutex_lock(&pc->cb_info->bridge_lock);
6948 if (!pc->cb_info->bridge) {
6949 CAM_LOG_ERROR("no media bridge");
6950 ret = CAMERA_ERROR_INVALID_OPERATION;
6951 goto _UNSET_MEDIA_BRIDGE_DONE;
6954 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6955 if (ret != CAMERA_ERROR_NONE) {
6956 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6957 goto _UNSET_MEDIA_BRIDGE_DONE;
6960 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6962 pc->cb_info->bridge = NULL;
6964 _UNSET_MEDIA_BRIDGE_DONE:
6965 g_mutex_unlock(&pc->cb_info->bridge_lock);
6972 int camera_create_network(camera_device_e device, camera_h *camera)
6974 return _camera_create_private(device, true, camera);
6978 int camera_device_manager_initialize(camera_device_manager_h *manager)
6981 int ret = CAMERA_ERROR_NONE;
6982 void *dl_handle = NULL;
6983 g_autofree camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
6984 cdm_symbol_table sym_table[] = {
6985 {(void **)&new_manager->initialize, "cdm_initialize"},
6986 {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
6987 {(void **)&new_manager->get_device_list, "cdm_get_device_list"},
6988 {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"},
6989 {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"},
6992 CAMERA_CHECK_DEVICE_MANAGER;
6995 CAM_LOG_ERROR("NULL manager");
6996 ret = CAMERA_ERROR_INVALID_PARAMETER;
6997 goto _INITIALIZE_FAILED;
7000 dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
7002 CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
7003 ret = CAMERA_ERROR_INVALID_OPERATION;
7004 goto _INITIALIZE_FAILED;
7008 for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
7009 *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
7010 if (*sym_table[i].func_ptr == NULL) {
7011 CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
7012 ret = CAMERA_ERROR_INVALID_OPERATION;
7013 goto _INITIALIZE_FAILED;
7017 ret = new_manager->initialize();
7018 if (ret != CAMERA_ERROR_NONE) {
7019 CAM_LOG_ERROR("failed[0x%x]", ret);
7020 goto _INITIALIZE_FAILED;
7023 new_manager->dl_handle = dl_handle;
7024 *manager = (camera_device_manager_h)g_steal_pointer(&new_manager);
7026 CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
7027 *manager, dl_handle);
7029 return CAMERA_ERROR_NONE;
7040 int camera_device_manager_deinitialize(camera_device_manager_h manager)
7042 int ret = CAMERA_ERROR_NONE;
7043 camera_device_manager *m = (camera_device_manager *)manager;
7045 CAMERA_CHECK_DEVICE_MANAGER;
7048 CAM_LOG_ERROR("NULL manager");
7049 return CAMERA_ERROR_INVALID_PARAMETER;
7052 CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
7054 ret = m->deinitialize();
7055 if (ret != CAMERA_ERROR_NONE) {
7056 CAM_LOG_ERROR("failed[0x%x]", ret);
7060 CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
7062 dlclose(m->dl_handle);
7064 memset(m, 0x0, sizeof(camera_device_manager));
7067 return CAMERA_ERROR_NONE;
7071 int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
7073 int ret = CAMERA_ERROR_NONE;
7075 camera_device_list_s device_list;
7076 camera_device_s *device = NULL;
7077 camera_device_manager *m = (camera_device_manager *)manager;
7079 CAMERA_CHECK_DEVICE_MANAGER;
7081 if (!m || !callback) {
7082 CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
7083 return CAMERA_ERROR_INVALID_PARAMETER;
7086 CAM_LOG_INFO("enter");
7088 memset(&device_list, 0x0, sizeof(camera_device_list_s));
7090 ret = m->get_device_list(&device_list);
7091 if (ret != CAMERA_ERROR_NONE) {
7092 CAM_LOG_ERROR("failed[0x%x]", ret);
7096 CAM_LOG_INFO("device count[%d]", device_list.count);
7098 for (i = 0 ; i < device_list.count ; i++) {
7099 device = &device_list.device[i];
7101 CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
7102 i, device->type, device->index,
7103 device->name, device->id, device->extra_stream_num);
7105 if (!callback(device, user_data)) {
7106 CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
7107 i + 1, device_list.count);
7112 return CAMERA_ERROR_NONE;
7116 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
7117 camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
7119 int ret = CAMERA_ERROR_NONE;
7120 camera_device_manager *m = (camera_device_manager *)manager;
7122 CAMERA_CHECK_DEVICE_MANAGER;
7124 if (!m || !callback || !cb_id) {
7125 CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
7126 return CAMERA_ERROR_INVALID_PARAMETER;
7129 CAM_LOG_INFO("enter");
7131 ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
7132 if (ret != CAMERA_ERROR_NONE) {
7133 CAM_LOG_ERROR("failed[0x%x]", ret);
7137 CAM_LOG_INFO("cb_id[%d] added", *cb_id);
7139 return CAMERA_ERROR_NONE;
7143 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
7145 int ret = CAMERA_ERROR_NONE;
7146 camera_device_manager *m = (camera_device_manager *)manager;
7148 CAMERA_CHECK_DEVICE_MANAGER;
7151 CAM_LOG_ERROR("NULL manager");
7152 return CAMERA_ERROR_INVALID_PARAMETER;
7155 CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
7157 ret = m->remove_device_connection_changed_cb(cb_id);
7158 if (ret != CAMERA_ERROR_NONE) {
7159 CAM_LOG_ERROR("failed[0x%x]", ret);
7163 CAM_LOG_INFO("cb_id[%d] removed", cb_id);
7165 return CAMERA_ERROR_NONE;
7170 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
7172 int ret = CAMERA_ERROR_NONE;
7173 camera_cli_s *pc = (camera_cli_s *)camera;
7174 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
7176 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7178 if (!camera_is_supported_extra_preview(camera)) {
7179 CAM_LOG_ERROR("extra preview is not supported");
7180 return CAMERA_ERROR_NOT_SUPPORTED;
7184 CAM_LOG_ERROR("NULL callback");
7185 return CAMERA_ERROR_INVALID_PARAMETER;
7188 CAM_LOG_INFO("Enter");
7190 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
7192 if (ret == CAMERA_ERROR_NONE) {
7193 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7195 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
7196 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
7198 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7201 CAM_LOG_INFO("ret : 0x%x", ret);
7207 int camera_unset_extra_preview_cb(camera_h camera)
7209 int ret = CAMERA_ERROR_NONE;
7210 camera_cli_s *pc = (camera_cli_s *)camera;
7211 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
7213 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7215 if (!camera_is_supported_extra_preview(camera)) {
7216 CAM_LOG_ERROR("extra preview is not supported");
7217 return CAMERA_ERROR_NOT_SUPPORTED;
7220 CAM_LOG_INFO("Enter");
7222 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
7224 if (ret == CAMERA_ERROR_NONE) {
7225 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7227 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
7228 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
7230 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7233 CAM_LOG_INFO("ret : 0x%x", ret);
7239 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)
7241 int ret = CAMERA_ERROR_NONE;
7242 int stream_format[4] = {pixel_format, width, height, fps};
7244 camera_cli_s *pc = (camera_cli_s *)camera;
7245 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
7247 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7249 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
7250 stream_id, pixel_format, width, height, fps);
7252 msg = muse_core_msg_new(api,
7253 MUSE_TYPE_INT, "stream_id", stream_id,
7254 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
7257 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
7263 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)
7265 int ret = CAMERA_ERROR_NONE;
7266 camera_cli_s *pc = (camera_cli_s *)camera;
7267 camera_msg_param param;
7268 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
7270 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
7271 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
7272 return CAMERA_ERROR_INVALID_PARAMETER;
7275 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7277 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7279 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7281 if (ret == CAMERA_ERROR_NONE) {
7282 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
7283 *width = pc->cb_info->get_extra_preview_stream_format[1];
7284 *height = pc->cb_info->get_extra_preview_stream_format[2];
7285 *fps = pc->cb_info->get_extra_preview_stream_format[3];
7288 CAM_LOG_INFO("ret : 0x%x", ret);
7294 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
7296 int ret = CAMERA_ERROR_NONE;
7297 camera_cli_s *pc = (camera_cli_s *)camera;
7298 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
7299 camera_msg_param param0;
7300 camera_msg_param param1;
7302 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7304 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
7306 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
7307 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
7309 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
7310 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
7312 CAM_LOG_INFO("ret : 0x%x", ret);
7318 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
7320 int ret = CAMERA_ERROR_NONE;
7321 camera_cli_s *pc = (camera_cli_s *)camera;
7322 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
7323 camera_msg_param param;
7325 if (!pc || !pc->cb_info || !bitrate) {
7326 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
7327 return CAMERA_ERROR_INVALID_PARAMETER;
7330 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7332 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7334 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7336 if (ret == CAMERA_ERROR_NONE) {
7337 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
7338 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
7340 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
7347 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
7349 int ret = CAMERA_ERROR_NONE;
7350 camera_cli_s *pc = (camera_cli_s *)camera;
7351 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
7352 camera_msg_param param0;
7353 camera_msg_param param1;
7355 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7357 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
7359 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
7360 CAMERA_MSG_PARAM_SET(param1, INT, interval);
7362 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
7363 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
7365 CAM_LOG_INFO("ret : 0x%x", ret);
7371 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
7373 int ret = CAMERA_ERROR_NONE;
7374 camera_cli_s *pc = (camera_cli_s *)camera;
7375 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
7376 camera_msg_param param;
7378 if (!pc || !pc->cb_info || !interval) {
7379 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
7380 return CAMERA_ERROR_INVALID_PARAMETER;
7383 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7385 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7387 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7389 if (ret == CAMERA_ERROR_NONE) {
7390 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
7391 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
7393 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
7400 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
7402 camera_cli_s *pc = (camera_cli_s *)camera;
7404 if (!pc || !pc->cb_info || !rotation) {
7405 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
7406 return CAMERA_ERROR_INVALID_PARAMETER;
7409 if (!pc->cb_info->stream_data) {
7410 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
7411 return CAMERA_ERROR_INVALID_OPERATION;
7414 *rotation = pc->cb_info->stream_data->rotation;
7416 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
7418 return CAMERA_ERROR_NONE;
7422 int _camera_get_log_level(void)
7424 return g_camera_log_level;