2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <mm_camcorder.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_client.h>
35 #define LOG_TAG "TIZEN_N_CAMERA"
36 #define MODULE_NAME "camera"
37 #define LIB_CAMERA_DEVICE_MANAGER PATH_LIBDIR"/libcamera_device_manager.so"
38 #define CAMERA_CHECK_DEVICE_MANAGER \
40 if (access(LIB_CAMERA_DEVICE_MANAGER, F_OK) != 0) {\
41 CAM_LOG_ERROR("no camera device maanger[errno:%d]", errno);\
42 return CAMERA_ERROR_NOT_SUPPORTED;\
47 /* for camera device manager */
48 typedef struct _cdm_symbol_table {
50 const char *func_name;
53 /* for device changed callback */
54 static GMutex g_cam_dev_state_changed_cb_lock;
55 static GList *g_cam_dev_state_changed_cb_list;
56 static int g_cam_dev_state_changed_cb_id;
57 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
58 static guint g_cam_dev_state_changed_cb_subscribe_id;
59 static GMutex g_cam_idle_event_lock;
62 static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO;
64 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
65 static void __camera_release_imported_bo(tbm_bo *bo);
67 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
68 camera_media_packet_data *mp_data, media_packet_h *packet);
69 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
70 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
71 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
73 static gboolean __camera_allocate_preview_buffer(camera_h camera);
74 static void __camera_release_preview_buffer(camera_h camera);
75 static void __camera_release_tfd(int tfd[MUSE_NUM_FD]);
77 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
78 int type, const char *thread_name, camera_cb_info_s *cb_info);
79 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info);
83 static gboolean __camera_allocate_preview_buffer(camera_h camera)
86 int ret = CAMERA_ERROR_NONE;
87 int format = CAMERA_PIXEL_FORMAT_INVALID;
91 camera_cli_s *pc = (camera_cli_s *)camera;
92 camera_cb_info_s *cb_info = NULL;
94 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, FALSE);
96 cb_info = pc->cb_info;
98 CAM_LOG_INFO("Enter");
100 /* get preview info and calculate size */
101 ret = camera_get_preview_format(camera, &format);
102 if (ret != CAMERA_ERROR_NONE) {
103 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
107 ret = camera_get_preview_resolution(camera, &width, &height);
108 if (ret != CAMERA_ERROR_NONE) {
109 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
113 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
116 case CAMERA_PIXEL_FORMAT_INVZ:
117 buffer_size = width * height;
119 case CAMERA_PIXEL_FORMAT_NV12:
120 case CAMERA_PIXEL_FORMAT_I420:
121 buffer_size = (width * height * 3) >> 1;
123 case CAMERA_PIXEL_FORMAT_YUYV:
124 case CAMERA_PIXEL_FORMAT_UYVY:
125 buffer_size = width * height * 2;
128 CAM_LOG_ERROR("unhandled format %d", format);
129 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
132 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
134 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
135 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
136 if (!cb_info->bos[i]) {
137 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
138 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
141 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
142 if (cb_info->fds[i] < 0) {
143 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
144 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
147 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
150 CAM_LOG_INFO("Done");
154 _ALLOCATE_PREVIEW_BUFFER_FAILED:
155 __camera_release_preview_buffer(camera);
160 static void __camera_release_preview_buffer(camera_h camera)
163 camera_cli_s *pc = (camera_cli_s *)camera;
164 camera_cb_info_s *cb_info = NULL;
166 CAMERA_CHECK_HANDLE_RETURN(pc);
168 CAM_LOG_INFO("Enter");
170 cb_info = pc->cb_info;
172 /* close exported fd and bos */
173 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
174 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
176 if (cb_info->bos[i]) {
177 tbm_bo_unref(cb_info->bos[i]);
178 cb_info->bos[i] = NULL;
183 if (CAMERA_IS_FD_VALID(cb_info->fds[i])) {
184 close(cb_info->fds[i]);
185 cb_info->fds[i] = CAMERA_FD_INIT;
189 CAM_LOG_INFO("Done");
193 static void __camera_release_tfd(int tfd[MUSE_NUM_FD])
198 CAM_LOG_WARNING("NULL tfd");
202 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
203 if (!CAMERA_IS_FD_VALID(tfd[i]))
207 tfd[i] = CAMERA_FD_INIT;
212 void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
215 api < 0 || api >= MUSE_CAMERA_API_MAX) {
216 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
220 g_mutex_lock(&(cb_info->api_mutex[api]));
221 cb_info->api_waiting[api] += value;
222 g_mutex_unlock(&(cb_info->api_mutex[api]));
224 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
225 api, value, cb_info->api_waiting[api]);
229 static void __camera_device_state_changed_cb(GDBusConnection *connection,
230 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
231 const gchar *signal_name, GVariant *param, gpointer user_data)
234 camera_device_e device = CAMERA_DEVICE_CAMERA0;
235 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
236 GList *tmp_list = NULL;
237 camera_cb_info *info = NULL;
239 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
241 if (!g_cam_dev_state_changed_cb_list || !param) {
242 CAM_LOG_WARNING("no callback or NULL param %p", param);
246 /* get device and state */
247 g_variant_get(param, "(i)", &value);
249 device = value >> 16;
250 state = 0x0000ffff & value;
252 CAM_LOG_INFO("device %d, state %d", device, state);
254 tmp_list = g_cam_dev_state_changed_cb_list;
257 info = (camera_cb_info *)tmp_list->data;
260 if (info->callback) {
261 CAM_LOG_INFO("start id[%d] callback", info->id);
262 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
263 CAM_LOG_INFO("returned id[%d] callback", info->id);
265 CAM_LOG_WARNING("NULL callback for id %d", info->id);
269 tmp_list = tmp_list->next;
273 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
277 static void __camera_preview_cb_monitoring_info_sub_reset(monitoring_info_sub_s *info_sub)
280 CAM_LOG_ERROR("NULL info_sub");
284 info_sub->frame_count = 0;
285 info_sub->elapsed_sec_accum = 0.0;
286 info_sub->elapsed_sec_peak = 0.0;
290 static void __camera_preview_cb_monitoring_info_reset(camera_preview_cb_monitoring_info_s *info)
293 CAM_LOG_ERROR("NULL info");
297 __camera_preview_cb_monitoring_info_sub_reset(info->total);
298 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
302 static void __camera_preview_cb_monitoring_info_start(camera_preview_cb_monitoring_info_s *info)
305 CAM_LOG_ERROR("NULL info");
309 g_timer_start(info->timer_calling);
311 if (info->interval->frame_count == 0)
312 g_timer_start(info->timer_interval);
316 static void __camera_preview_cb_monitoring_info_sub_update(monitoring_info_sub_s *info_sub, gdouble elapsed_sec)
319 CAM_LOG_ERROR("NULL info_sub");
323 info_sub->frame_count++;
324 info_sub->elapsed_sec_accum += elapsed_sec;
326 if (info_sub->elapsed_sec_peak < elapsed_sec)
327 info_sub->elapsed_sec_peak = elapsed_sec;
331 static void __camera_preview_cb_monitoring_info_end(camera_preview_cb_monitoring_info_s *info)
333 gdouble elapsed_sec = 0.0;
334 gdouble elapsed_sec_interval = 0.0;
337 CAM_LOG_ERROR("NULL info");
341 elapsed_sec = g_timer_elapsed(info->timer_calling, NULL);
342 elapsed_sec_interval = g_timer_elapsed(info->timer_interval, NULL);
344 __camera_preview_cb_monitoring_info_sub_update(info->total, elapsed_sec);
345 __camera_preview_cb_monitoring_info_sub_update(info->interval, elapsed_sec);
347 if (elapsed_sec_interval >= 1.0) {
348 CAM_LOG_INFO("id[%d], frame count[t:%llu,i:%llu], elapsed - avg[t:%dms,i:%dms], peak[t:%dms,i:%dms]",
349 info->stream_id, info->total->frame_count, info->interval->frame_count,
350 (int)((info->total->elapsed_sec_accum / (gdouble)info->total->frame_count) * 1000),
351 (int)((info->interval->elapsed_sec_accum / (gdouble)info->interval->frame_count) * 1000),
352 (int)(info->total->elapsed_sec_peak * 1000), (int)(info->interval->elapsed_sec_peak * 1000));
354 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
359 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
363 int ret_fd = CAMERA_FD_INIT;
364 int preview_fd = CAMERA_FD_INIT;
365 int num_buffer_fd = 0;
366 unsigned char *buf_pos = NULL;
369 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
370 tbm_bo_handle bo_handle = {.ptr = NULL};
371 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
372 tbm_bo data_bo = NULL;
373 tbm_bo_handle data_bo_handle = {.ptr = NULL};
375 camera_msg_param param;
376 camera_preview_data_s frame;
377 MMCamcorderVideoStreamDataType *stream = NULL;
378 camera_media_packet_data *mp_data = NULL;
379 media_packet_h pkt = NULL;
380 camera_preview_cb_monitoring_info_s *monitoring_info = NULL;
382 /* tfd[0]: MMCamcorderVideoStreamDataType
383 tfd[1]: data_bo or zero copy bo[0]
384 tfd[2]: zero copy bo[1]
385 tfd[3]: zero copy bo[2] */
387 if (!cb_info || !recv_msg || !tfd) {
388 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
392 muse_camera_msg_get(preview_fd, recv_msg);
393 muse_camera_msg_get(num_buffer_fd, recv_msg);
395 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
397 memset(&frame, 0x0, sizeof(camera_preview_data_s));
400 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
405 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
407 if (cb_info->invoke_preview_cb == FALSE) {
408 CAM_LOG_WARNING("Skip preview callback for fd[%d] due to preview stop.", ret_fd);
409 goto _PREVIEW_CB_HANDLER_DONE;
412 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
413 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
414 goto _PREVIEW_CB_HANDLER_DONE;
417 /* import tbm bo and get virtual address */
418 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
419 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
420 goto _PREVIEW_CB_HANDLER_DONE;
423 buf_pos = (unsigned char *)bo_handle.ptr;
425 /* get stream info */
426 stream = (MMCamcorderVideoStreamDataType *)buf_pos;
428 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
429 /* import tbm data_bo and get virtual address */
430 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
431 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
432 goto _PREVIEW_CB_HANDLER_DONE;
435 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
436 stream->data.encoded.data = data_bo_handle.ptr;
438 for (i = 0 ; i < num_buffer_fd ; i++) {
439 /* import buffer bo and get virtual address */
440 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
441 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
442 goto _PREVIEW_CB_HANDLER_DONE;
446 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
447 stream->data.encoded.data = buffer_bo_handle[0].ptr;
450 /* preview callback */
451 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
452 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]) {
453 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
455 /* set stream data for camera_get_preview_frame_rotation() */
456 cb_info->stream_data = stream;
458 if (stream->extra_stream_id < 0) {
459 monitoring_info = cb_info->monitoring_info_preview;
460 __camera_preview_cb_monitoring_info_start(monitoring_info);
462 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
463 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
464 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
466 monitoring_info = cb_info->monitoring_info_preview_ex[stream->extra_stream_id];
467 __camera_preview_cb_monitoring_info_start(monitoring_info);
469 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
470 ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
471 stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
474 __camera_preview_cb_monitoring_info_end(monitoring_info);
476 cb_info->stream_data = NULL;
479 if (stream->extra_stream_id >= 0)
480 goto _PREVIEW_CB_HANDLER_DONE;
482 /* make media packet with below cases.
483 * 1. media_packet_preview_cb is set
484 * 2. EVAS display rendering
485 * 3. media bridge is set
487 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
488 cb_info->is_evas_render ||
490 ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
491 if (ret != CAMERA_ERROR_NONE) {
492 CAM_LOG_ERROR("__camera_create_media_packet_data failed[0x%x]", ret);
493 goto _PREVIEW_CB_HANDLER_DONE;
496 ret = __camera_create_media_packet(cb_info, stream, mp_data, &pkt);
497 if (ret != CAMERA_ERROR_NONE) {
498 CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
499 __camera_release_media_packet_data(mp_data, cb_info);
501 goto _PREVIEW_CB_HANDLER_DONE;
505 /* 1. media packet preview callback */
506 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
507 media_packet_ref(pkt);
509 monitoring_info = cb_info->monitoring_info_preview_mp;
510 __camera_preview_cb_monitoring_info_start(monitoring_info);
512 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
513 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
515 __camera_preview_cb_monitoring_info_end(monitoring_info);
518 /* 2. call evas renderer */
519 if (cb_info->is_evas_render) {
520 if (cb_info->run_evas_render) {
521 media_packet_ref(pkt);
522 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
523 if (ret != MM_ERROR_NONE) {
524 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
525 media_packet_unref(pkt);
528 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
533 /* 3. media bridge */
534 g_mutex_lock(&cb_info->bridge_lock);
536 if (cb_info->bridge) {
537 media_packet_ref(pkt);
538 ret = media_bridge_push_packet(cb_info->bridge, pkt);
539 if (ret != MEDIA_BRIDGE_ERROR_NONE) {
540 CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
541 media_packet_unref(pkt);
546 g_mutex_unlock(&cb_info->bridge_lock);
548 _PREVIEW_CB_HANDLER_DONE:
549 /* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
550 and preview callback(normal or media packet) is set. */
551 if (num_buffer_fd > 0 &&
552 (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
553 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]))
554 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
557 media_packet_unref(pkt);
562 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
564 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
566 /* release imported bo and fd */
567 __camera_release_imported_bo(&data_bo);
568 __camera_release_imported_bo(&bo);
570 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
571 __camera_release_imported_bo(&buffer_bo[i]);
573 __camera_release_tfd(tfd);
577 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
580 int capture_fd_main = 0;
581 int capture_fd_post = 0;
582 int capture_fd_thumb = 0;
583 unsigned char *buf_pos = NULL;
585 camera_image_data_s *rImage = NULL;
586 camera_image_data_s *rPostview = NULL;
587 camera_image_data_s *rThumbnail = NULL;
589 tbm_bo bo_main = NULL;
590 tbm_bo bo_post = NULL;
591 tbm_bo bo_thumb = NULL;
592 tbm_bo_handle bo_main_handle = {.ptr = NULL};
593 tbm_bo_handle bo_post_handle = {.ptr = NULL};
594 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
596 if (!cb_info || !recv_msg || !tfd) {
597 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
601 muse_camera_msg_get(capture_fd_main, recv_msg);
602 muse_camera_msg_get(capture_fd_post, recv_msg);
603 muse_camera_msg_get(capture_fd_thumb, recv_msg);
605 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
606 capture_fd_main, capture_fd_post, capture_fd_thumb,
607 tfd[0], tfd[1], tfd[2]);
609 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
610 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
611 goto _CAPTURE_CB_HANDLER_DONE;
614 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
615 CAM_LOG_WARNING("NULL callback");
616 goto _CAPTURE_CB_HANDLER_DONE;
619 /* import tbm bo and get virtual address */
620 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
621 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
622 goto _CAPTURE_CB_HANDLER_DONE;
625 buf_pos = (unsigned char *)bo_main_handle.ptr;
626 rImage = (camera_image_data_s *)buf_pos;
627 rImage->data = buf_pos + sizeof(camera_image_data_s);
628 if (rImage->exif && rImage->exif_size > 0) {
629 rImage->exif = rImage->data + rImage->size;
632 rImage->exif_size = 0;
635 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
636 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
639 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
640 /* import tbm bo and get virtual address */
642 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
643 buf_pos = (unsigned char *)bo_post_handle.ptr;
644 rPostview = (camera_image_data_s *)buf_pos;
645 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
646 rPostview->data = buf_pos + sizeof(camera_image_data_s);
648 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
652 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
653 /* import tbm bo and get virtual address */
655 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
656 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
657 rThumbnail = (camera_image_data_s *)buf_pos;
658 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
659 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
661 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
666 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
667 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
669 _CAPTURE_CB_HANDLER_DONE:
671 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
672 __camera_release_imported_bo(&bo_main);
673 _camera_msg_return_buffer(capture_fd_main, cb_info);
676 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
677 __camera_release_imported_bo(&bo_post);
678 _camera_msg_return_buffer(capture_fd_post, cb_info);
681 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
682 __camera_release_imported_bo(&bo_thumb);
683 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
686 __camera_release_tfd(tfd);
688 CAM_LOG_INFO("return buffer done");
693 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
696 int face_fd = CAMERA_FD_INIT;
697 camera_detected_face_s *faces = NULL;
700 tbm_bo_handle bo_handle = {.ptr = NULL};
702 if (!cb_info || !recv_msg || !tfd) {
703 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
707 muse_camera_msg_get(count, recv_msg);
708 muse_camera_msg_get(face_fd, recv_msg);
710 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
711 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
713 if (CAMERA_IS_FD_VALID(tfd[0])) {
714 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
716 faces = bo_handle.ptr;
720 tfd[0] = CAMERA_FD_INIT;
723 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
724 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
727 __camera_release_imported_bo(&bo);
729 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
730 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
734 _camera_msg_return_buffer(face_fd, cb_info);
739 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
741 tbm_bo tmp_bo = NULL;
742 tbm_bo_handle tmp_bo_handle = {NULL, };
744 if (!bufmgr || !bo || !bo_handle || fd < 0) {
745 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
746 bufmgr, bo, bo_handle, fd);
750 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
751 if (tmp_bo == NULL) {
752 CAM_LOG_ERROR("import failed - fd %d", fd);
756 tmp_bo_handle = tbm_bo_get_handle(tmp_bo, TBM_DEVICE_CPU);
757 if (tmp_bo_handle.ptr == NULL) {
758 CAM_LOG_ERROR("tbm_bo_get_handle() failed %p", tmp_bo);
759 tbm_bo_unref(tmp_bo);
764 /* set bo and bo_handle */
766 *bo_handle = tmp_bo_handle;
768 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
773 static void __camera_release_imported_bo(tbm_bo *bo)
776 CAM_LOG_DEBUG("NULL bo");
785 static bool __is_supported(camera_h camera, muse_camera_api_e api)
787 int ret = CAMERA_ERROR_NONE;
788 camera_cli_s *pc = (camera_cli_s *)camera;
790 if (!pc || !pc->cb_info) {
791 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
792 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
796 CAM_LOG_INFO("Enter - api[%d]", api);
798 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
800 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
806 static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
808 int ret = CAMERA_ERROR_NONE;
809 camera_cli_s *pc = (camera_cli_s *)camera;
810 camera_msg_param param;
812 if (!pc || !pc->cb_info) {
813 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
814 return CAMERA_ERROR_INVALID_PARAMETER;
817 CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
819 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
821 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
823 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
829 static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
831 int ret = CAMERA_ERROR_NONE;
832 camera_cli_s *pc = (camera_cli_s *)camera;
833 camera_msg_param param;
835 if (!pc || !pc->cb_info) {
836 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
837 return CAMERA_ERROR_INVALID_PARAMETER;
840 CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
842 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
844 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
846 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
852 void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
857 CAM_LOG_ERROR("api[%d] message failed", api);
859 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
864 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
865 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
867 CAM_LOG_DEBUG("api[%d], message[%s]", api, msg);
869 if (cb_info->is_server_connected) {
870 _camera_update_api_waiting(cb_info, api, 1);
872 g_mutex_lock(&cb_info->fd_lock);
873 send_ret = muse_core_msg_send(cb_info->fd, msg);
874 g_mutex_unlock(&cb_info->fd_lock);
878 CAM_LOG_ERROR("message send failed");
880 *ret = CAMERA_ERROR_INVALID_OPERATION;
883 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
886 _camera_update_api_waiting(cb_info, api, -1);
888 muse_core_msg_free(msg);
890 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
891 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
893 CAM_LOG_DEBUG("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
897 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
899 int ret = CAMERA_ERROR_NONE;
902 if (!cb_info->is_server_connected) {
903 CAM_LOG_ERROR("server is disconnected");
904 return CAMERA_ERROR_SERVICE_DISCONNECTED;
907 g_mutex_lock(&(cb_info->api_mutex[api]));
909 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
911 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
913 while (!cb_info->api_activating[api]) {
914 if (time_out == CAMERA_CB_NO_TIMEOUT) {
915 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
916 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
917 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
918 CAM_LOG_ERROR("api %d TIMED OUT!", api);
919 ret = CAMERA_ERROR_INVALID_OPERATION;
923 if (!cb_info->is_server_connected) {
924 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
928 if (!cb_info->api_activating[api])
929 CAM_LOG_WARNING("invalid signal received, wait again...");
932 ret = cb_info->api_ret[api];
933 cb_info->api_activating[api] = FALSE;
936 g_mutex_unlock(&(cb_info->api_mutex[api]));
938 if (ret != CAMERA_ERROR_NONE)
939 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
945 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
946 int *ret, int timeout)
951 CAM_LOG_ERROR("NULL info - api %d", api);
954 *ret = CAMERA_ERROR_INVALID_PARAMETER;
959 msg = muse_core_msg_new(api, NULL);
961 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
965 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
966 int *ret, camera_msg_param *param, int timeout)
971 if (!cb_info || !param) {
972 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
975 *ret = CAMERA_ERROR_INVALID_PARAMETER;
980 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
982 switch (param->type) {
984 msg = muse_core_msg_new(api,
985 param->type, param->name, param->value.value_INT,
988 case MUSE_TYPE_STRING:
989 msg = muse_core_msg_new(api,
990 param->type, param->name, param->value.value_STRING,
993 case MUSE_TYPE_ARRAY:
994 array_length = param->value_size / sizeof(int) + \
995 (param->value_size % sizeof(int) ? 1 : 0);
997 msg = muse_core_msg_new(api,
998 param->type, param->name, array_length, param->value.value_ARRAY,
1002 CAM_LOG_ERROR("unknown type %d", param->type);
1006 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1010 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
1011 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
1015 if (!cb_info || !param0 || !param1) {
1016 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
1017 cb_info, param0, param1, api);
1020 *ret = CAMERA_ERROR_INVALID_PARAMETER;
1025 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
1027 param0->name, param0->value.value_INT,
1028 param1->name, param1->value.value_INT);
1030 msg = muse_core_msg_new(api,
1031 param0->type, param0->name, param0->value.value_INT,
1032 param1->type, param1->name, param1->value.value_INT,
1035 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1039 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
1041 camera_msg_param param;
1044 CAM_LOG_WARNING("invalid fd %d", ret_fd);
1048 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
1050 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1054 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
1056 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1057 in_format >= MM_PIXEL_FORMAT_NUM ||
1058 out_format == NULL) {
1059 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
1060 return CAMERA_ERROR_INVALID_PARAMETER;
1063 switch (in_format) {
1064 case MM_PIXEL_FORMAT_NV12:
1065 case MM_PIXEL_FORMAT_NV12T:
1066 *out_format = TBM_FORMAT_NV12;
1069 case MM_PIXEL_FORMAT_NV16:
1070 *out_format = TBM_FORMAT_NV16;
1072 case MM_PIXEL_FORMAT_NV21:
1073 *out_format = TBM_FORMAT_NV21;
1075 case MM_PIXEL_FORMAT_YUYV:
1076 *out_format = TBM_FORMAT_YUYV;
1078 case MM_PIXEL_FORMAT_UYVY:
1079 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1080 *out_format = TBM_FORMAT_UYVY;
1082 case MM_PIXEL_FORMAT_422P:
1083 *out_format = TBM_FORMAT_YUV422;
1085 case MM_PIXEL_FORMAT_I420:
1086 *out_format = TBM_FORMAT_YUV420;
1088 case MM_PIXEL_FORMAT_YV12:
1089 *out_format = TBM_FORMAT_YVU420;
1091 case MM_PIXEL_FORMAT_RGB565:
1092 *out_format = TBM_FORMAT_RGB565;
1094 case MM_PIXEL_FORMAT_RGB888:
1095 *out_format = TBM_FORMAT_RGB888;
1097 case MM_PIXEL_FORMAT_RGBA:
1098 *out_format = TBM_FORMAT_RGBA8888;
1100 case MM_PIXEL_FORMAT_ARGB:
1101 *out_format = TBM_FORMAT_ARGB8888;
1104 CAM_LOG_ERROR("invalid in_format %d", in_format);
1105 return CAMERA_ERROR_INVALID_PARAMETER;
1109 return CAMERA_ERROR_NONE;
1113 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1115 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1116 in_format >= MM_PIXEL_FORMAT_NUM ||
1118 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1119 return CAMERA_ERROR_INVALID_PARAMETER;
1122 switch (in_format) {
1123 case MM_PIXEL_FORMAT_NV12:
1124 case MM_PIXEL_FORMAT_NV12T:
1125 *mimetype = MEDIA_FORMAT_NV12;
1128 case MM_PIXEL_FORMAT_NV16:
1129 *mimetype = MEDIA_FORMAT_NV16;
1131 case MM_PIXEL_FORMAT_NV21:
1132 *mimetype = MEDIA_FORMAT_NV21;
1134 case MM_PIXEL_FORMAT_YUYV:
1135 *mimetype = MEDIA_FORMAT_YUYV;
1137 case MM_PIXEL_FORMAT_UYVY:
1138 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1139 *mimetype = MEDIA_FORMAT_UYVY;
1141 case MM_PIXEL_FORMAT_422P:
1142 *mimetype = MEDIA_FORMAT_422P;
1144 case MM_PIXEL_FORMAT_I420:
1145 *mimetype = MEDIA_FORMAT_I420;
1147 case MM_PIXEL_FORMAT_YV12:
1148 *mimetype = MEDIA_FORMAT_YV12;
1150 case MM_PIXEL_FORMAT_RGB565:
1151 *mimetype = MEDIA_FORMAT_RGB565;
1153 case MM_PIXEL_FORMAT_RGB888:
1154 *mimetype = MEDIA_FORMAT_RGB888;
1156 case MM_PIXEL_FORMAT_RGBA:
1157 *mimetype = MEDIA_FORMAT_RGBA;
1159 case MM_PIXEL_FORMAT_ARGB:
1160 *mimetype = MEDIA_FORMAT_ARGB;
1162 case MM_PIXEL_FORMAT_ENCODED_H264:
1163 /* TODO: How can we determine the profile for H.264 format? */
1164 *mimetype = MEDIA_FORMAT_H264_SP;
1166 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1167 *mimetype = MEDIA_FORMAT_MJPEG;
1169 case MM_PIXEL_FORMAT_ENCODED_VP8:
1170 *mimetype = MEDIA_FORMAT_VP8;
1172 case MM_PIXEL_FORMAT_ENCODED_VP9:
1173 *mimetype = MEDIA_FORMAT_VP9;
1176 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1177 return CAMERA_ERROR_NOT_SUPPORTED;
1181 return CAMERA_ERROR_NONE;
1185 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1186 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1189 int ret = CAMERA_ERROR_NONE;
1190 camera_media_packet_data *new_mp_data = NULL;
1192 if (!tfd || !mp_data) {
1193 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1194 return CAMERA_ERROR_INVALID_PARAMETER;
1197 new_mp_data = g_new0(camera_media_packet_data, 1);
1199 new_mp_data->ret_fd = ret_fd;
1200 new_mp_data->fd = tfd[0];
1201 new_mp_data->num_buffer_fd = num_buffer_fd;
1202 new_mp_data->bo = bo;
1204 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1208 new_mp_data->data_bo = data_bo;
1209 new_mp_data->data_fd = tfd[1];
1211 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1212 new_mp_data->data_bo, new_mp_data->data_fd);
1215 for (i = 0 ; i < num_buffer_fd ; i++) {
1216 new_mp_data->buffer_bo[i] = buffer_bo[i];
1217 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1219 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1220 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1223 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1224 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1226 new_mp_data->data_fd = CAMERA_FD_INIT;
1229 *mp_data = new_mp_data;
1231 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1236 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1240 if (!mp_data || !cb_info) {
1241 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1245 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1247 /* release imported bo and close fd */
1248 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1249 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1250 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1252 tbm_bo_unref(mp_data->buffer_bo[i]);
1254 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1255 close(mp_data->buffer_fd[i]);
1257 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1260 if (mp_data->data_bo) {
1261 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1262 mp_data->data_fd, mp_data->data_bo);
1264 tbm_bo_unref(mp_data->data_bo);
1266 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1267 close(mp_data->data_fd);
1269 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1272 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1274 tbm_bo_unref(mp_data->bo);
1276 if (CAMERA_IS_FD_VALID(mp_data->fd))
1279 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1282 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1288 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1291 int ret = CAMERA_ERROR_NONE;
1292 uint32_t tbm_format = 0;
1293 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1294 tbm_surface_info_s tsurf_info;
1296 if (!stream || !mp_data) {
1297 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1301 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1302 CAM_LOG_ERROR("No valid data");
1306 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1307 if (ret != CAMERA_ERROR_NONE)
1310 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1312 if (mp_data->num_buffer_fd > 0) {
1313 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1314 bos[i] = mp_data->buffer_bo[i];
1316 bos[0] = mp_data->data_bo;
1319 tsurf_info.width = stream->width;
1320 tsurf_info.height = stream->height;
1321 tsurf_info.format = tbm_format;
1322 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1323 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1325 switch (tbm_format) {
1326 case TBM_FORMAT_NV12: /* fall through */
1327 case TBM_FORMAT_NV21: /* fall through */
1328 case TBM_FORMAT_YUV420: /* fall through */
1329 case TBM_FORMAT_YVU420: /* fall through */
1330 case TBM_FORMAT_UYVY: /* fall through */
1331 case TBM_FORMAT_YUYV:
1332 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1333 tsurf_info.planes[i].stride = stream->stride[i];
1334 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1335 if (i != 0 && mp_data->num_buffer_fd <= 1)
1336 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1337 tsurf_info.size += tsurf_info.planes[i].size;
1339 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1340 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1344 case TBM_FORMAT_RGB565: /* fall through */
1345 case TBM_FORMAT_RGB888: /* fall through */
1346 case TBM_FORMAT_RGBA8888: /* fall through */
1347 case TBM_FORMAT_ARGB8888:
1348 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1349 tsurf_info.planes[0].offset = 0;
1350 tsurf_info.size = stream->data.rgb.length_data;
1353 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1358 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1359 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1363 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1365 int ret = CAMERA_ERROR_NONE;
1366 int pkt_fmt_width = 0;
1367 int pkt_fmt_height = 0;
1368 bool make_pkt_fmt = false;
1369 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1370 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1372 if (!cb_info || !stream) {
1373 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1374 return CAMERA_ERROR_INVALID_PARAMETER;
1377 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1378 if (ret != CAMERA_ERROR_NONE)
1381 /* check media packet format */
1382 if (cb_info->pkt_fmt) {
1383 media_format_get_video_info(cb_info->pkt_fmt,
1384 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1386 CAM_LOG_DEBUG("pkt_fmt %dx%d - stream %dx%d",
1387 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1389 if (pkt_fmt_mimetype != mimetype ||
1390 pkt_fmt_width != stream->width ||
1391 pkt_fmt_height != stream->height) {
1392 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1393 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1395 media_format_unref(cb_info->pkt_fmt);
1396 cb_info->pkt_fmt = NULL;
1397 make_pkt_fmt = true;
1400 make_pkt_fmt = true;
1403 /* create packet format */
1405 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1406 mimetype, stream->width, stream->height);
1408 ret = media_format_create(&cb_info->pkt_fmt);
1409 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1410 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1411 return CAMERA_ERROR_INVALID_OPERATION;
1414 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1415 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1416 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1417 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1418 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1419 return CAMERA_ERROR_INVALID_OPERATION;
1423 return CAMERA_ERROR_NONE;
1427 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1428 camera_media_packet_data *mp_data, media_packet_h *packet)
1430 media_packet_h pkt = NULL;
1431 tbm_surface_h tsurf = NULL;
1432 int ret = CAMERA_ERROR_NONE;
1434 if (!cb_info || !stream || !mp_data || !packet) {
1435 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1436 cb_info, stream, mp_data, packet);
1437 return CAMERA_ERROR_INVALID_PARAMETER;
1440 ret = __camera_update_media_packet_format(cb_info, stream);
1441 if (ret != CAMERA_ERROR_NONE)
1444 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1445 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1446 stream->data.encoded.data, stream->data.encoded.length_data,
1447 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1451 if (!stream->data.encoded.is_delta_frame)
1452 media_packet_set_flags(pkt, MEDIA_PACKET_SYNC_FRAME);
1454 if (stream->data.encoded.is_header_included) {
1455 media_packet_set_flags(pkt, MEDIA_PACKET_CODEC_CONFIG);
1456 CAM_LOG_INFO("Codec config in buffer");
1460 tsurf = __camera_get_tbm_surface(stream, mp_data);
1462 CAM_LOG_ERROR("get tbm surface failed");
1463 ret = CAMERA_ERROR_INVALID_OPERATION;
1464 goto _PACKET_CREATE_FAILED;
1467 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1468 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1469 (void *)cb_info, &pkt);
1472 if (ret != MEDIA_PACKET_ERROR_NONE) {
1473 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1474 goto _PACKET_CREATE_FAILED;
1477 ret = media_packet_set_extra(pkt, (void *)mp_data);
1478 if (ret != MEDIA_PACKET_ERROR_NONE) {
1479 CAM_LOG_ERROR("media_packet_set_extra failed");
1480 goto _PACKET_CREATE_FAILED;
1483 if (media_packet_set_pts(pkt, stream->timestamp_nsec) != MEDIA_PACKET_ERROR_NONE)
1484 CAM_LOG_WARNING("media_packet_set_pts failed");
1486 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1487 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1489 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1493 return CAMERA_ERROR_NONE;
1495 _PACKET_CREATE_FAILED:
1497 tbm_surface_destroy(tsurf);
1499 media_packet_unref(pkt);
1501 return CAMERA_ERROR_INVALID_OPERATION;
1504 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1507 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1508 camera_media_packet_data *mp_data = NULL;
1509 tbm_surface_h tsurf = NULL;
1511 if (!pkt || !cb_info) {
1512 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1516 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1517 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1518 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1522 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1524 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1525 pkt, mp_data, tsurf);
1528 tbm_surface_destroy(tsurf);
1530 g_mutex_lock(&cb_info->mp_data_mutex);
1531 __camera_release_media_packet_data(mp_data, cb_info);
1532 g_mutex_unlock(&cb_info->mp_data_mutex);
1535 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1540 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1541 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1545 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1547 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1549 if (cb_info->user_cb[event] == NULL) {
1550 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1551 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1552 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1553 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1554 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1555 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1559 /* return buffer message should be sent for some events.
1560 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1561 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1562 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1563 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1568 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1574 muse_camera_msg_get(previous, recv_msg);
1575 muse_camera_msg_get(current, recv_msg);
1576 muse_camera_msg_get(by_policy, recv_msg);
1578 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1579 previous, current, by_policy);
1581 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1582 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1585 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1589 muse_camera_msg_get(state, recv_msg);
1591 CAM_LOG_INFO("FOCUS state - %d", state);
1593 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1596 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1597 CAM_LOG_INFO("CAPTURE_COMPLETED");
1598 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1600 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1601 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1602 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1605 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1609 muse_camera_msg_get(percent, recv_msg);
1611 CAM_LOG_INFO("HDR progress - %d %%", percent);
1613 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1616 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1622 muse_camera_msg_get(policy, recv_msg);
1623 muse_camera_msg_get(previous, recv_msg);
1624 muse_camera_msg_get(current, recv_msg);
1626 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1628 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1629 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1632 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1637 muse_camera_msg_get(policy, recv_msg);
1638 muse_camera_msg_get(state, recv_msg);
1640 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1642 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1643 (camera_state_e)state, cb_info->user_data[event]);
1646 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1647 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1649 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1652 int current_state = 0;
1654 muse_camera_msg_get(error, recv_msg);
1655 muse_camera_msg_get(current_state, recv_msg);
1657 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1659 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1660 (camera_state_e)current_state, cb_info->user_data[event]);
1664 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1666 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1667 muse_camera_msg_get(param1, recv_msg);
1668 muse_camera_msg_get(param2, recv_msg);
1670 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1672 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1673 cb_info->user_cb[event] = NULL;
1674 cb_info->user_data[event] = NULL;
1675 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1678 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1680 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1682 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1684 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1686 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1688 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1690 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1692 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1694 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1696 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1698 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1700 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1702 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1705 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1707 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1708 muse_camera_msg_get(param1, recv_msg);
1710 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1712 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1713 cb_info->user_cb[event] = NULL;
1714 cb_info->user_data[event] = NULL;
1715 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1719 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1720 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1723 CAM_LOG_WARNING("unhandled event %d", event);
1727 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1730 static gboolean __camera_idle_event_callback(gpointer data)
1732 camera_cb_info_s *cb_info = NULL;
1733 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1735 if (cam_idle_event == NULL) {
1736 CAM_LOG_ERROR("cam_idle_event is NULL");
1741 g_mutex_lock(&g_cam_idle_event_lock);
1743 cb_info = cam_idle_event->cb_info;
1744 if (cb_info == NULL) {
1745 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1746 g_mutex_unlock(&g_cam_idle_event_lock);
1747 goto IDLE_EVENT_CALLBACK_DONE;
1750 /* remove event from list */
1751 if (cb_info->idle_event_list)
1752 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1754 g_mutex_unlock(&g_cam_idle_event_lock);
1757 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1759 IDLE_EVENT_CALLBACK_DONE:
1761 g_free(cam_idle_event);
1762 cam_idle_event = NULL;
1767 static gpointer __camera_msg_handler_func(gpointer data)
1771 camera_message_s *cam_msg = NULL;
1772 camera_idle_event_s *cam_idle_event = NULL;
1773 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1774 camera_cb_info_s *cb_info = NULL;
1775 GThread *thread = NULL;
1777 if (!handler_info || !handler_info->cb_info) {
1778 CAM_LOG_ERROR("NULL handler %p", handler_info);
1782 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1783 type = handler_info->type;
1784 thread = handler_info->thread;
1786 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1788 g_mutex_lock(&handler_info->mutex);
1790 while (g_atomic_int_get(&handler_info->running)) {
1791 if (g_queue_is_empty(handler_info->queue)) {
1792 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1793 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1794 CAM_LOG_VERBOSE("t[%d] signal received", type);
1796 if (g_atomic_int_get(&handler_info->running) == 0) {
1797 CAM_LOG_INFO("t:%d stop event thread", type);
1802 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1804 g_mutex_unlock(&handler_info->mutex);
1806 if (cam_msg == NULL) {
1807 CAM_LOG_ERROR("t:%d NULL message", type);
1808 g_mutex_lock(&handler_info->mutex);
1814 if (api < MUSE_CAMERA_API_MAX) {
1817 g_mutex_lock(&cb_info->api_mutex[api]);
1819 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1820 if (cb_info->api_waiting[api] > 0) {
1821 cb_info->api_ret[api] = ret;
1822 cb_info->api_activating[api] = TRUE;
1824 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1826 g_cond_broadcast(&cb_info->api_cond[api]);
1828 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1831 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1834 g_mutex_unlock(&cb_info->api_mutex[api]);
1835 } else if (api == MUSE_CAMERA_CB_EVENT) {
1836 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1837 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1838 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1841 switch (cam_msg->event_class) {
1842 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1843 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1845 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1846 cam_idle_event = g_new0(camera_idle_event_s, 1);
1847 if (cam_idle_event == NULL) {
1848 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1852 cam_idle_event->event = cam_msg->event;
1853 cam_idle_event->cb_info = cb_info;
1855 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1856 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1858 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1859 type, cam_msg->event, cam_idle_event);
1861 g_mutex_lock(&g_cam_idle_event_lock);
1862 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1863 g_mutex_unlock(&g_cam_idle_event_lock);
1865 g_idle_add_full(G_PRIORITY_DEFAULT,
1866 (GSourceFunc)__camera_idle_event_callback,
1867 (gpointer)cam_idle_event,
1871 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1875 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1881 g_mutex_lock(&handler_info->mutex);
1884 /* remove remained event */
1885 while (!g_queue_is_empty(handler_info->queue)) {
1886 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1888 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1889 __camera_release_tfd(cam_msg->tfd);
1892 CAM_LOG_WARNING("t:%d NULL message", type);
1896 g_mutex_unlock(&handler_info->mutex);
1898 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1904 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1906 camera_idle_event_s *cam_idle_event = NULL;
1909 if (cb_info == NULL) {
1910 CAM_LOG_ERROR("cb_info is NULL");
1914 g_mutex_lock(&g_cam_idle_event_lock);
1916 if (cb_info->idle_event_list == NULL) {
1917 CAM_LOG_INFO("No remained idle event");
1918 g_mutex_unlock(&g_cam_idle_event_lock);
1922 list = cb_info->idle_event_list;
1925 cam_idle_event = list->data;
1926 list = g_list_next(list);
1928 if (!cam_idle_event) {
1929 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1933 if (g_idle_remove_by_data(cam_idle_event)) {
1934 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1936 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1938 g_free(cam_idle_event);
1939 cam_idle_event = NULL;
1944 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1945 cam_idle_event, cam_idle_event->event);
1947 cam_idle_event->cb_info = NULL;
1949 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1952 g_list_free(cb_info->idle_event_list);
1953 cb_info->idle_event_list = NULL;
1955 g_mutex_unlock(&g_cam_idle_event_lock);
1959 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1961 camera_message_s *cam_msg = NULL;
1963 if (!cb_info || !msg) {
1964 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1968 cam_msg = g_new0(camera_message_s, 1);
1970 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1975 cam_msg->event = event;
1976 cam_msg->event_class = event_class;
1979 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1981 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1983 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1984 api, event, event_class);
1986 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1987 if (!cb_info->preview_cb_info.thread) {
1988 LOGI("The thread for preview cb is not created yet, create it now");
1989 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1990 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1991 CAM_LOG_ERROR("failed to create thread for preview cb");
1997 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1998 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1999 g_cond_signal(&cb_info->preview_cb_info.cond);
2000 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
2001 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
2002 g_mutex_lock(&cb_info->capture_cb_info.mutex);
2003 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
2004 g_cond_signal(&cb_info->capture_cb_info.cond);
2005 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
2007 g_mutex_lock(&cb_info->msg_handler_info.mutex);
2008 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
2009 g_cond_signal(&cb_info->msg_handler_info.cond);
2010 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
2017 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
2019 int ret = CAMERA_ERROR_NONE;
2023 int event_class = -1;
2027 if (!cb_info || !msg) {
2028 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
2032 CAM_LOG_DEBUG("msg[%s]", msg);
2034 if (!muse_camera_msg_get(api, msg)) {
2035 CAM_LOG_ERROR("failed to get camera api");
2039 if (api == MUSE_CAMERA_CB_EVENT) {
2040 if (!muse_camera_msg_get(event, msg) ||
2041 !muse_camera_msg_get(event_class, msg)) {
2042 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
2046 if (!muse_camera_msg_get(api_class, msg)) {
2047 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
2052 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
2053 if (api >= MUSE_CAMERA_API_MAX) {
2054 CAM_LOG_ERROR("invalid api %d", api);
2058 if (!muse_camera_msg_get(ret, msg)) {
2059 CAM_LOG_ERROR("failed to get camera ret");
2063 g_mutex_lock(&cb_info->api_mutex[api]);
2066 case MUSE_CAMERA_API_CREATE:
2067 if (ret != CAMERA_ERROR_NONE) {
2068 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2069 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
2072 case MUSE_CAMERA_API_DESTROY:
2073 if (ret == CAMERA_ERROR_NONE) {
2074 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2075 CAM_LOG_INFO("camera destroy done. close client cb handler");
2079 muse_camera_msg_get(get_type, msg);
2080 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
2081 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
2082 muse_camera_msg_get(get_index, msg);
2085 case MUSE_CAMERA_GET_TYPE_INT:
2086 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
2088 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
2089 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
2090 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
2092 case MUSE_CAMERA_GET_TYPE_ARRAY:
2094 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
2095 muse_core_msg_deserialize("get_value",
2096 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2097 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
2098 cb_info->get_display_roi_area[0],
2099 cb_info->get_display_roi_area[1],
2100 cb_info->get_display_roi_area[2],
2101 cb_info->get_display_roi_area[3]);
2103 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
2104 muse_core_msg_deserialize("get_value",
2105 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2106 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2107 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2109 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2110 muse_core_msg_deserialize("get_value",
2111 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2112 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2113 cb_info->get_extra_preview_stream_format[0],
2114 cb_info->get_extra_preview_stream_format[1],
2115 cb_info->get_extra_preview_stream_format[2],
2116 cb_info->get_extra_preview_stream_format[3]);
2119 CAM_LOG_WARNING("unknown api[%d]", api);
2123 case MUSE_CAMERA_GET_TYPE_STRING:
2124 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2127 CAM_LOG_WARNING("unknown type %d", get_type);
2134 if (cb_info->api_waiting[api] > 0) {
2135 cb_info->api_ret[api] = ret;
2136 cb_info->api_activating[api] = TRUE;
2138 g_cond_broadcast(&cb_info->api_cond[api]);
2140 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2143 g_mutex_unlock(&cb_info->api_mutex[api]);
2144 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2145 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2147 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2152 static gpointer __camera_msg_recv_func(gpointer data)
2155 int recv_length = 0;
2156 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2157 char *recv_msg = NULL;
2158 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2161 CAM_LOG_ERROR("cb_info NULL");
2165 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2167 recv_msg = cb_info->recv_msg;
2169 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2170 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2171 tfd[i] = CAMERA_FD_INIT;
2173 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2174 if (recv_length <= 0) {
2175 cb_info->is_server_connected = FALSE;
2176 CAM_LOG_ERROR("receive msg failed - server disconnected");
2180 if (CAMERA_IS_FD_VALID(tfd[0]))
2181 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2183 recv_msg[recv_length] = '\0';
2185 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2187 __camera_process_msg(cb_info, recv_msg, tfd);
2190 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2193 if (!cb_info->is_server_connected) {
2194 char *error_msg = NULL;
2196 if (cb_info->bufmgr == NULL) {
2197 CAM_LOG_ERROR("No need to send error(handle is not created)");
2201 if (cb_info->fd < 0) {
2202 CAM_LOG_ERROR("fd is closed in client side");
2206 /* send error msg for server disconnection */
2207 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2208 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2209 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2213 CAM_LOG_ERROR("error_msg failed");
2217 __camera_add_msg_to_queue(cb_info,
2218 MUSE_CAMERA_CB_EVENT,
2219 MUSE_CAMERA_EVENT_TYPE_ERROR,
2220 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2224 muse_core_msg_free(error_msg);
2227 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2228 if (cb_info->api_waiting[i])
2229 g_cond_broadcast(&cb_info->api_cond[i]);
2232 CAM_LOG_ERROR("add error msg for service disconnection done");
2240 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2241 int type, const char *thread_name, camera_cb_info_s *cb_info)
2243 if (!handler_info || !thread_name || !cb_info) {
2244 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2245 type, handler_info, thread_name, cb_info);
2249 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2251 if (handler_info->thread) {
2252 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2256 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2258 handler_info->type = type;
2259 handler_info->queue = g_queue_new();
2260 if (handler_info->queue == NULL) {
2261 CAM_LOG_ERROR("t:%d queue failed", type);
2265 handler_info->cb_info = (void *)cb_info;
2266 g_atomic_int_set(&handler_info->running, 1);
2268 handler_info->thread = g_thread_try_new(thread_name,
2269 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2270 if (handler_info->thread == NULL) {
2271 CAM_LOG_ERROR("t:%d thread failed", type);
2273 g_queue_free(handler_info->queue);
2274 handler_info->queue = NULL;
2279 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2285 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2287 GThread *thread = NULL;
2289 if (!handler_info) {
2290 CAM_LOG_ERROR("NULL handler");
2294 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2296 if (!handler_info->thread) {
2297 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2301 thread = handler_info->thread;
2302 handler_info->thread = NULL;
2304 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2306 g_atomic_int_set(&handler_info->running, 0);
2307 g_cond_signal(&handler_info->cond);
2309 g_clear_pointer(&locker, g_mutex_locker_free);
2311 g_thread_join(thread);
2313 g_queue_free(handler_info->queue);
2314 handler_info->queue = NULL;
2316 CAM_LOG_INFO("t:%d done", handler_info->type);
2320 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2325 CAM_LOG_ERROR("NULL cb_info");
2329 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2330 g_mutex_init(&cb_info->api_mutex[i]);
2331 g_cond_init(&cb_info->api_cond[i]);
2334 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2335 g_mutex_init(&cb_info->user_cb_mutex[i]);
2337 g_mutex_init(&cb_info->fd_lock);
2338 g_mutex_init(&cb_info->mp_data_mutex);
2339 g_mutex_init(&cb_info->bridge_lock);
2341 g_mutex_init(&cb_info->msg_handler_info.mutex);
2342 g_mutex_init(&cb_info->preview_cb_info.mutex);
2343 g_mutex_init(&cb_info->capture_cb_info.mutex);
2344 g_cond_init(&cb_info->msg_handler_info.cond);
2345 g_cond_init(&cb_info->preview_cb_info.cond);
2346 g_cond_init(&cb_info->capture_cb_info.cond);
2348 CAM_LOG_INFO("done");
2352 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2357 CAM_LOG_ERROR("NULL cb_info");
2361 g_mutex_clear(&cb_info->msg_handler_info.mutex);
2362 g_mutex_clear(&cb_info->preview_cb_info.mutex);
2363 g_mutex_clear(&cb_info->capture_cb_info.mutex);
2364 g_cond_clear(&cb_info->msg_handler_info.cond);
2365 g_cond_clear(&cb_info->preview_cb_info.cond);
2366 g_cond_clear(&cb_info->capture_cb_info.cond);
2368 g_mutex_clear(&cb_info->fd_lock);
2369 g_mutex_clear(&cb_info->mp_data_mutex);
2370 g_mutex_clear(&cb_info->bridge_lock);
2372 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2373 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2375 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2376 g_mutex_clear(&cb_info->api_mutex[i]);
2377 g_cond_clear(&cb_info->api_cond[i]);
2380 CAM_LOG_INFO("done");
2384 static camera_preview_cb_monitoring_info_s *__camera_preview_cb_monitoring_info_create(int stream_id)
2386 camera_preview_cb_monitoring_info_s *new_info = g_new0(camera_preview_cb_monitoring_info_s, 1);
2388 new_info->stream_id = stream_id;
2389 new_info->total = g_new0(monitoring_info_sub_s, 1);
2390 new_info->interval = g_new0(monitoring_info_sub_s, 1);
2391 new_info->timer_calling = g_timer_new();
2392 new_info->timer_interval = g_timer_new();
2394 CAM_LOG_INFO("create preview cb monitoring info[%p]", new_info);
2400 static void __camera_preview_cb_monitoring_info_destroy(camera_preview_cb_monitoring_info_s *info)
2405 g_timer_destroy(info->timer_calling);
2406 g_timer_destroy(info->timer_interval);
2407 g_free(info->total);
2408 g_free(info->interval);
2410 CAM_LOG_INFO("destroy preview cb monitoring info[%p]", info);
2416 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2419 camera_cb_info_s *cb_info = NULL;
2421 g_return_val_if_fail(sockfd > 0, NULL);
2423 cb_info = g_new0(camera_cb_info_s, 1);
2425 CAM_LOG_ERROR("cb_info failed");
2429 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2431 __camera_mutex_cond_init(cb_info);
2433 /* message handler thread */
2434 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2435 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2436 CAM_LOG_ERROR("msg_handler_info failed");
2440 /* message handler thread for capture callback */
2441 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2442 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2443 CAM_LOG_ERROR("capture_cb_info failed");
2447 cb_info->fd = sockfd;
2449 /* message receive thread */
2450 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2451 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2452 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2453 if (cb_info->msg_recv_thread == NULL) {
2454 CAM_LOG_ERROR("message receive thread creation failed");
2459 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2460 cb_info->fds[i] = CAMERA_FD_INIT;
2462 cb_info->is_server_connected = TRUE;
2464 cb_info->monitoring_info_preview = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW);
2465 cb_info->monitoring_info_preview_mp = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW_MP);
2466 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2467 cb_info->monitoring_info_preview_ex[i] = __camera_preview_cb_monitoring_info_create(i);
2473 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2474 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2476 __camera_mutex_cond_clear(cb_info);
2487 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2492 CAM_LOG_ERROR("NULL cb_info");
2496 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2498 g_thread_join(cb_info->msg_recv_thread);
2499 cb_info->msg_recv_thread = NULL;
2501 CAM_LOG_INFO("msg_recv thread removed");
2503 /* destroy msg handler threads */
2504 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2505 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2506 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2508 __camera_mutex_cond_clear(cb_info);
2510 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2511 muse_client_close(cb_info->fd);
2512 cb_info->fd = CAMERA_FD_INIT;
2515 if (cb_info->bufmgr) {
2516 tbm_bufmgr_deinit(cb_info->bufmgr);
2517 cb_info->bufmgr = NULL;
2519 if (cb_info->pkt_fmt) {
2520 media_format_unref(cb_info->pkt_fmt);
2521 cb_info->pkt_fmt = NULL;
2524 if (cb_info->dp_interface) {
2525 mm_display_interface_deinit(cb_info->dp_interface);
2526 cb_info->dp_interface = NULL;
2529 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview);
2530 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_mp);
2531 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2532 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_ex[i]);
2538 int _camera_start_evas_rendering(camera_h camera)
2540 camera_cli_s *pc = (camera_cli_s *)camera;
2542 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2544 CAM_LOG_INFO("start");
2546 if (!pc->cb_info->is_evas_render) {
2547 CAM_LOG_ERROR("EVAS surface is not set");
2548 return CAMERA_ERROR_NONE;
2551 /* set evas render flag as RUN */
2552 pc->cb_info->run_evas_render = true;
2554 return CAMERA_ERROR_NONE;
2558 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2560 int ret = CAMERA_ERROR_NONE;
2561 camera_cli_s *pc = (camera_cli_s *)camera;
2563 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2565 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2567 if (!pc->cb_info->is_evas_render) {
2568 CAM_LOG_ERROR("EVAS surface is not set");
2569 return CAMERA_ERROR_NONE;
2572 /* set evas render flag as STOP and release buffers */
2573 pc->cb_info->run_evas_render = false;
2575 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2576 if (ret == MM_ERROR_NONE) {
2577 ret = CAMERA_ERROR_NONE;
2579 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2580 ret = CAMERA_ERROR_INVALID_OPERATION;
2587 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2589 int ret = CAMERA_ERROR_NONE;
2590 int sock_fd = CAMERA_FD_INIT;
2591 int module_index = -1;
2593 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2595 /* create muse connection */
2596 if (!key || !value) {
2597 CAM_LOG_ERROR("NULL pointer");
2598 return CAMERA_ERROR_INVALID_PARAMETER;
2601 sock_fd = muse_client_new();
2603 CAM_LOG_ERROR("muse_client_new failed");
2604 return CAMERA_ERROR_INVALID_OPERATION;
2607 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2608 CAM_LOG_ERROR("muse client get module index failed");
2609 ret = CAMERA_ERROR_INVALID_OPERATION;
2613 msg = muse_core_msg_new(api,
2614 MUSE_TYPE_INT, "module", module_index,
2615 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2618 CAM_LOG_ERROR("msg failed");
2619 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2623 ret = muse_core_msg_send(sock_fd, msg);
2625 muse_core_msg_free(msg);
2629 CAM_LOG_ERROR("send msg failed");
2630 ret = CAMERA_ERROR_INVALID_OPERATION;
2634 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2636 CAM_LOG_ERROR("recv msg failed %d", errno);
2637 ret = CAMERA_ERROR_INVALID_OPERATION;
2641 if (!muse_camera_msg_get(ret, recv_msg)) {
2642 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2643 ret = CAMERA_ERROR_INVALID_OPERATION;
2647 if (ret == CAMERA_ERROR_NONE)
2648 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2650 CAM_LOG_INFO("api %d - value %d", api, *value);
2653 if (CAMERA_IS_FD_VALID(sock_fd)) {
2654 muse_client_close(sock_fd);
2655 sock_fd = CAMERA_FD_INIT;
2662 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2664 int sock_fd = CAMERA_FD_INIT;
2665 char *send_msg = NULL;
2667 int ret = CAMERA_ERROR_NONE;
2668 camera_cli_s *pc = NULL;
2669 tbm_bufmgr bufmgr = NULL;
2671 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2672 int module_index = -1;
2673 int device_type = (int)device;
2675 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2677 sock_fd = muse_client_new();
2679 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2680 ret = CAMERA_ERROR_INVALID_OPERATION;
2684 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2685 CAM_LOG_ERROR("muse client get module index failed");
2686 ret = CAMERA_ERROR_INVALID_OPERATION;
2690 send_msg = muse_core_msg_new(api,
2691 MUSE_TYPE_INT, "module", module_index,
2692 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2693 MUSE_TYPE_INT, "is_network", (int)is_network,
2697 CAM_LOG_ERROR("NULL msg");
2698 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2702 send_ret = muse_core_msg_send(sock_fd, send_msg);
2704 muse_core_msg_free(send_msg);
2708 CAM_LOG_ERROR("send msg failed %d", errno);
2709 ret = CAMERA_ERROR_INVALID_OPERATION;
2713 pc = g_new0(camera_cli_s, 1);
2715 CAM_LOG_ERROR("camera_cli_s alloc failed");
2716 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2720 bufmgr = tbm_bufmgr_init(-1);
2721 if (bufmgr == NULL) {
2722 CAM_LOG_ERROR("get tbm bufmgr failed");
2723 ret = CAMERA_ERROR_INVALID_OPERATION;
2727 pc->cb_info = __camera_client_callback_new(sock_fd);
2728 if (pc->cb_info == NULL) {
2729 CAM_LOG_ERROR("cb_info alloc failed");
2730 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2734 sock_fd = CAMERA_FD_INIT;
2736 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2738 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2740 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2742 if (ret == CAMERA_ERROR_NONE) {
2743 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2744 int user_buffer_supported = 0;
2745 int log_level = CAMERA_LOG_LEVEL_INFO;
2746 intptr_t handle = 0;
2748 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2750 CAM_LOG_ERROR("Receiving Handle Failed!!");
2751 ret = CAMERA_ERROR_INVALID_OPERATION;
2755 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2756 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2757 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2759 pc->remote_handle = handle;
2760 pc->cb_info->bufmgr = bufmgr;
2761 pc->cb_info->preview_format = preview_format;
2762 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2763 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2764 pc->cb_info->is_network = is_network;
2765 g_camera_log_level = log_level;
2767 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2768 preview_format, user_buffer_supported, g_camera_log_level);
2771 CAM_LOG_ERROR("NULL out handle");
2772 ret= CAMERA_ERROR_INVALID_PARAMETER;
2776 *camera = (camera_h)pc;
2778 /* get display interface handle */
2779 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2780 CAM_LOG_WARNING("display interface init failed");
2789 tbm_bufmgr_deinit(bufmgr);
2793 if (CAMERA_IS_FD_VALID(sock_fd)) {
2794 muse_client_close(sock_fd);
2795 sock_fd = CAMERA_FD_INIT;
2800 int temp_fd = pc->cb_info->fd;
2802 /* pc->cb_info->fd should be closed,
2803 because g_thread_join for msg_recv_thread is not returned
2804 in __camera_client_callback_destroy. */
2805 if (CAMERA_IS_FD_VALID(temp_fd)) {
2806 pc->cb_info->fd = CAMERA_FD_INIT;
2807 muse_client_close(temp_fd);
2810 __camera_client_callback_destroy(pc->cb_info);
2817 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2824 int camera_create(camera_device_e device, camera_h *camera)
2826 return _camera_create_private(device, false, camera);
2830 int camera_change_device(camera_h camera, camera_device_e device)
2833 int ret = CAMERA_ERROR_NONE;
2834 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2835 camera_cli_s *pc = (camera_cli_s *)camera;
2836 camera_msg_param param;
2838 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2840 CAMERA_MSG_PARAM_SET(param, INT, device);
2842 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2844 if (ret == CAMERA_ERROR_NONE) {
2845 /* reset callback and user data */
2846 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2847 pc->cb_info->user_cb[i] = NULL;
2848 pc->cb_info->user_data[i] = NULL;
2856 int camera_destroy(camera_h camera)
2858 int ret = CAMERA_ERROR_NONE;
2859 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2860 camera_cli_s *pc = (camera_cli_s *)camera;
2862 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2864 CAM_LOG_INFO("Enter");
2866 if (pc->cb_info->is_server_connected)
2867 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2869 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2871 if (ret == CAMERA_ERROR_NONE) {
2872 __camera_deactivate_idle_event_all(pc->cb_info);
2873 __camera_client_callback_destroy(pc->cb_info);
2880 CAM_LOG_INFO("ret : 0x%x", ret);
2885 int camera_start_preview(camera_h camera)
2888 int ret = CAMERA_ERROR_NONE;
2890 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2891 camera_cli_s *pc = (camera_cli_s *)camera;
2892 camera_state_e current_state = CAMERA_STATE_NONE;
2894 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2896 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2897 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2899 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2900 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2901 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2902 pc->cb_info->dp_info.type);
2903 return CAMERA_ERROR_INVALID_OPERATION;
2906 ret = camera_get_state(camera, ¤t_state);
2907 if (ret != CAMERA_ERROR_NONE) {
2908 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2912 if (current_state == CAMERA_STATE_CREATED) {
2913 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview);
2914 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_mp);
2915 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2916 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_ex[i]);
2918 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2919 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2920 CAM_LOG_ERROR("preview_cb_info failed");
2921 return CAMERA_ERROR_INVALID_OPERATION;
2924 if (pc->cb_info->user_buffer_supported) {
2925 if (!__camera_allocate_preview_buffer(camera)) {
2926 ret = CAMERA_ERROR_INVALID_OPERATION;
2930 fds = pc->cb_info->fds;
2934 pc->cb_info->invoke_preview_cb = TRUE;
2936 _camera_msg_send(api, fds, pc->cb_info, &ret,
2937 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2938 CAMERA_CB_NO_TIMEOUT);
2940 CAMERA_CB_TIMEOUT_FOR_PREVIEW);
2942 if (ret != CAMERA_ERROR_NONE)
2945 if (pc->cb_info->is_evas_render) {
2946 ret = _camera_start_evas_rendering(camera);
2947 if (ret != CAMERA_ERROR_NONE) {
2948 CAM_LOG_ERROR("stop preview because of error");
2949 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2954 CAM_LOG_INFO("done");
2956 return CAMERA_ERROR_NONE;
2959 if (current_state == CAMERA_STATE_CREATED) {
2960 if (pc->cb_info->user_buffer_supported)
2961 __camera_release_preview_buffer(camera);
2963 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2966 CAM_LOG_ERROR("failed : 0x%x", ret);
2972 int camera_stop_preview(camera_h camera)
2974 int ret = CAMERA_ERROR_NONE;
2975 camera_cli_s *pc = (camera_cli_s *)camera;
2976 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2977 camera_state_e current_state = CAMERA_STATE_NONE;
2979 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2981 CAM_LOG_INFO("Enter");
2984 if (pc->cb_info->is_evas_render) {
2985 ret = camera_get_state(camera, ¤t_state);
2986 if (ret != CAMERA_ERROR_NONE) {
2987 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2991 if (current_state == CAMERA_STATE_PREVIEW) {
2992 ret = _camera_stop_evas_rendering(camera, false);
2993 if (ret != CAMERA_ERROR_NONE)
2999 pc->cb_info->invoke_preview_cb = FALSE;
3001 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3003 if (ret == CAMERA_ERROR_NONE) {
3004 if (pc->cb_info->user_buffer_supported)
3005 __camera_release_preview_buffer(camera);
3007 /* release remained message for preview callback */
3008 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
3009 } else if (current_state == CAMERA_STATE_PREVIEW) {
3010 CAM_LOG_WARNING("restart evas rendering");
3011 _camera_start_evas_rendering(camera);
3014 CAM_LOG_INFO("ret : 0x%x", ret);
3020 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
3022 int ret = CAMERA_ERROR_NONE;
3023 camera_cli_s *pc = (camera_cli_s *)camera;
3024 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
3026 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3028 CAM_LOG_INFO("Enter");
3030 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3031 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3033 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3034 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3036 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3038 CAM_LOG_INFO("ret : 0x%x", ret);
3044 bool camera_is_supported_continuous_capture(camera_h camera)
3046 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
3050 int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
3052 int ret = CAMERA_ERROR_NONE;
3053 camera_cli_s *pc = (camera_cli_s *)camera;
3054 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
3055 camera_msg_param param;
3058 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3060 CAM_LOG_INFO("Enter");
3062 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3063 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3065 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3066 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3068 value = (count << 16) | interval;
3069 CAMERA_MSG_PARAM_SET(param, INT, value);
3071 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3073 CAM_LOG_INFO("ret : 0x%x", ret);
3079 int camera_stop_continuous_capture(camera_h camera)
3081 int ret = CAMERA_ERROR_NONE;
3082 camera_cli_s *pc = (camera_cli_s *)camera;
3083 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
3085 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3087 CAM_LOG_INFO("Enter");
3089 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3091 CAM_LOG_INFO("ret : 0x%x", ret);
3097 bool camera_is_supported_face_detection(camera_h camera)
3099 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
3103 bool camera_is_supported_zero_shutter_lag(camera_h camera)
3105 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
3109 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
3111 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
3115 bool camera_is_supported_extra_preview(camera_h camera)
3117 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
3121 int camera_get_device_count(camera_h camera, int *device_count)
3123 int ret = CAMERA_ERROR_NONE;
3124 camera_cli_s *pc = (camera_cli_s *)camera;
3125 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
3127 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3129 CAM_LOG_INFO("Enter");
3131 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3133 if (ret == CAMERA_ERROR_NONE)
3134 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3136 CAM_LOG_INFO("ret : 0x%x", ret);
3141 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3143 int ret = CAMERA_ERROR_NONE;
3144 camera_cli_s *pc = (camera_cli_s *)camera;
3145 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3147 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3149 CAM_LOG_INFO("Enter");
3151 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3153 if (ret == CAMERA_ERROR_NONE) {
3154 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3156 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3157 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3159 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3162 CAM_LOG_INFO("ret : 0x%x", ret);
3167 int camera_stop_face_detection(camera_h camera)
3169 int ret = CAMERA_ERROR_NONE;
3170 camera_cli_s *pc = (camera_cli_s *)camera;
3171 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3173 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3175 CAM_LOG_INFO("Enter");
3177 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3179 if (ret == CAMERA_ERROR_NONE) {
3180 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3182 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3183 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3185 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3188 CAM_LOG_INFO("ret : 0x%x", ret);
3193 int camera_get_state(camera_h camera, camera_state_e *state)
3195 int ret = CAMERA_ERROR_NONE;
3196 camera_cli_s *pc = (camera_cli_s *)camera;
3197 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3199 if (!pc || !pc->cb_info || !state) {
3200 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3201 return CAMERA_ERROR_INVALID_PARAMETER;
3204 CAM_LOG_INFO("Enter");
3206 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3208 if (ret == CAMERA_ERROR_NONE)
3209 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3211 CAM_LOG_INFO("ret : 0x%x", ret);
3216 int camera_start_focusing(camera_h camera, bool continuous)
3218 int ret = CAMERA_ERROR_NONE;
3219 camera_cli_s *pc = (camera_cli_s *)camera;
3220 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3221 camera_msg_param param;
3222 int is_continuous = (int)continuous;
3224 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3226 CAM_LOG_INFO("Enter");
3228 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3230 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3232 CAM_LOG_INFO("ret : 0x%x", ret);
3237 int camera_cancel_focusing(camera_h camera)
3239 int ret = CAMERA_ERROR_NONE;
3240 camera_cli_s *pc = (camera_cli_s *)camera;
3241 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3243 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3245 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3247 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3249 CAM_LOG_INFO("ret : 0x%x", ret);
3255 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3257 int mm_ret = MM_ERROR_NONE;
3258 int ret = CAMERA_ERROR_NONE;
3259 camera_cli_s *pc = (camera_cli_s *)camera;
3260 camera_cb_info_s *cb_info = NULL;
3261 camera_state_e current_state = CAMERA_STATE_NONE;
3262 camera_msg_param param;
3263 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3264 muse_camera_display_info_s *dp_info = NULL;
3266 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3268 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3269 CAM_LOG_ERROR("invalid type %d", type);
3270 return CAMERA_ERROR_INVALID_PARAMETER;
3273 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3274 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3275 return CAMERA_ERROR_INVALID_PARAMETER;
3278 cb_info = (camera_cb_info_s *)pc->cb_info;
3279 dp_info = &cb_info->dp_info;
3281 ret = camera_get_state(camera, ¤t_state);
3282 if (ret != CAMERA_ERROR_NONE) {
3283 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3287 if (current_state != CAMERA_STATE_CREATED) {
3288 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3289 return CAMERA_ERROR_INVALID_STATE;
3292 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3294 if (type != MM_DISPLAY_TYPE_NONE) {
3295 /* check display interface handle */
3296 if (!cb_info->dp_interface) {
3297 CAM_LOG_ERROR("display interface not supported");
3298 return CAMERA_ERROR_NOT_SUPPORTED;
3301 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3302 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3303 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3304 return CAMERA_ERROR_NOT_SUPPORTED;
3305 } else if (mm_ret != MM_ERROR_NONE) {
3306 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3307 return CAMERA_ERROR_INVALID_OPERATION;
3310 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3311 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3313 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3314 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3315 dp_info->window_rect.width, dp_info->window_rect.height);
3316 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3318 camera_flip_e flip = CAMERA_FLIP_NONE;
3319 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3320 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3327 camera_get_display_flip(camera, &flip);
3328 camera_get_display_mode(camera, &mode);
3329 camera_get_display_rotation(camera, &rotation);
3330 camera_is_display_visible(camera, &visible);
3332 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3333 flip, mode, rotation, visible);
3335 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3336 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3337 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3338 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3340 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3341 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3342 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3343 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3349 if (mm_ret != MM_ERROR_NONE) {
3350 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3351 return CAMERA_ERROR_INVALID_OPERATION;
3354 dp_info->type = type;
3356 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3358 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3360 if (ret == CAMERA_ERROR_NONE)
3361 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3367 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3369 CAM_LOG_INFO("type %d, display %p", type, display);
3370 return _camera_set_display(camera, (mm_display_type_e)type, display);
3374 int camera_set_preview_resolution(camera_h camera, int width, int height)
3376 int ret = CAMERA_ERROR_NONE;
3377 camera_state_e current_state = CAMERA_STATE_NONE;
3378 camera_cli_s *pc = (camera_cli_s *)camera;
3379 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3380 camera_msg_param param;
3383 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3385 if (pc->cb_info->is_evas_render) {
3386 ret = camera_get_state(camera, ¤t_state);
3387 if (ret != CAMERA_ERROR_NONE) {
3388 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3392 if (current_state == CAMERA_STATE_PREVIEW) {
3393 ret = _camera_stop_evas_rendering(camera, true);
3394 if (ret != CAMERA_ERROR_NONE)
3399 value = (width << 16) | height;
3400 CAMERA_MSG_PARAM_SET(param, INT, value);
3402 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3404 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3406 CAM_LOG_INFO("ret : 0x%x", ret);
3408 if (current_state == CAMERA_STATE_PREVIEW) {
3409 CAM_LOG_WARNING("restart evas rendering");
3410 _camera_start_evas_rendering(camera);
3417 int camera_set_capture_resolution(camera_h camera, int width, int height)
3419 int ret = CAMERA_ERROR_NONE;
3420 camera_cli_s *pc = (camera_cli_s *)camera;
3421 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3422 camera_msg_param param;
3425 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3427 CAM_LOG_INFO("Enter");
3429 value = (width << 16) | height;
3430 CAMERA_MSG_PARAM_SET(param, INT, value);
3432 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3434 CAM_LOG_INFO("ret : 0x%x", ret);
3440 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3442 int ret = CAMERA_ERROR_NONE;
3443 int set_format = (int)format;
3444 camera_cli_s *pc = (camera_cli_s *)camera;
3445 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3446 camera_msg_param param;
3448 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3450 CAM_LOG_INFO("Enter - format %d", set_format);
3452 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3454 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3456 CAM_LOG_INFO("ret : 0x%x", ret);
3462 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3464 int ret = CAMERA_ERROR_NONE;
3465 int set_format = (int)format;
3466 camera_msg_param param;
3467 camera_cli_s *pc = (camera_cli_s *)camera;
3468 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3470 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3472 CAM_LOG_INFO("Enter - format %d", set_format);
3474 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3476 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3478 if (ret == CAMERA_ERROR_NONE)
3479 pc->cb_info->preview_format = set_format;
3481 CAM_LOG_INFO("ret : 0x%x", ret);
3487 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3489 int ret = CAMERA_ERROR_NONE;
3490 camera_cli_s *pc = (camera_cli_s *)camera;
3491 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3493 if (!pc || !pc->cb_info || !width || !height) {
3494 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3495 return CAMERA_ERROR_INVALID_PARAMETER;
3498 CAM_LOG_INFO("Enter");
3500 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3502 if (ret == CAMERA_ERROR_NONE) {
3503 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3504 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3507 CAM_LOG_INFO("ret : 0x%x", ret);
3513 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3515 int ret = CAMERA_ERROR_NONE;
3516 int set_rotation = (int)rotation;
3517 camera_cli_s *pc = (camera_cli_s *)camera;
3518 camera_msg_param param;
3520 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3522 if (pc->cb_info->is_evas_render) {
3523 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3524 if (ret != MM_ERROR_NONE) {
3525 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3526 return CAMERA_ERROR_INVALID_OPERATION;
3530 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3532 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3538 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3540 int ret = CAMERA_ERROR_NONE;
3541 camera_cli_s *pc = (camera_cli_s *)camera;
3543 if (!pc || !pc->cb_info || !rotation) {
3544 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3545 return CAMERA_ERROR_INVALID_PARAMETER;
3548 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3550 if (ret == CAMERA_ERROR_NONE)
3551 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3557 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3559 int ret = CAMERA_ERROR_NONE;
3560 int set_flip = (int)flip;
3561 camera_cli_s *pc = (camera_cli_s *)camera;
3562 camera_msg_param param;
3564 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3566 if (pc->cb_info->is_evas_render) {
3567 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3568 if (ret != MM_ERROR_NONE) {
3569 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3570 return CAMERA_ERROR_INVALID_OPERATION;
3574 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3576 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3582 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3584 int ret = CAMERA_ERROR_NONE;
3585 camera_cli_s *pc = (camera_cli_s *)camera;
3587 if (!pc || !pc->cb_info || !flip) {
3588 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3589 return CAMERA_ERROR_INVALID_PARAMETER;
3592 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3594 if (ret == CAMERA_ERROR_NONE)
3595 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3601 int camera_set_display_visible(camera_h camera, bool visible)
3603 int ret = CAMERA_ERROR_NONE;
3604 int set_visible = (int)visible;
3605 camera_cli_s *pc = (camera_cli_s *)camera;
3606 camera_msg_param param;
3608 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3610 if (pc->cb_info->is_evas_render) {
3611 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3612 if (ret != MM_ERROR_NONE) {
3613 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3614 return CAMERA_ERROR_INVALID_OPERATION;
3618 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3620 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3626 int camera_is_display_visible(camera_h camera, bool *visible)
3628 int ret = CAMERA_ERROR_NONE;
3629 camera_cli_s *pc = (camera_cli_s *)camera;
3631 if (!pc || !pc->cb_info || !visible) {
3632 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3633 return CAMERA_ERROR_INVALID_PARAMETER;
3636 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3638 if (ret == CAMERA_ERROR_NONE)
3639 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3645 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3647 int ret = CAMERA_ERROR_NONE;
3648 int set_mode = (int)mode;
3649 camera_cli_s *pc = (camera_cli_s *)camera;
3650 camera_msg_param param;
3652 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3654 if (pc->cb_info->is_evas_render) {
3655 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3656 if (ret != MM_ERROR_NONE) {
3657 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3658 return CAMERA_ERROR_INVALID_OPERATION;
3662 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3664 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3670 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3672 int ret = CAMERA_ERROR_NONE;
3673 camera_cli_s *pc = (camera_cli_s *)camera;
3675 if (!pc || !pc->cb_info || !mode) {
3676 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3677 return CAMERA_ERROR_INVALID_PARAMETER;
3680 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3682 if (ret == CAMERA_ERROR_NONE)
3683 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3689 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3691 int ret = CAMERA_ERROR_NONE;
3692 int set_hint = (int)hint;
3693 camera_cli_s *pc = (camera_cli_s *)camera;
3694 camera_msg_param param;
3696 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3698 CAM_LOG_INFO("Enter - hint %d", set_hint);
3700 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3702 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3708 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3710 int ret = CAMERA_ERROR_NONE;
3711 camera_cli_s *pc = (camera_cli_s *)camera;
3712 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3714 if (!pc || !pc->cb_info || !hint) {
3715 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3716 return CAMERA_ERROR_INVALID_PARAMETER;
3719 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3721 if (ret == CAMERA_ERROR_NONE) {
3722 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3723 CAM_LOG_INFO("display reuse hint %d", *hint);
3730 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3732 int ret = CAMERA_ERROR_NONE;
3733 camera_cli_s *pc = (camera_cli_s *)camera;
3734 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3736 if (!pc || !pc->cb_info || !width || !height) {
3737 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3738 return CAMERA_ERROR_INVALID_PARAMETER;
3741 CAM_LOG_INFO("Enter");
3743 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3745 if (ret == CAMERA_ERROR_NONE) {
3746 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3747 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3750 CAM_LOG_INFO("ret : 0x%x", ret);
3756 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3758 int ret = CAMERA_ERROR_NONE;
3759 camera_cli_s *pc = (camera_cli_s *)camera;
3760 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3762 if (!pc || !pc->cb_info || !format) {
3763 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3764 return CAMERA_ERROR_INVALID_PARAMETER;
3767 CAM_LOG_INFO("Enter");
3769 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3771 if (ret == CAMERA_ERROR_NONE)
3772 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3774 CAM_LOG_INFO("ret : 0x%x", ret);
3780 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3782 int ret = CAMERA_ERROR_NONE;
3783 camera_cli_s *pc = (camera_cli_s *)camera;
3784 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3786 if (!pc || !pc->cb_info || !format) {
3787 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3788 return CAMERA_ERROR_INVALID_PARAMETER;
3791 CAM_LOG_INFO("Enter");
3793 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3795 if (ret == CAMERA_ERROR_NONE)
3796 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3798 CAM_LOG_INFO("ret : 0x%x", ret);
3804 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3806 int ret = CAMERA_ERROR_NONE;
3807 camera_cli_s *pc = (camera_cli_s *)camera;
3808 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3810 if (!pc || !pc->cb_info || !facing_direction) {
3811 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3812 return CAMERA_ERROR_INVALID_PARAMETER;
3815 CAM_LOG_INFO("Enter");
3817 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3819 if (ret == CAMERA_ERROR_NONE)
3820 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3822 CAM_LOG_INFO("ret : 0x%x", ret);
3828 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3830 int ret = CAMERA_ERROR_NONE;
3831 camera_cli_s *pc = (camera_cli_s *)camera;
3832 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3834 if (!pc || !pc->cb_info || !callback) {
3835 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3836 return CAMERA_ERROR_INVALID_PARAMETER;
3839 CAM_LOG_INFO("Enter");
3841 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3843 if (ret == CAMERA_ERROR_NONE) {
3844 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3846 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3847 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3849 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3852 CAM_LOG_INFO("ret : 0x%x", ret);
3858 int camera_unset_preview_cb(camera_h camera)
3860 int ret = CAMERA_ERROR_NONE;
3861 camera_cli_s *pc = (camera_cli_s *)camera;
3862 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3864 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3866 CAM_LOG_INFO("Enter");
3868 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3870 if (ret == CAMERA_ERROR_NONE) {
3871 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3873 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3874 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3876 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3879 CAM_LOG_INFO("ret : 0x%x", ret);
3885 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3887 int ret = CAMERA_ERROR_NONE;
3888 camera_cli_s *pc = (camera_cli_s *)camera;
3889 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3891 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3893 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3894 CAM_LOG_ERROR("NOT SUPPORTED");
3895 return CAMERA_ERROR_NOT_SUPPORTED;
3898 if (callback == NULL) {
3899 CAM_LOG_ERROR("NULL callback");
3900 return CAMERA_ERROR_INVALID_PARAMETER;
3903 CAM_LOG_INFO("Enter");
3905 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3907 if (ret == CAMERA_ERROR_NONE) {
3908 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3913 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3916 CAM_LOG_INFO("ret : 0x%x", ret);
3922 int camera_unset_media_packet_preview_cb(camera_h camera)
3924 int ret = CAMERA_ERROR_NONE;
3925 camera_cli_s *pc = (camera_cli_s *)camera;
3926 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3928 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3930 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3931 CAM_LOG_ERROR("NOT SUPPORTED");
3932 return CAMERA_ERROR_NOT_SUPPORTED;
3935 CAM_LOG_INFO("Enter");
3937 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3939 if (ret == CAMERA_ERROR_NONE) {
3940 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3942 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3943 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3945 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3948 CAM_LOG_INFO("ret : 0x%x", ret);
3954 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3956 int ret = CAMERA_ERROR_NONE;
3957 camera_cli_s *pc = (camera_cli_s *)camera;
3958 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3960 if (!pc || !pc->cb_info || !callback) {
3961 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3962 return CAMERA_ERROR_INVALID_PARAMETER;
3965 CAM_LOG_INFO("Enter");
3967 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3969 if (ret == CAMERA_ERROR_NONE) {
3970 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3972 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3973 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3975 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3978 CAM_LOG_INFO("ret : 0x%x", ret);
3984 int camera_unset_state_changed_cb(camera_h camera)
3986 int ret = CAMERA_ERROR_NONE;
3987 camera_cli_s *pc = (camera_cli_s *)camera;
3988 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3990 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3992 CAM_LOG_INFO("Enter");
3994 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3996 if (ret == CAMERA_ERROR_NONE) {
3997 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3999 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4000 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4002 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4005 CAM_LOG_INFO("ret : 0x%x", ret);
4011 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4013 int ret = CAMERA_ERROR_NONE;
4014 camera_cli_s *pc = (camera_cli_s *)camera;
4015 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4017 if (!pc || !pc->cb_info || !callback) {
4018 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4019 return CAMERA_ERROR_INVALID_PARAMETER;
4022 CAM_LOG_INFO("Enter");
4024 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4026 if (ret == CAMERA_ERROR_NONE) {
4027 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4029 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4030 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4032 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4035 CAM_LOG_INFO("ret : 0x%x", ret);
4041 int camera_unset_interrupted_cb(camera_h camera)
4043 int ret = CAMERA_ERROR_NONE;
4044 camera_cli_s *pc = (camera_cli_s *)camera;
4045 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4047 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4049 CAM_LOG_INFO("Enter");
4051 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4053 if (ret == CAMERA_ERROR_NONE) {
4054 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4056 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4057 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4059 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4062 CAM_LOG_INFO("ret : 0x%x", ret);
4068 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4070 int ret = CAMERA_ERROR_NONE;
4071 camera_cli_s *pc = (camera_cli_s *)camera;
4072 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4074 if (!pc || !pc->cb_info || !callback) {
4075 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4076 return CAMERA_ERROR_INVALID_PARAMETER;
4079 CAM_LOG_INFO("Enter");
4081 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4083 if (ret == CAMERA_ERROR_NONE) {
4084 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4086 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4087 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4089 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4092 CAM_LOG_INFO("ret : 0x%x", ret);
4098 int camera_unset_interrupt_started_cb(camera_h camera)
4100 int ret = CAMERA_ERROR_NONE;
4101 camera_cli_s *pc = (camera_cli_s *)camera;
4102 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4104 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4106 CAM_LOG_INFO("Enter");
4108 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4110 if (ret == CAMERA_ERROR_NONE) {
4111 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4113 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4114 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4116 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4119 CAM_LOG_INFO("ret : 0x%x", ret);
4125 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4127 int ret = CAMERA_ERROR_NONE;
4128 camera_cli_s *pc = (camera_cli_s *)camera;
4129 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4131 if (!pc || !pc->cb_info || !callback) {
4132 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4133 return CAMERA_ERROR_INVALID_PARAMETER;
4136 CAM_LOG_INFO("Enter");
4138 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4140 if (ret == CAMERA_ERROR_NONE) {
4141 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4143 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4144 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4146 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4149 CAM_LOG_INFO("ret : 0x%x", ret);
4155 int camera_unset_focus_changed_cb(camera_h camera)
4157 int ret = CAMERA_ERROR_NONE;
4158 camera_cli_s *pc = (camera_cli_s *)camera;
4159 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4161 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4163 CAM_LOG_INFO("Enter");
4165 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4167 if (ret == CAMERA_ERROR_NONE) {
4168 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4170 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4171 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4173 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4176 CAM_LOG_INFO("ret : 0x%x", ret);
4182 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4184 int ret = CAMERA_ERROR_NONE;
4185 camera_cli_s *pc = (camera_cli_s *)camera;
4186 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4188 if (!pc || !pc->cb_info || !callback) {
4189 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4190 return CAMERA_ERROR_INVALID_PARAMETER;
4193 CAM_LOG_INFO("Enter");
4195 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4197 if (ret == CAMERA_ERROR_NONE) {
4198 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4200 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4201 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4203 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4206 CAM_LOG_INFO("ret : 0x%x", ret);
4212 int camera_unset_error_cb(camera_h camera)
4214 int ret = CAMERA_ERROR_NONE;
4215 camera_cli_s *pc = (camera_cli_s *)camera;
4216 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4218 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4220 CAM_LOG_INFO("Enter");
4222 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4224 if (ret == CAMERA_ERROR_NONE) {
4225 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4227 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4228 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4230 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4233 CAM_LOG_INFO("ret : 0x%x", ret);
4239 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4241 int ret = CAMERA_ERROR_NONE;
4242 camera_cli_s *pc = (camera_cli_s *)camera;
4243 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4245 if (!pc || !pc->cb_info || !foreach_cb) {
4246 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4247 return CAMERA_ERROR_INVALID_PARAMETER;
4250 CAM_LOG_INFO("Enter");
4252 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4253 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4255 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4257 CAM_LOG_INFO("ret : 0x%x", ret);
4263 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4265 int ret = CAMERA_ERROR_NONE;
4266 camera_cli_s *pc = (camera_cli_s *)camera;
4267 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4269 if (!pc || !pc->cb_info || !foreach_cb) {
4270 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4271 return CAMERA_ERROR_INVALID_PARAMETER;
4274 CAM_LOG_INFO("Enter");
4276 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4277 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4279 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4281 CAM_LOG_INFO("ret : 0x%x", ret);
4287 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4289 int ret = CAMERA_ERROR_NONE;
4290 camera_cli_s *pc = (camera_cli_s *)camera;
4291 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4293 if (!pc || !pc->cb_info || !foreach_cb) {
4294 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4295 return CAMERA_ERROR_INVALID_PARAMETER;
4298 CAM_LOG_INFO("Enter");
4300 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4301 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4303 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4305 CAM_LOG_INFO("ret : 0x%x", ret);
4311 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4313 int ret = CAMERA_ERROR_NONE;
4314 camera_cli_s *pc = (camera_cli_s *)camera;
4315 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4317 if (!pc || !pc->cb_info || !foreach_cb) {
4318 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4319 return CAMERA_ERROR_INVALID_PARAMETER;
4322 CAM_LOG_INFO("Enter");
4324 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4325 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4327 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4329 CAM_LOG_INFO("ret : 0x%x", ret);
4335 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4337 int ret = CAMERA_ERROR_NONE;
4338 camera_cli_s *pc = (camera_cli_s *)camera;
4339 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4341 if (!pc || !pc->cb_info || !width || !height) {
4342 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4343 return CAMERA_ERROR_INVALID_PARAMETER;
4346 CAM_LOG_INFO("Enter");
4347 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4349 if (ret == CAMERA_ERROR_NONE) {
4350 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4351 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4354 CAM_LOG_INFO("ret : 0x%x", ret);
4360 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4362 int ret = CAMERA_ERROR_NONE;
4363 camera_cli_s *pc = (camera_cli_s *)camera;
4364 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4366 if (!pc || !pc->cb_info || !angle) {
4367 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4368 return CAMERA_ERROR_INVALID_PARAMETER;
4371 CAM_LOG_INFO("Enter");
4373 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4375 if (ret == CAMERA_ERROR_NONE)
4376 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4378 CAM_LOG_INFO("ret : 0x%x", ret);
4384 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4386 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4390 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4392 int ret = CAMERA_ERROR_NONE;
4393 camera_cli_s *pc = (camera_cli_s *)camera;
4394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4396 if (!pc || !pc->cb_info || !mode) {
4397 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4398 return CAMERA_ERROR_INVALID_PARAMETER;
4401 CAM_LOG_INFO("Enter");
4403 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4405 if (ret == CAMERA_ERROR_NONE)
4406 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4408 CAM_LOG_INFO("ret : 0x%x", ret);
4414 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4416 int ret = CAMERA_ERROR_NONE;
4417 camera_cli_s *pc = (camera_cli_s *)camera;
4418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4420 if (!pc || !pc->cb_info || !foreach_cb) {
4421 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4422 return CAMERA_ERROR_INVALID_PARAMETER;
4425 CAM_LOG_INFO("Enter");
4427 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4428 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4430 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4432 CAM_LOG_INFO("Finish, return :%x", ret);
4438 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4440 int ret = CAMERA_ERROR_NONE;
4441 camera_cli_s *pc = (camera_cli_s *)camera;
4442 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4443 camera_msg_param param;
4444 int set_fps = (int)fps;
4446 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4448 CAM_LOG_INFO("Enter");
4450 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4452 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4454 CAM_LOG_INFO("ret : 0x%x", ret);
4460 int camera_attr_set_image_quality(camera_h camera, int quality)
4462 int ret = CAMERA_ERROR_NONE;
4463 camera_cli_s *pc = (camera_cli_s *)camera;
4464 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4465 camera_msg_param param;
4467 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4469 CAM_LOG_INFO("Enter");
4471 CAMERA_MSG_PARAM_SET(param, INT, quality);
4473 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4475 CAM_LOG_INFO("ret : 0x%x", ret);
4481 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4483 int ret = CAMERA_ERROR_NONE;
4484 camera_cli_s *pc = (camera_cli_s *)camera;
4485 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4487 if (!pc || !pc->cb_info || !fps) {
4488 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4489 return CAMERA_ERROR_INVALID_PARAMETER;
4492 CAM_LOG_INFO("Enter");
4494 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4496 if (ret == CAMERA_ERROR_NONE)
4497 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4499 CAM_LOG_INFO("ret : 0x%x", ret);
4505 int camera_attr_get_image_quality(camera_h camera, int *quality)
4507 int ret = CAMERA_ERROR_NONE;
4508 camera_cli_s *pc = (camera_cli_s *)camera;
4509 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4511 if (!pc || !pc->cb_info || !quality) {
4512 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4513 return CAMERA_ERROR_INVALID_PARAMETER;
4516 CAM_LOG_INFO("Enter");
4518 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4520 if (ret == CAMERA_ERROR_NONE)
4521 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4523 CAM_LOG_INFO("ret : 0x%x", ret);
4529 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4531 int ret = CAMERA_ERROR_NONE;
4532 camera_cli_s *pc = (camera_cli_s *)camera;
4533 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4535 if (!pc || !pc->cb_info || !bitrate) {
4536 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4537 return CAMERA_ERROR_INVALID_PARAMETER;
4540 CAM_LOG_INFO("Enter");
4542 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4544 if (ret == CAMERA_ERROR_NONE)
4545 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4547 CAM_LOG_INFO("ret : 0x%x", ret);
4553 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4555 int ret = CAMERA_ERROR_NONE;
4556 camera_cli_s *pc = (camera_cli_s *)camera;
4557 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4558 camera_msg_param param;
4559 int set_bitrate = bitrate;
4561 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4563 CAM_LOG_INFO("Enter");
4565 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4567 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4569 CAM_LOG_INFO("ret : 0x%x", ret);
4575 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4577 int ret = CAMERA_ERROR_NONE;
4578 camera_cli_s *pc = (camera_cli_s *)camera;
4579 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4581 if (!pc || !pc->cb_info || !interval) {
4582 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4583 return CAMERA_ERROR_INVALID_PARAMETER;
4586 CAM_LOG_INFO("Enter");
4588 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4590 if (ret == CAMERA_ERROR_NONE)
4591 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4593 CAM_LOG_INFO("ret : 0x%x", ret);
4599 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4601 int ret = CAMERA_ERROR_NONE;
4602 camera_cli_s *pc = (camera_cli_s *)camera;
4603 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4604 camera_msg_param param;
4605 int set_gop_interval = interval;
4607 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4609 CAM_LOG_INFO("Enter");
4611 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4613 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4615 CAM_LOG_INFO("ret : 0x%x", ret);
4621 int camera_attr_set_zoom(camera_h camera, int zoom)
4623 int ret = CAMERA_ERROR_NONE;
4624 camera_cli_s *pc = (camera_cli_s *)camera;
4625 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4626 camera_msg_param param;
4628 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4630 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4632 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4634 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4636 CAM_LOG_INFO("ret : 0x%x", ret);
4642 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4644 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4648 int camera_attr_set_af_area(camera_h camera, int x, int y)
4650 int ret = CAMERA_ERROR_NONE;
4651 camera_cli_s *pc = (camera_cli_s *)camera;
4652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4653 camera_msg_param param;
4656 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4658 CAM_LOG_INFO("Enter - %d,%d", x, y);
4660 value = (x << 16) | y;
4661 CAMERA_MSG_PARAM_SET(param, INT, value);
4663 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4665 CAM_LOG_INFO("ret : 0x%x", ret);
4671 int camera_attr_clear_af_area(camera_h camera)
4673 int ret = CAMERA_ERROR_NONE;
4674 camera_cli_s *pc = (camera_cli_s *)camera;
4675 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4677 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4679 CAM_LOG_INFO("Enter");
4681 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4683 CAM_LOG_INFO("ret : 0x%x", ret);
4689 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4691 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4695 int camera_attr_set_exposure(camera_h camera, int value)
4697 int ret = CAMERA_ERROR_NONE;
4698 camera_cli_s *pc = (camera_cli_s *)camera;
4699 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4700 camera_msg_param param;
4702 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4704 CAM_LOG_INFO("Enter");
4706 CAMERA_MSG_PARAM_SET(param, INT, value);
4708 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4710 CAM_LOG_INFO("ret : 0x%x", ret);
4716 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4718 int ret = CAMERA_ERROR_NONE;
4719 camera_cli_s *pc = (camera_cli_s *)camera;
4720 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4721 camera_msg_param param;
4722 int set_iso = (int)iso;
4724 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4726 CAM_LOG_INFO("Enter");
4728 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4730 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4732 CAM_LOG_INFO("ret : 0x%x", ret);
4738 int camera_attr_set_brightness(camera_h camera, int level)
4740 int ret = CAMERA_ERROR_NONE;
4741 camera_cli_s *pc = (camera_cli_s *)camera;
4742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4743 camera_msg_param param;
4745 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4747 CAM_LOG_INFO("Enter");
4749 CAMERA_MSG_PARAM_SET(param, INT, level);
4751 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4753 CAM_LOG_INFO("ret : 0x%x", ret);
4759 int camera_attr_set_contrast(camera_h camera, int level)
4761 int ret = CAMERA_ERROR_NONE;
4762 camera_cli_s *pc = (camera_cli_s *)camera;
4763 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4764 camera_msg_param param;
4766 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4768 CAM_LOG_INFO("Enter");
4770 CAMERA_MSG_PARAM_SET(param, INT, level);
4772 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4774 CAM_LOG_INFO("ret : 0x%x", ret);
4780 int camera_attr_set_hue(camera_h camera, int level)
4782 int ret = CAMERA_ERROR_NONE;
4783 camera_cli_s *pc = (camera_cli_s *)camera;
4784 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4785 camera_msg_param param;
4787 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4789 CAM_LOG_INFO("Enter");
4791 CAMERA_MSG_PARAM_SET(param, INT, level);
4793 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4795 CAM_LOG_INFO("ret : 0x%x", ret);
4801 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4803 int ret = CAMERA_ERROR_NONE;
4804 camera_cli_s *pc = (camera_cli_s *)camera;
4805 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4806 camera_msg_param param;
4807 int set_whitebalance = (int)wb;
4809 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4811 CAM_LOG_INFO("Enter");
4813 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4815 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4817 CAM_LOG_INFO("ret : 0x%x", ret);
4823 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4825 int ret = CAMERA_ERROR_NONE;
4826 camera_cli_s *pc = (camera_cli_s *)camera;
4827 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4828 camera_msg_param param;
4829 int set_effect = (int)effect;
4831 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4833 CAM_LOG_INFO("Enter");
4835 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4837 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4839 CAM_LOG_INFO("ret : 0x%x", ret);
4845 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4847 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4851 int camera_attr_enable_tag(camera_h camera, bool enable)
4853 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4857 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4859 int ret = CAMERA_ERROR_NONE;
4860 camera_cli_s *pc = (camera_cli_s *)camera;
4861 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4862 camera_msg_param param;
4864 if (!pc || !pc->cb_info || !description) {
4865 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4866 return CAMERA_ERROR_INVALID_PARAMETER;
4869 CAM_LOG_INFO("Enter");
4871 CAMERA_MSG_PARAM_SET(param, STRING, description);
4873 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4875 CAM_LOG_INFO("ret : 0x%x", ret);
4881 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4883 int ret = CAMERA_ERROR_NONE;
4884 camera_cli_s *pc = (camera_cli_s *)camera;
4885 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4886 camera_msg_param param;
4887 int set_orientation = (int)orientation;
4889 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4891 CAM_LOG_INFO("Enter");
4893 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4895 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4897 CAM_LOG_INFO("ret : 0x%x", ret);
4903 int camera_attr_set_tag_software(camera_h camera, const char *software)
4905 int ret = CAMERA_ERROR_NONE;
4906 camera_cli_s *pc = (camera_cli_s *)camera;
4907 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4908 camera_msg_param param;
4910 if (!pc || !pc->cb_info || !software) {
4911 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4912 return CAMERA_ERROR_INVALID_PARAMETER;
4915 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4917 CAMERA_MSG_PARAM_SET(param, STRING, software);
4919 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4921 CAM_LOG_INFO("ret : 0x%x", ret);
4927 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4929 int ret = CAMERA_ERROR_NONE;
4930 camera_cli_s *pc = (camera_cli_s *)camera;
4931 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4932 double set_geotag[3] = {latitude, longitude, altitude};
4936 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4938 CAM_LOG_INFO("Enter");
4940 length = sizeof(set_geotag) / sizeof(int) + \
4941 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4943 msg = muse_core_msg_new(api,
4944 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4947 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
4953 int camera_attr_remove_geotag(camera_h camera)
4955 int ret = CAMERA_ERROR_NONE;
4956 camera_cli_s *pc = (camera_cli_s *)camera;
4957 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4959 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4961 CAM_LOG_INFO("Enter");
4963 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4965 CAM_LOG_INFO("ret : 0x%x", ret);
4971 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4973 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
4977 int camera_attr_get_zoom(camera_h camera, int *zoom)
4979 int ret = CAMERA_ERROR_NONE;
4980 camera_cli_s *pc = (camera_cli_s *)camera;
4981 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4983 if (!pc || !pc->cb_info || !zoom) {
4984 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4985 return CAMERA_ERROR_INVALID_PARAMETER;
4988 CAM_LOG_INFO("Enter");
4990 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4992 if (ret == CAMERA_ERROR_NONE)
4993 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4995 CAM_LOG_INFO("ret : 0x%x", ret);
5001 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5003 int ret = CAMERA_ERROR_NONE;
5004 camera_cli_s *pc = (camera_cli_s *)camera;
5005 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5007 if (!pc || !pc->cb_info || !min || !max) {
5008 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5009 return CAMERA_ERROR_INVALID_PARAMETER;
5012 CAM_LOG_INFO("Enter");
5014 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5016 if (ret == CAMERA_ERROR_NONE) {
5017 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5018 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5021 CAM_LOG_INFO("ret : 0x%x", ret);
5027 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5029 int ret = CAMERA_ERROR_NONE;
5030 camera_cli_s *pc = (camera_cli_s *)camera;
5031 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5033 if (!pc || !pc->cb_info || !mode) {
5034 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5035 return CAMERA_ERROR_INVALID_PARAMETER;
5038 CAM_LOG_INFO("Enter");
5040 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5042 if (ret == CAMERA_ERROR_NONE)
5043 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5045 CAM_LOG_INFO("ret : 0x%x", ret);
5051 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5053 int ret = CAMERA_ERROR_NONE;
5054 camera_cli_s *pc = (camera_cli_s *)camera;
5055 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5057 if (!pc || !pc->cb_info || !mode) {
5058 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5059 return CAMERA_ERROR_INVALID_PARAMETER;
5062 CAM_LOG_INFO("Enter");
5064 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5066 if (ret == CAMERA_ERROR_NONE)
5067 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5069 CAM_LOG_INFO("ret : 0x%x", ret);
5075 int camera_attr_get_exposure(camera_h camera, int *value)
5077 int ret = CAMERA_ERROR_NONE;
5078 camera_cli_s *pc = (camera_cli_s *)camera;
5079 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5081 if (!pc || !pc->cb_info || !value) {
5082 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5083 return CAMERA_ERROR_INVALID_PARAMETER;
5086 CAM_LOG_INFO("Enter");
5088 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5090 if (ret == CAMERA_ERROR_NONE)
5091 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5093 CAM_LOG_INFO("ret : 0x%x", ret);
5099 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5101 int ret = CAMERA_ERROR_NONE;
5102 camera_cli_s *pc = (camera_cli_s *)camera;
5103 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5105 if (!pc || !pc->cb_info || !min || !max) {
5106 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5107 return CAMERA_ERROR_INVALID_PARAMETER;
5110 CAM_LOG_INFO("Enter");
5112 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5114 if (ret == CAMERA_ERROR_NONE) {
5115 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5116 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5119 CAM_LOG_INFO("ret : 0x%x", ret);
5125 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5127 int ret = CAMERA_ERROR_NONE;
5128 camera_cli_s *pc = (camera_cli_s *)camera;
5129 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5131 if (!pc || !pc->cb_info || !iso) {
5132 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5133 return CAMERA_ERROR_INVALID_PARAMETER;
5136 CAM_LOG_INFO("Enter");
5138 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5140 if (ret == CAMERA_ERROR_NONE)
5141 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5143 CAM_LOG_INFO("ret : 0x%x", ret);
5149 int camera_attr_get_brightness(camera_h camera, int *level)
5151 int ret = CAMERA_ERROR_NONE;
5152 camera_cli_s *pc = (camera_cli_s *)camera;
5153 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5155 if (!pc || !pc->cb_info || !level) {
5156 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5157 return CAMERA_ERROR_INVALID_PARAMETER;
5160 CAM_LOG_INFO("Enter");
5162 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5164 if (ret == CAMERA_ERROR_NONE)
5165 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5167 CAM_LOG_INFO("ret : 0x%x", ret);
5173 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5175 int ret = CAMERA_ERROR_NONE;
5176 camera_cli_s *pc = (camera_cli_s *)camera;
5177 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5179 if (!pc || !pc->cb_info || !min || !max) {
5180 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5181 return CAMERA_ERROR_INVALID_PARAMETER;
5184 CAM_LOG_INFO("Enter");
5186 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5188 if (ret == CAMERA_ERROR_NONE) {
5189 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5190 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5193 CAM_LOG_INFO("ret : 0x%x", ret);
5199 int camera_attr_get_contrast(camera_h camera, int *level)
5201 int ret = CAMERA_ERROR_NONE;
5202 camera_cli_s *pc = (camera_cli_s *)camera;
5203 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5205 if (!pc || !pc->cb_info || !level) {
5206 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5207 return CAMERA_ERROR_INVALID_PARAMETER;
5210 CAM_LOG_INFO("Enter");
5212 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5214 if (ret == CAMERA_ERROR_NONE)
5215 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5217 CAM_LOG_INFO("ret : 0x%x", ret);
5223 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5225 int ret = CAMERA_ERROR_NONE;
5226 camera_cli_s *pc = (camera_cli_s *)camera;
5227 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5229 if (!pc || !pc->cb_info || !min || !max) {
5230 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5231 return CAMERA_ERROR_INVALID_PARAMETER;
5234 CAM_LOG_INFO("Enter");
5236 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5238 if (ret == CAMERA_ERROR_NONE) {
5239 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5240 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5241 CAM_LOG_INFO("min %d, max %d", *min, *max);
5244 CAM_LOG_INFO("ret : 0x%x", ret);
5250 int camera_attr_get_hue(camera_h camera, int *level)
5252 int ret = CAMERA_ERROR_NONE;
5253 camera_cli_s *pc = (camera_cli_s *)camera;
5254 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5256 if (!pc || !pc->cb_info || !level) {
5257 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5258 return CAMERA_ERROR_INVALID_PARAMETER;
5261 CAM_LOG_INFO("Enter");
5263 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5265 if (ret == CAMERA_ERROR_NONE)
5266 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5268 CAM_LOG_INFO("ret : 0x%x", ret);
5274 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5276 int ret = CAMERA_ERROR_NONE;
5277 camera_cli_s *pc = (camera_cli_s *)camera;
5278 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5280 if (!pc || !pc->cb_info || !min || !max) {
5281 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5282 return CAMERA_ERROR_INVALID_PARAMETER;
5285 CAM_LOG_INFO("Enter");
5287 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5289 if (ret == CAMERA_ERROR_NONE) {
5290 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5291 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5292 CAM_LOG_INFO("min %d, max %d", *min, *max);
5295 CAM_LOG_INFO("ret : 0x%x", ret);
5301 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5303 int ret = CAMERA_ERROR_NONE;
5304 camera_cli_s *pc = (camera_cli_s *)camera;
5305 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5307 if (!pc || !pc->cb_info || !wb) {
5308 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5309 return CAMERA_ERROR_INVALID_PARAMETER;
5312 CAM_LOG_INFO("Enter");
5314 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5316 if (ret == CAMERA_ERROR_NONE)
5317 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5319 CAM_LOG_INFO("ret : 0x%x", ret);
5325 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5327 int ret = CAMERA_ERROR_NONE;
5328 camera_cli_s *pc = (camera_cli_s *)camera;
5329 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5331 if (!pc || !pc->cb_info || !effect) {
5332 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5333 return CAMERA_ERROR_INVALID_PARAMETER;
5336 CAM_LOG_INFO("Enter");
5338 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5340 if (ret == CAMERA_ERROR_NONE)
5341 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5343 CAM_LOG_INFO("ret : 0x%x", ret);
5349 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5351 int ret = CAMERA_ERROR_NONE;
5352 camera_cli_s *pc = (camera_cli_s *)camera;
5353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5355 if (!pc || !pc->cb_info || !mode) {
5356 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5357 return CAMERA_ERROR_INVALID_PARAMETER;
5360 CAM_LOG_INFO("Enter");
5362 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5364 if (ret == CAMERA_ERROR_NONE)
5365 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5367 CAM_LOG_INFO("ret : 0x%x", ret);
5373 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5375 int ret = CAMERA_ERROR_NONE;
5376 camera_cli_s *pc = (camera_cli_s *)camera;
5377 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5379 if (!pc || !pc->cb_info || !enable) {
5380 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5381 return CAMERA_ERROR_INVALID_PARAMETER;
5384 CAM_LOG_INFO("Enter");
5386 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5388 if (ret == CAMERA_ERROR_NONE)
5389 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5391 CAM_LOG_INFO("ret : 0x%x", ret);
5397 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5399 int ret = CAMERA_ERROR_NONE;
5400 camera_cli_s *pc = (camera_cli_s *)camera;
5401 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5403 if (!pc || !pc->cb_info || !description) {
5404 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5405 return CAMERA_ERROR_INVALID_PARAMETER;
5408 CAM_LOG_INFO("Enter");
5410 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5412 if (ret == CAMERA_ERROR_NONE)
5413 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5415 CAM_LOG_INFO("ret : 0x%x", ret);
5421 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5423 int ret = CAMERA_ERROR_NONE;
5424 camera_cli_s *pc = (camera_cli_s *)camera;
5425 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5427 if (!pc || !pc->cb_info || !orientation) {
5428 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5429 return CAMERA_ERROR_INVALID_PARAMETER;
5432 CAM_LOG_INFO("Enter");
5434 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5436 if (ret == CAMERA_ERROR_NONE)
5437 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5439 CAM_LOG_INFO("ret : 0x%x", ret);
5445 int camera_attr_get_tag_software(camera_h camera, char **software)
5447 int ret = CAMERA_ERROR_NONE;
5448 camera_cli_s *pc = (camera_cli_s *)camera;
5449 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5451 if (!pc || !pc->cb_info || !software) {
5452 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5453 return CAMERA_ERROR_INVALID_PARAMETER;
5456 CAM_LOG_INFO("Enter");
5458 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5460 if (ret == CAMERA_ERROR_NONE)
5461 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5463 CAM_LOG_INFO("ret : 0x%x", ret);
5469 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5471 int ret = CAMERA_ERROR_NONE;
5472 camera_cli_s *pc = (camera_cli_s *)camera;
5473 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5475 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5476 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5477 return CAMERA_ERROR_INVALID_PARAMETER;
5480 CAM_LOG_INFO("Enter");
5482 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5484 if (ret == CAMERA_ERROR_NONE) {
5485 *latitude = pc->cb_info->get_geotag[0];
5486 *longitude = pc->cb_info->get_geotag[1];
5487 *altitude = pc->cb_info->get_geotag[2];
5490 CAM_LOG_INFO("ret : 0x%x", ret);
5496 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5498 int ret = CAMERA_ERROR_NONE;
5499 camera_cli_s *pc = (camera_cli_s *)camera;
5500 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5502 if (!pc || !pc->cb_info || !mode) {
5503 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5504 return CAMERA_ERROR_INVALID_PARAMETER;
5507 CAM_LOG_INFO("Enter");
5509 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5511 if (ret == CAMERA_ERROR_NONE)
5512 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5514 CAM_LOG_INFO("ret : 0x%x", ret);
5520 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5522 int ret = CAMERA_ERROR_NONE;
5523 int get_flash_state = 0;
5526 CAM_LOG_ERROR("NULL pointer");
5527 return CAMERA_ERROR_INVALID_PARAMETER;
5530 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5531 (int)device, "get_flash_state", &get_flash_state);
5533 if (ret == CAMERA_ERROR_NONE) {
5534 *state = (camera_flash_state_e)get_flash_state;
5535 CAM_LOG_INFO("flash state %d", *state);
5537 CAM_LOG_ERROR("failed 0x%x", ret);
5544 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5546 int ret = CAMERA_ERROR_NONE;
5547 camera_cli_s *pc = (camera_cli_s *)camera;
5548 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5550 if (!pc || !pc->cb_info || !foreach_cb) {
5551 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5552 return CAMERA_ERROR_INVALID_PARAMETER;
5555 CAM_LOG_INFO("Enter");
5557 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5558 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5560 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5562 CAM_LOG_INFO("ret : 0x%x", ret);
5568 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5570 int ret = CAMERA_ERROR_NONE;
5571 camera_cli_s *pc = (camera_cli_s *)camera;
5572 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5574 if (!pc || !pc->cb_info || !foreach_cb) {
5575 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5576 return CAMERA_ERROR_INVALID_PARAMETER;
5579 CAM_LOG_INFO("Enter");
5581 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5582 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5584 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5586 CAM_LOG_INFO("ret : 0x%x", ret);
5592 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5594 int ret = CAMERA_ERROR_NONE;
5595 camera_cli_s *pc = (camera_cli_s *)camera;
5596 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5598 if (!pc || !pc->cb_info || !foreach_cb) {
5599 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5600 return CAMERA_ERROR_INVALID_PARAMETER;
5603 CAM_LOG_INFO("Enter");
5605 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5606 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5608 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5610 CAM_LOG_INFO("ret : 0x%x", ret);
5616 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5618 int ret = CAMERA_ERROR_NONE;
5619 camera_cli_s *pc = (camera_cli_s *)camera;
5620 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5622 if (!pc || !pc->cb_info || !foreach_cb) {
5623 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5624 return CAMERA_ERROR_INVALID_PARAMETER;
5627 CAM_LOG_INFO("Enter");
5629 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5630 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5632 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5634 CAM_LOG_INFO("ret : 0x%x", ret);
5640 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_EFFECT;
5646 if (!pc || !pc->cb_info || !foreach_cb) {
5647 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5648 return CAMERA_ERROR_INVALID_PARAMETER;
5651 CAM_LOG_INFO("Enter");
5653 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5654 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5656 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5658 CAM_LOG_INFO("ret : 0x%x", ret);
5664 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_SCENE_MODE;
5670 if (!pc || !pc->cb_info || !foreach_cb) {
5671 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5672 return CAMERA_ERROR_INVALID_PARAMETER;
5675 CAM_LOG_INFO("Enter");
5677 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5678 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5680 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5682 CAM_LOG_INFO("ret : 0x%x", ret);
5688 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_FLASH_MODE;
5694 if (!pc || !pc->cb_info || !foreach_cb) {
5695 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5696 return CAMERA_ERROR_INVALID_PARAMETER;
5699 CAM_LOG_INFO("Enter");
5701 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5702 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5704 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5706 CAM_LOG_INFO("ret : 0x%x", ret);
5712 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_FPS;
5718 if (!pc || !pc->cb_info || !foreach_cb) {
5719 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5720 return CAMERA_ERROR_INVALID_PARAMETER;
5723 CAM_LOG_INFO("Enter");
5725 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5726 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5728 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5730 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5736 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)
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_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5741 camera_msg_param param;
5744 if (!pc || !pc->cb_info || !foreach_cb) {
5745 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5746 return CAMERA_ERROR_INVALID_PARAMETER;
5749 CAM_LOG_INFO("Enter");
5751 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5752 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5754 value = (width << 16) | height;
5755 CAMERA_MSG_PARAM_SET(param, INT, value);
5757 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5759 CAM_LOG_INFO("ret : 0x%x", ret);
5765 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5767 int ret = CAMERA_ERROR_NONE;
5768 camera_cli_s *pc = (camera_cli_s *)camera;
5769 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5771 if (!pc || !pc->cb_info || !foreach_cb) {
5772 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5773 return CAMERA_ERROR_INVALID_PARAMETER;
5776 CAM_LOG_INFO("Enter");
5778 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5779 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5781 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5783 CAM_LOG_INFO("ret : 0x%x", ret);
5789 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5791 int ret = CAMERA_ERROR_NONE;
5792 camera_cli_s *pc = (camera_cli_s *)camera;
5793 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5795 if (!pc || !pc->cb_info || !foreach_cb) {
5796 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5797 return CAMERA_ERROR_INVALID_PARAMETER;
5800 CAM_LOG_INFO("Enter");
5802 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5803 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5805 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5807 CAM_LOG_INFO("ret : 0x%x", ret);
5813 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5815 int ret = CAMERA_ERROR_NONE;
5816 camera_cli_s *pc = (camera_cli_s *)camera;
5817 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5818 camera_msg_param param;
5819 int set_rotation = (int)rotation;
5821 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5823 CAM_LOG_INFO("Enter");
5825 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5827 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5829 CAM_LOG_INFO("ret : 0x%x", ret);
5835 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
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_STREAM_ROTATION;
5841 if (!pc || !pc->cb_info || !rotation) {
5842 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
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 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5853 CAM_LOG_INFO("ret : 0x%x", ret);
5859 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5861 int ret = CAMERA_ERROR_NONE;
5862 camera_cli_s *pc = (camera_cli_s *)camera;
5863 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5864 camera_msg_param param;
5865 int set_flip = (int)flip;
5867 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5869 CAM_LOG_INFO("Enter");
5871 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5873 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5875 CAM_LOG_INFO("ret : 0x%x", ret);
5881 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5883 int ret = CAMERA_ERROR_NONE;
5884 camera_cli_s *pc = (camera_cli_s *)camera;
5885 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5887 if (!pc || !pc->cb_info || !flip) {
5888 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5889 return CAMERA_ERROR_INVALID_PARAMETER;
5892 CAM_LOG_INFO("Enter");
5894 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5896 if (ret == CAMERA_ERROR_NONE)
5897 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5899 CAM_LOG_INFO("ret : 0x%x", ret);
5904 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5906 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
5910 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5912 int ret = CAMERA_ERROR_NONE;
5913 camera_cli_s *pc = (camera_cli_s *)camera;
5914 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5916 if (!pc || !pc->cb_info || !mode) {
5917 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5918 return CAMERA_ERROR_INVALID_PARAMETER;
5921 CAM_LOG_INFO("Enter");
5923 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5925 if (ret == CAMERA_ERROR_NONE)
5926 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5928 CAM_LOG_INFO("ret : 0x%x", ret);
5934 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5936 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
5940 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5942 int ret = CAMERA_ERROR_NONE;
5943 camera_cli_s *pc = (camera_cli_s *)camera;
5944 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5946 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5948 CAM_LOG_INFO("Enter");
5950 if (!camera_attr_is_supported_hdr_capture(camera)) {
5951 CAM_LOG_ERROR("HDR not supported");
5952 return CAMERA_ERROR_NOT_SUPPORTED;
5956 CAM_LOG_ERROR("NULL callback");
5957 return CAMERA_ERROR_INVALID_PARAMETER;
5960 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5962 if (ret == CAMERA_ERROR_NONE) {
5963 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5965 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5966 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5968 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5971 CAM_LOG_INFO("ret : 0x%x", ret);
5977 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5979 int ret = CAMERA_ERROR_NONE;
5980 camera_cli_s *pc = (camera_cli_s *)camera;
5981 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5983 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5985 CAM_LOG_INFO("Enter");
5987 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5989 if (ret == CAMERA_ERROR_NONE) {
5990 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5992 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5993 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5995 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5998 CAM_LOG_INFO("ret : 0x%x", ret);
6004 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6006 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
6010 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6012 int ret = CAMERA_ERROR_NONE;
6013 camera_cli_s *pc = (camera_cli_s *)camera;
6014 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6016 if (!pc || !pc->cb_info || !enabled) {
6017 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6018 return CAMERA_ERROR_INVALID_PARAMETER;
6021 CAM_LOG_INFO("Enter");
6023 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6025 if (ret == CAMERA_ERROR_NONE)
6026 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6028 CAM_LOG_INFO("ret : 0x%x", ret);
6034 bool camera_attr_is_supported_anti_shake(camera_h camera)
6036 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
6040 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6042 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
6046 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6048 int ret = CAMERA_ERROR_NONE;
6049 camera_cli_s *pc = (camera_cli_s *)camera;
6050 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6052 if (!pc || !pc->cb_info || !enabled) {
6053 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6054 return CAMERA_ERROR_INVALID_PARAMETER;
6057 CAM_LOG_INFO("Enter");
6059 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6061 if (ret == CAMERA_ERROR_NONE)
6062 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6064 CAM_LOG_INFO("ret : 0x%x", ret);
6070 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6072 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
6076 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6078 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
6082 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6084 int ret = CAMERA_ERROR_NONE;
6085 camera_cli_s *pc = (camera_cli_s *)camera;
6086 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6088 if (!pc || !pc->cb_info || !enabled) {
6089 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6090 return CAMERA_ERROR_INVALID_PARAMETER;
6093 CAM_LOG_INFO("Enter");
6095 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6097 if (ret == CAMERA_ERROR_NONE)
6098 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6100 CAM_LOG_INFO("ret : 0x%x", ret);
6106 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6108 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
6112 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6114 int ret = CAMERA_ERROR_NONE;
6115 camera_cli_s *pc = (camera_cli_s *)camera;
6116 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6117 camera_msg_param param;
6118 int set_disable = (int)disable;
6120 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6122 CAM_LOG_INFO("Enter");
6124 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6126 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6128 CAM_LOG_INFO("ret : 0x%x", ret);
6134 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6136 int ret = CAMERA_ERROR_NONE;
6137 camera_cli_s *pc = (camera_cli_s *)camera;
6138 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6139 camera_msg_param param0;
6140 camera_msg_param param1;
6142 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6144 CAM_LOG_INFO("Enter");
6146 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6147 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6149 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6150 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6152 CAM_LOG_INFO("ret : 0x%x", ret);
6158 int camera_attr_get_pan(camera_h camera, int *pan_step)
6160 int ret = CAMERA_ERROR_NONE;
6161 camera_cli_s *pc = (camera_cli_s *)camera;
6162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6164 if (!pc || !pc->cb_info || !pan_step) {
6165 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6166 return CAMERA_ERROR_INVALID_PARAMETER;
6169 CAM_LOG_INFO("Enter");
6171 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6173 if (ret == CAMERA_ERROR_NONE)
6174 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6176 CAM_LOG_INFO("ret : 0x%x", ret);
6182 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6184 int ret = CAMERA_ERROR_NONE;
6185 camera_cli_s *pc = (camera_cli_s *)camera;
6186 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6188 if (!pc || !pc->cb_info || !min || !max) {
6189 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6190 return CAMERA_ERROR_INVALID_PARAMETER;
6193 CAM_LOG_INFO("Enter");
6195 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6197 if (ret == CAMERA_ERROR_NONE) {
6198 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6199 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6202 CAM_LOG_INFO("ret : 0x%x", ret);
6208 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6210 int ret = CAMERA_ERROR_NONE;
6211 camera_cli_s *pc = (camera_cli_s *)camera;
6212 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6213 camera_msg_param param0;
6214 camera_msg_param param1;
6216 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6218 CAM_LOG_INFO("Enter");
6220 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6221 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6223 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6224 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6226 CAM_LOG_INFO("ret : 0x%x", ret);
6232 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6234 int ret = CAMERA_ERROR_NONE;
6235 camera_cli_s *pc = (camera_cli_s *)camera;
6236 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6238 if (!pc || !pc->cb_info || !tilt_step) {
6239 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6240 return CAMERA_ERROR_INVALID_PARAMETER;
6243 CAM_LOG_INFO("Enter");
6245 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6247 if (ret == CAMERA_ERROR_NONE)
6248 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6250 CAM_LOG_INFO("ret : 0x%x", ret);
6256 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6258 int ret = CAMERA_ERROR_NONE;
6259 camera_cli_s *pc = (camera_cli_s *)camera;
6260 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6262 if (!pc || !pc->cb_info || !min || !max) {
6263 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6264 return CAMERA_ERROR_INVALID_PARAMETER;
6267 CAM_LOG_INFO("Enter");
6269 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6271 if (ret == CAMERA_ERROR_NONE) {
6272 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6273 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6276 CAM_LOG_INFO("ret : 0x%x", ret);
6282 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6284 int ret = CAMERA_ERROR_NONE;
6285 camera_cli_s *pc = (camera_cli_s *)camera;
6286 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6287 camera_msg_param param;
6288 int set_ptz_type = (int)ptz_type;
6290 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6292 CAM_LOG_INFO("Enter");
6294 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6296 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6298 CAM_LOG_INFO("ret : 0x%x", ret);
6304 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6306 int ret = CAMERA_ERROR_NONE;
6307 camera_cli_s *pc = (camera_cli_s *)camera;
6308 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6310 if (!pc || !pc->cb_info || !foreach_cb) {
6311 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6312 return CAMERA_ERROR_INVALID_PARAMETER;
6315 CAM_LOG_INFO("Enter");
6317 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6318 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6320 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6322 CAM_LOG_INFO("ret : 0x%x", ret);
6328 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6330 int ret = CAMERA_ERROR_NONE;
6331 camera_cli_s *pc = (camera_cli_s *)camera;
6332 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6333 int set_display_roi_area[4] = {x, y, width, height};
6337 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6339 CAM_LOG_INFO("Enter");
6341 if (pc->cb_info->is_evas_render) {
6342 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6343 if (ret != MM_ERROR_NONE) {
6344 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6345 return CAMERA_ERROR_INVALID_OPERATION;
6349 length = sizeof(set_display_roi_area) / sizeof(int) + \
6350 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6352 msg = muse_core_msg_new(api,
6353 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6356 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6362 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6364 camera_cli_s *pc = (camera_cli_s *)camera;
6365 int ret = CAMERA_ERROR_NONE;
6366 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6368 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6369 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6370 return CAMERA_ERROR_INVALID_PARAMETER;
6373 CAM_LOG_INFO("Enter");
6375 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6377 if (ret == CAMERA_ERROR_NONE) {
6378 *x = pc->cb_info->get_display_roi_area[0];
6379 *y = pc->cb_info->get_display_roi_area[1];
6380 *width = pc->cb_info->get_display_roi_area[2];
6381 *height = pc->cb_info->get_display_roi_area[3];
6384 CAM_LOG_INFO("ret : 0x%x", ret);
6390 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6392 int ret = CAMERA_ERROR_NONE;
6393 int get_device_state = 0;
6396 CAM_LOG_ERROR("NULL pointer");
6397 return CAMERA_ERROR_INVALID_PARAMETER;
6400 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6401 (int)device, "get_device_state", &get_device_state);
6403 if (ret == CAMERA_ERROR_NONE) {
6404 *state = (camera_device_state_e)get_device_state;
6405 CAM_LOG_INFO("device state %d", *state);
6407 CAM_LOG_ERROR("failed 0x%x", ret);
6414 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6416 int ret = CAMERA_ERROR_NONE;
6417 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6418 camera_cb_info *info = NULL;
6420 if (!callback || !cb_id) {
6421 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6422 return CAMERA_ERROR_INVALID_PARAMETER;
6425 /* check camera support */
6426 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6427 if (ret != CAMERA_ERROR_NONE) {
6428 CAM_LOG_ERROR("get device state failed");
6432 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6434 info = g_new0(camera_cb_info, 1);
6436 CAM_LOG_ERROR("info failed");
6437 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6441 info->id = ++g_cam_dev_state_changed_cb_id;
6442 info->callback = (void *)callback;
6443 info->user_data = user_data;
6447 /* subscribe dbus signal for camera state change */
6448 if (!g_cam_dev_state_changed_cb_conn) {
6449 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6450 if (!g_cam_dev_state_changed_cb_conn) {
6451 CAM_LOG_ERROR("failed to get gdbus connection");
6452 ret = CAMERA_ERROR_INVALID_OPERATION;
6456 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6457 MM_CAMCORDER_DBUS_OBJECT,
6458 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6459 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6461 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6462 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6463 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6464 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6465 CAM_LOG_ERROR("failed to get gdbus connection");
6466 ret = CAMERA_ERROR_INVALID_OPERATION;
6470 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6473 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6475 CAM_LOG_INFO("callback id %d", info->id);
6478 if (ret != CAMERA_ERROR_NONE) {
6484 if (g_cam_dev_state_changed_cb_conn) {
6485 g_object_unref(g_cam_dev_state_changed_cb_conn);
6486 g_cam_dev_state_changed_cb_conn = NULL;
6490 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6496 int camera_remove_device_state_changed_cb(int cb_id)
6498 int ret = CAMERA_ERROR_NONE;
6499 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6500 GList *tmp_list = NULL;
6501 camera_cb_info *info = NULL;
6503 /* check camera support */
6504 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6505 if (ret != CAMERA_ERROR_NONE) {
6506 CAM_LOG_ERROR("get device state failed");
6510 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6512 if (!g_cam_dev_state_changed_cb_list) {
6513 CAM_LOG_ERROR("there is no callback info");
6514 ret = CAMERA_ERROR_INVALID_OPERATION;
6518 tmp_list = g_cam_dev_state_changed_cb_list;
6521 info = tmp_list->data;
6522 tmp_list = tmp_list->next;
6525 CAM_LOG_WARNING("NULL info");
6529 if (info->id == cb_id) {
6530 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6535 if (!g_cam_dev_state_changed_cb_list) {
6536 /* no remained callback */
6537 if (g_cam_dev_state_changed_cb_conn) {
6538 /* unsubscribe signal */
6539 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6540 g_cam_dev_state_changed_cb_subscribe_id = 0;
6542 /* unref connection */
6543 g_object_unref(g_cam_dev_state_changed_cb_conn);
6544 g_cam_dev_state_changed_cb_conn = NULL;
6548 CAM_LOG_INFO("id %d callback removed", cb_id);
6549 ret = CAMERA_ERROR_NONE;
6555 CAM_LOG_ERROR("id %d callback not found", cb_id);
6556 ret = CAMERA_ERROR_INVALID_PARAMETER;
6559 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6566 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6568 int ret = CAMERA_ERROR_NONE;
6569 camera_cli_s *pc = (camera_cli_s *)camera;
6570 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6572 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6574 g_mutex_lock(&pc->cb_info->bridge_lock);
6576 if (pc->cb_info->bridge) {
6577 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6578 ret = CAMERA_ERROR_INVALID_OPERATION;
6579 goto _SET_MEDIA_BRIDGE_DONE;
6582 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6583 if (ret != CAMERA_ERROR_NONE) {
6584 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6585 goto _SET_MEDIA_BRIDGE_DONE;
6588 pc->cb_info->bridge = bridge;
6590 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6592 _SET_MEDIA_BRIDGE_DONE:
6593 g_mutex_unlock(&pc->cb_info->bridge_lock);
6599 int camera_media_bridge_unset_bridge(camera_h camera)
6601 int ret = CAMERA_ERROR_NONE;
6602 camera_cli_s *pc = (camera_cli_s *)camera;
6603 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6605 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6607 g_mutex_lock(&pc->cb_info->bridge_lock);
6609 if (!pc->cb_info->bridge) {
6610 CAM_LOG_ERROR("no media bridge");
6611 ret = CAMERA_ERROR_INVALID_OPERATION;
6612 goto _UNSET_MEDIA_BRIDGE_DONE;
6615 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6616 if (ret != CAMERA_ERROR_NONE) {
6617 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6618 goto _UNSET_MEDIA_BRIDGE_DONE;
6621 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6623 pc->cb_info->bridge = NULL;
6625 _UNSET_MEDIA_BRIDGE_DONE:
6626 g_mutex_unlock(&pc->cb_info->bridge_lock);
6633 int camera_create_network(camera_device_e device, camera_h *camera)
6635 return _camera_create_private(device, true, camera);
6639 int camera_device_manager_initialize(camera_device_manager_h *manager)
6642 int ret = CAMERA_ERROR_NONE;
6643 void *dl_handle = NULL;
6644 g_autofree camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
6645 cdm_symbol_table sym_table[] = {
6646 {(void **)&new_manager->initialize, "cdm_initialize"},
6647 {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
6648 {(void **)&new_manager->get_device_list, "cdm_get_device_list"},
6649 {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"},
6650 {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"},
6653 CAMERA_CHECK_DEVICE_MANAGER;
6656 CAM_LOG_ERROR("NULL manager");
6657 ret = CAMERA_ERROR_INVALID_PARAMETER;
6658 goto _INITIALIZE_FAILED;
6661 dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
6663 CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
6664 ret = CAMERA_ERROR_INVALID_OPERATION;
6665 goto _INITIALIZE_FAILED;
6669 for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
6670 *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
6671 if (*sym_table[i].func_ptr == NULL) {
6672 CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
6673 ret = CAMERA_ERROR_INVALID_OPERATION;
6674 goto _INITIALIZE_FAILED;
6678 ret = new_manager->initialize();
6679 if (ret != CAMERA_ERROR_NONE) {
6680 CAM_LOG_ERROR("failed[0x%x]", ret);
6681 goto _INITIALIZE_FAILED;
6684 new_manager->dl_handle = dl_handle;
6685 *manager = (camera_device_manager_h)g_steal_pointer(&new_manager);
6687 CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
6688 *manager, dl_handle);
6690 return CAMERA_ERROR_NONE;
6701 int camera_device_manager_deinitialize(camera_device_manager_h manager)
6703 int ret = CAMERA_ERROR_NONE;
6704 camera_device_manager *m = (camera_device_manager *)manager;
6706 CAMERA_CHECK_DEVICE_MANAGER;
6709 CAM_LOG_ERROR("NULL manager");
6710 return CAMERA_ERROR_INVALID_PARAMETER;
6713 CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
6715 ret = m->deinitialize();
6716 if (ret != CAMERA_ERROR_NONE) {
6717 CAM_LOG_ERROR("failed[0x%x]", ret);
6721 CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
6723 dlclose(m->dl_handle);
6725 memset(m, 0x0, sizeof(camera_device_manager));
6728 return CAMERA_ERROR_NONE;
6732 int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
6734 int ret = CAMERA_ERROR_NONE;
6736 camera_device_list_s device_list;
6737 camera_device_s *device = NULL;
6738 camera_device_manager *m = (camera_device_manager *)manager;
6740 CAMERA_CHECK_DEVICE_MANAGER;
6742 if (!m || !callback) {
6743 CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
6744 return CAMERA_ERROR_INVALID_PARAMETER;
6747 CAM_LOG_INFO("enter");
6749 memset(&device_list, 0x0, sizeof(camera_device_list_s));
6751 ret = m->get_device_list(&device_list);
6752 if (ret != CAMERA_ERROR_NONE) {
6753 CAM_LOG_ERROR("failed[0x%x]", ret);
6757 CAM_LOG_INFO("device count[%d]", device_list.count);
6759 for (i = 0 ; i < device_list.count ; i++) {
6760 device = &device_list.device[i];
6762 CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
6763 i, device->type, device->index,
6764 device->name, device->id, device->extra_stream_num);
6766 if (!callback(device, user_data)) {
6767 CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
6768 i + 1, device_list.count);
6773 return CAMERA_ERROR_NONE;
6777 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
6778 camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
6780 int ret = CAMERA_ERROR_NONE;
6781 camera_device_manager *m = (camera_device_manager *)manager;
6783 CAMERA_CHECK_DEVICE_MANAGER;
6785 if (!m || !callback || !cb_id) {
6786 CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
6787 return CAMERA_ERROR_INVALID_PARAMETER;
6790 CAM_LOG_INFO("enter");
6792 ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
6793 if (ret != CAMERA_ERROR_NONE) {
6794 CAM_LOG_ERROR("failed[0x%x]", ret);
6798 CAM_LOG_INFO("cb_id[%d] added", *cb_id);
6800 return CAMERA_ERROR_NONE;
6804 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
6806 int ret = CAMERA_ERROR_NONE;
6807 camera_device_manager *m = (camera_device_manager *)manager;
6809 CAMERA_CHECK_DEVICE_MANAGER;
6812 CAM_LOG_ERROR("NULL manager");
6813 return CAMERA_ERROR_INVALID_PARAMETER;
6816 CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
6818 ret = m->remove_device_connection_changed_cb(cb_id);
6819 if (ret != CAMERA_ERROR_NONE) {
6820 CAM_LOG_ERROR("failed[0x%x]", ret);
6824 CAM_LOG_INFO("cb_id[%d] removed", cb_id);
6826 return CAMERA_ERROR_NONE;
6831 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
6833 int ret = CAMERA_ERROR_NONE;
6834 camera_cli_s *pc = (camera_cli_s *)camera;
6835 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
6837 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6839 if (!camera_is_supported_extra_preview(camera)) {
6840 CAM_LOG_ERROR("extra preview is not supported");
6841 return CAMERA_ERROR_NOT_SUPPORTED;
6845 CAM_LOG_ERROR("NULL callback");
6846 return CAMERA_ERROR_INVALID_PARAMETER;
6849 CAM_LOG_INFO("Enter");
6851 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6853 if (ret == CAMERA_ERROR_NONE) {
6854 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6856 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
6857 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
6859 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6862 CAM_LOG_INFO("ret : 0x%x", ret);
6868 int camera_unset_extra_preview_cb(camera_h camera)
6870 int ret = CAMERA_ERROR_NONE;
6871 camera_cli_s *pc = (camera_cli_s *)camera;
6872 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
6874 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6876 if (!camera_is_supported_extra_preview(camera)) {
6877 CAM_LOG_ERROR("extra preview is not supported");
6878 return CAMERA_ERROR_NOT_SUPPORTED;
6881 CAM_LOG_INFO("Enter");
6883 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6885 if (ret == CAMERA_ERROR_NONE) {
6886 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6888 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6889 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6891 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6894 CAM_LOG_INFO("ret : 0x%x", ret);
6900 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)
6902 int ret = CAMERA_ERROR_NONE;
6903 int stream_format[4] = {pixel_format, width, height, fps};
6905 camera_cli_s *pc = (camera_cli_s *)camera;
6906 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
6908 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6910 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
6911 stream_id, pixel_format, width, height, fps);
6913 msg = muse_core_msg_new(api,
6914 MUSE_TYPE_INT, "stream_id", stream_id,
6915 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
6918 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6924 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)
6926 int ret = CAMERA_ERROR_NONE;
6927 camera_cli_s *pc = (camera_cli_s *)camera;
6928 camera_msg_param param;
6929 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
6931 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
6932 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
6933 return CAMERA_ERROR_INVALID_PARAMETER;
6936 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6938 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6940 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6942 if (ret == CAMERA_ERROR_NONE) {
6943 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
6944 *width = pc->cb_info->get_extra_preview_stream_format[1];
6945 *height = pc->cb_info->get_extra_preview_stream_format[2];
6946 *fps = pc->cb_info->get_extra_preview_stream_format[3];
6949 CAM_LOG_INFO("ret : 0x%x", ret);
6955 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
6957 int ret = CAMERA_ERROR_NONE;
6958 camera_cli_s *pc = (camera_cli_s *)camera;
6959 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
6960 camera_msg_param param0;
6961 camera_msg_param param1;
6963 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6965 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
6967 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6968 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
6970 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6971 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6973 CAM_LOG_INFO("ret : 0x%x", ret);
6979 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
6981 int ret = CAMERA_ERROR_NONE;
6982 camera_cli_s *pc = (camera_cli_s *)camera;
6983 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
6984 camera_msg_param param;
6986 if (!pc || !pc->cb_info || !bitrate) {
6987 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
6988 return CAMERA_ERROR_INVALID_PARAMETER;
6991 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6993 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6995 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6997 if (ret == CAMERA_ERROR_NONE) {
6998 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
6999 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
7001 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
7008 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
7010 int ret = CAMERA_ERROR_NONE;
7011 camera_cli_s *pc = (camera_cli_s *)camera;
7012 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
7013 camera_msg_param param0;
7014 camera_msg_param param1;
7016 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
7018 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
7020 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
7021 CAMERA_MSG_PARAM_SET(param1, INT, interval);
7023 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
7024 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
7026 CAM_LOG_INFO("ret : 0x%x", ret);
7032 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
7034 int ret = CAMERA_ERROR_NONE;
7035 camera_cli_s *pc = (camera_cli_s *)camera;
7036 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
7037 camera_msg_param param;
7039 if (!pc || !pc->cb_info || !interval) {
7040 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
7041 return CAMERA_ERROR_INVALID_PARAMETER;
7044 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7046 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7048 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7050 if (ret == CAMERA_ERROR_NONE) {
7051 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
7052 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
7054 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
7061 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
7063 camera_cli_s *pc = (camera_cli_s *)camera;
7065 if (!pc || !pc->cb_info || !rotation) {
7066 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
7067 return CAMERA_ERROR_INVALID_PARAMETER;
7070 if (!pc->cb_info->stream_data) {
7071 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
7072 return CAMERA_ERROR_INVALID_OPERATION;
7075 *rotation = pc->cb_info->stream_data->rotation;
7077 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
7079 return CAMERA_ERROR_NONE;
7083 int _camera_get_log_level(void)
7085 return g_camera_log_level;