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.
23 #include <muse_camera_msg.h>
24 #include <camera_private.h>
25 #include <muse_client.h>
32 #define LOG_TAG "TIZEN_N_CAMERA"
33 #define MODULE_NAME "camera"
35 /* for device changed callback */
36 static GMutex g_cam_dev_state_changed_cb_lock;
37 static GList *g_cam_dev_state_changed_cb_list;
38 static int g_cam_dev_state_changed_cb_id;
39 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
40 static guint g_cam_dev_state_changed_cb_subscribe_id;
41 static GMutex g_cam_idle_event_lock;
44 static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO;
46 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
47 static void __camera_release_imported_bo(tbm_bo *bo);
49 static int __camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
50 camera_media_packet_data *mp_data, media_packet_h *packet);
51 static int __camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
52 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
53 static void __camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
55 static gboolean __camera_allocate_preview_buffer(camera_h camera);
56 static void __camera_release_preview_buffer(camera_h camera);
59 static gboolean __camera_allocate_preview_buffer(camera_h camera)
62 int ret = CAMERA_ERROR_NONE;
63 int format = CAMERA_PIXEL_FORMAT_INVALID;
67 camera_cli_s *pc = (camera_cli_s *)camera;
68 camera_cb_info_s *cb_info = NULL;
70 if (!pc || !pc->cb_info) {
71 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
75 cb_info = pc->cb_info;
77 CAM_LOG_INFO("Enter");
79 /* get preview info and calculate size */
80 ret = camera_get_preview_format(camera, &format);
81 if (ret != CAMERA_ERROR_NONE) {
82 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
86 ret = camera_get_preview_resolution(camera, &width, &height);
87 if (ret != CAMERA_ERROR_NONE) {
88 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
92 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
95 case CAMERA_PIXEL_FORMAT_INVZ:
96 buffer_size = width * height;
98 case CAMERA_PIXEL_FORMAT_NV12:
99 case CAMERA_PIXEL_FORMAT_I420:
100 buffer_size = (width * height * 3) >> 1;
102 case CAMERA_PIXEL_FORMAT_YUYV:
103 case CAMERA_PIXEL_FORMAT_UYVY:
104 buffer_size = width * height * 2;
107 CAM_LOG_ERROR("unhandled format %d", format);
108 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
111 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
113 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
114 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
115 if (!cb_info->bos[i]) {
116 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
117 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
120 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
121 if (cb_info->fds[i] < 0) {
122 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
123 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
126 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
129 CAM_LOG_INFO("Done");
133 _ALLOCATE_PREVIEW_BUFFER_FAILED:
134 __camera_release_preview_buffer(camera);
139 static void __camera_release_preview_buffer(camera_h camera)
142 camera_cli_s *pc = (camera_cli_s *)camera;
143 camera_cb_info_s *cb_info = NULL;
145 if (!pc || !pc->cb_info) {
146 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
150 CAM_LOG_INFO("Enter");
152 cb_info = pc->cb_info;
154 /* close exported fd and bos */
155 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
156 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
158 if (cb_info->bos[i]) {
159 tbm_bo_unref(cb_info->bos[i]);
160 cb_info->bos[i] = NULL;
165 if (cb_info->fds[i] >= 0) {
166 close(cb_info->fds[i]);
167 cb_info->fds[i] = -1;
171 CAM_LOG_INFO("Done");
175 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
178 api < 0 || api >= MUSE_CAMERA_API_MAX) {
179 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
183 g_mutex_lock(&(cb_info->api_mutex[api]));
184 cb_info->api_waiting[api] += value;
185 g_mutex_unlock(&(cb_info->api_mutex[api]));
187 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
188 api, value, cb_info->api_waiting[api]);
192 static void __camera_device_state_changed_cb(GDBusConnection *connection,
193 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
194 const gchar *signal_name, GVariant *param, gpointer user_data)
197 camera_device_e device = CAMERA_DEVICE_CAMERA0;
198 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
199 GList *tmp_list = NULL;
200 camera_cb_info *info = NULL;
202 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
204 if (!g_cam_dev_state_changed_cb_list || !param) {
205 CAM_LOG_WARNING("no callback or NULL param %p", param);
209 /* get device and state */
210 g_variant_get(param, "(i)", &value);
212 device = value >> 16;
213 state = 0x0000ffff & value;
215 CAM_LOG_INFO("device %d, state %d", device, state);
217 tmp_list = g_cam_dev_state_changed_cb_list;
220 info = (camera_cb_info *)tmp_list->data;
223 if (info->callback) {
224 CAM_LOG_INFO("start id[%d] callback", info->id);
225 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
226 CAM_LOG_INFO("returned id[%d] callback", info->id);
228 CAM_LOG_WARNING("NULL callback for id %d", info->id);
232 tmp_list = tmp_list->next;
236 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
240 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
246 int num_buffer_fd = 0;
247 unsigned char *buf_pos = NULL;
250 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
251 tbm_bo_handle bo_handle = {.ptr = NULL};
252 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
253 tbm_bo data_bo = NULL;
254 tbm_bo_handle data_bo_handle = {.ptr = NULL};
256 camera_msg_param param;
257 camera_preview_data_s frame;
258 camera_stream_data_s *stream = NULL;
259 camera_media_packet_data *mp_data = NULL;
260 media_packet_h pkt = NULL;
262 /* tfd[0]: MMCamcorderVideoStreamDataType
263 tfd[1]: data_bo or zero copy bo[0]
264 tfd[2]: zero copy bo[1]
265 tfd[3]: zero copy bo[2] */
267 if (!cb_info || !recv_msg || !tfd) {
268 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
272 muse_camera_msg_get(preview_fd, recv_msg);
273 muse_camera_msg_get(num_buffer_fd, recv_msg);
275 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
277 memset(&frame, 0x0, sizeof(camera_preview_data_s));
280 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
285 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
287 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
288 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
289 goto _PREVIEW_CB_HANDLER_DONE;
292 if (num_buffer_fd == 0 && tfd[1] >= 0) {
293 /* import tbm data_bo and get virtual address */
294 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
295 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
296 goto _PREVIEW_CB_HANDLER_DONE;
300 /* import tbm bo and get virtual address */
301 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
302 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
303 goto _PREVIEW_CB_HANDLER_DONE;
306 buf_pos = (unsigned char *)bo_handle.ptr;
308 /* get stream info */
309 stream = (camera_stream_data_s *)buf_pos;
311 for (i = 0 ; i < num_buffer_fd ; i++) {
312 /* import buffer bo and get virtual address */
313 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
314 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
315 goto _PREVIEW_CB_HANDLER_DONE;
319 /* preview callback */
320 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
321 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
323 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
324 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
327 /* make media packet with below cases.
328 * 1. media_packet_preview_cb is set
329 * 2. EVAS display rendering
331 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
332 CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
333 ret = __camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
334 if (ret != CAMERA_ERROR_NONE) {
335 CAM_LOG_ERROR("__camera_media_packet_data_create failed[0x%x]", ret);
336 goto _PREVIEW_CB_HANDLER_DONE;
339 ret = __camera_media_packet_create(cb_info, stream, mp_data, &pkt);
340 if (ret != CAMERA_ERROR_NONE) {
341 CAM_LOG_ERROR("__camera_media_packet_create failed[0x%x]", ret);
342 __camera_media_packet_data_release(mp_data, cb_info);
344 goto _PREVIEW_CB_HANDLER_DONE;
348 /* 1. media packet preview callback */
349 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
350 media_packet_ref(pkt);
351 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
352 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
355 /* 2. call evas renderer */
356 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
357 if (cb_info->run_evas_render) {
358 media_packet_ref(pkt);
359 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
360 if (ret != MM_ERROR_NONE) {
361 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
362 media_packet_unref(pkt);
365 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
369 _PREVIEW_CB_HANDLER_DONE:
370 /* send message for preview callback return */
371 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
372 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])
373 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
376 media_packet_unref(pkt);
381 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
383 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
385 /* release imported bo */
386 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
387 __camera_release_imported_bo(&buffer_bo[i]);
389 /* unmap and unref tbm bo */
390 __camera_release_imported_bo(&data_bo);
391 __camera_release_imported_bo(&bo);
393 /* close imported fd */
394 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
405 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
409 int capture_fd_main = 0;
410 int capture_fd_post = 0;
411 int capture_fd_thumb = 0;
412 unsigned char *buf_pos = NULL;
414 camera_image_data_s *rImage = NULL;
415 camera_image_data_s *rPostview = NULL;
416 camera_image_data_s *rThumbnail = NULL;
418 tbm_bo bo_main = NULL;
419 tbm_bo bo_post = NULL;
420 tbm_bo bo_thumb = NULL;
421 tbm_bo_handle bo_main_handle = {.ptr = NULL};
422 tbm_bo_handle bo_post_handle = {.ptr = NULL};
423 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
425 if (!cb_info || !recv_msg || !tfd) {
426 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
430 muse_camera_msg_get(capture_fd_main, recv_msg);
431 muse_camera_msg_get(capture_fd_post, recv_msg);
432 muse_camera_msg_get(capture_fd_thumb, recv_msg);
434 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
435 capture_fd_main, capture_fd_post, capture_fd_thumb,
436 tfd[0], tfd[1], tfd[2]);
438 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
439 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
440 goto _CAPTURE_CB_HANDLER_DONE;
443 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
444 CAM_LOG_WARNING("NULL callback");
445 goto _CAPTURE_CB_HANDLER_DONE;
448 /* import tbm bo and get virtual address */
449 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
450 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
451 goto _CAPTURE_CB_HANDLER_DONE;
454 buf_pos = (unsigned char *)bo_main_handle.ptr;
455 rImage = (camera_image_data_s *)buf_pos;
456 rImage->data = buf_pos + sizeof(camera_image_data_s);
457 if (rImage->exif && rImage->exif_size > 0) {
458 rImage->exif = rImage->data + rImage->size;
461 rImage->exif_size = 0;
464 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
465 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
467 if (capture_fd_post >= 0) {
468 /* import tbm bo and get virtual address */
470 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
471 buf_pos = (unsigned char *)bo_post_handle.ptr;
472 rPostview = (camera_image_data_s *)buf_pos;
473 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
474 rPostview->data = buf_pos + sizeof(camera_image_data_s);
476 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
480 if (capture_fd_thumb >= 0) {
481 /* import tbm bo and get virtual address */
483 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
484 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
485 rThumbnail = (camera_image_data_s *)buf_pos;
486 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
487 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
489 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
493 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
494 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
496 _CAPTURE_CB_HANDLER_DONE:
498 if (capture_fd_main >= 0) {
499 __camera_release_imported_bo(&bo_main);
500 _camera_msg_return_buffer(capture_fd_main, cb_info);
503 if (capture_fd_post >= 0) {
504 __camera_release_imported_bo(&bo_post);
505 _camera_msg_return_buffer(capture_fd_post, cb_info);
508 if (capture_fd_thumb >= 0) {
509 __camera_release_imported_bo(&bo_thumb);
510 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
513 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
515 CAM_LOG_INFO("close %d", tfd[i]);
523 CAM_LOG_INFO("return buffer done");
527 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
531 camera_detected_face_s *faces = NULL;
534 tbm_bo_handle bo_handle = {.ptr = NULL};
536 if (!cb_info || !recv_msg || !tfd) {
537 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
541 muse_camera_msg_get(count, recv_msg);
542 muse_camera_msg_get(face_fd, recv_msg);
544 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
545 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
548 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
550 faces = bo_handle.ptr;
557 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
558 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
561 __camera_release_imported_bo(&bo);
563 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
564 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
568 _camera_msg_return_buffer(face_fd, cb_info);
572 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
574 tbm_bo tmp_bo = NULL;
575 tbm_bo_handle tmp_bo_handle = {NULL, };
577 if (!bufmgr || !bo || !bo_handle || fd < 0) {
578 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
579 bufmgr, bo, bo_handle, fd);
583 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
584 if (tmp_bo == NULL) {
585 CAM_LOG_ERROR("import failed - fd %d", fd);
589 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
590 if (tmp_bo_handle.ptr == NULL) {
591 CAM_LOG_ERROR("map failed %p", tmp_bo);
592 tbm_bo_unref(tmp_bo);
597 tbm_bo_unmap(tmp_bo);
599 /* set bo and bo_handle */
601 *bo_handle = tmp_bo_handle;
603 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
608 static void __camera_release_imported_bo(tbm_bo *bo)
611 CAM_LOG_DEBUG("NULL bo");
619 static int __camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
621 int ret = CAMERA_ERROR_NONE;
624 if (!cb_info->is_server_connected) {
625 CAM_LOG_ERROR("server is disconnected");
626 return CAMERA_ERROR_SERVICE_DISCONNECTED;
629 g_mutex_lock(&(cb_info->api_mutex[api]));
631 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
633 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
635 while (!cb_info->api_activating[api]) {
636 if (time_out == CAMERA_CB_NO_TIMEOUT) {
637 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
638 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
639 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
640 CAM_LOG_ERROR("api %d TIMED OUT!", api);
641 ret = CAMERA_ERROR_INVALID_OPERATION;
645 if (!cb_info->api_activating[api])
646 CAM_LOG_WARNING("invalid signal received, wait again...");
649 ret = cb_info->api_ret[api];
650 cb_info->api_activating[api] = FALSE;
653 g_mutex_unlock(&(cb_info->api_mutex[api]));
655 if (ret != CAMERA_ERROR_NONE)
656 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
662 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
663 int *ret, int timeout)
669 CAM_LOG_ERROR("NULL info - api %d", api);
672 *ret = CAMERA_ERROR_INVALID_PARAMETER;
677 msg = muse_core_msg_new(api, NULL);
679 CAM_LOG_ERROR("msg failed: api %d", api);
682 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
687 CAM_LOG_DEBUG("send msg[%s]", msg);
689 if (cb_info->is_server_connected) {
690 __camera_update_api_waiting(cb_info, api, 1);
692 g_mutex_lock(&cb_info->fd_lock);
693 send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
694 g_mutex_unlock(&cb_info->fd_lock);
698 CAM_LOG_ERROR("msg send failed");
700 *ret = CAMERA_ERROR_INVALID_OPERATION;
703 *ret = __camera_client_wait_for_cb_return(api, cb_info, timeout);
706 __camera_update_api_waiting(cb_info, api, -1);
708 muse_core_msg_free(msg);
712 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
713 int *ret, camera_msg_param *param, int timeout)
719 if (!cb_info || !param) {
720 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
723 *ret = CAMERA_ERROR_INVALID_PARAMETER;
728 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
730 switch (param->type) {
732 msg = muse_core_msg_new(api,
733 param->type, param->name, param->value.value_INT,
736 case MUSE_TYPE_STRING:
737 msg = muse_core_msg_new(api,
738 param->type, param->name, param->value.value_STRING,
741 case MUSE_TYPE_ARRAY:
742 array_length = param->value_size / sizeof(int) + \
743 (param->value_size % sizeof(int) ? 1 : 0);
745 msg = muse_core_msg_new(api,
746 param->type, param->name, array_length, param->value.value_ARRAY,
750 CAM_LOG_ERROR("unknown type %d", param->type);
755 CAM_LOG_ERROR("msg failed: api %d", api);
758 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
763 CAM_LOG_DEBUG("send msg[%s]", msg);
765 if (cb_info->is_server_connected) {
766 __camera_update_api_waiting(cb_info, api, 1);
768 g_mutex_lock(&cb_info->fd_lock);
769 send_ret = muse_core_msg_send(cb_info->fd, msg);
770 g_mutex_unlock(&cb_info->fd_lock);
774 CAM_LOG_ERROR("msg send failed");
777 *ret = CAMERA_ERROR_INVALID_OPERATION;
780 *ret = __camera_client_wait_for_cb_return(api, cb_info, timeout);
783 __camera_update_api_waiting(cb_info, api, -1);
785 muse_core_msg_free(msg);
789 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
790 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
792 int func_ret = CAMERA_ERROR_NONE;
796 if (!cb_info || !param0 || !param1) {
797 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
798 cb_info, param0, param1, api);
799 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
800 goto _SEND_PARAM2_INT_DONE;
803 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
805 param0->name, param0->value.value_INT,
806 param1->name, param1->value.value_INT);
808 msg = muse_core_msg_new(api,
809 param0->type, param0->name, param0->value.value_INT,
810 param1->type, param1->name, param1->value.value_INT,
813 CAM_LOG_ERROR("msg failed: api %d", api);
814 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
815 goto _SEND_PARAM2_INT_DONE;
818 CAM_LOG_DEBUG("send msg[%s]", msg);
820 if (cb_info->is_server_connected) {
821 __camera_update_api_waiting(cb_info, api, 1);
823 g_mutex_lock(&cb_info->fd_lock);
824 send_ret = muse_core_msg_send(cb_info->fd, msg);
825 g_mutex_unlock(&cb_info->fd_lock);
829 CAM_LOG_ERROR("msg send failed");
831 func_ret = CAMERA_ERROR_INVALID_OPERATION;
833 func_ret = __camera_client_wait_for_cb_return(api, cb_info, timeout);
836 __camera_update_api_waiting(cb_info, api, -1);
838 muse_core_msg_free(msg);
840 _SEND_PARAM2_INT_DONE:
846 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
848 camera_msg_param param;
851 CAM_LOG_WARNING("invalid fd %d", ret_fd);
855 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
857 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
861 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
863 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
864 in_format >= MM_PIXEL_FORMAT_NUM ||
865 out_format == NULL) {
866 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
867 return CAMERA_ERROR_INVALID_PARAMETER;
871 case MM_PIXEL_FORMAT_NV12:
872 case MM_PIXEL_FORMAT_NV12T:
873 *out_format = TBM_FORMAT_NV12;
876 case MM_PIXEL_FORMAT_NV16:
877 *out_format = TBM_FORMAT_NV16;
879 case MM_PIXEL_FORMAT_NV21:
880 *out_format = TBM_FORMAT_NV21;
882 case MM_PIXEL_FORMAT_YUYV:
883 *out_format = TBM_FORMAT_YUYV;
885 case MM_PIXEL_FORMAT_UYVY:
886 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
887 *out_format = TBM_FORMAT_UYVY;
889 case MM_PIXEL_FORMAT_422P:
890 *out_format = TBM_FORMAT_YUV422;
892 case MM_PIXEL_FORMAT_I420:
893 *out_format = TBM_FORMAT_YUV420;
895 case MM_PIXEL_FORMAT_YV12:
896 *out_format = TBM_FORMAT_YVU420;
898 case MM_PIXEL_FORMAT_RGB565:
899 *out_format = TBM_FORMAT_RGB565;
901 case MM_PIXEL_FORMAT_RGB888:
902 *out_format = TBM_FORMAT_RGB888;
904 case MM_PIXEL_FORMAT_RGBA:
905 *out_format = TBM_FORMAT_RGBA8888;
907 case MM_PIXEL_FORMAT_ARGB:
908 *out_format = TBM_FORMAT_ARGB8888;
911 CAM_LOG_ERROR("invalid in_format %d", in_format);
912 return CAMERA_ERROR_INVALID_PARAMETER;
916 return CAMERA_ERROR_NONE;
920 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
922 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
923 in_format >= MM_PIXEL_FORMAT_NUM ||
925 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
926 return CAMERA_ERROR_INVALID_PARAMETER;
930 case MM_PIXEL_FORMAT_NV12:
931 case MM_PIXEL_FORMAT_NV12T:
932 *mimetype = MEDIA_FORMAT_NV12;
935 case MM_PIXEL_FORMAT_NV16:
936 *mimetype = MEDIA_FORMAT_NV16;
938 case MM_PIXEL_FORMAT_NV21:
939 *mimetype = MEDIA_FORMAT_NV21;
941 case MM_PIXEL_FORMAT_YUYV:
942 *mimetype = MEDIA_FORMAT_YUYV;
944 case MM_PIXEL_FORMAT_UYVY:
945 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
946 *mimetype = MEDIA_FORMAT_UYVY;
948 case MM_PIXEL_FORMAT_422P:
949 *mimetype = MEDIA_FORMAT_422P;
951 case MM_PIXEL_FORMAT_I420:
952 *mimetype = MEDIA_FORMAT_I420;
954 case MM_PIXEL_FORMAT_YV12:
955 *mimetype = MEDIA_FORMAT_YV12;
957 case MM_PIXEL_FORMAT_RGB565:
958 *mimetype = MEDIA_FORMAT_RGB565;
960 case MM_PIXEL_FORMAT_RGB888:
961 *mimetype = MEDIA_FORMAT_RGB888;
963 case MM_PIXEL_FORMAT_RGBA:
964 *mimetype = MEDIA_FORMAT_RGBA;
966 case MM_PIXEL_FORMAT_ARGB:
967 *mimetype = MEDIA_FORMAT_ARGB;
970 CAM_LOG_ERROR("invalid in_format %d", in_format);
971 return CAMERA_ERROR_INVALID_PARAMETER;
975 return CAMERA_ERROR_NONE;
979 static int __camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
980 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
983 int ret = CAMERA_ERROR_NONE;
984 camera_media_packet_data *new_mp_data = NULL;
986 if (!tfd || !mp_data) {
987 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
988 return CAMERA_ERROR_INVALID_PARAMETER;
991 new_mp_data = g_new0(camera_media_packet_data, 1);
993 new_mp_data->ret_fd = ret_fd;
994 new_mp_data->fd = tfd[0];
995 new_mp_data->num_buffer_fd = num_buffer_fd;
996 new_mp_data->bo = bo;
998 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1002 new_mp_data->data_bo = data_bo;
1003 new_mp_data->data_fd = tfd[1];
1005 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1006 new_mp_data->data_bo, new_mp_data->data_fd);
1009 for (i = 0 ; i < num_buffer_fd ; i++) {
1010 new_mp_data->buffer_bo[i] = buffer_bo[i];
1011 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1013 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1014 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1018 *mp_data = new_mp_data;
1020 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1025 static void __camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1029 if (!mp_data || !cb_info) {
1030 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1034 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1036 /* release imported bo and close imported fd */
1037 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1038 tbm_bo_unref(mp_data->buffer_bo[i]);
1039 mp_data->buffer_bo[i] = NULL;
1041 close(mp_data->buffer_fd[i]);
1042 mp_data->buffer_fd[i] = -1;
1045 /* unref tbm bo and close imported fd */
1049 __camera_release_imported_bo(&mp_data->bo);
1051 if (mp_data->data_bo && mp_data->data_fd >= 0) {
1052 close(mp_data->data_fd);
1053 mp_data->data_fd = -1;
1055 __camera_release_imported_bo(&mp_data->data_bo);
1058 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1063 static int __camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1064 camera_media_packet_data *mp_data, media_packet_h *packet)
1066 media_packet_h pkt = NULL;
1067 bool make_pkt_fmt = false;
1068 tbm_surface_h tsurf = NULL;
1069 tbm_surface_info_s tsurf_info;
1070 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1071 uint32_t bo_format = 0;
1074 int num_buffer_fd = 0;
1075 int pkt_fmt_width = 0;
1076 int pkt_fmt_height = 0;
1077 tbm_bo *buffer_bo = NULL;
1078 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1080 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1081 CAM_LOG_ERROR("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1082 cb_info, stream, mp_data, packet);
1083 return CAMERA_ERROR_INVALID_PARAMETER;
1086 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1088 buffer_bo = mp_data->buffer_bo;
1089 num_buffer_fd = mp_data->num_buffer_fd;
1091 /* create tbm surface */
1092 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1093 tsurf_info.planes[i].stride = stream->stride[i];
1095 /* get tbm surface format */
1096 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1097 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1098 if (ret != CAMERA_ERROR_NONE)
1101 tsurf_info.width = stream->width;
1102 tsurf_info.height = stream->height;
1103 tsurf_info.format = bo_format;
1104 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1105 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1107 if (num_buffer_fd > 0) {
1108 switch (bo_format) {
1109 case TBM_FORMAT_NV12:
1110 case TBM_FORMAT_NV21:
1111 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1112 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1113 tsurf_info.planes[0].offset = 0;
1114 if (num_buffer_fd == 1)
1115 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1116 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1119 case TBM_FORMAT_YUV420:
1120 case TBM_FORMAT_YVU420:
1121 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1122 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1123 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1124 tsurf_info.planes[0].offset = 0;
1125 if (num_buffer_fd == 1) {
1126 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1127 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1129 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1131 case TBM_FORMAT_UYVY:
1132 case TBM_FORMAT_YUYV:
1133 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1134 tsurf_info.planes[0].offset = 0;
1135 tsurf_info.size = tsurf_info.planes[0].size;
1142 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1143 } else if (mp_data->data_bo) {
1145 switch (bo_format) {
1146 case TBM_FORMAT_NV12:
1147 case TBM_FORMAT_NV21:
1148 tsurf_info.planes[0].size = stream->width * stream->height;
1149 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1150 tsurf_info.planes[0].offset = 0;
1151 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1152 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1154 case TBM_FORMAT_YUV420:
1155 case TBM_FORMAT_YVU420:
1156 tsurf_info.planes[0].size = stream->width * stream->height;
1157 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1158 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1159 tsurf_info.planes[0].offset = 0;
1160 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1161 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1162 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1164 case TBM_FORMAT_UYVY:
1165 case TBM_FORMAT_YUYV:
1166 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1167 tsurf_info.planes[0].offset = 0;
1168 tsurf_info.size = tsurf_info.planes[0].size;
1174 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1179 CAM_LOG_ERROR("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1180 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1181 return CAMERA_ERROR_INVALID_OPERATION;
1184 /* check media packet format */
1185 if (cb_info->pkt_fmt) {
1186 media_format_get_video_info(cb_info->pkt_fmt,
1187 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1189 CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d",
1190 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1192 if (pkt_fmt_mimetype != mimetype ||
1193 pkt_fmt_width != stream->width ||
1194 pkt_fmt_height != stream->height) {
1195 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1196 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1198 media_format_unref(cb_info->pkt_fmt);
1199 cb_info->pkt_fmt = NULL;
1200 make_pkt_fmt = true;
1203 make_pkt_fmt = true;
1206 /* create packet format */
1208 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1209 mimetype, stream->width, stream->height);
1211 ret = media_format_create(&cb_info->pkt_fmt);
1212 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1213 CAM_LOG_WARNING("media_format_create failed 0x%x", ret);
1214 goto _PACKET_CREATE_FAILED;
1217 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1218 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1219 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1220 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1221 CAM_LOG_WARNING("media format set failed 0x%x", ret);
1222 goto _PACKET_CREATE_FAILED;
1226 /* create media packet */
1227 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1228 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1229 (void *)cb_info, &pkt);
1230 if (ret != MEDIA_PACKET_ERROR_NONE) {
1231 CAM_LOG_ERROR("media_packet_new failed 0x%x", ret);
1232 goto _PACKET_CREATE_FAILED;
1235 /* set media packet data */
1236 ret = media_packet_set_extra(pkt, (void *)mp_data);
1237 if (ret != MEDIA_PACKET_ERROR_NONE) {
1238 CAM_LOG_ERROR("media_packet_set_extra failed");
1239 goto _PACKET_CREATE_FAILED;
1242 /* set timestamp : msec -> nsec */
1243 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1244 CAM_LOG_WARNING("media_packet_set_pts failed");
1248 return CAMERA_ERROR_NONE;
1250 _PACKET_CREATE_FAILED:
1252 tbm_surface_destroy(tsurf);
1254 media_packet_unref(pkt);
1256 return CAMERA_ERROR_INVALID_OPERATION;
1259 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1262 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1263 camera_media_packet_data *mp_data = NULL;
1264 tbm_surface_h tsurf = NULL;
1266 if (!pkt || !cb_info) {
1267 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1271 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1272 if (ret != MEDIA_PACKET_ERROR_NONE) {
1273 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1277 CAM_LOG_VERBOSE("mp_data[%p]", mp_data);
1279 g_mutex_lock(&cb_info->mp_data_mutex);
1281 __camera_media_packet_data_release(mp_data, cb_info);
1284 g_mutex_unlock(&cb_info->mp_data_mutex);
1286 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1287 if (ret != MEDIA_PACKET_ERROR_NONE)
1288 CAM_LOG_ERROR("get tbm_surface failed 0x%x", ret);
1291 tbm_surface_destroy(tsurf);
1296 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1301 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1302 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1306 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1308 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1310 if (cb_info->user_cb[event] == NULL) {
1311 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1312 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1313 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1314 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1315 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1316 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1320 /* return buffer message should be sent for some events.
1321 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1322 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1323 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1324 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1329 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1335 muse_camera_msg_get(previous, recv_msg);
1336 muse_camera_msg_get(current, recv_msg);
1337 muse_camera_msg_get(by_policy, recv_msg);
1339 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1340 previous, current, by_policy);
1342 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1343 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1346 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1350 muse_camera_msg_get(state, recv_msg);
1352 CAM_LOG_INFO("FOCUS state - %d", state);
1354 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1357 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1358 CAM_LOG_INFO("CAPTURE_COMPLETED");
1359 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1361 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1362 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1363 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1366 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1370 muse_camera_msg_get(percent, recv_msg);
1372 CAM_LOG_INFO("HDR progress - %d %%", percent);
1374 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1377 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1383 muse_camera_msg_get(policy, recv_msg);
1384 muse_camera_msg_get(previous, recv_msg);
1385 muse_camera_msg_get(current, recv_msg);
1387 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1389 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1390 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1393 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1398 muse_camera_msg_get(policy, recv_msg);
1399 muse_camera_msg_get(state, recv_msg);
1401 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1403 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1404 (camera_state_e)state, cb_info->user_data[event]);
1407 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1408 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1410 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1413 int current_state = 0;
1415 muse_camera_msg_get(error, recv_msg);
1416 muse_camera_msg_get(current_state, recv_msg);
1418 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1420 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1421 (camera_state_e)current_state, cb_info->user_data[event]);
1425 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1427 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1428 muse_camera_msg_get(param1, recv_msg);
1429 muse_camera_msg_get(param2, recv_msg);
1431 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1433 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1434 cb_info->user_cb[event] = NULL;
1435 cb_info->user_data[event] = NULL;
1436 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1439 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1441 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1443 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1445 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1447 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1449 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1451 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1453 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1455 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1457 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1459 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1461 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1463 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1466 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1468 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1469 muse_camera_msg_get(param1, recv_msg);
1471 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1473 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1474 cb_info->user_cb[event] = NULL;
1475 cb_info->user_data[event] = NULL;
1476 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1480 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1481 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1484 CAM_LOG_WARNING("unhandled event %d", event);
1488 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1491 static gboolean __camera_idle_event_callback(gpointer data)
1493 camera_cb_info_s *cb_info = NULL;
1494 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1496 if (cam_idle_event == NULL) {
1497 CAM_LOG_ERROR("cam_idle_event is NULL");
1502 g_mutex_lock(&g_cam_idle_event_lock);
1504 cb_info = cam_idle_event->cb_info;
1505 if (cb_info == NULL) {
1506 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1507 g_mutex_unlock(&g_cam_idle_event_lock);
1508 goto IDLE_EVENT_CALLBACK_DONE;
1511 /* remove event from list */
1512 if (cb_info->idle_event_list)
1513 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1515 g_mutex_unlock(&g_cam_idle_event_lock);
1518 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1520 IDLE_EVENT_CALLBACK_DONE:
1522 g_free(cam_idle_event);
1523 cam_idle_event = NULL;
1528 static gpointer __camera_msg_handler_func(gpointer data)
1532 camera_message_s *cam_msg = NULL;
1533 camera_idle_event_s *cam_idle_event = NULL;
1534 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1535 camera_cb_info_s *cb_info = NULL;
1537 if (!handler_info || !handler_info->cb_info) {
1538 CAM_LOG_ERROR("NULL handler %p", handler_info);
1542 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1543 type = handler_info->type;
1545 CAM_LOG_INFO("t:%d start", type);
1547 g_mutex_lock(&handler_info->mutex);
1549 while (g_atomic_int_get(&handler_info->running)) {
1550 if (g_queue_is_empty(handler_info->queue)) {
1551 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1552 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1553 CAM_LOG_VERBOSE("t[%d] signal received", type);
1555 if (g_atomic_int_get(&handler_info->running) == 0) {
1556 CAM_LOG_INFO("t:%d stop event thread", type);
1561 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1563 g_mutex_unlock(&handler_info->mutex);
1565 if (cam_msg == NULL) {
1566 CAM_LOG_ERROR("t:%d NULL message", type);
1567 g_mutex_lock(&handler_info->mutex);
1573 if (api < MUSE_CAMERA_API_MAX) {
1576 g_mutex_lock(&cb_info->api_mutex[api]);
1578 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1579 if (cb_info->api_waiting[api] > 0) {
1580 cb_info->api_ret[api] = ret;
1581 cb_info->api_activating[api] = TRUE;
1583 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1585 g_cond_signal(&cb_info->api_cond[api]);
1587 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1590 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1593 g_mutex_unlock(&cb_info->api_mutex[api]);
1594 } else if (api == MUSE_CAMERA_CB_EVENT) {
1595 switch (cam_msg->event_class) {
1596 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1597 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1599 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1600 cam_idle_event = g_new0(camera_idle_event_s, 1);
1601 if (cam_idle_event == NULL) {
1602 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1606 cam_idle_event->event = cam_msg->event;
1607 cam_idle_event->cb_info = cb_info;
1609 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1610 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1612 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1613 type, cam_msg->event, cam_idle_event);
1615 g_mutex_lock(&g_cam_idle_event_lock);
1616 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1617 g_mutex_unlock(&g_cam_idle_event_lock);
1619 g_idle_add_full(G_PRIORITY_DEFAULT,
1620 (GSourceFunc)__camera_idle_event_callback,
1621 (gpointer)cam_idle_event,
1625 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1629 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1635 g_mutex_lock(&handler_info->mutex);
1638 /* remove remained event */
1639 while (!g_queue_is_empty(handler_info->queue)) {
1640 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1642 CAM_LOG_INFO("t:%d remove camera message %p", type, cam_msg);
1646 CAM_LOG_WARNING("t:%d NULL camera message", type);
1650 g_mutex_unlock(&handler_info->mutex);
1652 CAM_LOG_INFO("t:%d return", type);
1658 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1660 camera_idle_event_s *cam_idle_event = NULL;
1663 if (cb_info == NULL) {
1664 CAM_LOG_ERROR("cb_info is NULL");
1668 g_mutex_lock(&g_cam_idle_event_lock);
1670 if (cb_info->idle_event_list == NULL) {
1671 CAM_LOG_INFO("No remained idle event");
1672 g_mutex_unlock(&g_cam_idle_event_lock);
1676 list = cb_info->idle_event_list;
1679 cam_idle_event = list->data;
1680 list = g_list_next(list);
1682 if (!cam_idle_event) {
1683 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1687 if (g_idle_remove_by_data(cam_idle_event)) {
1688 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1690 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1692 g_free(cam_idle_event);
1693 cam_idle_event = NULL;
1698 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1699 cam_idle_event, cam_idle_event->event);
1701 cam_idle_event->cb_info = NULL;
1703 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1706 g_list_free(cb_info->idle_event_list);
1707 cb_info->idle_event_list = NULL;
1709 g_mutex_unlock(&g_cam_idle_event_lock);
1713 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1715 camera_message_s *cam_msg = NULL;
1717 if (!cb_info || !msg) {
1718 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1722 cam_msg = g_new0(camera_message_s, 1);
1724 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1729 cam_msg->event = event;
1730 cam_msg->event_class = event_class;
1732 if (tfd && tfd[0] >= 0)
1733 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1735 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1737 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1738 api, event, event_class);
1740 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1741 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1742 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1743 g_cond_signal(&cb_info->preview_cb_info.cond);
1744 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1745 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1746 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1747 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1748 g_cond_signal(&cb_info->capture_cb_info.cond);
1749 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1751 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1752 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1753 g_cond_signal(&cb_info->msg_handler_info.cond);
1754 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1761 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1763 int ret = CAMERA_ERROR_NONE;
1767 int event_class = -1;
1771 if (!cb_info || !msg) {
1772 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
1776 CAM_LOG_DEBUG("msg[%s]", msg);
1778 if (!muse_camera_msg_get(api, msg)) {
1779 CAM_LOG_ERROR("failed to get camera api");
1783 if (api == MUSE_CAMERA_CB_EVENT) {
1784 if (!muse_camera_msg_get(event, msg) ||
1785 !muse_camera_msg_get(event_class, msg)) {
1786 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
1790 if (!muse_camera_msg_get(api_class, msg)) {
1791 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
1796 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1797 if (api >= MUSE_CAMERA_API_MAX) {
1798 CAM_LOG_ERROR("invalid api %d", api);
1802 if (!muse_camera_msg_get(ret, msg)) {
1803 CAM_LOG_ERROR("failed to get camera ret");
1807 g_mutex_lock(&cb_info->api_mutex[api]);
1810 case MUSE_CAMERA_API_CREATE:
1811 if (ret != CAMERA_ERROR_NONE) {
1812 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1813 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
1816 case MUSE_CAMERA_API_DESTROY:
1817 if (ret == CAMERA_ERROR_NONE) {
1818 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1819 CAM_LOG_INFO("camera destroy done. close client cb handler");
1823 muse_camera_msg_get(get_type, msg);
1824 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1825 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1826 muse_camera_msg_get(get_index, msg);
1829 case MUSE_CAMERA_GET_TYPE_INT:
1830 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1832 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1833 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1834 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1836 case MUSE_CAMERA_GET_TYPE_ARRAY:
1837 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1838 muse_core_msg_deserialize("get_value",
1839 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1840 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
1841 cb_info->get_display_roi_area[0],
1842 cb_info->get_display_roi_area[1],
1843 cb_info->get_display_roi_area[2],
1844 cb_info->get_display_roi_area[3]);
1846 muse_core_msg_deserialize("get_value",
1847 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1848 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
1849 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1852 case MUSE_CAMERA_GET_TYPE_STRING:
1853 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1856 CAM_LOG_WARNING("unknown type %d", get_type);
1863 if (cb_info->api_waiting[api] > 0) {
1864 cb_info->api_ret[api] = ret;
1865 cb_info->api_activating[api] = TRUE;
1867 g_cond_signal(&cb_info->api_cond[api]);
1869 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1872 g_mutex_unlock(&cb_info->api_mutex[api]);
1873 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1874 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
1876 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
1881 static gpointer __camera_msg_recv_func(gpointer data)
1884 int recv_length = 0;
1885 int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
1886 char *recv_msg = NULL;
1887 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1890 CAM_LOG_ERROR("cb_info NULL");
1894 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
1896 recv_msg = cb_info->recv_msg;
1898 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1899 for (i = 0 ; i < MUSE_NUM_FD ; i++)
1902 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
1903 if (recv_length <= 0) {
1904 cb_info->is_server_connected = FALSE;
1905 CAM_LOG_ERROR("receive msg failed - server disconnected");
1910 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
1912 recv_msg[recv_length] = '\0';
1914 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
1916 __camera_process_msg(cb_info, recv_msg, tfd);
1919 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
1921 if (!cb_info->is_server_connected) {
1922 char *error_msg = NULL;
1924 if (cb_info->bufmgr == NULL) {
1925 CAM_LOG_ERROR("No need to send error(handle is not created)");
1929 if (cb_info->fd < 0) {
1930 CAM_LOG_ERROR("fd is closed in client side");
1934 /* send error msg for server disconnection */
1935 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1936 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1937 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1941 CAM_LOG_ERROR("error_msg failed");
1945 __camera_add_msg_to_queue(cb_info,
1946 MUSE_CAMERA_CB_EVENT,
1947 MUSE_CAMERA_EVENT_TYPE_ERROR,
1948 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1952 muse_core_msg_free(error_msg);
1955 CAM_LOG_ERROR("add error msg for service disconnection done");
1962 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1963 int type, const char *thread_name, camera_cb_info_s *cb_info)
1965 if (!handler_info || !thread_name || !cb_info) {
1966 CAM_LOG_ERROR("t:%d NULL %p %p %p",
1967 type, handler_info, thread_name, cb_info);
1971 CAM_LOG_INFO("t:%d", type);
1973 handler_info->type = type;
1974 handler_info->queue = g_queue_new();
1975 if (handler_info->queue == NULL) {
1976 CAM_LOG_ERROR("t:%d queue failed", type);
1980 g_mutex_init(&handler_info->mutex);
1981 g_cond_init(&handler_info->cond);
1983 handler_info->cb_info = (void *)cb_info;
1984 g_atomic_int_set(&handler_info->running, 1);
1986 handler_info->thread = g_thread_try_new(thread_name,
1987 __camera_msg_handler_func, (gpointer)handler_info, NULL);
1988 if (handler_info->thread == NULL) {
1989 CAM_LOG_ERROR("t:%d thread failed", type);
1991 g_mutex_clear(&handler_info->mutex);
1992 g_cond_clear(&handler_info->cond);
1993 g_queue_free(handler_info->queue);
1994 handler_info->queue = NULL;
1999 CAM_LOG_INFO("t:%d done", type);
2005 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2009 if (!handler_info) {
2010 CAM_LOG_ERROR("NULL handler");
2014 if (!handler_info->thread) {
2015 CAM_LOG_WARNING("thread is not created");
2019 type = handler_info->type;
2021 CAM_LOG_INFO("t:%d thread %p", type, handler_info->thread);
2023 g_mutex_lock(&handler_info->mutex);
2024 g_atomic_int_set(&handler_info->running, 0);
2025 g_cond_signal(&handler_info->cond);
2026 g_mutex_unlock(&handler_info->mutex);
2028 g_thread_join(handler_info->thread);
2029 handler_info->thread = NULL;
2031 g_mutex_clear(&handler_info->mutex);
2032 g_cond_clear(&handler_info->cond);
2033 g_queue_free(handler_info->queue);
2034 handler_info->queue = NULL;
2036 CAM_LOG_INFO("t:%d done", type);
2040 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2042 camera_cb_info_s *cb_info = NULL;
2045 g_return_val_if_fail(sockfd > 0, NULL);
2047 cb_info = g_new0(camera_cb_info_s, 1);
2048 if (cb_info == NULL) {
2049 CAM_LOG_ERROR("cb_info failed");
2053 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2055 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2056 g_mutex_init(&cb_info->api_mutex[i]);
2057 g_cond_init(&cb_info->api_cond[i]);
2060 g_mutex_init(&cb_info->fd_lock);
2061 g_mutex_init(&cb_info->mp_data_mutex);
2063 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2064 g_mutex_init(&cb_info->user_cb_mutex[i]);
2066 /* message handler thread */
2067 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2068 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2069 CAM_LOG_ERROR("msg_handler_info failed");
2073 /* message handler thread for preview callback */
2074 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2075 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2076 CAM_LOG_ERROR("preview_cb_info failed");
2080 /* message handler thread for capture callback */
2081 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2082 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2083 CAM_LOG_ERROR("capture_cb_info failed");
2087 cb_info->fd = sockfd;
2088 cb_info->preview_cb_flag = 0;
2090 /* message receive thread */
2091 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2092 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2093 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2094 if (cb_info->msg_recv_thread == NULL) {
2095 CAM_LOG_ERROR("message receive thread creation failed");
2100 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2101 cb_info->fds[i] = -1;
2103 cb_info->is_server_connected = TRUE;
2109 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2110 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2111 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2113 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2114 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2116 g_mutex_clear(&cb_info->fd_lock);
2117 g_mutex_clear(&cb_info->mp_data_mutex);
2119 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2120 g_mutex_clear(&cb_info->api_mutex[i]);
2121 g_cond_clear(&cb_info->api_cond[i]);
2132 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2136 g_return_if_fail(cb_info != NULL);
2138 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2140 g_thread_join(cb_info->msg_recv_thread);
2141 cb_info->msg_recv_thread = NULL;
2143 CAM_LOG_INFO("msg_recv thread removed");
2145 /* destroy msg handler threads */
2146 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2147 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2148 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2150 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2151 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2153 g_mutex_clear(&cb_info->fd_lock);
2154 g_mutex_clear(&cb_info->mp_data_mutex);
2156 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2157 g_mutex_clear(&cb_info->api_mutex[i]);
2158 g_cond_clear(&cb_info->api_cond[i]);
2161 if (cb_info->fd > -1) {
2162 muse_client_close(cb_info->fd);
2166 if (cb_info->bufmgr) {
2167 tbm_bufmgr_deinit(cb_info->bufmgr);
2168 cb_info->bufmgr = NULL;
2170 if (cb_info->pkt_fmt) {
2171 media_format_unref(cb_info->pkt_fmt);
2172 cb_info->pkt_fmt = NULL;
2175 if (cb_info->dp_interface) {
2176 mm_display_interface_deinit(cb_info->dp_interface);
2177 cb_info->dp_interface = NULL;
2180 cb_info->preview_cb_flag = 0;
2186 int _camera_start_evas_rendering(camera_h camera)
2188 camera_cli_s *pc = (camera_cli_s *)camera;
2190 if (!pc || !pc->cb_info) {
2191 CAM_LOG_ERROR("NULL handle");
2192 return CAMERA_ERROR_INVALID_PARAMETER;
2195 CAM_LOG_INFO("start");
2197 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2198 CAM_LOG_ERROR("EVAS surface is not set");
2199 return CAMERA_ERROR_NONE;
2202 /* set evas render flag as RUN */
2203 pc->cb_info->run_evas_render = true;
2205 return CAMERA_ERROR_NONE;
2209 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2211 int ret = CAMERA_ERROR_NONE;
2212 camera_cli_s *pc = (camera_cli_s *)camera;
2214 if (!pc || !pc->cb_info) {
2215 CAM_LOG_ERROR("NULL handle");
2216 return CAMERA_ERROR_INVALID_PARAMETER;
2219 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2221 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2222 CAM_LOG_ERROR("EVAS surface is not set");
2223 return CAMERA_ERROR_NONE;
2226 /* set evas render flag as STOP and release buffers */
2227 pc->cb_info->run_evas_render = false;
2229 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2230 if (ret == MM_ERROR_NONE) {
2231 ret = CAMERA_ERROR_NONE;
2233 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2234 ret = CAMERA_ERROR_INVALID_OPERATION;
2241 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2243 int ret = CAMERA_ERROR_NONE;
2245 int module_index = -1;
2247 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2249 /* create muse connection */
2250 if (!key || !value) {
2251 CAM_LOG_ERROR("NULL pointer");
2252 return CAMERA_ERROR_INVALID_PARAMETER;
2255 sock_fd = muse_client_new();
2257 CAM_LOG_ERROR("muse_client_new failed");
2258 return CAMERA_ERROR_INVALID_OPERATION;
2261 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2262 CAM_LOG_ERROR("muse client get module index failed");
2263 ret = CAMERA_ERROR_INVALID_OPERATION;
2267 msg = muse_core_msg_new(api,
2268 MUSE_TYPE_INT, "module", module_index,
2269 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2272 CAM_LOG_ERROR("msg failed");
2273 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2277 ret = muse_core_msg_send(sock_fd, msg);
2279 muse_core_msg_free(msg);
2283 CAM_LOG_ERROR("send msg failed");
2284 ret = CAMERA_ERROR_INVALID_OPERATION;
2288 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2290 CAM_LOG_ERROR("recv msg failed %d", errno);
2291 ret = CAMERA_ERROR_INVALID_OPERATION;
2295 if (!muse_camera_msg_get(ret, recv_msg)) {
2296 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2297 ret = CAMERA_ERROR_INVALID_OPERATION;
2301 if (ret == CAMERA_ERROR_NONE)
2302 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2304 CAM_LOG_INFO("api %d - value %d", api, *value);
2308 muse_client_close(sock_fd);
2316 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2319 char *send_msg = NULL;
2321 int ret = CAMERA_ERROR_NONE;
2322 camera_cli_s *pc = NULL;
2323 tbm_bufmgr bufmgr = NULL;
2325 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2326 int module_index = -1;
2327 int device_type = (int)device;
2330 CAM_LOG_ERROR("NULL pointer");
2331 return CAMERA_ERROR_INVALID_PARAMETER;
2334 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2336 sock_fd = muse_client_new();
2338 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2339 ret = CAMERA_ERROR_INVALID_OPERATION;
2343 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2344 CAM_LOG_ERROR("muse client get module index failed");
2345 ret = CAMERA_ERROR_INVALID_OPERATION;
2349 send_msg = muse_core_msg_new(api,
2350 MUSE_TYPE_INT, "module", module_index,
2351 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2352 MUSE_TYPE_INT, "is_network", (int)is_network,
2356 CAM_LOG_ERROR("NULL msg");
2357 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2361 send_ret = muse_core_msg_send(sock_fd, send_msg);
2363 muse_core_msg_free(send_msg);
2367 CAM_LOG_ERROR("send msg failed %d", errno);
2368 ret = CAMERA_ERROR_INVALID_OPERATION;
2372 pc = g_new0(camera_cli_s, 1);
2374 CAM_LOG_ERROR("camera_cli_s alloc failed");
2375 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2379 bufmgr = tbm_bufmgr_init(-1);
2380 if (bufmgr == NULL) {
2381 CAM_LOG_ERROR("get tbm bufmgr failed");
2382 ret = CAMERA_ERROR_INVALID_OPERATION;
2386 pc->cb_info = __camera_client_callback_new(sock_fd);
2387 if (pc->cb_info == NULL) {
2388 CAM_LOG_ERROR("cb_info alloc failed");
2389 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2395 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2397 ret = __camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2399 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2401 if (ret == CAMERA_ERROR_NONE) {
2402 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2403 int user_buffer_supported = 0;
2404 int log_level = CAMERA_LOG_LEVEL_INFO;
2405 intptr_t handle = 0;
2407 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2409 CAM_LOG_ERROR("Receiving Handle Failed!!");
2410 ret = CAMERA_ERROR_INVALID_OPERATION;
2414 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2415 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2416 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2418 pc->remote_handle = handle;
2419 pc->cb_info->bufmgr = bufmgr;
2420 pc->cb_info->preview_format = preview_format;
2421 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2422 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2423 g_camera_log_level = log_level;
2425 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2426 preview_format, user_buffer_supported, g_camera_log_level);
2428 *camera = (camera_h)pc;
2430 /* get display interface handle */
2431 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2432 CAM_LOG_WARNING("display interface init failed");
2441 tbm_bufmgr_deinit(bufmgr);
2446 muse_client_close(sock_fd);
2452 int temp_fd = pc->cb_info->fd;
2454 /* pc->cb_info->fd should be closed,
2455 because g_thread_join for msg_recv_thread is not returned
2456 in __camera_client_callback_destroy. */
2458 pc->cb_info->fd = -1;
2459 muse_client_close(temp_fd);
2462 __camera_client_callback_destroy(pc->cb_info);
2469 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2476 int camera_create(camera_device_e device, camera_h *camera)
2478 return _camera_create_private(device, false, camera);
2482 int camera_change_device(camera_h camera, camera_device_e device)
2485 int ret = CAMERA_ERROR_NONE;
2486 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2487 camera_cli_s *pc = (camera_cli_s *)camera;
2488 camera_msg_param param;
2490 if (!pc || !pc->cb_info) {
2491 CAM_LOG_ERROR("NULL handle");
2492 return CAMERA_ERROR_INVALID_PARAMETER;
2495 CAMERA_MSG_PARAM_SET(param, INT, device);
2497 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2499 if (ret == CAMERA_ERROR_NONE) {
2500 /* reset callback and user data */
2501 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2502 pc->cb_info->user_cb[i] = NULL;
2503 pc->cb_info->user_data[i] = NULL;
2505 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2512 int camera_destroy(camera_h camera)
2514 int ret = CAMERA_ERROR_NONE;
2515 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2516 camera_cli_s *pc = (camera_cli_s *)camera;
2518 if (!pc || !pc->cb_info) {
2519 CAM_LOG_ERROR("NULL handle");
2520 return CAMERA_ERROR_INVALID_PARAMETER;
2523 CAM_LOG_INFO("Enter");
2525 if (pc->cb_info->is_server_connected)
2526 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2528 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2530 if (ret == CAMERA_ERROR_NONE) {
2531 __camera_deactivate_idle_event_all(pc->cb_info);
2532 __camera_client_callback_destroy(pc->cb_info);
2539 CAM_LOG_INFO("ret : 0x%x", ret);
2544 int camera_start_preview(camera_h camera)
2546 int ret = CAMERA_ERROR_NONE;
2547 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2548 camera_cli_s *pc = (camera_cli_s *)camera;
2549 camera_state_e current_state = CAMERA_STATE_NONE;
2551 if (!pc || !pc->cb_info) {
2552 CAM_LOG_ERROR("NULL handle");
2553 return CAMERA_ERROR_INVALID_PARAMETER;
2556 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2557 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2559 ret = camera_get_state(camera, ¤t_state);
2560 if (ret != CAMERA_ERROR_NONE) {
2561 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2565 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2566 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2567 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2568 pc->cb_info->dp_info.type);
2569 return CAMERA_ERROR_INVALID_OPERATION;
2572 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2573 if (!__camera_allocate_preview_buffer(camera))
2574 return CAMERA_ERROR_INVALID_OPERATION;
2576 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2578 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2581 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2582 ret = _camera_start_evas_rendering(camera);
2583 if (ret != CAMERA_ERROR_NONE) {
2584 CAM_LOG_ERROR("stop preview because of error");
2585 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2589 CAM_LOG_INFO("ret : 0x%x", ret);
2595 int camera_stop_preview(camera_h camera)
2597 int ret = CAMERA_ERROR_NONE;
2598 camera_cli_s *pc = (camera_cli_s *)camera;
2599 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2600 camera_state_e current_state = CAMERA_STATE_NONE;
2602 if (!pc || !pc->cb_info) {
2603 CAM_LOG_ERROR("NULL handle");
2604 return CAMERA_ERROR_INVALID_PARAMETER;
2607 CAM_LOG_INFO("Enter");
2610 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2611 ret = camera_get_state(camera, ¤t_state);
2612 if (ret != CAMERA_ERROR_NONE) {
2613 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2617 if (current_state == CAMERA_STATE_PREVIEW) {
2618 ret = _camera_stop_evas_rendering(camera, false);
2619 if (ret != CAMERA_ERROR_NONE)
2624 /* send stop preview message */
2625 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2627 if (ret == CAMERA_ERROR_NONE) {
2628 if (pc->cb_info->user_buffer_supported)
2629 __camera_release_preview_buffer(camera);
2630 } else if (current_state == CAMERA_STATE_PREVIEW) {
2631 CAM_LOG_WARNING("restart evas rendering");
2632 _camera_start_evas_rendering(camera);
2635 CAM_LOG_INFO("ret : 0x%x", ret);
2641 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2643 int ret = CAMERA_ERROR_NONE;
2644 camera_cli_s *pc = (camera_cli_s *)camera;
2645 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2647 if (!pc || !pc->cb_info) {
2648 CAM_LOG_ERROR("NULL handle");
2649 return CAMERA_ERROR_INVALID_PARAMETER;
2652 CAM_LOG_INFO("Enter");
2654 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2655 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2657 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2658 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2660 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2662 CAM_LOG_INFO("ret : 0x%x", ret);
2668 bool camera_is_supported_continuous_capture(camera_h camera)
2670 int ret = CAMERA_ERROR_NONE;
2671 camera_cli_s *pc = (camera_cli_s *)camera;
2672 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2674 if (!pc || !pc->cb_info) {
2675 CAM_LOG_ERROR("NULL handle");
2676 return CAMERA_ERROR_INVALID_PARAMETER;
2679 CAM_LOG_INFO("Enter");
2681 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2684 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2688 CAM_LOG_INFO("ret : %d", ret);
2694 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)
2696 int ret = CAMERA_ERROR_NONE;
2697 camera_cli_s *pc = (camera_cli_s *)camera;
2698 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2699 camera_msg_param param;
2702 if (!pc || !pc->cb_info) {
2703 CAM_LOG_ERROR("NULL handle");
2704 return CAMERA_ERROR_INVALID_PARAMETER;
2707 CAM_LOG_INFO("Enter");
2709 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2710 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2712 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2713 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2715 value = (count << 16) | interval;
2716 CAMERA_MSG_PARAM_SET(param, INT, value);
2718 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2720 CAM_LOG_INFO("ret : 0x%x", ret);
2726 int camera_stop_continuous_capture(camera_h camera)
2728 int ret = CAMERA_ERROR_NONE;
2729 camera_cli_s *pc = (camera_cli_s *)camera;
2730 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2732 if (!pc || !pc->cb_info) {
2733 CAM_LOG_ERROR("NULL handle");
2734 return CAMERA_ERROR_INVALID_PARAMETER;
2737 CAM_LOG_INFO("Enter");
2739 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2741 CAM_LOG_INFO("ret : 0x%x", ret);
2747 bool camera_is_supported_face_detection(camera_h camera)
2749 int ret = CAMERA_ERROR_NONE;
2750 camera_cli_s *pc = (camera_cli_s *)camera;
2751 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2753 if (!pc || !pc->cb_info) {
2754 CAM_LOG_ERROR("NULL handle");
2755 return CAMERA_ERROR_INVALID_PARAMETER;
2758 CAM_LOG_INFO("Enter");
2760 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2763 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2767 CAM_LOG_INFO("ret : %d", ret);
2773 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2775 int ret = CAMERA_ERROR_NONE;
2776 camera_cli_s *pc = (camera_cli_s *)camera;
2777 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2779 if (!pc || !pc->cb_info) {
2780 CAM_LOG_ERROR("NULL handle");
2781 return CAMERA_ERROR_INVALID_PARAMETER;
2784 CAM_LOG_INFO("Enter");
2786 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2789 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2793 CAM_LOG_INFO("ret : %d", ret);
2799 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2801 int ret = CAMERA_ERROR_NONE;
2802 camera_cli_s *pc = (camera_cli_s *)camera;
2803 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2805 if (!pc || !pc->cb_info) {
2806 CAM_LOG_ERROR("NULL handle");
2807 return CAMERA_ERROR_INVALID_PARAMETER;
2810 CAM_LOG_INFO("Enter");
2812 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2815 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2819 CAM_LOG_INFO("ret : %d", ret);
2824 int camera_get_device_count(camera_h camera, int *device_count)
2826 int ret = CAMERA_ERROR_NONE;
2827 camera_cli_s *pc = (camera_cli_s *)camera;
2828 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2830 if (!pc || !pc->cb_info) {
2831 CAM_LOG_ERROR("NULL handle");
2832 return CAMERA_ERROR_INVALID_PARAMETER;
2835 CAM_LOG_INFO("Enter");
2837 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2839 if (ret == CAMERA_ERROR_NONE)
2840 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2842 CAM_LOG_INFO("ret : 0x%x", ret);
2847 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2849 int ret = CAMERA_ERROR_NONE;
2850 camera_cli_s *pc = (camera_cli_s *)camera;
2851 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2853 if (!pc || !pc->cb_info) {
2854 CAM_LOG_ERROR("NULL handle");
2855 return CAMERA_ERROR_INVALID_PARAMETER;
2858 CAM_LOG_INFO("Enter");
2860 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2862 if (ret == CAMERA_ERROR_NONE) {
2863 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2865 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2866 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2868 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2871 CAM_LOG_INFO("ret : 0x%x", ret);
2876 int camera_stop_face_detection(camera_h camera)
2878 int ret = CAMERA_ERROR_NONE;
2879 camera_cli_s *pc = (camera_cli_s *)camera;
2880 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2882 if (!pc || !pc->cb_info) {
2883 CAM_LOG_ERROR("NULL handle");
2884 return CAMERA_ERROR_INVALID_PARAMETER;
2887 CAM_LOG_INFO("Enter");
2889 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2891 if (ret == CAMERA_ERROR_NONE) {
2892 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2894 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2895 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2897 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2900 CAM_LOG_INFO("ret : 0x%x", ret);
2905 int camera_get_state(camera_h camera, camera_state_e *state)
2907 int ret = CAMERA_ERROR_NONE;
2908 camera_cli_s *pc = (camera_cli_s *)camera;
2909 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2911 if (!pc || !pc->cb_info || !state) {
2912 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
2913 return CAMERA_ERROR_INVALID_PARAMETER;
2916 CAM_LOG_INFO("Enter");
2918 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2920 if (ret == CAMERA_ERROR_NONE)
2921 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2923 CAM_LOG_INFO("ret : 0x%x", ret);
2928 int camera_start_focusing(camera_h camera, bool continuous)
2930 int ret = CAMERA_ERROR_NONE;
2931 camera_cli_s *pc = (camera_cli_s *)camera;
2932 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2933 camera_msg_param param;
2934 int is_continuous = (int)continuous;
2936 if (!pc || !pc->cb_info) {
2937 CAM_LOG_ERROR("NULL handle");
2938 return CAMERA_ERROR_INVALID_PARAMETER;
2941 CAM_LOG_INFO("Enter");
2943 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2945 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2947 CAM_LOG_INFO("ret : 0x%x", ret);
2952 int camera_cancel_focusing(camera_h camera)
2954 int ret = CAMERA_ERROR_NONE;
2955 camera_cli_s *pc = (camera_cli_s *)camera;
2956 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2958 if (!pc || !pc->cb_info) {
2959 CAM_LOG_ERROR("NULL handle");
2960 return CAMERA_ERROR_INVALID_PARAMETER;
2963 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
2965 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2967 CAM_LOG_INFO("ret : 0x%x", ret);
2973 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
2975 int mm_ret = MM_ERROR_NONE;
2976 int ret = CAMERA_ERROR_NONE;
2977 camera_cli_s *pc = (camera_cli_s *)camera;
2978 camera_cb_info_s *cb_info = NULL;
2979 camera_state_e current_state = CAMERA_STATE_NONE;
2980 camera_msg_param param;
2981 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2982 muse_camera_display_info_s *dp_info = NULL;
2984 if (!pc || !pc->cb_info) {
2985 CAM_LOG_ERROR("NULL handle");
2986 return CAMERA_ERROR_INVALID_PARAMETER;
2989 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
2990 CAM_LOG_ERROR("invalid type %d", type);
2991 return CAMERA_ERROR_INVALID_PARAMETER;
2994 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
2995 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
2996 return CAMERA_ERROR_INVALID_PARAMETER;
2999 cb_info = (camera_cb_info_s *)pc->cb_info;
3000 dp_info = &cb_info->dp_info;
3002 ret = camera_get_state(camera, ¤t_state);
3003 if (ret != CAMERA_ERROR_NONE) {
3004 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3008 if (current_state != CAMERA_STATE_CREATED) {
3009 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3010 return CAMERA_ERROR_INVALID_STATE;
3013 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3015 if (type != MM_DISPLAY_TYPE_NONE) {
3016 /* check display interface handle */
3017 if (!cb_info->dp_interface) {
3018 CAM_LOG_ERROR("display interface not supported");
3019 return CAMERA_ERROR_NOT_SUPPORTED;
3022 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3023 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3024 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3025 return CAMERA_ERROR_NOT_SUPPORTED;
3026 } else if (mm_ret != MM_ERROR_NONE) {
3027 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3028 return CAMERA_ERROR_INVALID_OPERATION;
3031 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3032 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3034 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3035 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3036 dp_info->window_rect.width, dp_info->window_rect.height);
3037 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3039 camera_flip_e flip = CAMERA_FLIP_NONE;
3040 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3041 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3048 camera_get_display_flip(camera, &flip);
3049 camera_get_display_mode(camera, &mode);
3050 camera_get_display_rotation(camera, &rotation);
3051 camera_is_display_visible(camera, &visible);
3053 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3054 flip, mode, rotation, visible);
3056 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3057 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3058 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3059 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3061 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3062 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3063 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3064 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3070 if (mm_ret != MM_ERROR_NONE) {
3071 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3072 return CAMERA_ERROR_INVALID_OPERATION;
3075 dp_info->type = type;
3077 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3079 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3081 if (ret == CAMERA_ERROR_NONE) {
3082 if (type == MM_DISPLAY_TYPE_EVAS)
3083 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3090 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3092 CAM_LOG_INFO("type %d, display %p", type, display);
3093 return _camera_set_display(camera, (mm_display_type_e)type, display);
3097 int camera_set_preview_resolution(camera_h camera, int width, int height)
3099 int ret = CAMERA_ERROR_NONE;
3100 camera_state_e current_state = CAMERA_STATE_NONE;
3101 camera_cli_s *pc = (camera_cli_s *)camera;
3102 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3103 camera_msg_param param;
3106 if (!pc || !pc->cb_info) {
3107 CAM_LOG_ERROR("NULL handle");
3108 return CAMERA_ERROR_INVALID_PARAMETER;
3111 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3112 ret = camera_get_state(camera, ¤t_state);
3113 if (ret != CAMERA_ERROR_NONE) {
3114 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3118 if (current_state == CAMERA_STATE_PREVIEW) {
3119 ret = _camera_stop_evas_rendering(camera, true);
3120 if (ret != CAMERA_ERROR_NONE)
3125 value = (width << 16) | height;
3126 CAMERA_MSG_PARAM_SET(param, INT, value);
3128 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3130 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3132 CAM_LOG_INFO("ret : 0x%x", ret);
3134 if (current_state == CAMERA_STATE_PREVIEW) {
3135 CAM_LOG_WARNING("restart evas rendering");
3136 _camera_start_evas_rendering(camera);
3143 int camera_set_capture_resolution(camera_h camera, int width, int height)
3145 int ret = CAMERA_ERROR_NONE;
3146 camera_cli_s *pc = (camera_cli_s *)camera;
3147 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3148 camera_msg_param param;
3151 if (!pc || !pc->cb_info) {
3152 CAM_LOG_ERROR("NULL handle");
3153 return CAMERA_ERROR_INVALID_PARAMETER;
3156 CAM_LOG_INFO("Enter");
3158 value = (width << 16) | height;
3159 CAMERA_MSG_PARAM_SET(param, INT, value);
3161 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3163 CAM_LOG_INFO("ret : 0x%x", ret);
3169 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3171 int ret = CAMERA_ERROR_NONE;
3172 int set_format = (int)format;
3173 camera_cli_s *pc = (camera_cli_s *)camera;
3174 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3175 camera_msg_param param;
3177 if (!pc || !pc->cb_info) {
3178 CAM_LOG_ERROR("NULL handle");
3179 return CAMERA_ERROR_INVALID_PARAMETER;
3182 CAM_LOG_INFO("Enter - format %d", set_format);
3184 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3186 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3188 CAM_LOG_INFO("ret : 0x%x", ret);
3194 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3196 int ret = CAMERA_ERROR_NONE;
3197 int set_format = (int)format;
3198 camera_msg_param param;
3199 camera_cli_s *pc = (camera_cli_s *)camera;
3200 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3202 if (!pc || !pc->cb_info) {
3203 CAM_LOG_ERROR("NULL handle");
3204 return CAMERA_ERROR_INVALID_PARAMETER;
3207 CAM_LOG_INFO("Enter - format %d", set_format);
3209 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3211 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3213 if (ret == CAMERA_ERROR_NONE)
3214 pc->cb_info->preview_format = set_format;
3216 CAM_LOG_INFO("ret : 0x%x", ret);
3222 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3224 int ret = CAMERA_ERROR_NONE;
3225 camera_cli_s *pc = (camera_cli_s *)camera;
3226 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3228 if (!pc || !pc->cb_info || !width || !height) {
3229 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3230 return CAMERA_ERROR_INVALID_PARAMETER;
3233 CAM_LOG_INFO("Enter");
3235 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3237 if (ret == CAMERA_ERROR_NONE) {
3238 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3239 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3242 CAM_LOG_INFO("ret : 0x%x", ret);
3248 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3250 int ret = CAMERA_ERROR_NONE;
3251 int set_rotation = (int)rotation;
3252 camera_cli_s *pc = (camera_cli_s *)camera;
3253 camera_msg_param param;
3255 if (!pc || !pc->cb_info) {
3256 CAM_LOG_ERROR("NULL handle");
3257 return CAMERA_ERROR_INVALID_PARAMETER;
3260 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3261 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3262 if (ret != MM_ERROR_NONE) {
3263 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3264 return CAMERA_ERROR_INVALID_OPERATION;
3268 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3270 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3276 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3278 int ret = CAMERA_ERROR_NONE;
3279 camera_cli_s *pc = (camera_cli_s *)camera;
3281 if (!pc || !pc->cb_info || !rotation) {
3282 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3283 return CAMERA_ERROR_INVALID_PARAMETER;
3286 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3288 if (ret == CAMERA_ERROR_NONE)
3289 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3295 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3297 int ret = CAMERA_ERROR_NONE;
3298 int set_flip = (int)flip;
3299 camera_cli_s *pc = (camera_cli_s *)camera;
3300 camera_msg_param param;
3302 if (!pc || !pc->cb_info) {
3303 CAM_LOG_ERROR("NULL handle");
3304 return CAMERA_ERROR_INVALID_PARAMETER;
3307 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3308 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3309 if (ret != MM_ERROR_NONE) {
3310 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3311 return CAMERA_ERROR_INVALID_OPERATION;
3315 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3317 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3323 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3325 int ret = CAMERA_ERROR_NONE;
3326 camera_cli_s *pc = (camera_cli_s *)camera;
3328 if (!pc || !pc->cb_info || !flip) {
3329 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3330 return CAMERA_ERROR_INVALID_PARAMETER;
3333 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3335 if (ret == CAMERA_ERROR_NONE)
3336 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3342 int camera_set_display_visible(camera_h camera, bool visible)
3344 int ret = CAMERA_ERROR_NONE;
3345 int set_visible = (int)visible;
3346 camera_cli_s *pc = (camera_cli_s *)camera;
3347 camera_msg_param param;
3349 if (!pc || !pc->cb_info) {
3350 CAM_LOG_ERROR("NULL handle");
3351 return CAMERA_ERROR_INVALID_PARAMETER;
3354 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3355 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3356 if (ret != MM_ERROR_NONE) {
3357 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3358 return CAMERA_ERROR_INVALID_OPERATION;
3362 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3364 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3370 int camera_is_display_visible(camera_h camera, bool *visible)
3372 int ret = CAMERA_ERROR_NONE;
3373 camera_cli_s *pc = (camera_cli_s *)camera;
3375 if (!pc || !pc->cb_info || !visible) {
3376 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3377 return CAMERA_ERROR_INVALID_PARAMETER;
3380 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3382 if (ret == CAMERA_ERROR_NONE)
3383 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3389 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3391 int ret = CAMERA_ERROR_NONE;
3392 int set_mode = (int)mode;
3393 camera_cli_s *pc = (camera_cli_s *)camera;
3394 camera_msg_param param;
3396 if (!pc || !pc->cb_info) {
3397 CAM_LOG_ERROR("NULL handle");
3398 return CAMERA_ERROR_INVALID_PARAMETER;
3401 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3402 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3403 if (ret != MM_ERROR_NONE) {
3404 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3405 return CAMERA_ERROR_INVALID_OPERATION;
3409 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3411 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3417 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3419 int ret = CAMERA_ERROR_NONE;
3420 camera_cli_s *pc = (camera_cli_s *)camera;
3422 if (!pc || !pc->cb_info || !mode) {
3423 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3424 return CAMERA_ERROR_INVALID_PARAMETER;
3427 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3429 if (ret == CAMERA_ERROR_NONE)
3430 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3436 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3438 int ret = CAMERA_ERROR_NONE;
3439 int set_hint = (int)hint;
3440 camera_cli_s *pc = (camera_cli_s *)camera;
3441 camera_msg_param param;
3443 if (!pc || !pc->cb_info) {
3444 CAM_LOG_ERROR("NULL handle");
3445 return CAMERA_ERROR_INVALID_PARAMETER;
3448 CAM_LOG_INFO("Enter - hint %d", set_hint);
3450 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3452 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3458 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3460 int ret = CAMERA_ERROR_NONE;
3461 camera_cli_s *pc = (camera_cli_s *)camera;
3462 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3464 if (!pc || !pc->cb_info || !hint) {
3465 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3466 return CAMERA_ERROR_INVALID_PARAMETER;
3469 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3471 if (ret == CAMERA_ERROR_NONE) {
3472 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3473 CAM_LOG_INFO("display reuse hint %d", *hint);
3480 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3482 int ret = CAMERA_ERROR_NONE;
3483 camera_cli_s *pc = (camera_cli_s *)camera;
3484 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3486 if (!pc || !pc->cb_info || !width || !height) {
3487 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3488 return CAMERA_ERROR_INVALID_PARAMETER;
3491 CAM_LOG_INFO("Enter");
3493 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3495 if (ret == CAMERA_ERROR_NONE) {
3496 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3497 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3500 CAM_LOG_INFO("ret : 0x%x", ret);
3506 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3508 int ret = CAMERA_ERROR_NONE;
3509 camera_cli_s *pc = (camera_cli_s *)camera;
3510 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3512 if (!pc || !pc->cb_info || !format) {
3513 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3514 return CAMERA_ERROR_INVALID_PARAMETER;
3517 CAM_LOG_INFO("Enter");
3519 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3521 if (ret == CAMERA_ERROR_NONE)
3522 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3524 CAM_LOG_INFO("ret : 0x%x", ret);
3530 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3532 int ret = CAMERA_ERROR_NONE;
3533 camera_cli_s *pc = (camera_cli_s *)camera;
3534 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3536 if (!pc || !pc->cb_info || !format) {
3537 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3538 return CAMERA_ERROR_INVALID_PARAMETER;
3541 CAM_LOG_INFO("Enter");
3543 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3545 if (ret == CAMERA_ERROR_NONE)
3546 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3548 CAM_LOG_INFO("ret : 0x%x", ret);
3554 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3556 int ret = CAMERA_ERROR_NONE;
3557 camera_cli_s *pc = (camera_cli_s *)camera;
3558 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3560 if (!pc || !pc->cb_info || !facing_direction) {
3561 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3562 return CAMERA_ERROR_INVALID_PARAMETER;
3565 CAM_LOG_INFO("Enter");
3567 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3569 if (ret == CAMERA_ERROR_NONE)
3570 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3572 CAM_LOG_INFO("ret : 0x%x", ret);
3578 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3580 int ret = CAMERA_ERROR_NONE;
3581 camera_cli_s *pc = (camera_cli_s *)camera;
3582 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3584 if (!pc || !pc->cb_info || !callback) {
3585 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3586 return CAMERA_ERROR_INVALID_PARAMETER;
3589 CAM_LOG_INFO("Enter");
3591 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3593 if (ret == CAMERA_ERROR_NONE) {
3594 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3596 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3597 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3599 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3601 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3604 CAM_LOG_INFO("ret : 0x%x", ret);
3610 int camera_unset_preview_cb(camera_h camera)
3612 int ret = CAMERA_ERROR_NONE;
3613 camera_cli_s *pc = (camera_cli_s *)camera;
3614 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3616 if (!pc || !pc->cb_info) {
3617 CAM_LOG_ERROR("NULL handle");
3618 return CAMERA_ERROR_INVALID_PARAMETER;
3621 CAM_LOG_INFO("Enter");
3623 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3625 if (ret == CAMERA_ERROR_NONE) {
3626 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3628 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3629 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3631 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3633 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3636 CAM_LOG_INFO("ret : 0x%x", ret);
3642 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3644 int ret = CAMERA_ERROR_NONE;
3645 camera_cli_s *pc = (camera_cli_s *)camera;
3646 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3648 if (!pc || !pc->cb_info) {
3649 CAM_LOG_ERROR("NULL handle");
3650 return CAMERA_ERROR_INVALID_PARAMETER;
3653 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3654 CAM_LOG_ERROR("NOT SUPPORTED");
3655 return CAMERA_ERROR_NOT_SUPPORTED;
3658 if (callback == NULL) {
3659 CAM_LOG_ERROR("NULL callback");
3660 return CAMERA_ERROR_INVALID_PARAMETER;
3663 CAM_LOG_INFO("Enter");
3665 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3667 if (ret == CAMERA_ERROR_NONE) {
3668 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3673 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3676 CAM_LOG_INFO("ret : 0x%x", ret);
3682 int camera_unset_media_packet_preview_cb(camera_h camera)
3684 int ret = CAMERA_ERROR_NONE;
3685 camera_cli_s *pc = (camera_cli_s *)camera;
3686 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3688 if (!pc || !pc->cb_info) {
3689 CAM_LOG_ERROR("NULL handle");
3690 return CAMERA_ERROR_INVALID_PARAMETER;
3693 CAM_LOG_INFO("Enter");
3695 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3697 if (ret == CAMERA_ERROR_NONE) {
3698 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3700 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3701 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3703 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3706 CAM_LOG_INFO("ret : 0x%x", ret);
3712 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3714 int ret = CAMERA_ERROR_NONE;
3715 camera_cli_s *pc = (camera_cli_s *)camera;
3716 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3718 if (!pc || !pc->cb_info || !callback) {
3719 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3720 return CAMERA_ERROR_INVALID_PARAMETER;
3723 CAM_LOG_INFO("Enter");
3725 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3727 if (ret == CAMERA_ERROR_NONE) {
3728 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3730 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3731 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3733 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3736 CAM_LOG_INFO("ret : 0x%x", ret);
3742 int camera_unset_state_changed_cb(camera_h camera)
3744 int ret = CAMERA_ERROR_NONE;
3745 camera_cli_s *pc = (camera_cli_s *)camera;
3746 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3748 if (!pc || !pc->cb_info) {
3749 CAM_LOG_ERROR("NULL handle");
3750 return CAMERA_ERROR_INVALID_PARAMETER;
3753 CAM_LOG_INFO("Enter");
3755 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3757 if (ret == CAMERA_ERROR_NONE) {
3758 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3760 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3761 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3763 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3766 CAM_LOG_INFO("ret : 0x%x", ret);
3772 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3774 int ret = CAMERA_ERROR_NONE;
3775 camera_cli_s *pc = (camera_cli_s *)camera;
3776 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3778 if (!pc || !pc->cb_info || !callback) {
3779 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3780 return CAMERA_ERROR_INVALID_PARAMETER;
3783 CAM_LOG_INFO("Enter");
3785 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3787 if (ret == CAMERA_ERROR_NONE) {
3788 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3790 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3791 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3793 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3796 CAM_LOG_INFO("ret : 0x%x", ret);
3802 int camera_unset_interrupted_cb(camera_h camera)
3804 int ret = CAMERA_ERROR_NONE;
3805 camera_cli_s *pc = (camera_cli_s *)camera;
3806 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3808 if (!pc || !pc->cb_info) {
3809 CAM_LOG_ERROR("NULL handle");
3810 return CAMERA_ERROR_INVALID_PARAMETER;
3813 CAM_LOG_INFO("Enter");
3815 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3817 if (ret == CAMERA_ERROR_NONE) {
3818 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3820 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3821 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3823 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3826 CAM_LOG_INFO("ret : 0x%x", ret);
3832 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3834 int ret = CAMERA_ERROR_NONE;
3835 camera_cli_s *pc = (camera_cli_s *)camera;
3836 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3838 if (!pc || !pc->cb_info || !callback) {
3839 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3840 return CAMERA_ERROR_INVALID_PARAMETER;
3843 CAM_LOG_INFO("Enter");
3845 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3847 if (ret == CAMERA_ERROR_NONE) {
3848 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3850 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3851 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3853 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3856 CAM_LOG_INFO("ret : 0x%x", ret);
3862 int camera_unset_interrupt_started_cb(camera_h camera)
3864 int ret = CAMERA_ERROR_NONE;
3865 camera_cli_s *pc = (camera_cli_s *)camera;
3866 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3868 if (!pc || !pc->cb_info) {
3869 CAM_LOG_ERROR("NULL handle");
3870 return CAMERA_ERROR_INVALID_PARAMETER;
3873 CAM_LOG_INFO("Enter");
3875 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3877 if (ret == CAMERA_ERROR_NONE) {
3878 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3880 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3881 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3883 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3886 CAM_LOG_INFO("ret : 0x%x", ret);
3892 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3894 int ret = CAMERA_ERROR_NONE;
3895 camera_cli_s *pc = (camera_cli_s *)camera;
3896 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3898 if (!pc || !pc->cb_info || !callback) {
3899 CAM_LOG_ERROR("NULL pointer %p %p", pc, 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_FOCUS_CHANGE]);
3910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3913 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3916 CAM_LOG_INFO("ret : 0x%x", ret);
3922 int camera_unset_focus_changed_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_FOCUS_CHANGED_CB;
3928 if (!pc || !pc->cb_info) {
3929 CAM_LOG_ERROR("NULL handle");
3930 return CAMERA_ERROR_INVALID_PARAMETER;
3933 CAM_LOG_INFO("Enter");
3935 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3937 if (ret == CAMERA_ERROR_NONE) {
3938 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3940 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3941 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3943 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3946 CAM_LOG_INFO("ret : 0x%x", ret);
3952 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3954 int ret = CAMERA_ERROR_NONE;
3955 camera_cli_s *pc = (camera_cli_s *)camera;
3956 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3958 if (!pc || !pc->cb_info || !callback) {
3959 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3960 return CAMERA_ERROR_INVALID_PARAMETER;
3963 CAM_LOG_INFO("Enter");
3965 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3967 if (ret == CAMERA_ERROR_NONE) {
3968 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3970 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3971 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3973 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3976 CAM_LOG_INFO("ret : 0x%x", ret);
3982 int camera_unset_error_cb(camera_h camera)
3984 int ret = CAMERA_ERROR_NONE;
3985 camera_cli_s *pc = (camera_cli_s *)camera;
3986 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3988 if (!pc || !pc->cb_info) {
3989 CAM_LOG_ERROR("NULL handle");
3990 return CAMERA_ERROR_INVALID_PARAMETER;
3993 CAM_LOG_INFO("Enter");
3995 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3997 if (ret == CAMERA_ERROR_NONE) {
3998 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4000 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4001 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4003 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4006 CAM_LOG_INFO("ret : 0x%x", ret);
4012 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4014 int ret = CAMERA_ERROR_NONE;
4015 camera_cli_s *pc = (camera_cli_s *)camera;
4016 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4018 if (!pc || !pc->cb_info || !foreach_cb) {
4019 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4020 return CAMERA_ERROR_INVALID_PARAMETER;
4023 CAM_LOG_INFO("Enter");
4025 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4026 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4028 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4030 CAM_LOG_INFO("ret : 0x%x", ret);
4036 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4038 int ret = CAMERA_ERROR_NONE;
4039 camera_cli_s *pc = (camera_cli_s *)camera;
4040 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4042 if (!pc || !pc->cb_info || !foreach_cb) {
4043 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4044 return CAMERA_ERROR_INVALID_PARAMETER;
4047 CAM_LOG_INFO("Enter");
4049 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4050 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4052 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4054 CAM_LOG_INFO("ret : 0x%x", ret);
4060 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4062 int ret = CAMERA_ERROR_NONE;
4063 camera_cli_s *pc = (camera_cli_s *)camera;
4064 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4066 if (!pc || !pc->cb_info || !foreach_cb) {
4067 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4068 return CAMERA_ERROR_INVALID_PARAMETER;
4071 CAM_LOG_INFO("Enter");
4073 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4074 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4076 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4078 CAM_LOG_INFO("ret : 0x%x", ret);
4084 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4086 int ret = CAMERA_ERROR_NONE;
4087 camera_cli_s *pc = (camera_cli_s *)camera;
4088 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4090 if (!pc || !pc->cb_info || !foreach_cb) {
4091 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4092 return CAMERA_ERROR_INVALID_PARAMETER;
4095 CAM_LOG_INFO("Enter");
4097 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4098 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4100 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4102 CAM_LOG_INFO("ret : 0x%x", ret);
4108 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4110 int ret = CAMERA_ERROR_NONE;
4111 camera_cli_s *pc = (camera_cli_s *)camera;
4112 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4114 if (!pc || !pc->cb_info || !width || !height) {
4115 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4116 return CAMERA_ERROR_INVALID_PARAMETER;
4119 CAM_LOG_INFO("Enter");
4120 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4122 if (ret == CAMERA_ERROR_NONE) {
4123 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4124 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4127 CAM_LOG_INFO("ret : 0x%x", ret);
4133 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4135 int ret = CAMERA_ERROR_NONE;
4136 camera_cli_s *pc = (camera_cli_s *)camera;
4137 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4139 if (!pc || !pc->cb_info || !angle) {
4140 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4141 return CAMERA_ERROR_INVALID_PARAMETER;
4144 CAM_LOG_INFO("Enter");
4146 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4148 if (ret == CAMERA_ERROR_NONE)
4149 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4151 CAM_LOG_INFO("ret : 0x%x", ret);
4157 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4159 int ret = CAMERA_ERROR_NONE;
4160 camera_cli_s *pc = (camera_cli_s *)camera;
4161 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4162 camera_msg_param param;
4163 int set_mode = (int)mode;
4165 if (!pc || !pc->cb_info) {
4166 CAM_LOG_ERROR("NULL handle");
4167 return CAMERA_ERROR_INVALID_PARAMETER;
4170 CAM_LOG_INFO("Enter");
4172 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4174 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4176 CAM_LOG_INFO("ret : 0x%x", ret);
4182 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4184 int ret = CAMERA_ERROR_NONE;
4185 camera_cli_s *pc = (camera_cli_s *)camera;
4186 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4188 if (!pc || !pc->cb_info || !mode) {
4189 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
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 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4200 CAM_LOG_INFO("ret : 0x%x", ret);
4206 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4208 int ret = CAMERA_ERROR_NONE;
4209 camera_cli_s *pc = (camera_cli_s *)camera;
4210 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4212 if (!pc || !pc->cb_info || !foreach_cb) {
4213 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4214 return CAMERA_ERROR_INVALID_PARAMETER;
4217 CAM_LOG_INFO("Enter");
4219 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4220 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4222 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4224 CAM_LOG_INFO("Finish, return :%x", ret);
4230 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4232 int ret = CAMERA_ERROR_NONE;
4233 camera_cli_s *pc = (camera_cli_s *)camera;
4234 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4235 camera_msg_param param;
4236 int set_fps = (int)fps;
4238 if (!pc || !pc->cb_info) {
4239 CAM_LOG_ERROR("NULL handle");
4240 return CAMERA_ERROR_INVALID_PARAMETER;
4243 CAM_LOG_INFO("Enter");
4245 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4247 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4249 CAM_LOG_INFO("ret : 0x%x", ret);
4255 int camera_attr_set_image_quality(camera_h camera, int quality)
4257 int ret = CAMERA_ERROR_NONE;
4258 camera_cli_s *pc = (camera_cli_s *)camera;
4259 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4260 camera_msg_param param;
4262 if (!pc || !pc->cb_info) {
4263 CAM_LOG_ERROR("NULL handle");
4264 return CAMERA_ERROR_INVALID_PARAMETER;
4267 CAM_LOG_INFO("Enter");
4269 CAMERA_MSG_PARAM_SET(param, INT, quality);
4271 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4273 CAM_LOG_INFO("ret : 0x%x", ret);
4279 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4281 int ret = CAMERA_ERROR_NONE;
4282 camera_cli_s *pc = (camera_cli_s *)camera;
4283 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4285 if (!pc || !pc->cb_info || !fps) {
4286 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4287 return CAMERA_ERROR_INVALID_PARAMETER;
4290 CAM_LOG_INFO("Enter");
4292 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4294 if (ret == CAMERA_ERROR_NONE)
4295 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4297 CAM_LOG_INFO("ret : 0x%x", ret);
4303 int camera_attr_get_image_quality(camera_h camera, int *quality)
4305 int ret = CAMERA_ERROR_NONE;
4306 camera_cli_s *pc = (camera_cli_s *)camera;
4307 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4309 if (!pc || !pc->cb_info || !quality) {
4310 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4311 return CAMERA_ERROR_INVALID_PARAMETER;
4314 CAM_LOG_INFO("Enter");
4316 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4318 if (ret == CAMERA_ERROR_NONE)
4319 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4321 CAM_LOG_INFO("ret : 0x%x", ret);
4327 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4329 int ret = CAMERA_ERROR_NONE;
4330 camera_cli_s *pc = (camera_cli_s *)camera;
4331 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4333 if (!pc || !pc->cb_info || !bitrate) {
4334 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4335 return CAMERA_ERROR_INVALID_PARAMETER;
4338 CAM_LOG_INFO("Enter");
4340 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4342 if (ret == CAMERA_ERROR_NONE)
4343 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4345 CAM_LOG_INFO("ret : 0x%x", ret);
4351 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4353 int ret = CAMERA_ERROR_NONE;
4354 camera_cli_s *pc = (camera_cli_s *)camera;
4355 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4356 camera_msg_param param;
4357 int set_bitrate = bitrate;
4359 if (!pc || !pc->cb_info) {
4360 CAM_LOG_ERROR("NULL handle");
4361 return CAMERA_ERROR_INVALID_PARAMETER;
4364 CAM_LOG_INFO("Enter");
4366 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4368 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4370 CAM_LOG_INFO("ret : 0x%x", ret);
4376 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4378 int ret = CAMERA_ERROR_NONE;
4379 camera_cli_s *pc = (camera_cli_s *)camera;
4380 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4382 if (!pc || !pc->cb_info || !interval) {
4383 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4384 return CAMERA_ERROR_INVALID_PARAMETER;
4387 CAM_LOG_INFO("Enter");
4389 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4391 if (ret == CAMERA_ERROR_NONE)
4392 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4394 CAM_LOG_INFO("ret : 0x%x", ret);
4400 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4402 int ret = CAMERA_ERROR_NONE;
4403 camera_cli_s *pc = (camera_cli_s *)camera;
4404 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4405 camera_msg_param param;
4406 int set_gop_interval = interval;
4408 if (!pc || !pc->cb_info) {
4409 CAM_LOG_ERROR("NULL handle");
4410 return CAMERA_ERROR_INVALID_PARAMETER;
4413 CAM_LOG_INFO("Enter");
4415 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4417 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4419 CAM_LOG_INFO("ret : 0x%x", ret);
4425 int camera_attr_set_zoom(camera_h camera, int zoom)
4427 int ret = CAMERA_ERROR_NONE;
4428 camera_cli_s *pc = (camera_cli_s *)camera;
4429 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4430 camera_msg_param param;
4432 if (!pc || !pc->cb_info) {
4433 CAM_LOG_ERROR("NULL handle");
4434 return CAMERA_ERROR_INVALID_PARAMETER;
4437 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4439 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4441 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4443 CAM_LOG_INFO("ret : 0x%x", ret);
4449 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4451 int ret = CAMERA_ERROR_NONE;
4452 camera_cli_s *pc = (camera_cli_s *)camera;
4453 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4454 camera_msg_param param;
4455 int set_mode = (int)mode;
4457 if (!pc || !pc->cb_info) {
4458 CAM_LOG_ERROR("NULL handle");
4459 return CAMERA_ERROR_INVALID_PARAMETER;
4462 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4464 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4466 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4472 int camera_attr_set_af_area(camera_h camera, int x, int y)
4474 int ret = CAMERA_ERROR_NONE;
4475 camera_cli_s *pc = (camera_cli_s *)camera;
4476 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4477 camera_msg_param param;
4480 if (!pc || !pc->cb_info) {
4481 CAM_LOG_ERROR("NULL handle");
4482 return CAMERA_ERROR_INVALID_PARAMETER;
4485 CAM_LOG_INFO("Enter - %d,%d", x, y);
4487 value = (x << 16) | y;
4488 CAMERA_MSG_PARAM_SET(param, INT, value);
4490 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4492 CAM_LOG_INFO("ret : 0x%x", ret);
4498 int camera_attr_clear_af_area(camera_h camera)
4500 int ret = CAMERA_ERROR_NONE;
4501 camera_cli_s *pc = (camera_cli_s *)camera;
4502 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4504 if (!pc || !pc->cb_info) {
4505 CAM_LOG_ERROR("NULL handle");
4506 return CAMERA_ERROR_INVALID_PARAMETER;
4509 CAM_LOG_INFO("Enter");
4511 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4513 CAM_LOG_INFO("ret : 0x%x", ret);
4519 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4521 int ret = CAMERA_ERROR_NONE;
4522 camera_cli_s *pc = (camera_cli_s *)camera;
4523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4524 camera_msg_param param;
4525 int set_mode = (int)mode;
4527 if (!pc || !pc->cb_info) {
4528 CAM_LOG_ERROR("NULL handle");
4529 return CAMERA_ERROR_INVALID_PARAMETER;
4532 CAM_LOG_INFO("Enter");
4534 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4536 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4538 CAM_LOG_INFO("ret : 0x%x", ret);
4544 int camera_attr_set_exposure(camera_h camera, int value)
4546 int ret = CAMERA_ERROR_NONE;
4547 camera_cli_s *pc = (camera_cli_s *)camera;
4548 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4549 camera_msg_param param;
4551 if (!pc || !pc->cb_info) {
4552 CAM_LOG_ERROR("NULL handle");
4553 return CAMERA_ERROR_INVALID_PARAMETER;
4556 CAM_LOG_INFO("Enter");
4558 CAMERA_MSG_PARAM_SET(param, INT, value);
4560 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4562 CAM_LOG_INFO("ret : 0x%x", ret);
4568 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4570 int ret = CAMERA_ERROR_NONE;
4571 camera_cli_s *pc = (camera_cli_s *)camera;
4572 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4573 camera_msg_param param;
4574 int set_iso = (int)iso;
4576 if (!pc || !pc->cb_info) {
4577 CAM_LOG_ERROR("NULL handle");
4578 return CAMERA_ERROR_INVALID_PARAMETER;
4581 CAM_LOG_INFO("Enter");
4583 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4585 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4587 CAM_LOG_INFO("ret : 0x%x", ret);
4593 int camera_attr_set_brightness(camera_h camera, int level)
4595 int ret = CAMERA_ERROR_NONE;
4596 camera_cli_s *pc = (camera_cli_s *)camera;
4597 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4598 camera_msg_param param;
4600 if (!pc || !pc->cb_info) {
4601 CAM_LOG_ERROR("NULL handle");
4602 return CAMERA_ERROR_INVALID_PARAMETER;
4605 CAM_LOG_INFO("Enter");
4607 CAMERA_MSG_PARAM_SET(param, INT, level);
4609 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4611 CAM_LOG_INFO("ret : 0x%x", ret);
4617 int camera_attr_set_contrast(camera_h camera, int level)
4619 int ret = CAMERA_ERROR_NONE;
4620 camera_cli_s *pc = (camera_cli_s *)camera;
4621 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4622 camera_msg_param param;
4624 if (!pc || !pc->cb_info) {
4625 CAM_LOG_ERROR("NULL handle");
4626 return CAMERA_ERROR_INVALID_PARAMETER;
4629 CAM_LOG_INFO("Enter");
4631 CAMERA_MSG_PARAM_SET(param, INT, level);
4633 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4635 CAM_LOG_INFO("ret : 0x%x", ret);
4641 int camera_attr_set_hue(camera_h camera, int level)
4643 int ret = CAMERA_ERROR_NONE;
4644 camera_cli_s *pc = (camera_cli_s *)camera;
4645 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4646 camera_msg_param param;
4648 if (!pc || !pc->cb_info) {
4649 CAM_LOG_ERROR("NULL handle");
4650 return CAMERA_ERROR_INVALID_PARAMETER;
4653 CAM_LOG_INFO("Enter");
4655 CAMERA_MSG_PARAM_SET(param, INT, level);
4657 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4659 CAM_LOG_INFO("ret : 0x%x", ret);
4665 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4667 int ret = CAMERA_ERROR_NONE;
4668 camera_cli_s *pc = (camera_cli_s *)camera;
4669 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4670 camera_msg_param param;
4671 int set_whitebalance = (int)wb;
4673 if (!pc || !pc->cb_info) {
4674 CAM_LOG_ERROR("NULL handle");
4675 return CAMERA_ERROR_INVALID_PARAMETER;
4678 CAM_LOG_INFO("Enter");
4680 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4682 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4684 CAM_LOG_INFO("ret : 0x%x", ret);
4690 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4692 int ret = CAMERA_ERROR_NONE;
4693 camera_cli_s *pc = (camera_cli_s *)camera;
4694 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4695 camera_msg_param param;
4696 int set_effect = (int)effect;
4698 if (!pc || !pc->cb_info) {
4699 CAM_LOG_ERROR("NULL handle");
4700 return CAMERA_ERROR_INVALID_PARAMETER;
4703 CAM_LOG_INFO("Enter");
4705 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4707 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4709 CAM_LOG_INFO("ret : 0x%x", ret);
4715 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4717 int ret = CAMERA_ERROR_NONE;
4718 camera_cli_s *pc = (camera_cli_s *)camera;
4719 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4720 camera_msg_param param;
4721 int set_mode = (int)mode;
4723 if (!pc || !pc->cb_info) {
4724 CAM_LOG_ERROR("NULL handle");
4725 return CAMERA_ERROR_INVALID_PARAMETER;
4728 CAM_LOG_INFO("Enter");
4730 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4732 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4734 CAM_LOG_INFO("ret : 0x%x", ret);
4740 int camera_attr_enable_tag(camera_h camera, bool enable)
4742 int ret = CAMERA_ERROR_NONE;
4743 camera_cli_s *pc = (camera_cli_s *)camera;
4744 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4745 camera_msg_param param;
4746 int set_enable = (int)enable;
4748 if (!pc || !pc->cb_info) {
4749 CAM_LOG_ERROR("NULL handle");
4750 return CAMERA_ERROR_INVALID_PARAMETER;
4753 CAM_LOG_INFO("Enter");
4755 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4757 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4759 CAM_LOG_INFO("ret : 0x%x", ret);
4765 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4767 int ret = CAMERA_ERROR_NONE;
4768 camera_cli_s *pc = (camera_cli_s *)camera;
4769 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4770 camera_msg_param param;
4772 if (!pc || !pc->cb_info || !description) {
4773 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4774 return CAMERA_ERROR_INVALID_PARAMETER;
4777 CAM_LOG_INFO("Enter");
4779 CAMERA_MSG_PARAM_SET(param, STRING, description);
4781 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4783 CAM_LOG_INFO("ret : 0x%x", ret);
4789 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4791 int ret = CAMERA_ERROR_NONE;
4792 camera_cli_s *pc = (camera_cli_s *)camera;
4793 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4794 camera_msg_param param;
4795 int set_orientation = (int)orientation;
4797 if (!pc || !pc->cb_info) {
4798 CAM_LOG_ERROR("NULL handle");
4799 return CAMERA_ERROR_INVALID_PARAMETER;
4802 CAM_LOG_INFO("Enter");
4804 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4806 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4808 CAM_LOG_INFO("ret : 0x%x", ret);
4814 int camera_attr_set_tag_software(camera_h camera, const char *software)
4816 int ret = CAMERA_ERROR_NONE;
4817 camera_cli_s *pc = (camera_cli_s *)camera;
4818 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4819 camera_msg_param param;
4821 if (!pc || !pc->cb_info || !software) {
4822 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4823 return CAMERA_ERROR_INVALID_PARAMETER;
4826 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4828 CAMERA_MSG_PARAM_SET(param, STRING, software);
4830 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4832 CAM_LOG_INFO("ret : 0x%x", ret);
4838 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4840 int ret = CAMERA_ERROR_NONE;
4841 camera_cli_s *pc = (camera_cli_s *)camera;
4842 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4843 double set_geotag[3] = {latitude, longitude, altitude};
4848 if (!pc || !pc->cb_info) {
4849 CAM_LOG_ERROR("NULL handle");
4850 return CAMERA_ERROR_INVALID_PARAMETER;
4853 CAM_LOG_INFO("Enter");
4855 length = sizeof(set_geotag) / sizeof(int) + \
4856 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4858 msg = muse_core_msg_new(api,
4859 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4862 CAM_LOG_ERROR("msg creation failed: api %d", api);
4863 return CAMERA_ERROR_OUT_OF_MEMORY;
4866 if (pc->cb_info->is_server_connected) {
4867 __camera_update_api_waiting(pc->cb_info, api, 1);
4869 g_mutex_lock(&pc->cb_info->fd_lock);
4870 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4871 g_mutex_unlock(&pc->cb_info->fd_lock);
4875 CAM_LOG_ERROR("message send failed");
4876 ret = CAMERA_ERROR_INVALID_OPERATION;
4878 ret = __camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4881 __camera_update_api_waiting(pc->cb_info, api, -1);
4883 muse_core_msg_free(msg);
4885 CAM_LOG_INFO("ret : 0x%x", ret);
4891 int camera_attr_remove_geotag(camera_h camera)
4893 int ret = CAMERA_ERROR_NONE;
4894 camera_cli_s *pc = (camera_cli_s *)camera;
4895 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4897 if (!pc || !pc->cb_info) {
4898 CAM_LOG_ERROR("NULL handle");
4899 return CAMERA_ERROR_INVALID_PARAMETER;
4902 CAM_LOG_INFO("Enter");
4904 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4906 CAM_LOG_INFO("ret : 0x%x", ret);
4912 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4914 int ret = CAMERA_ERROR_NONE;
4915 camera_cli_s *pc = (camera_cli_s *)camera;
4916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4917 camera_msg_param param;
4918 int set_mode = (int)mode;
4920 if (!pc || !pc->cb_info) {
4921 CAM_LOG_ERROR("NULL handle");
4922 return CAMERA_ERROR_INVALID_PARAMETER;
4925 CAM_LOG_INFO("Enter");
4927 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4929 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4931 CAM_LOG_INFO("ret : 0x%x", ret);
4937 int camera_attr_get_zoom(camera_h camera, int *zoom)
4939 int ret = CAMERA_ERROR_NONE;
4940 camera_cli_s *pc = (camera_cli_s *)camera;
4941 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4943 if (!pc || !pc->cb_info || !zoom) {
4944 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4945 return CAMERA_ERROR_INVALID_PARAMETER;
4948 CAM_LOG_INFO("Enter");
4950 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4952 if (ret == CAMERA_ERROR_NONE)
4953 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4955 CAM_LOG_INFO("ret : 0x%x", ret);
4961 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4963 int ret = CAMERA_ERROR_NONE;
4964 camera_cli_s *pc = (camera_cli_s *)camera;
4965 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4967 if (!pc || !pc->cb_info || !min || !max) {
4968 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4969 return CAMERA_ERROR_INVALID_PARAMETER;
4972 CAM_LOG_INFO("Enter");
4974 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4976 if (ret == CAMERA_ERROR_NONE) {
4977 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4978 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4981 CAM_LOG_INFO("ret : 0x%x", ret);
4987 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4989 int ret = CAMERA_ERROR_NONE;
4990 camera_cli_s *pc = (camera_cli_s *)camera;
4991 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4993 if (!pc || !pc->cb_info || !mode) {
4994 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4995 return CAMERA_ERROR_INVALID_PARAMETER;
4998 CAM_LOG_INFO("Enter");
5000 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5002 if (ret == CAMERA_ERROR_NONE)
5003 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5005 CAM_LOG_INFO("ret : 0x%x", ret);
5011 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5013 int ret = CAMERA_ERROR_NONE;
5014 camera_cli_s *pc = (camera_cli_s *)camera;
5015 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5017 if (!pc || !pc->cb_info || !mode) {
5018 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5019 return CAMERA_ERROR_INVALID_PARAMETER;
5022 CAM_LOG_INFO("Enter");
5024 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5026 if (ret == CAMERA_ERROR_NONE)
5027 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5029 CAM_LOG_INFO("ret : 0x%x", ret);
5035 int camera_attr_get_exposure(camera_h camera, int *value)
5037 int ret = CAMERA_ERROR_NONE;
5038 camera_cli_s *pc = (camera_cli_s *)camera;
5039 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5041 if (!pc || !pc->cb_info || !value) {
5042 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5043 return CAMERA_ERROR_INVALID_PARAMETER;
5046 CAM_LOG_INFO("Enter");
5048 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5050 if (ret == CAMERA_ERROR_NONE)
5051 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5053 CAM_LOG_INFO("ret : 0x%x", ret);
5059 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5061 int ret = CAMERA_ERROR_NONE;
5062 camera_cli_s *pc = (camera_cli_s *)camera;
5063 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5065 if (!pc || !pc->cb_info || !min || !max) {
5066 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5067 return CAMERA_ERROR_INVALID_PARAMETER;
5070 CAM_LOG_INFO("Enter");
5072 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5074 if (ret == CAMERA_ERROR_NONE) {
5075 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5076 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5079 CAM_LOG_INFO("ret : 0x%x", ret);
5085 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5087 int ret = CAMERA_ERROR_NONE;
5088 camera_cli_s *pc = (camera_cli_s *)camera;
5089 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5091 if (!pc || !pc->cb_info || !iso) {
5092 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5093 return CAMERA_ERROR_INVALID_PARAMETER;
5096 CAM_LOG_INFO("Enter");
5098 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5100 if (ret == CAMERA_ERROR_NONE)
5101 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5103 CAM_LOG_INFO("ret : 0x%x", ret);
5109 int camera_attr_get_brightness(camera_h camera, int *level)
5111 int ret = CAMERA_ERROR_NONE;
5112 camera_cli_s *pc = (camera_cli_s *)camera;
5113 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5115 if (!pc || !pc->cb_info || !level) {
5116 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5117 return CAMERA_ERROR_INVALID_PARAMETER;
5120 CAM_LOG_INFO("Enter");
5122 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5124 if (ret == CAMERA_ERROR_NONE)
5125 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5127 CAM_LOG_INFO("ret : 0x%x", ret);
5133 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5135 int ret = CAMERA_ERROR_NONE;
5136 camera_cli_s *pc = (camera_cli_s *)camera;
5137 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5139 if (!pc || !pc->cb_info || !min || !max) {
5140 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5141 return CAMERA_ERROR_INVALID_PARAMETER;
5144 CAM_LOG_INFO("Enter");
5146 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5148 if (ret == CAMERA_ERROR_NONE) {
5149 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5150 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5153 CAM_LOG_INFO("ret : 0x%x", ret);
5159 int camera_attr_get_contrast(camera_h camera, int *level)
5161 int ret = CAMERA_ERROR_NONE;
5162 camera_cli_s *pc = (camera_cli_s *)camera;
5163 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5165 if (!pc || !pc->cb_info || !level) {
5166 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5167 return CAMERA_ERROR_INVALID_PARAMETER;
5170 CAM_LOG_INFO("Enter");
5172 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5174 if (ret == CAMERA_ERROR_NONE)
5175 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5177 CAM_LOG_INFO("ret : 0x%x", ret);
5183 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5185 int ret = CAMERA_ERROR_NONE;
5186 camera_cli_s *pc = (camera_cli_s *)camera;
5187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5189 if (!pc || !pc->cb_info || !min || !max) {
5190 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5191 return CAMERA_ERROR_INVALID_PARAMETER;
5194 CAM_LOG_INFO("Enter");
5196 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5198 if (ret == CAMERA_ERROR_NONE) {
5199 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5200 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5201 CAM_LOG_INFO("min %d, max %d", *min, *max);
5204 CAM_LOG_INFO("ret : 0x%x", ret);
5210 int camera_attr_get_hue(camera_h camera, int *level)
5212 int ret = CAMERA_ERROR_NONE;
5213 camera_cli_s *pc = (camera_cli_s *)camera;
5214 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5216 if (!pc || !pc->cb_info || !level) {
5217 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5218 return CAMERA_ERROR_INVALID_PARAMETER;
5221 CAM_LOG_INFO("Enter");
5223 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5225 if (ret == CAMERA_ERROR_NONE)
5226 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5228 CAM_LOG_INFO("ret : 0x%x", ret);
5234 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5236 int ret = CAMERA_ERROR_NONE;
5237 camera_cli_s *pc = (camera_cli_s *)camera;
5238 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5240 if (!pc || !pc->cb_info || !min || !max) {
5241 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5242 return CAMERA_ERROR_INVALID_PARAMETER;
5245 CAM_LOG_INFO("Enter");
5247 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5249 if (ret == CAMERA_ERROR_NONE) {
5250 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5251 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5252 CAM_LOG_INFO("min %d, max %d", *min, *max);
5255 CAM_LOG_INFO("ret : 0x%x", ret);
5261 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5263 int ret = CAMERA_ERROR_NONE;
5264 camera_cli_s *pc = (camera_cli_s *)camera;
5265 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5267 if (!pc || !pc->cb_info || !wb) {
5268 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5269 return CAMERA_ERROR_INVALID_PARAMETER;
5272 CAM_LOG_INFO("Enter");
5274 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5276 if (ret == CAMERA_ERROR_NONE)
5277 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5279 CAM_LOG_INFO("ret : 0x%x", ret);
5285 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5287 int ret = CAMERA_ERROR_NONE;
5288 camera_cli_s *pc = (camera_cli_s *)camera;
5289 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5291 if (!pc || !pc->cb_info || !effect) {
5292 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5293 return CAMERA_ERROR_INVALID_PARAMETER;
5296 CAM_LOG_INFO("Enter");
5298 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5300 if (ret == CAMERA_ERROR_NONE)
5301 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5303 CAM_LOG_INFO("ret : 0x%x", ret);
5309 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5311 int ret = CAMERA_ERROR_NONE;
5312 camera_cli_s *pc = (camera_cli_s *)camera;
5313 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5315 if (!pc || !pc->cb_info || !mode) {
5316 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5317 return CAMERA_ERROR_INVALID_PARAMETER;
5320 CAM_LOG_INFO("Enter");
5322 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5324 if (ret == CAMERA_ERROR_NONE)
5325 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5327 CAM_LOG_INFO("ret : 0x%x", ret);
5333 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5335 int ret = CAMERA_ERROR_NONE;
5336 camera_cli_s *pc = (camera_cli_s *)camera;
5337 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5339 if (!pc || !pc->cb_info || !enable) {
5340 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5341 return CAMERA_ERROR_INVALID_PARAMETER;
5344 CAM_LOG_INFO("Enter");
5346 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5348 if (ret == CAMERA_ERROR_NONE)
5349 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5351 CAM_LOG_INFO("ret : 0x%x", ret);
5357 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5359 int ret = CAMERA_ERROR_NONE;
5360 camera_cli_s *pc = (camera_cli_s *)camera;
5361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5363 if (!pc || !pc->cb_info || !description) {
5364 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5365 return CAMERA_ERROR_INVALID_PARAMETER;
5368 CAM_LOG_INFO("Enter");
5370 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5372 if (ret == CAMERA_ERROR_NONE)
5373 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5375 CAM_LOG_INFO("ret : 0x%x", ret);
5381 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5383 int ret = CAMERA_ERROR_NONE;
5384 camera_cli_s *pc = (camera_cli_s *)camera;
5385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5387 if (!pc || !pc->cb_info || !orientation) {
5388 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5389 return CAMERA_ERROR_INVALID_PARAMETER;
5392 CAM_LOG_INFO("Enter");
5394 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5396 if (ret == CAMERA_ERROR_NONE)
5397 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5399 CAM_LOG_INFO("ret : 0x%x", ret);
5405 int camera_attr_get_tag_software(camera_h camera, char **software)
5407 int ret = CAMERA_ERROR_NONE;
5408 camera_cli_s *pc = (camera_cli_s *)camera;
5409 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5411 if (!pc || !pc->cb_info || !software) {
5412 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5413 return CAMERA_ERROR_INVALID_PARAMETER;
5416 CAM_LOG_INFO("Enter");
5418 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5420 if (ret == CAMERA_ERROR_NONE)
5421 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5423 CAM_LOG_INFO("ret : 0x%x", ret);
5429 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5431 int ret = CAMERA_ERROR_NONE;
5432 camera_cli_s *pc = (camera_cli_s *)camera;
5433 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5435 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5436 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5437 return CAMERA_ERROR_INVALID_PARAMETER;
5440 CAM_LOG_INFO("Enter");
5442 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5444 if (ret == CAMERA_ERROR_NONE) {
5445 *latitude = pc->cb_info->get_geotag[0];
5446 *longitude = pc->cb_info->get_geotag[1];
5447 *altitude = pc->cb_info->get_geotag[2];
5450 CAM_LOG_INFO("ret : 0x%x", ret);
5456 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5458 int ret = CAMERA_ERROR_NONE;
5459 camera_cli_s *pc = (camera_cli_s *)camera;
5460 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5462 if (!pc || !pc->cb_info || !mode) {
5463 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5464 return CAMERA_ERROR_INVALID_PARAMETER;
5467 CAM_LOG_INFO("Enter");
5469 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5471 if (ret == CAMERA_ERROR_NONE)
5472 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5474 CAM_LOG_INFO("ret : 0x%x", ret);
5480 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5482 int ret = CAMERA_ERROR_NONE;
5483 int get_flash_state = 0;
5486 CAM_LOG_ERROR("NULL pointer");
5487 return CAMERA_ERROR_INVALID_PARAMETER;
5490 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5491 (int)device, "get_flash_state", &get_flash_state);
5493 if (ret == CAMERA_ERROR_NONE) {
5494 *state = (camera_flash_state_e)get_flash_state;
5495 CAM_LOG_INFO("flash state %d", *state);
5497 CAM_LOG_ERROR("failed 0x%x", ret);
5504 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5506 int ret = CAMERA_ERROR_NONE;
5507 camera_cli_s *pc = (camera_cli_s *)camera;
5508 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5510 if (!pc || !pc->cb_info || !foreach_cb) {
5511 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5512 return CAMERA_ERROR_INVALID_PARAMETER;
5515 CAM_LOG_INFO("Enter");
5517 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5518 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5520 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5522 CAM_LOG_INFO("ret : 0x%x", ret);
5528 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5530 int ret = CAMERA_ERROR_NONE;
5531 camera_cli_s *pc = (camera_cli_s *)camera;
5532 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5534 if (!pc || !pc->cb_info || !foreach_cb) {
5535 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5536 return CAMERA_ERROR_INVALID_PARAMETER;
5539 CAM_LOG_INFO("Enter");
5541 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5542 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5544 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5546 CAM_LOG_INFO("ret : 0x%x", ret);
5552 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5554 int ret = CAMERA_ERROR_NONE;
5555 camera_cli_s *pc = (camera_cli_s *)camera;
5556 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5558 if (!pc || !pc->cb_info || !foreach_cb) {
5559 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5560 return CAMERA_ERROR_INVALID_PARAMETER;
5563 CAM_LOG_INFO("Enter");
5565 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5566 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5568 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5570 CAM_LOG_INFO("ret : 0x%x", ret);
5576 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5578 int ret = CAMERA_ERROR_NONE;
5579 camera_cli_s *pc = (camera_cli_s *)camera;
5580 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5582 if (!pc || !pc->cb_info || !foreach_cb) {
5583 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5584 return CAMERA_ERROR_INVALID_PARAMETER;
5587 CAM_LOG_INFO("Enter");
5589 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5590 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5592 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5594 CAM_LOG_INFO("ret : 0x%x", ret);
5600 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5602 int ret = CAMERA_ERROR_NONE;
5603 camera_cli_s *pc = (camera_cli_s *)camera;
5604 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5606 if (!pc || !pc->cb_info || !foreach_cb) {
5607 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5608 return CAMERA_ERROR_INVALID_PARAMETER;
5611 CAM_LOG_INFO("Enter");
5613 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5614 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5616 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5618 CAM_LOG_INFO("ret : 0x%x", ret);
5624 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5626 int ret = CAMERA_ERROR_NONE;
5627 camera_cli_s *pc = (camera_cli_s *)camera;
5628 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5630 if (!pc || !pc->cb_info || !foreach_cb) {
5631 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5632 return CAMERA_ERROR_INVALID_PARAMETER;
5635 CAM_LOG_INFO("Enter");
5637 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5638 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5640 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5642 CAM_LOG_INFO("ret : 0x%x", ret);
5648 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5650 int ret = CAMERA_ERROR_NONE;
5651 camera_cli_s *pc = (camera_cli_s *)camera;
5652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5654 if (!pc || !pc->cb_info || !foreach_cb) {
5655 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5656 return CAMERA_ERROR_INVALID_PARAMETER;
5659 CAM_LOG_INFO("Enter");
5661 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5662 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5664 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5666 CAM_LOG_INFO("ret : 0x%x", ret);
5672 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5674 int ret = CAMERA_ERROR_NONE;
5675 camera_cli_s *pc = (camera_cli_s *)camera;
5676 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5678 if (!pc || !pc->cb_info || !foreach_cb) {
5679 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5680 return CAMERA_ERROR_INVALID_PARAMETER;
5683 CAM_LOG_INFO("Enter");
5685 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5686 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5688 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5690 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5696 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)
5698 int ret = CAMERA_ERROR_NONE;
5699 camera_cli_s *pc = (camera_cli_s *)camera;
5700 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5701 camera_msg_param param;
5704 if (!pc || !pc->cb_info || !foreach_cb) {
5705 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5706 return CAMERA_ERROR_INVALID_PARAMETER;
5709 CAM_LOG_INFO("Enter");
5711 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5712 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5714 value = (width << 16) | height;
5715 CAMERA_MSG_PARAM_SET(param, INT, value);
5717 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5719 CAM_LOG_INFO("ret : 0x%x", ret);
5725 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5727 int ret = CAMERA_ERROR_NONE;
5728 camera_cli_s *pc = (camera_cli_s *)camera;
5729 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5731 if (!pc || !pc->cb_info || !foreach_cb) {
5732 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5733 return CAMERA_ERROR_INVALID_PARAMETER;
5736 CAM_LOG_INFO("Enter");
5738 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5739 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5741 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5743 CAM_LOG_INFO("ret : 0x%x", ret);
5749 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5751 int ret = CAMERA_ERROR_NONE;
5752 camera_cli_s *pc = (camera_cli_s *)camera;
5753 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5755 if (!pc || !pc->cb_info || !foreach_cb) {
5756 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5757 return CAMERA_ERROR_INVALID_PARAMETER;
5760 CAM_LOG_INFO("Enter");
5762 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5763 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5765 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5767 CAM_LOG_INFO("ret : 0x%x", ret);
5773 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5775 int ret = CAMERA_ERROR_NONE;
5776 camera_cli_s *pc = (camera_cli_s *)camera;
5777 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5778 camera_msg_param param;
5779 int set_rotation = (int)rotation;
5781 if (!pc || !pc->cb_info) {
5782 CAM_LOG_ERROR("NULL handle");
5783 return CAMERA_ERROR_INVALID_PARAMETER;
5786 CAM_LOG_INFO("Enter");
5788 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5790 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5792 CAM_LOG_INFO("ret : 0x%x", ret);
5798 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5800 int ret = CAMERA_ERROR_NONE;
5801 camera_cli_s *pc = (camera_cli_s *)camera;
5802 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5804 if (!pc || !pc->cb_info || !rotation) {
5805 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5806 return CAMERA_ERROR_INVALID_PARAMETER;
5809 CAM_LOG_INFO("Enter");
5811 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5813 if (ret == CAMERA_ERROR_NONE)
5814 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5816 CAM_LOG_INFO("ret : 0x%x", ret);
5822 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5824 int ret = CAMERA_ERROR_NONE;
5825 camera_cli_s *pc = (camera_cli_s *)camera;
5826 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5827 camera_msg_param param;
5828 int set_flip = (int)flip;
5830 if (!pc || !pc->cb_info) {
5831 CAM_LOG_ERROR("NULL handle");
5832 return CAMERA_ERROR_INVALID_PARAMETER;
5835 CAM_LOG_INFO("Enter");
5837 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5839 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5841 CAM_LOG_INFO("ret : 0x%x", ret);
5847 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5849 int ret = CAMERA_ERROR_NONE;
5850 camera_cli_s *pc = (camera_cli_s *)camera;
5851 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5853 if (!pc || !pc->cb_info || !flip) {
5854 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5855 return CAMERA_ERROR_INVALID_PARAMETER;
5858 CAM_LOG_INFO("Enter");
5860 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5862 if (ret == CAMERA_ERROR_NONE)
5863 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5865 CAM_LOG_INFO("ret : 0x%x", ret);
5870 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5872 int ret = CAMERA_ERROR_NONE;
5873 camera_cli_s *pc = (camera_cli_s *)camera;
5874 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5875 camera_msg_param param;
5876 int set_mode = (int)mode;
5878 if (!pc || !pc->cb_info) {
5879 CAM_LOG_ERROR("NULL handle");
5880 return CAMERA_ERROR_INVALID_PARAMETER;
5883 CAM_LOG_INFO("Enter");
5885 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5887 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5889 CAM_LOG_INFO("ret : 0x%x", ret);
5895 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5897 int ret = CAMERA_ERROR_NONE;
5898 camera_cli_s *pc = (camera_cli_s *)camera;
5899 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5901 if (!pc || !pc->cb_info || !mode) {
5902 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5903 return CAMERA_ERROR_INVALID_PARAMETER;
5906 CAM_LOG_INFO("Enter");
5908 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5910 if (ret == CAMERA_ERROR_NONE)
5911 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5913 CAM_LOG_INFO("ret : 0x%x", ret);
5919 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5921 int ret = CAMERA_ERROR_NONE;
5922 camera_cli_s *pc = (camera_cli_s *)camera;
5923 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5925 if (!pc || !pc->cb_info) {
5926 CAM_LOG_ERROR("NULL handle");
5927 return CAMERA_ERROR_INVALID_PARAMETER;
5930 CAM_LOG_INFO("Enter");
5932 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5935 CAM_LOG_ERROR("error is occurred 0x%x", ret);
5939 CAM_LOG_INFO("ret : %d", ret);
5945 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5947 int ret = CAMERA_ERROR_NONE;
5948 camera_cli_s *pc = (camera_cli_s *)camera;
5949 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5951 if (!pc || !pc->cb_info) {
5952 CAM_LOG_ERROR("NULL handle");
5953 return CAMERA_ERROR_INVALID_PARAMETER;
5956 CAM_LOG_INFO("Enter");
5958 if (!camera_attr_is_supported_hdr_capture(camera)) {
5959 CAM_LOG_ERROR("HDR not supported");
5960 return CAMERA_ERROR_NOT_SUPPORTED;
5964 CAM_LOG_ERROR("NULL callback");
5965 return CAMERA_ERROR_INVALID_PARAMETER;
5968 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5970 if (ret == CAMERA_ERROR_NONE) {
5971 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5973 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5974 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5976 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5979 CAM_LOG_INFO("ret : 0x%x", ret);
5985 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5987 int ret = CAMERA_ERROR_NONE;
5988 camera_cli_s *pc = (camera_cli_s *)camera;
5989 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5991 if (!pc || !pc->cb_info) {
5992 CAM_LOG_ERROR("NULL handle");
5993 return CAMERA_ERROR_INVALID_PARAMETER;
5996 CAM_LOG_INFO("Enter");
5998 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6000 if (ret == CAMERA_ERROR_NONE) {
6001 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6003 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6004 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6006 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6009 CAM_LOG_INFO("ret : 0x%x", ret);
6015 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6017 int ret = CAMERA_ERROR_NONE;
6018 camera_cli_s *pc = (camera_cli_s *)camera;
6019 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6020 camera_msg_param param;
6021 int set_enable = (int)enable;
6023 if (!pc || !pc->cb_info) {
6024 CAM_LOG_ERROR("NULL handle");
6025 return CAMERA_ERROR_INVALID_PARAMETER;
6028 CAM_LOG_INFO("Enter");
6030 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6032 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6034 CAM_LOG_INFO("ret : 0x%x", ret);
6040 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6042 int ret = CAMERA_ERROR_NONE;
6043 camera_cli_s *pc = (camera_cli_s *)camera;
6044 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6046 if (!pc || !pc->cb_info || !enabled) {
6047 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6048 return CAMERA_ERROR_INVALID_PARAMETER;
6051 CAM_LOG_INFO("Enter");
6053 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6055 if (ret == CAMERA_ERROR_NONE)
6056 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6058 CAM_LOG_INFO("ret : 0x%x", ret);
6064 bool camera_attr_is_supported_anti_shake(camera_h camera)
6066 int ret = CAMERA_ERROR_NONE;
6067 camera_cli_s *pc = (camera_cli_s *)camera;
6068 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6070 if (!pc || !pc->cb_info) {
6071 CAM_LOG_ERROR("NULL handle");
6072 return CAMERA_ERROR_INVALID_PARAMETER;
6075 CAM_LOG_INFO("Enter");
6077 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6080 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6084 CAM_LOG_INFO("ret : %d", ret);
6090 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6092 int ret = CAMERA_ERROR_NONE;
6093 camera_cli_s *pc = (camera_cli_s *)camera;
6094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6095 camera_msg_param param;
6096 int set_enable = (int)enable;
6098 if (!pc || !pc->cb_info) {
6099 CAM_LOG_ERROR("NULL handle");
6100 return CAMERA_ERROR_INVALID_PARAMETER;
6103 CAM_LOG_INFO("Enter");
6105 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6107 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6109 CAM_LOG_INFO("ret : 0x%x", ret);
6115 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6117 int ret = CAMERA_ERROR_NONE;
6118 camera_cli_s *pc = (camera_cli_s *)camera;
6119 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6121 if (!pc || !pc->cb_info || !enabled) {
6122 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6123 return CAMERA_ERROR_INVALID_PARAMETER;
6126 CAM_LOG_INFO("Enter");
6128 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6130 if (ret == CAMERA_ERROR_NONE)
6131 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6133 CAM_LOG_INFO("ret : 0x%x", ret);
6139 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6141 int ret = CAMERA_ERROR_NONE;
6142 camera_cli_s *pc = (camera_cli_s *)camera;
6143 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6145 if (!pc || !pc->cb_info) {
6146 CAM_LOG_ERROR("NULL handle");
6147 return CAMERA_ERROR_INVALID_PARAMETER;
6150 CAM_LOG_INFO("Enter");
6152 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6155 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6159 CAM_LOG_INFO("ret : %d", ret);
6165 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6167 int ret = CAMERA_ERROR_NONE;
6168 camera_cli_s *pc = (camera_cli_s *)camera;
6169 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6170 camera_msg_param param;
6171 int set_enable = (int)enable;
6173 if (!pc || !pc->cb_info) {
6174 CAM_LOG_ERROR("NULL handle");
6175 return CAMERA_ERROR_INVALID_PARAMETER;
6178 CAM_LOG_INFO("Enter");
6180 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6182 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6184 CAM_LOG_INFO("ret : 0x%x", ret);
6190 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6192 int ret = CAMERA_ERROR_NONE;
6193 camera_cli_s *pc = (camera_cli_s *)camera;
6194 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6196 if (!pc || !pc->cb_info || !enabled) {
6197 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6198 return CAMERA_ERROR_INVALID_PARAMETER;
6201 CAM_LOG_INFO("Enter");
6203 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6205 if (ret == CAMERA_ERROR_NONE)
6206 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6208 CAM_LOG_INFO("ret : 0x%x", ret);
6214 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6216 int ret = CAMERA_ERROR_NONE;
6217 camera_cli_s *pc = (camera_cli_s *)camera;
6218 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6220 if (!pc || !pc->cb_info) {
6221 CAM_LOG_ERROR("NULL handle");
6222 return CAMERA_ERROR_INVALID_PARAMETER;
6225 CAM_LOG_INFO("Enter");
6227 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6230 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6234 CAM_LOG_INFO("ret : %d", ret);
6240 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6242 int ret = CAMERA_ERROR_NONE;
6243 camera_cli_s *pc = (camera_cli_s *)camera;
6244 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6245 camera_msg_param param;
6246 int set_disable = (int)disable;
6248 if (!pc || !pc->cb_info) {
6249 CAM_LOG_ERROR("NULL handle");
6250 return CAMERA_ERROR_INVALID_PARAMETER;
6253 CAM_LOG_INFO("Enter");
6255 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6257 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6259 CAM_LOG_INFO("ret : 0x%x", ret);
6265 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6267 int ret = CAMERA_ERROR_NONE;
6268 camera_cli_s *pc = (camera_cli_s *)camera;
6269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6270 camera_msg_param param0;
6271 camera_msg_param param1;
6273 if (!pc || !pc->cb_info) {
6274 CAM_LOG_ERROR("NULL handle");
6275 return CAMERA_ERROR_INVALID_PARAMETER;
6278 CAM_LOG_INFO("Enter");
6280 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6281 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6283 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6284 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6286 CAM_LOG_INFO("ret : 0x%x", ret);
6292 int camera_attr_get_pan(camera_h camera, int *pan_step)
6294 int ret = CAMERA_ERROR_NONE;
6295 camera_cli_s *pc = (camera_cli_s *)camera;
6296 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6298 if (!pc || !pc->cb_info || !pan_step) {
6299 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6300 return CAMERA_ERROR_INVALID_PARAMETER;
6303 CAM_LOG_INFO("Enter");
6305 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6307 if (ret == CAMERA_ERROR_NONE)
6308 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6310 CAM_LOG_INFO("ret : 0x%x", ret);
6316 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6318 int ret = CAMERA_ERROR_NONE;
6319 camera_cli_s *pc = (camera_cli_s *)camera;
6320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6322 if (!pc || !pc->cb_info || !min || !max) {
6323 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6324 return CAMERA_ERROR_INVALID_PARAMETER;
6327 CAM_LOG_INFO("Enter");
6329 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6331 if (ret == CAMERA_ERROR_NONE) {
6332 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6333 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6336 CAM_LOG_INFO("ret : 0x%x", ret);
6342 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6344 int ret = CAMERA_ERROR_NONE;
6345 camera_cli_s *pc = (camera_cli_s *)camera;
6346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6347 camera_msg_param param0;
6348 camera_msg_param param1;
6350 if (!pc || !pc->cb_info) {
6351 CAM_LOG_ERROR("NULL handle");
6352 return CAMERA_ERROR_INVALID_PARAMETER;
6355 CAM_LOG_INFO("Enter");
6357 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6358 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6360 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6361 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6363 CAM_LOG_INFO("ret : 0x%x", ret);
6369 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6371 int ret = CAMERA_ERROR_NONE;
6372 camera_cli_s *pc = (camera_cli_s *)camera;
6373 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6375 if (!pc || !pc->cb_info || !tilt_step) {
6376 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6377 return CAMERA_ERROR_INVALID_PARAMETER;
6380 CAM_LOG_INFO("Enter");
6382 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6384 if (ret == CAMERA_ERROR_NONE)
6385 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6387 CAM_LOG_INFO("ret : 0x%x", ret);
6393 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6395 int ret = CAMERA_ERROR_NONE;
6396 camera_cli_s *pc = (camera_cli_s *)camera;
6397 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6399 if (!pc || !pc->cb_info || !min || !max) {
6400 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6401 return CAMERA_ERROR_INVALID_PARAMETER;
6404 CAM_LOG_INFO("Enter");
6406 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6408 if (ret == CAMERA_ERROR_NONE) {
6409 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6410 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6413 CAM_LOG_INFO("ret : 0x%x", ret);
6419 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6421 int ret = CAMERA_ERROR_NONE;
6422 camera_cli_s *pc = (camera_cli_s *)camera;
6423 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6424 camera_msg_param param;
6425 int set_ptz_type = (int)ptz_type;
6427 if (!pc || !pc->cb_info) {
6428 CAM_LOG_ERROR("NULL handle");
6429 return CAMERA_ERROR_INVALID_PARAMETER;
6432 CAM_LOG_INFO("Enter");
6434 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6436 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6438 CAM_LOG_INFO("ret : 0x%x", ret);
6444 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6446 int ret = CAMERA_ERROR_NONE;
6447 camera_cli_s *pc = (camera_cli_s *)camera;
6448 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6450 if (!pc || !pc->cb_info || !foreach_cb) {
6451 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6452 return CAMERA_ERROR_INVALID_PARAMETER;
6455 CAM_LOG_INFO("Enter");
6457 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6458 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6460 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6462 CAM_LOG_INFO("ret : 0x%x", ret);
6468 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6470 int ret = CAMERA_ERROR_NONE;
6471 camera_cli_s *pc = (camera_cli_s *)camera;
6472 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6473 int set_display_roi_area[4] = {x, y, width, height};
6478 if (!pc || !pc->cb_info) {
6479 CAM_LOG_ERROR("NULL handle");
6480 return CAMERA_ERROR_INVALID_PARAMETER;
6483 CAM_LOG_INFO("Enter");
6485 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6486 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6487 if (ret != MM_ERROR_NONE) {
6488 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6489 return CAMERA_ERROR_INVALID_OPERATION;
6493 length = sizeof(set_display_roi_area) / sizeof(int) + \
6494 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6496 msg = muse_core_msg_new(api,
6497 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6500 CAM_LOG_ERROR("msg creation failed: api %d", api);
6501 return CAMERA_ERROR_OUT_OF_MEMORY;
6504 if (pc->cb_info->is_server_connected) {
6505 __camera_update_api_waiting(pc->cb_info, api, 1);
6507 g_mutex_lock(&pc->cb_info->fd_lock);
6508 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6509 g_mutex_unlock(&pc->cb_info->fd_lock);
6513 CAM_LOG_ERROR("message send failed");
6514 ret = CAMERA_ERROR_INVALID_OPERATION;
6516 ret = __camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6519 __camera_update_api_waiting(pc->cb_info, api, -1);
6521 muse_core_msg_free(msg);
6523 CAM_LOG_INFO("ret : 0x%x", ret);
6529 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6531 camera_cli_s *pc = (camera_cli_s *)camera;
6532 int ret = CAMERA_ERROR_NONE;
6533 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6535 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6536 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6537 return CAMERA_ERROR_INVALID_PARAMETER;
6540 CAM_LOG_INFO("Enter");
6542 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6544 if (ret == CAMERA_ERROR_NONE) {
6545 *x = pc->cb_info->get_display_roi_area[0];
6546 *y = pc->cb_info->get_display_roi_area[1];
6547 *width = pc->cb_info->get_display_roi_area[2];
6548 *height = pc->cb_info->get_display_roi_area[3];
6551 CAM_LOG_INFO("ret : 0x%x", ret);
6557 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6559 int ret = CAMERA_ERROR_NONE;
6560 int get_device_state = 0;
6563 CAM_LOG_ERROR("NULL pointer");
6564 return CAMERA_ERROR_INVALID_PARAMETER;
6567 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6568 (int)device, "get_device_state", &get_device_state);
6570 if (ret == CAMERA_ERROR_NONE) {
6571 *state = (camera_device_state_e)get_device_state;
6572 CAM_LOG_INFO("device state %d", *state);
6574 CAM_LOG_ERROR("failed 0x%x", ret);
6581 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6583 int ret = CAMERA_ERROR_NONE;
6584 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6585 camera_cb_info *info = NULL;
6587 if (!callback || !cb_id) {
6588 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6589 return CAMERA_ERROR_INVALID_PARAMETER;
6592 /* check camera support */
6593 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6594 if (ret != CAMERA_ERROR_NONE) {
6595 CAM_LOG_ERROR("get device state failed");
6599 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6601 info = g_new0(camera_cb_info, 1);
6603 CAM_LOG_ERROR("info failed");
6604 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6608 info->id = ++g_cam_dev_state_changed_cb_id;
6609 info->callback = (void *)callback;
6610 info->user_data = user_data;
6614 /* subscribe dbus signal for camera state change */
6615 if (!g_cam_dev_state_changed_cb_conn) {
6616 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6617 if (!g_cam_dev_state_changed_cb_conn) {
6618 CAM_LOG_ERROR("failed to get gdbus connection");
6619 ret = CAMERA_ERROR_INVALID_OPERATION;
6623 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6624 MM_CAMCORDER_DBUS_OBJECT,
6625 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6626 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6628 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6629 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6630 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6631 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6632 CAM_LOG_ERROR("failed to get gdbus connection");
6633 ret = CAMERA_ERROR_INVALID_OPERATION;
6637 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6640 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6642 CAM_LOG_INFO("callback id %d", info->id);
6645 if (ret != CAMERA_ERROR_NONE) {
6651 if (g_cam_dev_state_changed_cb_conn) {
6652 g_object_unref(g_cam_dev_state_changed_cb_conn);
6653 g_cam_dev_state_changed_cb_conn = NULL;
6657 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6663 int camera_remove_device_state_changed_cb(int cb_id)
6665 int ret = CAMERA_ERROR_NONE;
6666 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6667 GList *tmp_list = NULL;
6668 camera_cb_info *info = NULL;
6670 /* check camera support */
6671 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6672 if (ret != CAMERA_ERROR_NONE) {
6673 CAM_LOG_ERROR("get device state failed");
6677 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6679 if (!g_cam_dev_state_changed_cb_list) {
6680 CAM_LOG_ERROR("there is no callback info");
6681 ret = CAMERA_ERROR_INVALID_OPERATION;
6685 tmp_list = g_cam_dev_state_changed_cb_list;
6688 info = tmp_list->data;
6689 tmp_list = tmp_list->next;
6692 CAM_LOG_WARNING("NULL info");
6696 if (info->id == cb_id) {
6697 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6702 if (!g_cam_dev_state_changed_cb_list) {
6703 /* no remained callback */
6704 if (g_cam_dev_state_changed_cb_conn) {
6705 /* unsubscribe signal */
6706 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6707 g_cam_dev_state_changed_cb_subscribe_id = 0;
6709 /* unref connection */
6710 g_object_unref(g_cam_dev_state_changed_cb_conn);
6711 g_cam_dev_state_changed_cb_conn = NULL;
6715 CAM_LOG_INFO("id %d callback removed", cb_id);
6716 ret = CAMERA_ERROR_NONE;
6722 CAM_LOG_ERROR("id %d callback not found", cb_id);
6723 ret = CAMERA_ERROR_INVALID_PARAMETER;
6726 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6732 int _camera_get_log_level(void)
6734 return g_camera_log_level;