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 int g_mmcam_log_level = CAMERA_LOG_LEVEL_INFO;
46 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
47 int *ret, int timeout);
48 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
49 int *ret, camera_msg_param *param, int timeout);
50 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
51 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
52 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info);
53 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
54 static void _camera_release_imported_bo(tbm_bo *bo);
55 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
56 camera_media_packet_data *mp_data, media_packet_h *packet);
57 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
58 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
59 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
60 static gboolean _camera_allocate_preview_buffer(camera_h camera);
61 static void _camera_release_preview_buffer(camera_h camera);
64 static gboolean _camera_allocate_preview_buffer(camera_h camera)
67 int ret = CAMERA_ERROR_NONE;
68 int format = CAMERA_PIXEL_FORMAT_INVALID;
72 camera_cli_s *pc = (camera_cli_s *)camera;
73 camera_cb_info_s *cb_info = NULL;
75 if (!pc || !pc->cb_info) {
76 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
80 cb_info = pc->cb_info;
82 CAM_LOG_INFO("Enter");
84 /* get preview info and calculate size */
85 ret = camera_get_preview_format(camera, &format);
86 if (ret != CAMERA_ERROR_NONE) {
87 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
91 ret = camera_get_preview_resolution(camera, &width, &height);
92 if (ret != CAMERA_ERROR_NONE) {
93 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
97 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
100 case CAMERA_PIXEL_FORMAT_INVZ:
101 buffer_size = width * height;
103 case CAMERA_PIXEL_FORMAT_NV12:
104 case CAMERA_PIXEL_FORMAT_I420:
105 buffer_size = (width * height * 3) >> 1;
107 case CAMERA_PIXEL_FORMAT_YUYV:
108 case CAMERA_PIXEL_FORMAT_UYVY:
109 buffer_size = width * height * 2;
112 CAM_LOG_ERROR("unhandled format %d", format);
113 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
116 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
118 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
119 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
120 if (!cb_info->bos[i]) {
121 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
122 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
125 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
126 if (cb_info->fds[i] < 0) {
127 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
128 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
131 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
134 CAM_LOG_INFO("Done");
138 _ALLOCATE_PREVIEW_BUFFER_FAILED:
139 _camera_release_preview_buffer(camera);
144 static void _camera_release_preview_buffer(camera_h camera)
147 camera_cli_s *pc = (camera_cli_s *)camera;
148 camera_cb_info_s *cb_info = NULL;
150 if (!pc || !pc->cb_info) {
151 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
155 CAM_LOG_INFO("Enter");
157 cb_info = pc->cb_info;
159 /* close exported fd and bos */
160 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
161 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
163 if (cb_info->bos[i]) {
164 tbm_bo_unref(cb_info->bos[i]);
165 cb_info->bos[i] = NULL;
170 if (cb_info->fds[i] >= 0) {
171 close(cb_info->fds[i]);
172 cb_info->fds[i] = -1;
176 CAM_LOG_INFO("Done");
182 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
185 api < 0 || api >= MUSE_CAMERA_API_MAX) {
186 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
190 g_mutex_lock(&(cb_info->api_mutex[api]));
191 cb_info->api_waiting[api] += value;
192 g_mutex_unlock(&(cb_info->api_mutex[api]));
194 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
195 api, value, cb_info->api_waiting[api]);
201 static void __camera_device_state_changed_cb(GDBusConnection *connection,
202 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
203 const gchar *signal_name, GVariant *param, gpointer user_data)
206 camera_device_e device = CAMERA_DEVICE_CAMERA0;
207 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
208 GList *tmp_list = NULL;
209 camera_cb_info *info = NULL;
211 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
213 if (!g_cam_dev_state_changed_cb_list || !param) {
214 CAM_LOG_WARNING("no callback or NULL param %p", param);
218 /* get device and state */
219 g_variant_get(param, "(i)", &value);
221 device = value >> 16;
222 state = 0x0000ffff & value;
224 CAM_LOG_INFO("device %d, state %d", device, state);
226 tmp_list = g_cam_dev_state_changed_cb_list;
229 info = (camera_cb_info *)tmp_list->data;
232 if (info->callback) {
233 CAM_LOG_INFO("start id[%d] callback", info->id);
234 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
235 CAM_LOG_INFO("returned id[%d] callback", info->id);
237 CAM_LOG_WARNING("NULL callback for id %d", info->id);
241 tmp_list = tmp_list->next;
245 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
251 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
257 int num_buffer_fd = 0;
258 unsigned char *buf_pos = NULL;
261 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
262 tbm_bo_handle bo_handle = {.ptr = NULL};
263 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
264 tbm_bo data_bo = NULL;
265 tbm_bo_handle data_bo_handle = {.ptr = NULL};
267 camera_msg_param param;
268 camera_preview_data_s frame;
269 camera_stream_data_s *stream = NULL;
270 camera_media_packet_data *mp_data = NULL;
271 media_packet_h pkt = NULL;
272 media_packet_h pkt_evas = NULL;
274 /* tfd[0]: MMCamcorderVideoStreamDataType
275 tfd[1]: data_bo or zero copy bo[0]
276 tfd[2]: zero copy bo[1]
277 tfd[3]: zero copy bo[2] */
279 if (!cb_info || !recv_msg || !tfd) {
280 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
284 muse_camera_msg_get(preview_fd, recv_msg);
285 muse_camera_msg_get(num_buffer_fd, recv_msg);
287 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
289 memset(&frame, 0x0, sizeof(camera_preview_data_s));
292 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
297 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
299 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
300 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
301 goto _PREVIEW_CB_HANDLER_DONE;
304 if (num_buffer_fd == 0 && tfd[1] >= 0) {
305 /* import tbm data_bo and get virtual address */
306 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
307 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
308 goto _PREVIEW_CB_HANDLER_DONE;
312 /* import tbm bo and get virtual address */
313 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
314 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
315 goto _PREVIEW_CB_HANDLER_DONE;
318 buf_pos = (unsigned char *)bo_handle.ptr;
320 /* get stream info */
321 stream = (camera_stream_data_s *)buf_pos;
323 for (i = 0 ; i < num_buffer_fd ; i++) {
324 /* import buffer bo and get virtual address */
325 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
326 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
327 goto _PREVIEW_CB_HANDLER_DONE;
331 /* call preview callback */
332 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
333 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
335 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
336 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
339 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
340 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
342 if (ret == CAMERA_ERROR_NONE) {
343 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
344 if (ret != CAMERA_ERROR_NONE) {
345 CAM_LOG_ERROR("create pkt for evas failed");
346 _camera_media_packet_data_release(mp_data, cb_info);
352 /* call media packet callback */
353 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
354 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
356 if (ret == CAMERA_ERROR_NONE) {
357 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
359 if (ret == CAMERA_ERROR_NONE) {
360 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
361 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
363 _camera_media_packet_data_release(mp_data, cb_info);
369 /* call evas renderer */
371 if (cb_info->run_evas_render) {
372 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
374 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
375 media_packet_destroy(pkt_evas);
380 /* send message for preview callback return */
381 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
382 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
384 _PREVIEW_CB_HANDLER_DONE:
385 if (mp_data == NULL) {
386 /* release imported bo */
387 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
388 _camera_release_imported_bo(&buffer_bo[i]);
390 /* unmap and unref tbm bo */
391 _camera_release_imported_bo(&data_bo);
392 _camera_release_imported_bo(&bo);
394 /* close imported fd */
395 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
405 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
407 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
414 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
418 int capture_fd_main = 0;
419 int capture_fd_post = 0;
420 int capture_fd_thumb = 0;
421 unsigned char *buf_pos = NULL;
423 camera_image_data_s *rImage = NULL;
424 camera_image_data_s *rPostview = NULL;
425 camera_image_data_s *rThumbnail = NULL;
427 tbm_bo bo_main = NULL;
428 tbm_bo bo_post = NULL;
429 tbm_bo bo_thumb = NULL;
430 tbm_bo_handle bo_main_handle = {.ptr = NULL};
431 tbm_bo_handle bo_post_handle = {.ptr = NULL};
432 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
434 if (!cb_info || !recv_msg || !tfd) {
435 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
439 muse_camera_msg_get(capture_fd_main, recv_msg);
440 muse_camera_msg_get(capture_fd_post, recv_msg);
441 muse_camera_msg_get(capture_fd_thumb, recv_msg);
443 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
444 capture_fd_main, capture_fd_post, capture_fd_thumb,
445 tfd[0], tfd[1], tfd[2]);
447 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
448 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
449 goto _CAPTURE_CB_HANDLER_DONE;
452 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
453 CAM_LOG_WARNING("NULL callback");
454 goto _CAPTURE_CB_HANDLER_DONE;
457 /* import tbm bo and get virtual address */
458 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
459 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
460 goto _CAPTURE_CB_HANDLER_DONE;
463 buf_pos = (unsigned char *)bo_main_handle.ptr;
464 rImage = (camera_image_data_s *)buf_pos;
465 rImage->data = buf_pos + sizeof(camera_image_data_s);
466 if (rImage->exif && rImage->exif_size > 0) {
467 rImage->exif = rImage->data + rImage->size;
470 rImage->exif_size = 0;
473 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
474 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
476 if (capture_fd_post >= 0) {
477 /* import tbm bo and get virtual address */
479 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
480 buf_pos = (unsigned char *)bo_post_handle.ptr;
481 rPostview = (camera_image_data_s *)buf_pos;
482 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
483 rPostview->data = buf_pos + sizeof(camera_image_data_s);
485 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
489 if (capture_fd_thumb >= 0) {
490 /* import tbm bo and get virtual address */
492 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
493 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
494 rThumbnail = (camera_image_data_s *)buf_pos;
495 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
496 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
498 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
502 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
503 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
505 _CAPTURE_CB_HANDLER_DONE:
507 if (capture_fd_main >= 0) {
508 _camera_release_imported_bo(&bo_main);
509 _camera_msg_return_buffer(capture_fd_main, cb_info);
512 if (capture_fd_post >= 0) {
513 _camera_release_imported_bo(&bo_post);
514 _camera_msg_return_buffer(capture_fd_post, cb_info);
517 if (capture_fd_thumb >= 0) {
518 _camera_release_imported_bo(&bo_thumb);
519 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
522 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
524 CAM_LOG_INFO("close %d", tfd[i]);
532 CAM_LOG_INFO("return buffer done");
538 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
542 camera_detected_face_s *faces = NULL;
545 tbm_bo_handle bo_handle = {.ptr = NULL};
547 if (!cb_info || !recv_msg || !tfd) {
548 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
552 muse_camera_msg_get(count, recv_msg);
553 muse_camera_msg_get(face_fd, recv_msg);
555 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
556 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
559 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
561 faces = bo_handle.ptr;
568 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
569 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
572 _camera_release_imported_bo(&bo);
574 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
575 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
579 _camera_msg_return_buffer(face_fd, cb_info);
585 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
587 tbm_bo tmp_bo = NULL;
588 tbm_bo_handle tmp_bo_handle = {NULL, };
590 if (!bufmgr || !bo || !bo_handle || fd < 0) {
591 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
592 bufmgr, bo, bo_handle, fd);
596 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
597 if (tmp_bo == NULL) {
598 CAM_LOG_ERROR("import failed - fd %d", fd);
602 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
603 if (tmp_bo_handle.ptr == NULL) {
604 CAM_LOG_ERROR("map failed %p", tmp_bo);
605 tbm_bo_unref(tmp_bo);
610 tbm_bo_unmap(tmp_bo);
612 /* set bo and bo_handle */
614 *bo_handle = tmp_bo_handle;
616 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
621 static void _camera_release_imported_bo(tbm_bo *bo)
624 CAM_LOG_DEBUG("NULL bo");
634 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
636 int ret = CAMERA_ERROR_NONE;
639 if (!cb_info->is_server_connected) {
640 CAM_LOG_ERROR("server is disconnected");
641 return CAMERA_ERROR_SERVICE_DISCONNECTED;
644 g_mutex_lock(&(cb_info->api_mutex[api]));
646 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
648 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
650 while (!cb_info->api_activating[api]) {
651 if (time_out == CAMERA_CB_NO_TIMEOUT) {
652 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
653 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
654 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
655 CAM_LOG_ERROR("api %d TIMED OUT!", api);
656 ret = CAMERA_ERROR_INVALID_OPERATION;
660 if (!cb_info->api_activating[api])
661 CAM_LOG_WARNING("invalid signal received, wait again...");
664 ret = cb_info->api_ret[api];
665 cb_info->api_activating[api] = FALSE;
668 g_mutex_unlock(&(cb_info->api_mutex[api]));
670 if (ret != CAMERA_ERROR_NONE)
671 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
677 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
678 int *ret, int timeout)
684 CAM_LOG_ERROR("NULL info - api %d", api);
687 *ret = CAMERA_ERROR_INVALID_PARAMETER;
692 msg = muse_core_msg_new(api, NULL);
694 CAM_LOG_ERROR("msg failed: api %d", api);
697 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
702 CAM_LOG_DEBUG("send msg[%s]", msg);
704 if (cb_info->is_server_connected) {
705 __camera_update_api_waiting(cb_info, api, 1);
707 g_mutex_lock(&cb_info->fd_lock);
708 send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
709 g_mutex_unlock(&cb_info->fd_lock);
713 CAM_LOG_ERROR("msg send failed");
715 *ret = CAMERA_ERROR_INVALID_OPERATION;
718 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
721 __camera_update_api_waiting(cb_info, api, -1);
723 muse_core_msg_free(msg);
729 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
730 int *ret, camera_msg_param *param, int timeout)
736 if (!cb_info || !param) {
737 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
740 *ret = CAMERA_ERROR_INVALID_PARAMETER;
745 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
747 switch (param->type) {
749 msg = muse_core_msg_new(api,
750 param->type, param->name, param->value.value_INT,
753 case MUSE_TYPE_STRING:
754 msg = muse_core_msg_new(api,
755 param->type, param->name, param->value.value_STRING,
758 case MUSE_TYPE_ARRAY:
759 array_length = param->value_size / sizeof(int) + \
760 (param->value_size % sizeof(int) ? 1 : 0);
762 msg = muse_core_msg_new(api,
763 param->type, param->name, array_length, param->value.value_ARRAY,
767 CAM_LOG_ERROR("unknown type %d", param->type);
772 CAM_LOG_ERROR("msg failed: api %d", api);
775 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
780 CAM_LOG_DEBUG("send msg[%s]", msg);
782 if (cb_info->is_server_connected) {
783 __camera_update_api_waiting(cb_info, api, 1);
785 g_mutex_lock(&cb_info->fd_lock);
786 send_ret = muse_core_msg_send(cb_info->fd, msg);
787 g_mutex_unlock(&cb_info->fd_lock);
791 CAM_LOG_ERROR("msg send failed");
794 *ret = CAMERA_ERROR_INVALID_OPERATION;
797 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
800 __camera_update_api_waiting(cb_info, api, -1);
802 muse_core_msg_free(msg);
808 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
809 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
811 int func_ret = CAMERA_ERROR_NONE;
815 if (!cb_info || !param0 || !param1) {
816 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
817 cb_info, param0, param1, api);
818 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
819 goto _SEND_PARAM2_INT_DONE;
822 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
824 param0->name, param0->value.value_INT,
825 param1->name, param1->value.value_INT);
827 msg = muse_core_msg_new(api,
828 param0->type, param0->name, param0->value.value_INT,
829 param1->type, param1->name, param1->value.value_INT,
832 CAM_LOG_ERROR("msg failed: api %d", api);
833 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
834 goto _SEND_PARAM2_INT_DONE;
837 CAM_LOG_DEBUG("send msg[%s]", msg);
839 if (cb_info->is_server_connected) {
840 __camera_update_api_waiting(cb_info, api, 1);
842 g_mutex_lock(&cb_info->fd_lock);
843 send_ret = muse_core_msg_send(cb_info->fd, msg);
844 g_mutex_unlock(&cb_info->fd_lock);
848 CAM_LOG_ERROR("msg send failed");
850 func_ret = CAMERA_ERROR_INVALID_OPERATION;
852 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
855 __camera_update_api_waiting(cb_info, api, -1);
857 muse_core_msg_free(msg);
859 _SEND_PARAM2_INT_DONE:
867 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
869 camera_msg_param param;
872 CAM_LOG_WARNING("invalid fd %d", ret_fd);
876 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
878 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
884 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
886 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
887 in_format >= MM_PIXEL_FORMAT_NUM ||
888 out_format == NULL) {
889 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
890 return CAMERA_ERROR_INVALID_PARAMETER;
894 case MM_PIXEL_FORMAT_NV12:
895 case MM_PIXEL_FORMAT_NV12T:
896 *out_format = TBM_FORMAT_NV12;
899 case MM_PIXEL_FORMAT_NV16:
900 *out_format = TBM_FORMAT_NV16;
902 case MM_PIXEL_FORMAT_NV21:
903 *out_format = TBM_FORMAT_NV21;
905 case MM_PIXEL_FORMAT_YUYV:
906 *out_format = TBM_FORMAT_YUYV;
908 case MM_PIXEL_FORMAT_UYVY:
909 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
910 *out_format = TBM_FORMAT_UYVY;
912 case MM_PIXEL_FORMAT_422P:
913 *out_format = TBM_FORMAT_YUV422;
915 case MM_PIXEL_FORMAT_I420:
916 *out_format = TBM_FORMAT_YUV420;
918 case MM_PIXEL_FORMAT_YV12:
919 *out_format = TBM_FORMAT_YVU420;
921 case MM_PIXEL_FORMAT_RGB565:
922 *out_format = TBM_FORMAT_RGB565;
924 case MM_PIXEL_FORMAT_RGB888:
925 *out_format = TBM_FORMAT_RGB888;
927 case MM_PIXEL_FORMAT_RGBA:
928 *out_format = TBM_FORMAT_RGBA8888;
930 case MM_PIXEL_FORMAT_ARGB:
931 *out_format = TBM_FORMAT_ARGB8888;
934 CAM_LOG_ERROR("invalid in_format %d", in_format);
935 return CAMERA_ERROR_INVALID_PARAMETER;
939 return CAMERA_ERROR_NONE;
943 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
945 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
946 in_format >= MM_PIXEL_FORMAT_NUM ||
948 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
949 return CAMERA_ERROR_INVALID_PARAMETER;
953 case MM_PIXEL_FORMAT_NV12:
954 case MM_PIXEL_FORMAT_NV12T:
955 *mimetype = MEDIA_FORMAT_NV12;
958 case MM_PIXEL_FORMAT_NV16:
959 *mimetype = MEDIA_FORMAT_NV16;
961 case MM_PIXEL_FORMAT_NV21:
962 *mimetype = MEDIA_FORMAT_NV21;
964 case MM_PIXEL_FORMAT_YUYV:
965 *mimetype = MEDIA_FORMAT_YUYV;
967 case MM_PIXEL_FORMAT_UYVY:
968 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
969 *mimetype = MEDIA_FORMAT_UYVY;
971 case MM_PIXEL_FORMAT_422P:
972 *mimetype = MEDIA_FORMAT_422P;
974 case MM_PIXEL_FORMAT_I420:
975 *mimetype = MEDIA_FORMAT_I420;
977 case MM_PIXEL_FORMAT_YV12:
978 *mimetype = MEDIA_FORMAT_YV12;
980 case MM_PIXEL_FORMAT_RGB565:
981 *mimetype = MEDIA_FORMAT_RGB565;
983 case MM_PIXEL_FORMAT_RGB888:
984 *mimetype = MEDIA_FORMAT_RGB888;
986 case MM_PIXEL_FORMAT_RGBA:
987 *mimetype = MEDIA_FORMAT_RGBA;
989 case MM_PIXEL_FORMAT_ARGB:
990 *mimetype = MEDIA_FORMAT_ARGB;
993 CAM_LOG_ERROR("invalid in_format %d", in_format);
994 return CAMERA_ERROR_INVALID_PARAMETER;
998 return CAMERA_ERROR_NONE;
1002 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1003 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1006 int ret = CAMERA_ERROR_NONE;
1007 camera_media_packet_data *tmp_mp_data = NULL;
1010 CAM_LOG_ERROR("NULL tfd");
1011 return CAMERA_ERROR_INVALID_PARAMETER;
1014 if (*mp_data == NULL) {
1015 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1017 tmp_mp_data->ret_fd = ret_fd;
1018 tmp_mp_data->fd = tfd[0];
1019 tmp_mp_data->num_buffer_fd = num_buffer_fd;
1020 tmp_mp_data->bo = bo;
1022 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", tmp_mp_data->fd, tmp_mp_data->ret_fd);
1026 tmp_mp_data->data_bo = data_bo;
1027 tmp_mp_data->data_fd = tfd[1];
1029 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1030 tmp_mp_data->data_bo, tmp_mp_data->data_fd);
1033 for (i = 0 ; i < num_buffer_fd ; i++) {
1034 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1035 tmp_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1037 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1038 i, tmp_mp_data->buffer_bo[i], tmp_mp_data->buffer_fd[i]);
1042 tmp_mp_data->ref_cnt++;
1044 *mp_data = tmp_mp_data;
1046 CAM_LOG_DEBUG("mp_data %p", tmp_mp_data);
1048 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1049 CAM_LOG_ERROR("failed to alloc media packet data");
1052 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1058 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1062 if (!mp_data || !cb_info) {
1063 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1067 if (mp_data->ref_cnt > 1) {
1069 CAM_LOG_INFO("ref count %d", mp_data->ref_cnt);
1071 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1073 /* release imported bo and close imported fd */
1074 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1075 tbm_bo_unref(mp_data->buffer_bo[i]);
1076 mp_data->buffer_bo[i] = NULL;
1078 close(mp_data->buffer_fd[i]);
1079 mp_data->buffer_fd[i] = -1;
1082 /* unref tbm bo and close imported fd */
1086 _camera_release_imported_bo(&mp_data->bo);
1088 if (mp_data->data_bo && mp_data->data_fd >= 0) {
1089 close(mp_data->data_fd);
1090 mp_data->data_fd = -1;
1092 _camera_release_imported_bo(&mp_data->data_bo);
1095 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1103 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1104 camera_media_packet_data *mp_data, media_packet_h *packet)
1106 media_packet_h pkt = NULL;
1107 bool make_pkt_fmt = false;
1108 tbm_surface_h tsurf = NULL;
1109 tbm_surface_info_s tsurf_info;
1110 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1111 uint32_t bo_format = 0;
1114 int num_buffer_fd = 0;
1115 tbm_bo *buffer_bo = NULL;
1117 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1118 CAM_LOG_ERROR("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1119 cb_info, stream, mp_data, packet);
1120 return CAMERA_ERROR_INVALID_PARAMETER;
1123 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1124 buffer_bo = mp_data->buffer_bo;
1125 num_buffer_fd = mp_data->num_buffer_fd;
1127 /* create tbm surface */
1128 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1129 tsurf_info.planes[i].stride = stream->stride[i];
1131 /* get tbm surface format */
1132 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1133 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1135 if (ret == CAMERA_ERROR_NONE) {
1136 tsurf_info.width = stream->width;
1137 tsurf_info.height = stream->height;
1138 tsurf_info.format = bo_format;
1139 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1140 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1142 if (num_buffer_fd > 0) {
1143 switch (bo_format) {
1144 case TBM_FORMAT_NV12:
1145 case TBM_FORMAT_NV21:
1146 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1147 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1148 tsurf_info.planes[0].offset = 0;
1149 if (num_buffer_fd == 1)
1150 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1151 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->stride[0] * stream->elevation[0];
1157 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1158 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1159 tsurf_info.planes[0].offset = 0;
1160 if (num_buffer_fd == 1) {
1161 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1162 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1164 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1166 case TBM_FORMAT_UYVY:
1167 case TBM_FORMAT_YUYV:
1168 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1169 tsurf_info.planes[0].offset = 0;
1170 tsurf_info.size = tsurf_info.planes[0].size;
1177 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1178 } else if (mp_data->data_bo) {
1180 switch (bo_format) {
1181 case TBM_FORMAT_NV12:
1182 case TBM_FORMAT_NV21:
1183 tsurf_info.planes[0].size = stream->width * stream->height;
1184 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1185 tsurf_info.planes[0].offset = 0;
1186 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1187 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1189 case TBM_FORMAT_YUV420:
1190 case TBM_FORMAT_YVU420:
1191 tsurf_info.planes[0].size = stream->width * stream->height;
1192 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1193 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1194 tsurf_info.planes[0].offset = 0;
1195 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1196 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1197 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1199 case TBM_FORMAT_UYVY:
1200 case TBM_FORMAT_YUYV:
1201 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1202 tsurf_info.planes[0].offset = 0;
1203 tsurf_info.size = tsurf_info.planes[0].size;
1209 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1215 /* check media packet format */
1216 if (cb_info->pkt_fmt) {
1217 int pkt_fmt_width = 0;
1218 int pkt_fmt_height = 0;
1219 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1221 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1223 CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d", pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1225 if (pkt_fmt_mimetype != mimetype ||
1226 pkt_fmt_width != stream->width ||
1227 pkt_fmt_height != stream->height) {
1228 CAM_LOG_WARNING("change fmt: current 0x%x, %dx%d",
1229 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1230 media_format_unref(cb_info->pkt_fmt);
1231 cb_info->pkt_fmt = NULL;
1232 make_pkt_fmt = true;
1235 make_pkt_fmt = true;
1238 /* create packet format */
1240 CAM_LOG_WARNING("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1241 ret = media_format_create(&cb_info->pkt_fmt);
1242 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1243 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1244 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1245 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1246 CAM_LOG_WARNING("media_format_set : 0x%x", ret);
1248 CAM_LOG_WARNING("media_format_create failed 0x%x", ret);
1252 /* create media packet */
1253 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1254 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1255 (void *)cb_info, &pkt);
1256 if (ret != MEDIA_PACKET_ERROR_NONE) {
1257 CAM_LOG_ERROR("media_packet_create failed 0x%x", ret);
1258 tbm_surface_destroy(tsurf);
1262 CAM_LOG_ERROR("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1263 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1267 /* set media packet data */
1268 ret = media_packet_set_extra(pkt, (void *)mp_data);
1269 if (ret != MEDIA_PACKET_ERROR_NONE) {
1270 CAM_LOG_ERROR("media_packet_set_extra failed");
1272 _camera_media_packet_data_release(mp_data, cb_info);
1274 media_packet_destroy(pkt);
1276 /* set timestamp : msec -> nsec */
1277 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1278 CAM_LOG_WARNING("media_packet_set_pts failed");
1287 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1290 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1291 camera_media_packet_data *mp_data = NULL;
1292 tbm_surface_h tsurf = NULL;
1294 if (!pkt || !cb_info) {
1295 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1296 return MEDIA_PACKET_FINALIZE;
1299 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1300 if (ret != MEDIA_PACKET_ERROR_NONE) {
1301 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1302 return MEDIA_PACKET_FINALIZE;
1305 CAM_LOG_VERBOSE("mp_data[%p]", mp_data);
1307 g_mutex_lock(&cb_info->mp_data_mutex);
1309 _camera_media_packet_data_release(mp_data, cb_info);
1312 g_mutex_unlock(&cb_info->mp_data_mutex);
1314 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1315 if (ret != MEDIA_PACKET_ERROR_NONE)
1316 CAM_LOG_ERROR("get tbm_surface failed 0x%x", ret);
1319 tbm_surface_destroy(tsurf);
1323 return MEDIA_PACKET_FINALIZE;
1326 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1331 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1332 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1336 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1338 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1340 if (cb_info->user_cb[event] == NULL) {
1341 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1342 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1343 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1344 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1345 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1346 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1350 /* return buffer message should be sent for some events.
1351 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1352 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1353 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1354 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1359 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1365 muse_camera_msg_get(previous, recv_msg);
1366 muse_camera_msg_get(current, recv_msg);
1367 muse_camera_msg_get(by_policy, recv_msg);
1369 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1370 previous, current, by_policy);
1372 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1373 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1376 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1380 muse_camera_msg_get(state, recv_msg);
1382 CAM_LOG_INFO("FOCUS state - %d", state);
1384 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1387 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1388 CAM_LOG_INFO("CAPTURE_COMPLETED");
1389 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1391 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1392 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1393 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1396 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1400 muse_camera_msg_get(percent, recv_msg);
1402 CAM_LOG_INFO("HDR progress - %d %%", percent);
1404 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1407 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1413 muse_camera_msg_get(policy, recv_msg);
1414 muse_camera_msg_get(previous, recv_msg);
1415 muse_camera_msg_get(current, recv_msg);
1417 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1419 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1420 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1423 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1428 muse_camera_msg_get(policy, recv_msg);
1429 muse_camera_msg_get(state, recv_msg);
1431 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1433 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1434 (camera_state_e)state, cb_info->user_data[event]);
1437 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1438 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1440 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1443 int current_state = 0;
1445 muse_camera_msg_get(error, recv_msg);
1446 muse_camera_msg_get(current_state, recv_msg);
1448 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1450 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1451 (camera_state_e)current_state, cb_info->user_data[event]);
1455 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1457 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1458 muse_camera_msg_get(param1, recv_msg);
1459 muse_camera_msg_get(param2, recv_msg);
1461 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1463 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1464 cb_info->user_cb[event] = NULL;
1465 cb_info->user_data[event] = NULL;
1466 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1469 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1471 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1473 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1475 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1477 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1479 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1481 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1483 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1485 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1487 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1489 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1491 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1493 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1496 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1498 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1499 muse_camera_msg_get(param1, recv_msg);
1501 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1503 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1504 cb_info->user_cb[event] = NULL;
1505 cb_info->user_data[event] = NULL;
1506 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1510 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1511 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1514 CAM_LOG_WARNING("unhandled event %d", event);
1518 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1523 static gboolean _camera_idle_event_callback(gpointer data)
1525 camera_cb_info_s *cb_info = NULL;
1526 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1528 if (cam_idle_event == NULL) {
1529 CAM_LOG_ERROR("cam_idle_event is NULL");
1534 g_mutex_lock(&g_cam_idle_event_lock);
1536 cb_info = cam_idle_event->cb_info;
1537 if (cb_info == NULL) {
1538 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1539 g_mutex_unlock(&g_cam_idle_event_lock);
1540 goto IDLE_EVENT_CALLBACK_DONE;
1543 /* remove event from list */
1544 if (cb_info->idle_event_list)
1545 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1547 g_mutex_unlock(&g_cam_idle_event_lock);
1550 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1552 IDLE_EVENT_CALLBACK_DONE:
1554 g_free(cam_idle_event);
1555 cam_idle_event = NULL;
1560 static gpointer _camera_msg_handler_func(gpointer data)
1564 camera_message_s *cam_msg = NULL;
1565 camera_idle_event_s *cam_idle_event = NULL;
1566 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1567 camera_cb_info_s *cb_info = NULL;
1569 if (!handler_info || !handler_info->cb_info) {
1570 CAM_LOG_ERROR("NULL handler %p", handler_info);
1574 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1575 type = handler_info->type;
1577 CAM_LOG_INFO("t:%d start", type);
1579 g_mutex_lock(&handler_info->mutex);
1581 while (g_atomic_int_get(&handler_info->running)) {
1582 if (g_queue_is_empty(handler_info->queue)) {
1583 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1584 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1585 CAM_LOG_VERBOSE("t[%d] signal received", type);
1587 if (g_atomic_int_get(&handler_info->running) == 0) {
1588 CAM_LOG_INFO("t:%d stop event thread", type);
1593 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1595 g_mutex_unlock(&handler_info->mutex);
1597 if (cam_msg == NULL) {
1598 CAM_LOG_ERROR("t:%d NULL message", type);
1599 g_mutex_lock(&handler_info->mutex);
1605 if (api < MUSE_CAMERA_API_MAX) {
1608 g_mutex_lock(&cb_info->api_mutex[api]);
1610 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1611 if (cb_info->api_waiting[api] > 0) {
1612 cb_info->api_ret[api] = ret;
1613 cb_info->api_activating[api] = TRUE;
1615 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1617 g_cond_signal(&cb_info->api_cond[api]);
1619 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1622 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1625 g_mutex_unlock(&cb_info->api_mutex[api]);
1626 } else if (api == MUSE_CAMERA_CB_EVENT) {
1627 switch (cam_msg->event_class) {
1628 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1629 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1631 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1632 cam_idle_event = g_new0(camera_idle_event_s, 1);
1633 if (cam_idle_event == NULL) {
1634 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1638 cam_idle_event->event = cam_msg->event;
1639 cam_idle_event->cb_info = cb_info;
1641 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1642 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1644 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1645 type, cam_msg->event, cam_idle_event);
1647 g_mutex_lock(&g_cam_idle_event_lock);
1648 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1649 g_mutex_unlock(&g_cam_idle_event_lock);
1651 g_idle_add_full(G_PRIORITY_DEFAULT,
1652 (GSourceFunc)_camera_idle_event_callback,
1653 (gpointer)cam_idle_event,
1657 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1661 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1667 g_mutex_lock(&handler_info->mutex);
1670 /* remove remained event */
1671 while (!g_queue_is_empty(handler_info->queue)) {
1672 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1674 CAM_LOG_INFO("t:%d remove camera message %p", type, cam_msg);
1678 CAM_LOG_WARNING("t:%d NULL camera message", type);
1682 g_mutex_unlock(&handler_info->mutex);
1684 CAM_LOG_INFO("t:%d return", type);
1690 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1692 camera_idle_event_s *cam_idle_event = NULL;
1695 if (cb_info == NULL) {
1696 CAM_LOG_ERROR("cb_info is NULL");
1700 g_mutex_lock(&g_cam_idle_event_lock);
1702 if (cb_info->idle_event_list == NULL) {
1703 CAM_LOG_INFO("No remained idle event");
1704 g_mutex_unlock(&g_cam_idle_event_lock);
1708 list = cb_info->idle_event_list;
1711 cam_idle_event = list->data;
1712 list = g_list_next(list);
1714 if (!cam_idle_event) {
1715 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1719 if (g_idle_remove_by_data(cam_idle_event)) {
1720 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1722 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1724 g_free(cam_idle_event);
1725 cam_idle_event = NULL;
1730 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1731 cam_idle_event, cam_idle_event->event);
1733 cam_idle_event->cb_info = NULL;
1735 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1738 g_list_free(cb_info->idle_event_list);
1739 cb_info->idle_event_list = NULL;
1741 g_mutex_unlock(&g_cam_idle_event_lock);
1747 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1749 camera_message_s *cam_msg = NULL;
1751 if (!cb_info || !msg) {
1752 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1756 cam_msg = g_new0(camera_message_s, 1);
1758 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1763 cam_msg->event = event;
1764 cam_msg->event_class = event_class;
1766 if (tfd && tfd[0] >= 0)
1767 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1769 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1771 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1772 api, event, event_class);
1774 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1775 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1776 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1777 g_cond_signal(&cb_info->preview_cb_info.cond);
1778 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1779 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1780 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1781 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1782 g_cond_signal(&cb_info->capture_cb_info.cond);
1783 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1785 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1786 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1787 g_cond_signal(&cb_info->msg_handler_info.cond);
1788 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1797 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1799 int ret = CAMERA_ERROR_NONE;
1803 int event_class = -1;
1807 if (!cb_info || !msg) {
1808 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
1812 CAM_LOG_DEBUG("msg[%s]", msg);
1814 if (!muse_camera_msg_get(api, msg)) {
1815 CAM_LOG_ERROR("failed to get camera api");
1819 if (api == MUSE_CAMERA_CB_EVENT) {
1820 if (!muse_camera_msg_get(event, msg) ||
1821 !muse_camera_msg_get(event_class, msg)) {
1822 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
1826 if (!muse_camera_msg_get(api_class, msg)) {
1827 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
1832 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1833 if (api >= MUSE_CAMERA_API_MAX) {
1834 CAM_LOG_ERROR("invalid api %d", api);
1838 if (!muse_camera_msg_get(ret, msg)) {
1839 CAM_LOG_ERROR("failed to get camera ret");
1843 g_mutex_lock(&cb_info->api_mutex[api]);
1846 case MUSE_CAMERA_API_CREATE:
1847 if (ret != CAMERA_ERROR_NONE) {
1848 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1849 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
1852 case MUSE_CAMERA_API_DESTROY:
1853 if (ret == CAMERA_ERROR_NONE) {
1854 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1855 CAM_LOG_INFO("camera destroy done. close client cb handler");
1859 muse_camera_msg_get(get_type, msg);
1860 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1861 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1862 muse_camera_msg_get(get_index, msg);
1865 case MUSE_CAMERA_GET_TYPE_INT:
1866 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1868 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1869 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1870 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1872 case MUSE_CAMERA_GET_TYPE_ARRAY:
1873 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1874 muse_core_msg_deserialize("get_value",
1875 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1876 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
1877 cb_info->get_display_roi_area[0],
1878 cb_info->get_display_roi_area[1],
1879 cb_info->get_display_roi_area[2],
1880 cb_info->get_display_roi_area[3]);
1882 muse_core_msg_deserialize("get_value",
1883 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1884 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
1885 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1888 case MUSE_CAMERA_GET_TYPE_STRING:
1889 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1892 CAM_LOG_WARNING("unknown type %d", get_type);
1899 if (cb_info->api_waiting[api] > 0) {
1900 cb_info->api_ret[api] = ret;
1901 cb_info->api_activating[api] = TRUE;
1903 g_cond_signal(&cb_info->api_cond[api]);
1905 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1908 g_mutex_unlock(&cb_info->api_mutex[api]);
1909 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1910 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
1912 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
1919 static gpointer _camera_msg_recv_func(gpointer data)
1922 int recv_length = 0;
1923 int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
1924 char *recv_msg = NULL;
1925 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1928 CAM_LOG_ERROR("cb_info NULL");
1932 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
1934 recv_msg = cb_info->recv_msg;
1936 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1937 for (i = 0 ; i < MUSE_NUM_FD ; i++)
1940 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
1941 if (recv_length <= 0) {
1942 cb_info->is_server_connected = FALSE;
1943 CAM_LOG_ERROR("receive msg failed - server disconnected");
1948 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
1950 recv_msg[recv_length] = '\0';
1952 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
1954 __camera_process_msg(cb_info, recv_msg, tfd);
1957 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
1959 if (!cb_info->is_server_connected) {
1960 char *error_msg = NULL;
1962 if (cb_info->bufmgr == NULL) {
1963 CAM_LOG_ERROR("No need to send error(handle is not created)");
1967 if (cb_info->fd < 0) {
1968 CAM_LOG_ERROR("fd is closed in client side");
1972 /* send error msg for server disconnection */
1973 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1974 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1975 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1979 CAM_LOG_ERROR("error_msg failed");
1983 __camera_add_msg_to_queue(cb_info,
1984 MUSE_CAMERA_CB_EVENT,
1985 MUSE_CAMERA_EVENT_TYPE_ERROR,
1986 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1990 muse_core_msg_free(error_msg);
1993 CAM_LOG_ERROR("add error msg for service disconnection done");
2000 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2001 int type, const char *thread_name, camera_cb_info_s *cb_info)
2003 if (!handler_info || !thread_name || !cb_info) {
2004 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2005 type, handler_info, thread_name, cb_info);
2009 CAM_LOG_INFO("t:%d", type);
2011 handler_info->type = type;
2012 handler_info->queue = g_queue_new();
2013 if (handler_info->queue == NULL) {
2014 CAM_LOG_ERROR("t:%d queue failed", type);
2018 g_mutex_init(&handler_info->mutex);
2019 g_cond_init(&handler_info->cond);
2021 handler_info->cb_info = (void *)cb_info;
2022 g_atomic_int_set(&handler_info->running, 1);
2024 handler_info->thread = g_thread_try_new(thread_name,
2025 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2026 if (handler_info->thread == NULL) {
2027 CAM_LOG_ERROR("t:%d thread failed", type);
2029 g_mutex_clear(&handler_info->mutex);
2030 g_cond_clear(&handler_info->cond);
2031 g_queue_free(handler_info->queue);
2032 handler_info->queue = NULL;
2037 CAM_LOG_INFO("t:%d done", type);
2043 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2047 if (!handler_info) {
2048 CAM_LOG_ERROR("NULL handler");
2052 if (!handler_info->thread) {
2053 CAM_LOG_WARNING("thread is not created");
2057 type = handler_info->type;
2059 CAM_LOG_INFO("t:%d thread %p", type, handler_info->thread);
2061 g_mutex_lock(&handler_info->mutex);
2062 g_atomic_int_set(&handler_info->running, 0);
2063 g_cond_signal(&handler_info->cond);
2064 g_mutex_unlock(&handler_info->mutex);
2066 g_thread_join(handler_info->thread);
2067 handler_info->thread = NULL;
2069 g_mutex_clear(&handler_info->mutex);
2070 g_cond_clear(&handler_info->cond);
2071 g_queue_free(handler_info->queue);
2072 handler_info->queue = NULL;
2074 CAM_LOG_INFO("t:%d done", type);
2080 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2082 camera_cb_info_s *cb_info = NULL;
2085 g_return_val_if_fail(sockfd > 0, NULL);
2087 cb_info = g_new0(camera_cb_info_s, 1);
2088 if (cb_info == NULL) {
2089 CAM_LOG_ERROR("cb_info failed");
2093 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2095 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2096 g_mutex_init(&cb_info->api_mutex[i]);
2097 g_cond_init(&cb_info->api_cond[i]);
2100 g_mutex_init(&cb_info->fd_lock);
2101 g_mutex_init(&cb_info->mp_data_mutex);
2103 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2104 g_mutex_init(&cb_info->user_cb_mutex[i]);
2106 /* message handler thread */
2107 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2108 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2109 CAM_LOG_ERROR("msg_handler_info failed");
2113 /* message handler thread for preview callback */
2114 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2115 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2116 CAM_LOG_ERROR("preview_cb_info failed");
2120 /* message handler thread for capture callback */
2121 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2122 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2123 CAM_LOG_ERROR("capture_cb_info failed");
2127 cb_info->fd = sockfd;
2128 cb_info->preview_cb_flag = 0;
2130 /* message receive thread */
2131 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2132 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2133 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2134 if (cb_info->msg_recv_thread == NULL) {
2135 CAM_LOG_ERROR("message receive thread creation failed");
2140 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2141 cb_info->fds[i] = -1;
2143 cb_info->is_server_connected = TRUE;
2149 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2150 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2151 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2153 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2154 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2156 g_mutex_clear(&cb_info->fd_lock);
2157 g_mutex_clear(&cb_info->mp_data_mutex);
2159 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2160 g_mutex_clear(&cb_info->api_mutex[i]);
2161 g_cond_clear(&cb_info->api_cond[i]);
2172 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2176 g_return_if_fail(cb_info != NULL);
2178 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2180 g_thread_join(cb_info->msg_recv_thread);
2181 cb_info->msg_recv_thread = NULL;
2183 CAM_LOG_INFO("msg_recv thread removed");
2185 /* destroy msg handler threads */
2186 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2187 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2188 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2190 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2191 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2193 g_mutex_clear(&cb_info->fd_lock);
2194 g_mutex_clear(&cb_info->mp_data_mutex);
2196 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2197 g_mutex_clear(&cb_info->api_mutex[i]);
2198 g_cond_clear(&cb_info->api_cond[i]);
2201 if (cb_info->fd > -1) {
2202 muse_client_close(cb_info->fd);
2206 if (cb_info->bufmgr) {
2207 tbm_bufmgr_deinit(cb_info->bufmgr);
2208 cb_info->bufmgr = NULL;
2210 if (cb_info->pkt_fmt) {
2211 media_format_unref(cb_info->pkt_fmt);
2212 cb_info->pkt_fmt = NULL;
2215 if (cb_info->dp_interface) {
2216 mm_display_interface_deinit(cb_info->dp_interface);
2217 cb_info->dp_interface = NULL;
2220 cb_info->preview_cb_flag = 0;
2228 int _camera_start_evas_rendering(camera_h camera)
2230 camera_cli_s *pc = (camera_cli_s *)camera;
2232 if (!pc || !pc->cb_info) {
2233 CAM_LOG_ERROR("NULL handle");
2234 return CAMERA_ERROR_INVALID_PARAMETER;
2237 CAM_LOG_INFO("start");
2239 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2240 CAM_LOG_ERROR("EVAS surface is not set");
2241 return CAMERA_ERROR_NONE;
2244 /* set evas render flag as RUN */
2245 pc->cb_info->run_evas_render = true;
2247 return CAMERA_ERROR_NONE;
2251 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2253 int ret = CAMERA_ERROR_NONE;
2254 camera_cli_s *pc = (camera_cli_s *)camera;
2256 if (!pc || !pc->cb_info) {
2257 CAM_LOG_ERROR("NULL handle");
2258 return CAMERA_ERROR_INVALID_PARAMETER;
2261 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2263 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2264 CAM_LOG_ERROR("EVAS surface is not set");
2265 return CAMERA_ERROR_NONE;
2268 /* set evas render flag as STOP and release buffers */
2269 pc->cb_info->run_evas_render = false;
2271 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2272 if (ret == MM_ERROR_NONE) {
2273 ret = CAMERA_ERROR_NONE;
2275 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2276 ret = CAMERA_ERROR_INVALID_OPERATION;
2283 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2285 int ret = CAMERA_ERROR_NONE;
2287 int module_index = -1;
2289 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2291 /* create muse connection */
2292 if (!key || !value) {
2293 CAM_LOG_ERROR("NULL pointer");
2294 return CAMERA_ERROR_INVALID_PARAMETER;
2297 sock_fd = muse_client_new();
2299 CAM_LOG_ERROR("muse_client_new failed");
2300 return CAMERA_ERROR_INVALID_OPERATION;
2303 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2304 CAM_LOG_ERROR("muse client get module index failed");
2305 ret = CAMERA_ERROR_INVALID_OPERATION;
2309 msg = muse_core_msg_new(api,
2310 MUSE_TYPE_INT, "module", module_index,
2311 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2314 CAM_LOG_ERROR("msg failed");
2315 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2319 ret = muse_core_msg_send(sock_fd, msg);
2321 muse_core_msg_free(msg);
2325 CAM_LOG_ERROR("send msg failed");
2326 ret = CAMERA_ERROR_INVALID_OPERATION;
2330 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2332 CAM_LOG_ERROR("recv msg failed %d", errno);
2333 ret = CAMERA_ERROR_INVALID_OPERATION;
2337 if (!muse_camera_msg_get(ret, recv_msg)) {
2338 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2339 ret = CAMERA_ERROR_INVALID_OPERATION;
2343 if (ret == CAMERA_ERROR_NONE)
2344 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2346 CAM_LOG_INFO("api %d - value %d", api, *value);
2350 muse_client_close(sock_fd);
2358 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2361 char *send_msg = NULL;
2363 int ret = CAMERA_ERROR_NONE;
2364 camera_cli_s *pc = NULL;
2365 tbm_bufmgr bufmgr = NULL;
2367 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2368 int module_index = -1;
2369 int device_type = (int)device;
2372 CAM_LOG_ERROR("NULL pointer");
2373 return CAMERA_ERROR_INVALID_PARAMETER;
2376 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2378 sock_fd = muse_client_new();
2380 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2381 ret = CAMERA_ERROR_INVALID_OPERATION;
2385 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2386 CAM_LOG_ERROR("muse client get module index failed");
2387 ret = CAMERA_ERROR_INVALID_OPERATION;
2391 send_msg = muse_core_msg_new(api,
2392 MUSE_TYPE_INT, "module", module_index,
2393 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2394 MUSE_TYPE_INT, "is_network", (int)is_network,
2398 CAM_LOG_ERROR("NULL msg");
2399 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2403 send_ret = muse_core_msg_send(sock_fd, send_msg);
2405 muse_core_msg_free(send_msg);
2409 CAM_LOG_ERROR("send msg failed %d", errno);
2410 ret = CAMERA_ERROR_INVALID_OPERATION;
2414 pc = g_new0(camera_cli_s, 1);
2416 CAM_LOG_ERROR("camera_cli_s alloc failed");
2417 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2421 bufmgr = tbm_bufmgr_init(-1);
2422 if (bufmgr == NULL) {
2423 CAM_LOG_ERROR("get tbm bufmgr failed");
2424 ret = CAMERA_ERROR_INVALID_OPERATION;
2428 pc->cb_info = _camera_client_callback_new(sock_fd);
2429 if (pc->cb_info == NULL) {
2430 CAM_LOG_ERROR("cb_info alloc failed");
2431 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2437 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2439 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2441 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2443 if (ret == CAMERA_ERROR_NONE) {
2444 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2445 int user_buffer_supported = 0;
2446 int log_level = CAMERA_LOG_LEVEL_INFO;
2447 intptr_t handle = 0;
2449 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2451 CAM_LOG_ERROR("Receiving Handle Failed!!");
2452 ret = CAMERA_ERROR_INVALID_OPERATION;
2456 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2457 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2458 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2460 pc->remote_handle = handle;
2461 pc->cb_info->bufmgr = bufmgr;
2462 pc->cb_info->preview_format = preview_format;
2463 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2464 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2465 g_mmcam_log_level = log_level;
2467 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2468 preview_format, user_buffer_supported, g_mmcam_log_level);
2470 *camera = (camera_h)pc;
2472 /* get display interface handle */
2473 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2474 CAM_LOG_WARNING("display interface init failed");
2483 tbm_bufmgr_deinit(bufmgr);
2488 muse_client_close(sock_fd);
2494 int temp_fd = pc->cb_info->fd;
2496 /* pc->cb_info->fd should be closed,
2497 because g_thread_join for msg_recv_thread is not returned
2498 in _camera_client_callback_destroy. */
2500 pc->cb_info->fd = -1;
2501 muse_client_close(temp_fd);
2504 _camera_client_callback_destroy(pc->cb_info);
2511 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2518 int camera_create(camera_device_e device, camera_h *camera)
2520 return _camera_create_private(device, false, camera);
2524 int camera_change_device(camera_h camera, camera_device_e device)
2527 int ret = CAMERA_ERROR_NONE;
2528 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2529 camera_cli_s *pc = (camera_cli_s *)camera;
2530 camera_msg_param param;
2532 if (!pc || !pc->cb_info) {
2533 CAM_LOG_ERROR("NULL handle");
2534 return CAMERA_ERROR_INVALID_PARAMETER;
2537 CAMERA_MSG_PARAM_SET(param, INT, device);
2539 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2541 if (ret == CAMERA_ERROR_NONE) {
2542 /* reset callback and user data */
2543 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2544 pc->cb_info->user_cb[i] = NULL;
2545 pc->cb_info->user_data[i] = NULL;
2547 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2554 int camera_destroy(camera_h camera)
2556 int ret = CAMERA_ERROR_NONE;
2557 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2558 camera_cli_s *pc = (camera_cli_s *)camera;
2560 if (!pc || !pc->cb_info) {
2561 CAM_LOG_ERROR("NULL handle");
2562 return CAMERA_ERROR_INVALID_PARAMETER;
2565 CAM_LOG_INFO("Enter");
2567 if (pc->cb_info->is_server_connected)
2568 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2570 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2572 if (ret == CAMERA_ERROR_NONE) {
2573 _camera_deactivate_idle_event_all(pc->cb_info);
2574 _camera_client_callback_destroy(pc->cb_info);
2581 CAM_LOG_INFO("ret : 0x%x", ret);
2586 int camera_start_preview(camera_h camera)
2588 int ret = CAMERA_ERROR_NONE;
2589 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2590 camera_cli_s *pc = (camera_cli_s *)camera;
2591 camera_state_e current_state = CAMERA_STATE_NONE;
2593 if (!pc || !pc->cb_info) {
2594 CAM_LOG_ERROR("NULL handle");
2595 return CAMERA_ERROR_INVALID_PARAMETER;
2598 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2599 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2601 ret = camera_get_state(camera, ¤t_state);
2602 if (ret != CAMERA_ERROR_NONE) {
2603 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2607 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2608 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2609 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2610 pc->cb_info->dp_info.type);
2611 return CAMERA_ERROR_INVALID_OPERATION;
2614 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2615 if (!_camera_allocate_preview_buffer(camera))
2616 return CAMERA_ERROR_INVALID_OPERATION;
2618 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2620 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2623 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2624 ret = _camera_start_evas_rendering(camera);
2625 if (ret != CAMERA_ERROR_NONE) {
2626 CAM_LOG_ERROR("stop preview because of error");
2627 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2631 CAM_LOG_INFO("ret : 0x%x", ret);
2637 int camera_stop_preview(camera_h camera)
2639 int ret = CAMERA_ERROR_NONE;
2640 camera_cli_s *pc = (camera_cli_s *)camera;
2641 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2642 camera_state_e current_state = CAMERA_STATE_NONE;
2644 if (!pc || !pc->cb_info) {
2645 CAM_LOG_ERROR("NULL handle");
2646 return CAMERA_ERROR_INVALID_PARAMETER;
2649 CAM_LOG_INFO("Enter");
2652 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2653 ret = camera_get_state(camera, ¤t_state);
2654 if (ret != CAMERA_ERROR_NONE) {
2655 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2659 if (current_state == CAMERA_STATE_PREVIEW) {
2660 ret = _camera_stop_evas_rendering(camera, false);
2661 if (ret != CAMERA_ERROR_NONE)
2666 /* send stop preview message */
2667 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2669 if (ret == CAMERA_ERROR_NONE) {
2670 if (pc->cb_info->user_buffer_supported)
2671 _camera_release_preview_buffer(camera);
2672 } else if (current_state == CAMERA_STATE_PREVIEW) {
2673 CAM_LOG_WARNING("restart evas rendering");
2674 _camera_start_evas_rendering(camera);
2677 CAM_LOG_INFO("ret : 0x%x", ret);
2683 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2685 int ret = CAMERA_ERROR_NONE;
2686 camera_cli_s *pc = (camera_cli_s *)camera;
2687 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2689 if (!pc || !pc->cb_info) {
2690 CAM_LOG_ERROR("NULL handle");
2691 return CAMERA_ERROR_INVALID_PARAMETER;
2694 CAM_LOG_INFO("Enter");
2696 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2697 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2699 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2700 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2702 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2704 CAM_LOG_INFO("ret : 0x%x", ret);
2710 bool camera_is_supported_continuous_capture(camera_h camera)
2712 int ret = CAMERA_ERROR_NONE;
2713 camera_cli_s *pc = (camera_cli_s *)camera;
2714 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2716 if (!pc || !pc->cb_info) {
2717 CAM_LOG_ERROR("NULL handle");
2718 return CAMERA_ERROR_INVALID_PARAMETER;
2721 CAM_LOG_INFO("Enter");
2723 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2726 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2730 CAM_LOG_INFO("ret : %d", ret);
2736 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)
2738 int ret = CAMERA_ERROR_NONE;
2739 camera_cli_s *pc = (camera_cli_s *)camera;
2740 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2741 camera_msg_param param;
2744 if (!pc || !pc->cb_info) {
2745 CAM_LOG_ERROR("NULL handle");
2746 return CAMERA_ERROR_INVALID_PARAMETER;
2749 CAM_LOG_INFO("Enter");
2751 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2752 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2754 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2755 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2757 value = (count << 16) | interval;
2758 CAMERA_MSG_PARAM_SET(param, INT, value);
2760 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2762 CAM_LOG_INFO("ret : 0x%x", ret);
2768 int camera_stop_continuous_capture(camera_h camera)
2770 int ret = CAMERA_ERROR_NONE;
2771 camera_cli_s *pc = (camera_cli_s *)camera;
2772 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2774 if (!pc || !pc->cb_info) {
2775 CAM_LOG_ERROR("NULL handle");
2776 return CAMERA_ERROR_INVALID_PARAMETER;
2779 CAM_LOG_INFO("Enter");
2781 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2783 CAM_LOG_INFO("ret : 0x%x", ret);
2789 bool camera_is_supported_face_detection(camera_h camera)
2791 int ret = CAMERA_ERROR_NONE;
2792 camera_cli_s *pc = (camera_cli_s *)camera;
2793 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2795 if (!pc || !pc->cb_info) {
2796 CAM_LOG_ERROR("NULL handle");
2797 return CAMERA_ERROR_INVALID_PARAMETER;
2800 CAM_LOG_INFO("Enter");
2802 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2805 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2809 CAM_LOG_INFO("ret : %d", ret);
2815 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2817 int ret = CAMERA_ERROR_NONE;
2818 camera_cli_s *pc = (camera_cli_s *)camera;
2819 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2821 if (!pc || !pc->cb_info) {
2822 CAM_LOG_ERROR("NULL handle");
2823 return CAMERA_ERROR_INVALID_PARAMETER;
2826 CAM_LOG_INFO("Enter");
2828 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2831 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2835 CAM_LOG_INFO("ret : %d", ret);
2841 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2843 int ret = CAMERA_ERROR_NONE;
2844 camera_cli_s *pc = (camera_cli_s *)camera;
2845 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2847 if (!pc || !pc->cb_info) {
2848 CAM_LOG_ERROR("NULL handle");
2849 return CAMERA_ERROR_INVALID_PARAMETER;
2852 CAM_LOG_INFO("Enter");
2854 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2857 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2861 CAM_LOG_INFO("ret : %d", ret);
2866 int camera_get_device_count(camera_h camera, int *device_count)
2868 int ret = CAMERA_ERROR_NONE;
2869 camera_cli_s *pc = (camera_cli_s *)camera;
2870 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2872 if (!pc || !pc->cb_info) {
2873 CAM_LOG_ERROR("NULL handle");
2874 return CAMERA_ERROR_INVALID_PARAMETER;
2877 CAM_LOG_INFO("Enter");
2879 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2881 if (ret == CAMERA_ERROR_NONE)
2882 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2884 CAM_LOG_INFO("ret : 0x%x", ret);
2889 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2891 int ret = CAMERA_ERROR_NONE;
2892 camera_cli_s *pc = (camera_cli_s *)camera;
2893 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2895 if (!pc || !pc->cb_info) {
2896 CAM_LOG_ERROR("NULL handle");
2897 return CAMERA_ERROR_INVALID_PARAMETER;
2900 CAM_LOG_INFO("Enter");
2902 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2904 if (ret == CAMERA_ERROR_NONE) {
2905 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2907 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2908 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2910 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2913 CAM_LOG_INFO("ret : 0x%x", ret);
2918 int camera_stop_face_detection(camera_h camera)
2920 int ret = CAMERA_ERROR_NONE;
2921 camera_cli_s *pc = (camera_cli_s *)camera;
2922 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2924 if (!pc || !pc->cb_info) {
2925 CAM_LOG_ERROR("NULL handle");
2926 return CAMERA_ERROR_INVALID_PARAMETER;
2929 CAM_LOG_INFO("Enter");
2931 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2933 if (ret == CAMERA_ERROR_NONE) {
2934 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2936 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2937 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2939 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2942 CAM_LOG_INFO("ret : 0x%x", ret);
2947 int camera_get_state(camera_h camera, camera_state_e *state)
2949 int ret = CAMERA_ERROR_NONE;
2950 camera_cli_s *pc = (camera_cli_s *)camera;
2951 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2953 if (!pc || !pc->cb_info || !state) {
2954 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
2955 return CAMERA_ERROR_INVALID_PARAMETER;
2958 CAM_LOG_INFO("Enter");
2960 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2962 if (ret == CAMERA_ERROR_NONE)
2963 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2965 CAM_LOG_INFO("ret : 0x%x", ret);
2970 int camera_start_focusing(camera_h camera, bool continuous)
2972 int ret = CAMERA_ERROR_NONE;
2973 camera_cli_s *pc = (camera_cli_s *)camera;
2974 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2975 camera_msg_param param;
2976 int is_continuous = (int)continuous;
2978 if (!pc || !pc->cb_info) {
2979 CAM_LOG_ERROR("NULL handle");
2980 return CAMERA_ERROR_INVALID_PARAMETER;
2983 CAM_LOG_INFO("Enter");
2985 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2987 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2989 CAM_LOG_INFO("ret : 0x%x", ret);
2994 int camera_cancel_focusing(camera_h camera)
2996 int ret = CAMERA_ERROR_NONE;
2997 camera_cli_s *pc = (camera_cli_s *)camera;
2998 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3000 if (!pc || !pc->cb_info) {
3001 CAM_LOG_ERROR("NULL handle");
3002 return CAMERA_ERROR_INVALID_PARAMETER;
3005 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3007 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3009 CAM_LOG_INFO("ret : 0x%x", ret);
3015 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3017 int mm_ret = MM_ERROR_NONE;
3018 int ret = CAMERA_ERROR_NONE;
3019 camera_cli_s *pc = (camera_cli_s *)camera;
3020 camera_cb_info_s *cb_info = NULL;
3021 camera_state_e current_state = CAMERA_STATE_NONE;
3022 camera_msg_param param;
3023 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3024 muse_camera_display_info_s *dp_info = NULL;
3026 if (!pc || !pc->cb_info) {
3027 CAM_LOG_ERROR("NULL handle");
3028 return CAMERA_ERROR_INVALID_PARAMETER;
3031 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3032 CAM_LOG_ERROR("invalid type %d", type);
3033 return CAMERA_ERROR_INVALID_PARAMETER;
3036 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3037 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3038 return CAMERA_ERROR_INVALID_PARAMETER;
3041 cb_info = (camera_cb_info_s *)pc->cb_info;
3042 dp_info = &cb_info->dp_info;
3044 ret = camera_get_state(camera, ¤t_state);
3045 if (ret != CAMERA_ERROR_NONE) {
3046 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3050 if (current_state != CAMERA_STATE_CREATED) {
3051 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3052 return CAMERA_ERROR_INVALID_STATE;
3055 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3057 if (type != MM_DISPLAY_TYPE_NONE) {
3058 /* check display interface handle */
3059 if (!cb_info->dp_interface) {
3060 CAM_LOG_ERROR("display interface not supported");
3061 return CAMERA_ERROR_NOT_SUPPORTED;
3064 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3065 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3066 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3067 return CAMERA_ERROR_NOT_SUPPORTED;
3068 } else if (mm_ret != MM_ERROR_NONE) {
3069 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3070 return CAMERA_ERROR_INVALID_OPERATION;
3073 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3074 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3076 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3077 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3078 dp_info->window_rect.width, dp_info->window_rect.height);
3079 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3081 camera_flip_e flip = CAMERA_FLIP_NONE;
3082 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3083 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3090 camera_get_display_flip(camera, &flip);
3091 camera_get_display_mode(camera, &mode);
3092 camera_get_display_rotation(camera, &rotation);
3093 camera_is_display_visible(camera, &visible);
3095 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3096 flip, mode, rotation, visible);
3098 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3099 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3100 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3101 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3103 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3104 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3105 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3106 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3112 if (mm_ret != MM_ERROR_NONE) {
3113 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3114 return CAMERA_ERROR_INVALID_OPERATION;
3117 dp_info->type = type;
3119 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3121 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3123 if (ret == CAMERA_ERROR_NONE) {
3124 if (type == MM_DISPLAY_TYPE_EVAS)
3125 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3132 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3134 CAM_LOG_INFO("type %d, display %p", type, display);
3135 return _camera_set_display(camera, (mm_display_type_e)type, display);
3139 int camera_set_preview_resolution(camera_h camera, int width, int height)
3141 int ret = CAMERA_ERROR_NONE;
3142 camera_state_e current_state = CAMERA_STATE_NONE;
3143 camera_cli_s *pc = (camera_cli_s *)camera;
3144 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3145 camera_msg_param param;
3148 if (!pc || !pc->cb_info) {
3149 CAM_LOG_ERROR("NULL handle");
3150 return CAMERA_ERROR_INVALID_PARAMETER;
3153 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3154 ret = camera_get_state(camera, ¤t_state);
3155 if (ret != CAMERA_ERROR_NONE) {
3156 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3160 if (current_state == CAMERA_STATE_PREVIEW) {
3161 ret = _camera_stop_evas_rendering(camera, true);
3162 if (ret != CAMERA_ERROR_NONE)
3167 value = (width << 16) | height;
3168 CAMERA_MSG_PARAM_SET(param, INT, value);
3170 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3172 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3174 CAM_LOG_INFO("ret : 0x%x", ret);
3176 if (current_state == CAMERA_STATE_PREVIEW) {
3177 CAM_LOG_WARNING("restart evas rendering");
3178 _camera_start_evas_rendering(camera);
3185 int camera_set_capture_resolution(camera_h camera, int width, int height)
3187 int ret = CAMERA_ERROR_NONE;
3188 camera_cli_s *pc = (camera_cli_s *)camera;
3189 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3190 camera_msg_param param;
3193 if (!pc || !pc->cb_info) {
3194 CAM_LOG_ERROR("NULL handle");
3195 return CAMERA_ERROR_INVALID_PARAMETER;
3198 CAM_LOG_INFO("Enter");
3200 value = (width << 16) | height;
3201 CAMERA_MSG_PARAM_SET(param, INT, value);
3203 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3205 CAM_LOG_INFO("ret : 0x%x", ret);
3211 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3213 int ret = CAMERA_ERROR_NONE;
3214 int set_format = (int)format;
3215 camera_cli_s *pc = (camera_cli_s *)camera;
3216 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3217 camera_msg_param param;
3219 if (!pc || !pc->cb_info) {
3220 CAM_LOG_ERROR("NULL handle");
3221 return CAMERA_ERROR_INVALID_PARAMETER;
3224 CAM_LOG_INFO("Enter - format %d", set_format);
3226 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3228 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3230 CAM_LOG_INFO("ret : 0x%x", ret);
3236 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3238 int ret = CAMERA_ERROR_NONE;
3239 int set_format = (int)format;
3240 camera_msg_param param;
3241 camera_cli_s *pc = (camera_cli_s *)camera;
3242 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3244 if (!pc || !pc->cb_info) {
3245 CAM_LOG_ERROR("NULL handle");
3246 return CAMERA_ERROR_INVALID_PARAMETER;
3249 CAM_LOG_INFO("Enter - format %d", set_format);
3251 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3253 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3255 if (ret == CAMERA_ERROR_NONE)
3256 pc->cb_info->preview_format = set_format;
3258 CAM_LOG_INFO("ret : 0x%x", ret);
3264 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3266 int ret = CAMERA_ERROR_NONE;
3267 camera_cli_s *pc = (camera_cli_s *)camera;
3268 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3270 if (!pc || !pc->cb_info || !width || !height) {
3271 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3272 return CAMERA_ERROR_INVALID_PARAMETER;
3275 CAM_LOG_INFO("Enter");
3277 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3279 if (ret == CAMERA_ERROR_NONE) {
3280 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3281 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3284 CAM_LOG_INFO("ret : 0x%x", ret);
3290 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3292 int ret = CAMERA_ERROR_NONE;
3293 int set_rotation = (int)rotation;
3294 camera_cli_s *pc = (camera_cli_s *)camera;
3295 camera_msg_param param;
3297 if (!pc || !pc->cb_info) {
3298 CAM_LOG_ERROR("NULL handle");
3299 return CAMERA_ERROR_INVALID_PARAMETER;
3302 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3303 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3304 if (ret != MM_ERROR_NONE) {
3305 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3306 return CAMERA_ERROR_INVALID_OPERATION;
3310 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3312 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3318 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3320 int ret = CAMERA_ERROR_NONE;
3321 camera_cli_s *pc = (camera_cli_s *)camera;
3323 if (!pc || !pc->cb_info || !rotation) {
3324 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3325 return CAMERA_ERROR_INVALID_PARAMETER;
3328 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3330 if (ret == CAMERA_ERROR_NONE)
3331 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3337 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3339 int ret = CAMERA_ERROR_NONE;
3340 int set_flip = (int)flip;
3341 camera_cli_s *pc = (camera_cli_s *)camera;
3342 camera_msg_param param;
3344 if (!pc || !pc->cb_info) {
3345 CAM_LOG_ERROR("NULL handle");
3346 return CAMERA_ERROR_INVALID_PARAMETER;
3349 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3350 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3351 if (ret != MM_ERROR_NONE) {
3352 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3353 return CAMERA_ERROR_INVALID_OPERATION;
3357 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3359 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3365 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3367 int ret = CAMERA_ERROR_NONE;
3368 camera_cli_s *pc = (camera_cli_s *)camera;
3370 if (!pc || !pc->cb_info || !flip) {
3371 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3372 return CAMERA_ERROR_INVALID_PARAMETER;
3375 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3377 if (ret == CAMERA_ERROR_NONE)
3378 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3384 int camera_set_display_visible(camera_h camera, bool visible)
3386 int ret = CAMERA_ERROR_NONE;
3387 int set_visible = (int)visible;
3388 camera_cli_s *pc = (camera_cli_s *)camera;
3389 camera_msg_param param;
3391 if (!pc || !pc->cb_info) {
3392 CAM_LOG_ERROR("NULL handle");
3393 return CAMERA_ERROR_INVALID_PARAMETER;
3396 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3397 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3398 if (ret != MM_ERROR_NONE) {
3399 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3400 return CAMERA_ERROR_INVALID_OPERATION;
3404 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3406 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3412 int camera_is_display_visible(camera_h camera, bool *visible)
3414 int ret = CAMERA_ERROR_NONE;
3415 camera_cli_s *pc = (camera_cli_s *)camera;
3417 if (!pc || !pc->cb_info || !visible) {
3418 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3419 return CAMERA_ERROR_INVALID_PARAMETER;
3422 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3424 if (ret == CAMERA_ERROR_NONE)
3425 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3431 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3433 int ret = CAMERA_ERROR_NONE;
3434 int set_mode = (int)mode;
3435 camera_cli_s *pc = (camera_cli_s *)camera;
3436 camera_msg_param param;
3438 if (!pc || !pc->cb_info) {
3439 CAM_LOG_ERROR("NULL handle");
3440 return CAMERA_ERROR_INVALID_PARAMETER;
3443 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3444 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3445 if (ret != MM_ERROR_NONE) {
3446 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3447 return CAMERA_ERROR_INVALID_OPERATION;
3451 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3453 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3459 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3461 int ret = CAMERA_ERROR_NONE;
3462 camera_cli_s *pc = (camera_cli_s *)camera;
3464 if (!pc || !pc->cb_info || !mode) {
3465 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3466 return CAMERA_ERROR_INVALID_PARAMETER;
3469 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3471 if (ret == CAMERA_ERROR_NONE)
3472 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3478 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3480 int ret = CAMERA_ERROR_NONE;
3481 int set_hint = (int)hint;
3482 camera_cli_s *pc = (camera_cli_s *)camera;
3483 camera_msg_param param;
3485 if (!pc || !pc->cb_info) {
3486 CAM_LOG_ERROR("NULL handle");
3487 return CAMERA_ERROR_INVALID_PARAMETER;
3490 CAM_LOG_INFO("Enter - hint %d", set_hint);
3492 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3494 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3500 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3502 int ret = CAMERA_ERROR_NONE;
3503 camera_cli_s *pc = (camera_cli_s *)camera;
3504 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3506 if (!pc || !pc->cb_info || !hint) {
3507 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3508 return CAMERA_ERROR_INVALID_PARAMETER;
3511 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3513 if (ret == CAMERA_ERROR_NONE) {
3514 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3515 CAM_LOG_INFO("display reuse hint %d", *hint);
3522 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3524 int ret = CAMERA_ERROR_NONE;
3525 camera_cli_s *pc = (camera_cli_s *)camera;
3526 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3528 if (!pc || !pc->cb_info || !width || !height) {
3529 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3530 return CAMERA_ERROR_INVALID_PARAMETER;
3533 CAM_LOG_INFO("Enter");
3535 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3537 if (ret == CAMERA_ERROR_NONE) {
3538 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3539 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3542 CAM_LOG_INFO("ret : 0x%x", ret);
3548 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3550 int ret = CAMERA_ERROR_NONE;
3551 camera_cli_s *pc = (camera_cli_s *)camera;
3552 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3554 if (!pc || !pc->cb_info || !format) {
3555 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3556 return CAMERA_ERROR_INVALID_PARAMETER;
3559 CAM_LOG_INFO("Enter");
3561 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3563 if (ret == CAMERA_ERROR_NONE)
3564 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3566 CAM_LOG_INFO("ret : 0x%x", ret);
3572 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3574 int ret = CAMERA_ERROR_NONE;
3575 camera_cli_s *pc = (camera_cli_s *)camera;
3576 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3578 if (!pc || !pc->cb_info || !format) {
3579 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3580 return CAMERA_ERROR_INVALID_PARAMETER;
3583 CAM_LOG_INFO("Enter");
3585 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3587 if (ret == CAMERA_ERROR_NONE)
3588 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3590 CAM_LOG_INFO("ret : 0x%x", ret);
3596 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3598 int ret = CAMERA_ERROR_NONE;
3599 camera_cli_s *pc = (camera_cli_s *)camera;
3600 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3602 if (!pc || !pc->cb_info || !facing_direction) {
3603 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3604 return CAMERA_ERROR_INVALID_PARAMETER;
3607 CAM_LOG_INFO("Enter");
3609 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3611 if (ret == CAMERA_ERROR_NONE)
3612 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3614 CAM_LOG_INFO("ret : 0x%x", ret);
3620 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3622 int ret = CAMERA_ERROR_NONE;
3623 camera_cli_s *pc = (camera_cli_s *)camera;
3624 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3626 if (!pc || !pc->cb_info || !callback) {
3627 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3628 return CAMERA_ERROR_INVALID_PARAMETER;
3631 CAM_LOG_INFO("Enter");
3633 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3635 if (ret == CAMERA_ERROR_NONE) {
3636 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3638 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3639 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3641 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3643 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3646 CAM_LOG_INFO("ret : 0x%x", ret);
3652 int camera_unset_preview_cb(camera_h camera)
3654 int ret = CAMERA_ERROR_NONE;
3655 camera_cli_s *pc = (camera_cli_s *)camera;
3656 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3658 if (!pc || !pc->cb_info) {
3659 CAM_LOG_ERROR("NULL handle");
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_PREVIEW]);
3670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3673 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3675 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3678 CAM_LOG_INFO("ret : 0x%x", ret);
3684 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3686 int ret = CAMERA_ERROR_NONE;
3687 camera_cli_s *pc = (camera_cli_s *)camera;
3688 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3690 if (!pc || !pc->cb_info) {
3691 CAM_LOG_ERROR("NULL handle");
3692 return CAMERA_ERROR_INVALID_PARAMETER;
3695 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3696 CAM_LOG_ERROR("NOT SUPPORTED");
3697 return CAMERA_ERROR_NOT_SUPPORTED;
3700 if (callback == NULL) {
3701 CAM_LOG_ERROR("NULL callback");
3702 return CAMERA_ERROR_INVALID_PARAMETER;
3705 CAM_LOG_INFO("Enter");
3707 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3709 if (ret == CAMERA_ERROR_NONE) {
3710 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3712 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3713 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3715 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3718 CAM_LOG_INFO("ret : 0x%x", ret);
3724 int camera_unset_media_packet_preview_cb(camera_h camera)
3726 int ret = CAMERA_ERROR_NONE;
3727 camera_cli_s *pc = (camera_cli_s *)camera;
3728 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3730 if (!pc || !pc->cb_info) {
3731 CAM_LOG_ERROR("NULL handle");
3732 return CAMERA_ERROR_INVALID_PARAMETER;
3735 CAM_LOG_INFO("Enter");
3737 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3739 if (ret == CAMERA_ERROR_NONE) {
3740 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3742 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3743 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3745 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3748 CAM_LOG_INFO("ret : 0x%x", ret);
3754 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3756 int ret = CAMERA_ERROR_NONE;
3757 camera_cli_s *pc = (camera_cli_s *)camera;
3758 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3760 if (!pc || !pc->cb_info || !callback) {
3761 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3762 return CAMERA_ERROR_INVALID_PARAMETER;
3765 CAM_LOG_INFO("Enter");
3767 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3769 if (ret == CAMERA_ERROR_NONE) {
3770 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3772 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3773 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3775 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3778 CAM_LOG_INFO("ret : 0x%x", ret);
3784 int camera_unset_state_changed_cb(camera_h camera)
3786 int ret = CAMERA_ERROR_NONE;
3787 camera_cli_s *pc = (camera_cli_s *)camera;
3788 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3790 if (!pc || !pc->cb_info) {
3791 CAM_LOG_ERROR("NULL handle");
3792 return CAMERA_ERROR_INVALID_PARAMETER;
3795 CAM_LOG_INFO("Enter");
3797 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3799 if (ret == CAMERA_ERROR_NONE) {
3800 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3802 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3803 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3805 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3808 CAM_LOG_INFO("ret : 0x%x", ret);
3814 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3816 int ret = CAMERA_ERROR_NONE;
3817 camera_cli_s *pc = (camera_cli_s *)camera;
3818 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3820 if (!pc || !pc->cb_info || !callback) {
3821 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3822 return CAMERA_ERROR_INVALID_PARAMETER;
3825 CAM_LOG_INFO("Enter");
3827 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3829 if (ret == CAMERA_ERROR_NONE) {
3830 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3832 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3833 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3835 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3838 CAM_LOG_INFO("ret : 0x%x", ret);
3844 int camera_unset_interrupted_cb(camera_h camera)
3846 int ret = CAMERA_ERROR_NONE;
3847 camera_cli_s *pc = (camera_cli_s *)camera;
3848 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3850 if (!pc || !pc->cb_info) {
3851 CAM_LOG_ERROR("NULL handle");
3852 return CAMERA_ERROR_INVALID_PARAMETER;
3855 CAM_LOG_INFO("Enter");
3857 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3859 if (ret == CAMERA_ERROR_NONE) {
3860 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3862 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3863 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3865 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3868 CAM_LOG_INFO("ret : 0x%x", ret);
3874 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3876 int ret = CAMERA_ERROR_NONE;
3877 camera_cli_s *pc = (camera_cli_s *)camera;
3878 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3880 if (!pc || !pc->cb_info || !callback) {
3881 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3882 return CAMERA_ERROR_INVALID_PARAMETER;
3885 CAM_LOG_INFO("Enter");
3887 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3889 if (ret == CAMERA_ERROR_NONE) {
3890 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3892 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3893 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3895 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3898 CAM_LOG_INFO("ret : 0x%x", ret);
3904 int camera_unset_interrupt_started_cb(camera_h camera)
3906 int ret = CAMERA_ERROR_NONE;
3907 camera_cli_s *pc = (camera_cli_s *)camera;
3908 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3910 if (!pc || !pc->cb_info) {
3911 CAM_LOG_ERROR("NULL handle");
3912 return CAMERA_ERROR_INVALID_PARAMETER;
3915 CAM_LOG_INFO("Enter");
3917 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3919 if (ret == CAMERA_ERROR_NONE) {
3920 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3922 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3923 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3925 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3928 CAM_LOG_INFO("ret : 0x%x", ret);
3934 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3936 int ret = CAMERA_ERROR_NONE;
3937 camera_cli_s *pc = (camera_cli_s *)camera;
3938 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3940 if (!pc || !pc->cb_info || !callback) {
3941 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3942 return CAMERA_ERROR_INVALID_PARAMETER;
3945 CAM_LOG_INFO("Enter");
3947 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3949 if (ret == CAMERA_ERROR_NONE) {
3950 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3952 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3953 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3955 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3958 CAM_LOG_INFO("ret : 0x%x", ret);
3964 int camera_unset_focus_changed_cb(camera_h camera)
3966 int ret = CAMERA_ERROR_NONE;
3967 camera_cli_s *pc = (camera_cli_s *)camera;
3968 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3970 if (!pc || !pc->cb_info) {
3971 CAM_LOG_ERROR("NULL handle");
3972 return CAMERA_ERROR_INVALID_PARAMETER;
3975 CAM_LOG_INFO("Enter");
3977 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3979 if (ret == CAMERA_ERROR_NONE) {
3980 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3982 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3983 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3985 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3988 CAM_LOG_INFO("ret : 0x%x", ret);
3994 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3996 int ret = CAMERA_ERROR_NONE;
3997 camera_cli_s *pc = (camera_cli_s *)camera;
3998 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4000 if (!pc || !pc->cb_info || !callback) {
4001 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4002 return CAMERA_ERROR_INVALID_PARAMETER;
4005 CAM_LOG_INFO("Enter");
4007 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4009 if (ret == CAMERA_ERROR_NONE) {
4010 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4012 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4013 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4015 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4018 CAM_LOG_INFO("ret : 0x%x", ret);
4024 int camera_unset_error_cb(camera_h camera)
4026 int ret = CAMERA_ERROR_NONE;
4027 camera_cli_s *pc = (camera_cli_s *)camera;
4028 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4030 if (!pc || !pc->cb_info) {
4031 CAM_LOG_ERROR("NULL handle");
4032 return CAMERA_ERROR_INVALID_PARAMETER;
4035 CAM_LOG_INFO("Enter");
4037 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4039 if (ret == CAMERA_ERROR_NONE) {
4040 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4042 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4043 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4045 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4048 CAM_LOG_INFO("ret : 0x%x", ret);
4054 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4056 int ret = CAMERA_ERROR_NONE;
4057 camera_cli_s *pc = (camera_cli_s *)camera;
4058 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4060 if (!pc || !pc->cb_info || !foreach_cb) {
4061 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4062 return CAMERA_ERROR_INVALID_PARAMETER;
4065 CAM_LOG_INFO("Enter");
4067 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4068 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4070 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4072 CAM_LOG_INFO("ret : 0x%x", ret);
4078 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4080 int ret = CAMERA_ERROR_NONE;
4081 camera_cli_s *pc = (camera_cli_s *)camera;
4082 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4084 if (!pc || !pc->cb_info || !foreach_cb) {
4085 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4086 return CAMERA_ERROR_INVALID_PARAMETER;
4089 CAM_LOG_INFO("Enter");
4091 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4092 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4094 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4096 CAM_LOG_INFO("ret : 0x%x", ret);
4102 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4104 int ret = CAMERA_ERROR_NONE;
4105 camera_cli_s *pc = (camera_cli_s *)camera;
4106 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4108 if (!pc || !pc->cb_info || !foreach_cb) {
4109 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4110 return CAMERA_ERROR_INVALID_PARAMETER;
4113 CAM_LOG_INFO("Enter");
4115 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4116 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4118 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4120 CAM_LOG_INFO("ret : 0x%x", ret);
4126 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4128 int ret = CAMERA_ERROR_NONE;
4129 camera_cli_s *pc = (camera_cli_s *)camera;
4130 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4132 if (!pc || !pc->cb_info || !foreach_cb) {
4133 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4134 return CAMERA_ERROR_INVALID_PARAMETER;
4137 CAM_LOG_INFO("Enter");
4139 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4140 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4142 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4144 CAM_LOG_INFO("ret : 0x%x", ret);
4150 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4152 int ret = CAMERA_ERROR_NONE;
4153 camera_cli_s *pc = (camera_cli_s *)camera;
4154 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4156 if (!pc || !pc->cb_info || !width || !height) {
4157 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4158 return CAMERA_ERROR_INVALID_PARAMETER;
4161 CAM_LOG_INFO("Enter");
4162 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4164 if (ret == CAMERA_ERROR_NONE) {
4165 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4166 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4169 CAM_LOG_INFO("ret : 0x%x", ret);
4175 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4177 int ret = CAMERA_ERROR_NONE;
4178 camera_cli_s *pc = (camera_cli_s *)camera;
4179 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4181 if (!pc || !pc->cb_info || !angle) {
4182 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4183 return CAMERA_ERROR_INVALID_PARAMETER;
4186 CAM_LOG_INFO("Enter");
4188 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4190 if (ret == CAMERA_ERROR_NONE)
4191 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4193 CAM_LOG_INFO("ret : 0x%x", ret);
4199 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4201 int ret = CAMERA_ERROR_NONE;
4202 camera_cli_s *pc = (camera_cli_s *)camera;
4203 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4204 camera_msg_param param;
4205 int set_mode = (int)mode;
4207 if (!pc || !pc->cb_info) {
4208 CAM_LOG_ERROR("NULL handle");
4209 return CAMERA_ERROR_INVALID_PARAMETER;
4212 CAM_LOG_INFO("Enter");
4214 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4216 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4218 CAM_LOG_INFO("ret : 0x%x", ret);
4224 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4226 int ret = CAMERA_ERROR_NONE;
4227 camera_cli_s *pc = (camera_cli_s *)camera;
4228 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4230 if (!pc || !pc->cb_info || !mode) {
4231 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4232 return CAMERA_ERROR_INVALID_PARAMETER;
4235 CAM_LOG_INFO("Enter");
4237 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4239 if (ret == CAMERA_ERROR_NONE)
4240 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4242 CAM_LOG_INFO("ret : 0x%x", ret);
4248 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4250 int ret = CAMERA_ERROR_NONE;
4251 camera_cli_s *pc = (camera_cli_s *)camera;
4252 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4254 if (!pc || !pc->cb_info || !foreach_cb) {
4255 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4256 return CAMERA_ERROR_INVALID_PARAMETER;
4259 CAM_LOG_INFO("Enter");
4261 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4262 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4264 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4266 CAM_LOG_INFO("Finish, return :%x", ret);
4272 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4274 int ret = CAMERA_ERROR_NONE;
4275 camera_cli_s *pc = (camera_cli_s *)camera;
4276 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4277 camera_msg_param param;
4278 int set_fps = (int)fps;
4280 if (!pc || !pc->cb_info) {
4281 CAM_LOG_ERROR("NULL handle");
4282 return CAMERA_ERROR_INVALID_PARAMETER;
4285 CAM_LOG_INFO("Enter");
4287 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4289 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4291 CAM_LOG_INFO("ret : 0x%x", ret);
4297 int camera_attr_set_image_quality(camera_h camera, int quality)
4299 int ret = CAMERA_ERROR_NONE;
4300 camera_cli_s *pc = (camera_cli_s *)camera;
4301 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4302 camera_msg_param param;
4304 if (!pc || !pc->cb_info) {
4305 CAM_LOG_ERROR("NULL handle");
4306 return CAMERA_ERROR_INVALID_PARAMETER;
4309 CAM_LOG_INFO("Enter");
4311 CAMERA_MSG_PARAM_SET(param, INT, quality);
4313 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4315 CAM_LOG_INFO("ret : 0x%x", ret);
4321 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4323 int ret = CAMERA_ERROR_NONE;
4324 camera_cli_s *pc = (camera_cli_s *)camera;
4325 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4327 if (!pc || !pc->cb_info || !fps) {
4328 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4329 return CAMERA_ERROR_INVALID_PARAMETER;
4332 CAM_LOG_INFO("Enter");
4334 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4336 if (ret == CAMERA_ERROR_NONE)
4337 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4339 CAM_LOG_INFO("ret : 0x%x", ret);
4345 int camera_attr_get_image_quality(camera_h camera, int *quality)
4347 int ret = CAMERA_ERROR_NONE;
4348 camera_cli_s *pc = (camera_cli_s *)camera;
4349 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4351 if (!pc || !pc->cb_info || !quality) {
4352 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4353 return CAMERA_ERROR_INVALID_PARAMETER;
4356 CAM_LOG_INFO("Enter");
4358 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4360 if (ret == CAMERA_ERROR_NONE)
4361 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4363 CAM_LOG_INFO("ret : 0x%x", ret);
4369 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4371 int ret = CAMERA_ERROR_NONE;
4372 camera_cli_s *pc = (camera_cli_s *)camera;
4373 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4375 if (!pc || !pc->cb_info || !bitrate) {
4376 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4377 return CAMERA_ERROR_INVALID_PARAMETER;
4380 CAM_LOG_INFO("Enter");
4382 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4384 if (ret == CAMERA_ERROR_NONE)
4385 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4387 CAM_LOG_INFO("ret : 0x%x", ret);
4393 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4395 int ret = CAMERA_ERROR_NONE;
4396 camera_cli_s *pc = (camera_cli_s *)camera;
4397 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4398 camera_msg_param param;
4399 int set_bitrate = bitrate;
4401 if (!pc || !pc->cb_info) {
4402 CAM_LOG_ERROR("NULL handle");
4403 return CAMERA_ERROR_INVALID_PARAMETER;
4406 CAM_LOG_INFO("Enter");
4408 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4410 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4412 CAM_LOG_INFO("ret : 0x%x", ret);
4418 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4420 int ret = CAMERA_ERROR_NONE;
4421 camera_cli_s *pc = (camera_cli_s *)camera;
4422 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4424 if (!pc || !pc->cb_info || !interval) {
4425 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4426 return CAMERA_ERROR_INVALID_PARAMETER;
4429 CAM_LOG_INFO("Enter");
4431 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4433 if (ret == CAMERA_ERROR_NONE)
4434 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4436 CAM_LOG_INFO("ret : 0x%x", ret);
4442 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4444 int ret = CAMERA_ERROR_NONE;
4445 camera_cli_s *pc = (camera_cli_s *)camera;
4446 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4447 camera_msg_param param;
4448 int set_gop_interval = interval;
4450 if (!pc || !pc->cb_info) {
4451 CAM_LOG_ERROR("NULL handle");
4452 return CAMERA_ERROR_INVALID_PARAMETER;
4455 CAM_LOG_INFO("Enter");
4457 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4459 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4461 CAM_LOG_INFO("ret : 0x%x", ret);
4467 int camera_attr_set_zoom(camera_h camera, int zoom)
4469 int ret = CAMERA_ERROR_NONE;
4470 camera_cli_s *pc = (camera_cli_s *)camera;
4471 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4472 camera_msg_param param;
4474 if (!pc || !pc->cb_info) {
4475 CAM_LOG_ERROR("NULL handle");
4476 return CAMERA_ERROR_INVALID_PARAMETER;
4479 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4481 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4483 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4485 CAM_LOG_INFO("ret : 0x%x", ret);
4491 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4493 int ret = CAMERA_ERROR_NONE;
4494 camera_cli_s *pc = (camera_cli_s *)camera;
4495 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4496 camera_msg_param param;
4497 int set_mode = (int)mode;
4499 if (!pc || !pc->cb_info) {
4500 CAM_LOG_ERROR("NULL handle");
4501 return CAMERA_ERROR_INVALID_PARAMETER;
4504 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4506 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4508 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4514 int camera_attr_set_af_area(camera_h camera, int x, int y)
4516 int ret = CAMERA_ERROR_NONE;
4517 camera_cli_s *pc = (camera_cli_s *)camera;
4518 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4519 camera_msg_param param;
4522 if (!pc || !pc->cb_info) {
4523 CAM_LOG_ERROR("NULL handle");
4524 return CAMERA_ERROR_INVALID_PARAMETER;
4527 CAM_LOG_INFO("Enter - %d,%d", x, y);
4529 value = (x << 16) | y;
4530 CAMERA_MSG_PARAM_SET(param, INT, value);
4532 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4534 CAM_LOG_INFO("ret : 0x%x", ret);
4540 int camera_attr_clear_af_area(camera_h camera)
4542 int ret = CAMERA_ERROR_NONE;
4543 camera_cli_s *pc = (camera_cli_s *)camera;
4544 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4546 if (!pc || !pc->cb_info) {
4547 CAM_LOG_ERROR("NULL handle");
4548 return CAMERA_ERROR_INVALID_PARAMETER;
4551 CAM_LOG_INFO("Enter");
4553 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4555 CAM_LOG_INFO("ret : 0x%x", ret);
4561 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4563 int ret = CAMERA_ERROR_NONE;
4564 camera_cli_s *pc = (camera_cli_s *)camera;
4565 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4566 camera_msg_param param;
4567 int set_mode = (int)mode;
4569 if (!pc || !pc->cb_info) {
4570 CAM_LOG_ERROR("NULL handle");
4571 return CAMERA_ERROR_INVALID_PARAMETER;
4574 CAM_LOG_INFO("Enter");
4576 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4578 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4580 CAM_LOG_INFO("ret : 0x%x", ret);
4586 int camera_attr_set_exposure(camera_h camera, int value)
4588 int ret = CAMERA_ERROR_NONE;
4589 camera_cli_s *pc = (camera_cli_s *)camera;
4590 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4591 camera_msg_param param;
4593 if (!pc || !pc->cb_info) {
4594 CAM_LOG_ERROR("NULL handle");
4595 return CAMERA_ERROR_INVALID_PARAMETER;
4598 CAM_LOG_INFO("Enter");
4600 CAMERA_MSG_PARAM_SET(param, INT, value);
4602 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4604 CAM_LOG_INFO("ret : 0x%x", ret);
4610 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4612 int ret = CAMERA_ERROR_NONE;
4613 camera_cli_s *pc = (camera_cli_s *)camera;
4614 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4615 camera_msg_param param;
4616 int set_iso = (int)iso;
4618 if (!pc || !pc->cb_info) {
4619 CAM_LOG_ERROR("NULL handle");
4620 return CAMERA_ERROR_INVALID_PARAMETER;
4623 CAM_LOG_INFO("Enter");
4625 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4627 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4629 CAM_LOG_INFO("ret : 0x%x", ret);
4635 int camera_attr_set_brightness(camera_h camera, int level)
4637 int ret = CAMERA_ERROR_NONE;
4638 camera_cli_s *pc = (camera_cli_s *)camera;
4639 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4640 camera_msg_param param;
4642 if (!pc || !pc->cb_info) {
4643 CAM_LOG_ERROR("NULL handle");
4644 return CAMERA_ERROR_INVALID_PARAMETER;
4647 CAM_LOG_INFO("Enter");
4649 CAMERA_MSG_PARAM_SET(param, INT, level);
4651 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4653 CAM_LOG_INFO("ret : 0x%x", ret);
4659 int camera_attr_set_contrast(camera_h camera, int level)
4661 int ret = CAMERA_ERROR_NONE;
4662 camera_cli_s *pc = (camera_cli_s *)camera;
4663 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4664 camera_msg_param param;
4666 if (!pc || !pc->cb_info) {
4667 CAM_LOG_ERROR("NULL handle");
4668 return CAMERA_ERROR_INVALID_PARAMETER;
4671 CAM_LOG_INFO("Enter");
4673 CAMERA_MSG_PARAM_SET(param, INT, level);
4675 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4677 CAM_LOG_INFO("ret : 0x%x", ret);
4683 int camera_attr_set_hue(camera_h camera, int level)
4685 int ret = CAMERA_ERROR_NONE;
4686 camera_cli_s *pc = (camera_cli_s *)camera;
4687 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4688 camera_msg_param param;
4690 if (!pc || !pc->cb_info) {
4691 CAM_LOG_ERROR("NULL handle");
4692 return CAMERA_ERROR_INVALID_PARAMETER;
4695 CAM_LOG_INFO("Enter");
4697 CAMERA_MSG_PARAM_SET(param, INT, level);
4699 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4701 CAM_LOG_INFO("ret : 0x%x", ret);
4707 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4709 int ret = CAMERA_ERROR_NONE;
4710 camera_cli_s *pc = (camera_cli_s *)camera;
4711 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4712 camera_msg_param param;
4713 int set_whitebalance = (int)wb;
4715 if (!pc || !pc->cb_info) {
4716 CAM_LOG_ERROR("NULL handle");
4717 return CAMERA_ERROR_INVALID_PARAMETER;
4720 CAM_LOG_INFO("Enter");
4722 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4724 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4726 CAM_LOG_INFO("ret : 0x%x", ret);
4732 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4734 int ret = CAMERA_ERROR_NONE;
4735 camera_cli_s *pc = (camera_cli_s *)camera;
4736 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4737 camera_msg_param param;
4738 int set_effect = (int)effect;
4740 if (!pc || !pc->cb_info) {
4741 CAM_LOG_ERROR("NULL handle");
4742 return CAMERA_ERROR_INVALID_PARAMETER;
4745 CAM_LOG_INFO("Enter");
4747 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4749 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4751 CAM_LOG_INFO("ret : 0x%x", ret);
4757 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4759 int ret = CAMERA_ERROR_NONE;
4760 camera_cli_s *pc = (camera_cli_s *)camera;
4761 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4762 camera_msg_param param;
4763 int set_mode = (int)mode;
4765 if (!pc || !pc->cb_info) {
4766 CAM_LOG_ERROR("NULL handle");
4767 return CAMERA_ERROR_INVALID_PARAMETER;
4770 CAM_LOG_INFO("Enter");
4772 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4774 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4776 CAM_LOG_INFO("ret : 0x%x", ret);
4782 int camera_attr_enable_tag(camera_h camera, bool enable)
4784 int ret = CAMERA_ERROR_NONE;
4785 camera_cli_s *pc = (camera_cli_s *)camera;
4786 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4787 camera_msg_param param;
4788 int set_enable = (int)enable;
4790 if (!pc || !pc->cb_info) {
4791 CAM_LOG_ERROR("NULL handle");
4792 return CAMERA_ERROR_INVALID_PARAMETER;
4795 CAM_LOG_INFO("Enter");
4797 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4799 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4801 CAM_LOG_INFO("ret : 0x%x", ret);
4807 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4809 int ret = CAMERA_ERROR_NONE;
4810 camera_cli_s *pc = (camera_cli_s *)camera;
4811 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4812 camera_msg_param param;
4814 if (!pc || !pc->cb_info || !description) {
4815 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4816 return CAMERA_ERROR_INVALID_PARAMETER;
4819 CAM_LOG_INFO("Enter");
4821 CAMERA_MSG_PARAM_SET(param, STRING, description);
4823 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4825 CAM_LOG_INFO("ret : 0x%x", ret);
4831 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4833 int ret = CAMERA_ERROR_NONE;
4834 camera_cli_s *pc = (camera_cli_s *)camera;
4835 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4836 camera_msg_param param;
4837 int set_orientation = (int)orientation;
4839 if (!pc || !pc->cb_info) {
4840 CAM_LOG_ERROR("NULL handle");
4841 return CAMERA_ERROR_INVALID_PARAMETER;
4844 CAM_LOG_INFO("Enter");
4846 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4848 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4850 CAM_LOG_INFO("ret : 0x%x", ret);
4856 int camera_attr_set_tag_software(camera_h camera, const char *software)
4858 int ret = CAMERA_ERROR_NONE;
4859 camera_cli_s *pc = (camera_cli_s *)camera;
4860 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4861 camera_msg_param param;
4863 if (!pc || !pc->cb_info || !software) {
4864 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4865 return CAMERA_ERROR_INVALID_PARAMETER;
4868 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4870 CAMERA_MSG_PARAM_SET(param, STRING, software);
4872 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4874 CAM_LOG_INFO("ret : 0x%x", ret);
4880 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4882 int ret = CAMERA_ERROR_NONE;
4883 camera_cli_s *pc = (camera_cli_s *)camera;
4884 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4885 double set_geotag[3] = {latitude, longitude, altitude};
4890 if (!pc || !pc->cb_info) {
4891 CAM_LOG_ERROR("NULL handle");
4892 return CAMERA_ERROR_INVALID_PARAMETER;
4895 CAM_LOG_INFO("Enter");
4897 length = sizeof(set_geotag) / sizeof(int) + \
4898 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4900 msg = muse_core_msg_new(api,
4901 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4904 CAM_LOG_ERROR("msg creation failed: api %d", api);
4905 return CAMERA_ERROR_OUT_OF_MEMORY;
4908 if (pc->cb_info->is_server_connected) {
4909 __camera_update_api_waiting(pc->cb_info, api, 1);
4911 g_mutex_lock(&pc->cb_info->fd_lock);
4912 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4913 g_mutex_unlock(&pc->cb_info->fd_lock);
4917 CAM_LOG_ERROR("message send failed");
4918 ret = CAMERA_ERROR_INVALID_OPERATION;
4920 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4923 __camera_update_api_waiting(pc->cb_info, api, -1);
4925 muse_core_msg_free(msg);
4927 CAM_LOG_INFO("ret : 0x%x", ret);
4933 int camera_attr_remove_geotag(camera_h camera)
4935 int ret = CAMERA_ERROR_NONE;
4936 camera_cli_s *pc = (camera_cli_s *)camera;
4937 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4939 if (!pc || !pc->cb_info) {
4940 CAM_LOG_ERROR("NULL handle");
4941 return CAMERA_ERROR_INVALID_PARAMETER;
4944 CAM_LOG_INFO("Enter");
4946 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4948 CAM_LOG_INFO("ret : 0x%x", ret);
4954 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4956 int ret = CAMERA_ERROR_NONE;
4957 camera_cli_s *pc = (camera_cli_s *)camera;
4958 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4959 camera_msg_param param;
4960 int set_mode = (int)mode;
4962 if (!pc || !pc->cb_info) {
4963 CAM_LOG_ERROR("NULL handle");
4964 return CAMERA_ERROR_INVALID_PARAMETER;
4967 CAM_LOG_INFO("Enter");
4969 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4971 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4973 CAM_LOG_INFO("ret : 0x%x", ret);
4979 int camera_attr_get_zoom(camera_h camera, int *zoom)
4981 int ret = CAMERA_ERROR_NONE;
4982 camera_cli_s *pc = (camera_cli_s *)camera;
4983 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4985 if (!pc || !pc->cb_info || !zoom) {
4986 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4987 return CAMERA_ERROR_INVALID_PARAMETER;
4990 CAM_LOG_INFO("Enter");
4992 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4994 if (ret == CAMERA_ERROR_NONE)
4995 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4997 CAM_LOG_INFO("ret : 0x%x", ret);
5003 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5005 int ret = CAMERA_ERROR_NONE;
5006 camera_cli_s *pc = (camera_cli_s *)camera;
5007 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5009 if (!pc || !pc->cb_info || !min || !max) {
5010 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5011 return CAMERA_ERROR_INVALID_PARAMETER;
5014 CAM_LOG_INFO("Enter");
5016 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5018 if (ret == CAMERA_ERROR_NONE) {
5019 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5020 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5023 CAM_LOG_INFO("ret : 0x%x", ret);
5029 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5031 int ret = CAMERA_ERROR_NONE;
5032 camera_cli_s *pc = (camera_cli_s *)camera;
5033 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5035 if (!pc || !pc->cb_info || !mode) {
5036 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5037 return CAMERA_ERROR_INVALID_PARAMETER;
5040 CAM_LOG_INFO("Enter");
5042 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5044 if (ret == CAMERA_ERROR_NONE)
5045 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5047 CAM_LOG_INFO("ret : 0x%x", ret);
5053 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5055 int ret = CAMERA_ERROR_NONE;
5056 camera_cli_s *pc = (camera_cli_s *)camera;
5057 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5059 if (!pc || !pc->cb_info || !mode) {
5060 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5061 return CAMERA_ERROR_INVALID_PARAMETER;
5064 CAM_LOG_INFO("Enter");
5066 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5068 if (ret == CAMERA_ERROR_NONE)
5069 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5071 CAM_LOG_INFO("ret : 0x%x", ret);
5077 int camera_attr_get_exposure(camera_h camera, int *value)
5079 int ret = CAMERA_ERROR_NONE;
5080 camera_cli_s *pc = (camera_cli_s *)camera;
5081 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5083 if (!pc || !pc->cb_info || !value) {
5084 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5085 return CAMERA_ERROR_INVALID_PARAMETER;
5088 CAM_LOG_INFO("Enter");
5090 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5092 if (ret == CAMERA_ERROR_NONE)
5093 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5095 CAM_LOG_INFO("ret : 0x%x", ret);
5101 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5103 int ret = CAMERA_ERROR_NONE;
5104 camera_cli_s *pc = (camera_cli_s *)camera;
5105 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5107 if (!pc || !pc->cb_info || !min || !max) {
5108 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5109 return CAMERA_ERROR_INVALID_PARAMETER;
5112 CAM_LOG_INFO("Enter");
5114 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5116 if (ret == CAMERA_ERROR_NONE) {
5117 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5118 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5121 CAM_LOG_INFO("ret : 0x%x", ret);
5127 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5129 int ret = CAMERA_ERROR_NONE;
5130 camera_cli_s *pc = (camera_cli_s *)camera;
5131 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5133 if (!pc || !pc->cb_info || !iso) {
5134 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5135 return CAMERA_ERROR_INVALID_PARAMETER;
5138 CAM_LOG_INFO("Enter");
5140 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5142 if (ret == CAMERA_ERROR_NONE)
5143 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5145 CAM_LOG_INFO("ret : 0x%x", ret);
5151 int camera_attr_get_brightness(camera_h camera, int *level)
5153 int ret = CAMERA_ERROR_NONE;
5154 camera_cli_s *pc = (camera_cli_s *)camera;
5155 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5157 if (!pc || !pc->cb_info || !level) {
5158 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5159 return CAMERA_ERROR_INVALID_PARAMETER;
5162 CAM_LOG_INFO("Enter");
5164 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5166 if (ret == CAMERA_ERROR_NONE)
5167 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5169 CAM_LOG_INFO("ret : 0x%x", ret);
5175 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5177 int ret = CAMERA_ERROR_NONE;
5178 camera_cli_s *pc = (camera_cli_s *)camera;
5179 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5181 if (!pc || !pc->cb_info || !min || !max) {
5182 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5183 return CAMERA_ERROR_INVALID_PARAMETER;
5186 CAM_LOG_INFO("Enter");
5188 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5190 if (ret == CAMERA_ERROR_NONE) {
5191 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5192 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5195 CAM_LOG_INFO("ret : 0x%x", ret);
5201 int camera_attr_get_contrast(camera_h camera, int *level)
5203 int ret = CAMERA_ERROR_NONE;
5204 camera_cli_s *pc = (camera_cli_s *)camera;
5205 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5207 if (!pc || !pc->cb_info || !level) {
5208 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5209 return CAMERA_ERROR_INVALID_PARAMETER;
5212 CAM_LOG_INFO("Enter");
5214 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5216 if (ret == CAMERA_ERROR_NONE)
5217 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5219 CAM_LOG_INFO("ret : 0x%x", ret);
5225 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5227 int ret = CAMERA_ERROR_NONE;
5228 camera_cli_s *pc = (camera_cli_s *)camera;
5229 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5231 if (!pc || !pc->cb_info || !min || !max) {
5232 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5233 return CAMERA_ERROR_INVALID_PARAMETER;
5236 CAM_LOG_INFO("Enter");
5238 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5240 if (ret == CAMERA_ERROR_NONE) {
5241 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5242 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5243 CAM_LOG_INFO("min %d, max %d", *min, *max);
5246 CAM_LOG_INFO("ret : 0x%x", ret);
5252 int camera_attr_get_hue(camera_h camera, int *level)
5254 int ret = CAMERA_ERROR_NONE;
5255 camera_cli_s *pc = (camera_cli_s *)camera;
5256 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5258 if (!pc || !pc->cb_info || !level) {
5259 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5260 return CAMERA_ERROR_INVALID_PARAMETER;
5263 CAM_LOG_INFO("Enter");
5265 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5267 if (ret == CAMERA_ERROR_NONE)
5268 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5270 CAM_LOG_INFO("ret : 0x%x", ret);
5276 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5278 int ret = CAMERA_ERROR_NONE;
5279 camera_cli_s *pc = (camera_cli_s *)camera;
5280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5282 if (!pc || !pc->cb_info || !min || !max) {
5283 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5284 return CAMERA_ERROR_INVALID_PARAMETER;
5287 CAM_LOG_INFO("Enter");
5289 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5291 if (ret == CAMERA_ERROR_NONE) {
5292 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5293 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5294 CAM_LOG_INFO("min %d, max %d", *min, *max);
5297 CAM_LOG_INFO("ret : 0x%x", ret);
5303 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5305 int ret = CAMERA_ERROR_NONE;
5306 camera_cli_s *pc = (camera_cli_s *)camera;
5307 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5309 if (!pc || !pc->cb_info || !wb) {
5310 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5311 return CAMERA_ERROR_INVALID_PARAMETER;
5314 CAM_LOG_INFO("Enter");
5316 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5318 if (ret == CAMERA_ERROR_NONE)
5319 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5321 CAM_LOG_INFO("ret : 0x%x", ret);
5327 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5329 int ret = CAMERA_ERROR_NONE;
5330 camera_cli_s *pc = (camera_cli_s *)camera;
5331 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5333 if (!pc || !pc->cb_info || !effect) {
5334 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5335 return CAMERA_ERROR_INVALID_PARAMETER;
5338 CAM_LOG_INFO("Enter");
5340 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5342 if (ret == CAMERA_ERROR_NONE)
5343 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5345 CAM_LOG_INFO("ret : 0x%x", ret);
5351 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5353 int ret = CAMERA_ERROR_NONE;
5354 camera_cli_s *pc = (camera_cli_s *)camera;
5355 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5357 if (!pc || !pc->cb_info || !mode) {
5358 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5359 return CAMERA_ERROR_INVALID_PARAMETER;
5362 CAM_LOG_INFO("Enter");
5364 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5366 if (ret == CAMERA_ERROR_NONE)
5367 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5369 CAM_LOG_INFO("ret : 0x%x", ret);
5375 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5377 int ret = CAMERA_ERROR_NONE;
5378 camera_cli_s *pc = (camera_cli_s *)camera;
5379 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5381 if (!pc || !pc->cb_info || !enable) {
5382 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5383 return CAMERA_ERROR_INVALID_PARAMETER;
5386 CAM_LOG_INFO("Enter");
5388 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5390 if (ret == CAMERA_ERROR_NONE)
5391 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5393 CAM_LOG_INFO("ret : 0x%x", ret);
5399 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5401 int ret = CAMERA_ERROR_NONE;
5402 camera_cli_s *pc = (camera_cli_s *)camera;
5403 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5405 if (!pc || !pc->cb_info || !description) {
5406 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5407 return CAMERA_ERROR_INVALID_PARAMETER;
5410 CAM_LOG_INFO("Enter");
5412 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5414 if (ret == CAMERA_ERROR_NONE)
5415 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5417 CAM_LOG_INFO("ret : 0x%x", ret);
5423 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5425 int ret = CAMERA_ERROR_NONE;
5426 camera_cli_s *pc = (camera_cli_s *)camera;
5427 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5429 if (!pc || !pc->cb_info || !orientation) {
5430 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5431 return CAMERA_ERROR_INVALID_PARAMETER;
5434 CAM_LOG_INFO("Enter");
5436 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5438 if (ret == CAMERA_ERROR_NONE)
5439 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5441 CAM_LOG_INFO("ret : 0x%x", ret);
5447 int camera_attr_get_tag_software(camera_h camera, char **software)
5449 int ret = CAMERA_ERROR_NONE;
5450 camera_cli_s *pc = (camera_cli_s *)camera;
5451 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5453 if (!pc || !pc->cb_info || !software) {
5454 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5455 return CAMERA_ERROR_INVALID_PARAMETER;
5458 CAM_LOG_INFO("Enter");
5460 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5462 if (ret == CAMERA_ERROR_NONE)
5463 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5465 CAM_LOG_INFO("ret : 0x%x", ret);
5471 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5473 int ret = CAMERA_ERROR_NONE;
5474 camera_cli_s *pc = (camera_cli_s *)camera;
5475 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5477 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5478 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5479 return CAMERA_ERROR_INVALID_PARAMETER;
5482 CAM_LOG_INFO("Enter");
5484 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5486 if (ret == CAMERA_ERROR_NONE) {
5487 *latitude = pc->cb_info->get_geotag[0];
5488 *longitude = pc->cb_info->get_geotag[1];
5489 *altitude = pc->cb_info->get_geotag[2];
5492 CAM_LOG_INFO("ret : 0x%x", ret);
5498 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5500 int ret = CAMERA_ERROR_NONE;
5501 camera_cli_s *pc = (camera_cli_s *)camera;
5502 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5504 if (!pc || !pc->cb_info || !mode) {
5505 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5506 return CAMERA_ERROR_INVALID_PARAMETER;
5509 CAM_LOG_INFO("Enter");
5511 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5513 if (ret == CAMERA_ERROR_NONE)
5514 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5516 CAM_LOG_INFO("ret : 0x%x", ret);
5522 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5524 int ret = CAMERA_ERROR_NONE;
5525 int get_flash_state = 0;
5528 CAM_LOG_ERROR("NULL pointer");
5529 return CAMERA_ERROR_INVALID_PARAMETER;
5532 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5533 (int)device, "get_flash_state", &get_flash_state);
5535 if (ret == CAMERA_ERROR_NONE) {
5536 *state = (camera_flash_state_e)get_flash_state;
5537 CAM_LOG_INFO("flash state %d", *state);
5539 CAM_LOG_ERROR("failed 0x%x", ret);
5546 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5548 int ret = CAMERA_ERROR_NONE;
5549 camera_cli_s *pc = (camera_cli_s *)camera;
5550 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5552 if (!pc || !pc->cb_info || !foreach_cb) {
5553 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5554 return CAMERA_ERROR_INVALID_PARAMETER;
5557 CAM_LOG_INFO("Enter");
5559 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5560 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5562 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5564 CAM_LOG_INFO("ret : 0x%x", ret);
5570 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5572 int ret = CAMERA_ERROR_NONE;
5573 camera_cli_s *pc = (camera_cli_s *)camera;
5574 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5576 if (!pc || !pc->cb_info || !foreach_cb) {
5577 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5578 return CAMERA_ERROR_INVALID_PARAMETER;
5581 CAM_LOG_INFO("Enter");
5583 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5584 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5586 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5588 CAM_LOG_INFO("ret : 0x%x", ret);
5594 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5596 int ret = CAMERA_ERROR_NONE;
5597 camera_cli_s *pc = (camera_cli_s *)camera;
5598 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5600 if (!pc || !pc->cb_info || !foreach_cb) {
5601 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5602 return CAMERA_ERROR_INVALID_PARAMETER;
5605 CAM_LOG_INFO("Enter");
5607 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5608 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5610 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5612 CAM_LOG_INFO("ret : 0x%x", ret);
5618 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5620 int ret = CAMERA_ERROR_NONE;
5621 camera_cli_s *pc = (camera_cli_s *)camera;
5622 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5624 if (!pc || !pc->cb_info || !foreach_cb) {
5625 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5626 return CAMERA_ERROR_INVALID_PARAMETER;
5629 CAM_LOG_INFO("Enter");
5631 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5632 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5634 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5636 CAM_LOG_INFO("ret : 0x%x", ret);
5642 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5644 int ret = CAMERA_ERROR_NONE;
5645 camera_cli_s *pc = (camera_cli_s *)camera;
5646 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5648 if (!pc || !pc->cb_info || !foreach_cb) {
5649 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5650 return CAMERA_ERROR_INVALID_PARAMETER;
5653 CAM_LOG_INFO("Enter");
5655 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5656 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5658 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5660 CAM_LOG_INFO("ret : 0x%x", ret);
5666 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5668 int ret = CAMERA_ERROR_NONE;
5669 camera_cli_s *pc = (camera_cli_s *)camera;
5670 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5672 if (!pc || !pc->cb_info || !foreach_cb) {
5673 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5674 return CAMERA_ERROR_INVALID_PARAMETER;
5677 CAM_LOG_INFO("Enter");
5679 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5680 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5682 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5684 CAM_LOG_INFO("ret : 0x%x", ret);
5690 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5692 int ret = CAMERA_ERROR_NONE;
5693 camera_cli_s *pc = (camera_cli_s *)camera;
5694 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5696 if (!pc || !pc->cb_info || !foreach_cb) {
5697 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5698 return CAMERA_ERROR_INVALID_PARAMETER;
5701 CAM_LOG_INFO("Enter");
5703 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5704 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5706 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5708 CAM_LOG_INFO("ret : 0x%x", ret);
5714 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5716 int ret = CAMERA_ERROR_NONE;
5717 camera_cli_s *pc = (camera_cli_s *)camera;
5718 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5720 if (!pc || !pc->cb_info || !foreach_cb) {
5721 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5722 return CAMERA_ERROR_INVALID_PARAMETER;
5725 CAM_LOG_INFO("Enter");
5727 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5728 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5730 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5732 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5738 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)
5740 int ret = CAMERA_ERROR_NONE;
5741 camera_cli_s *pc = (camera_cli_s *)camera;
5742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5743 camera_msg_param param;
5746 if (!pc || !pc->cb_info || !foreach_cb) {
5747 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5748 return CAMERA_ERROR_INVALID_PARAMETER;
5751 CAM_LOG_INFO("Enter");
5753 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5754 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5756 value = (width << 16) | height;
5757 CAMERA_MSG_PARAM_SET(param, INT, value);
5759 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5761 CAM_LOG_INFO("ret : 0x%x", ret);
5767 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5769 int ret = CAMERA_ERROR_NONE;
5770 camera_cli_s *pc = (camera_cli_s *)camera;
5771 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5773 if (!pc || !pc->cb_info || !foreach_cb) {
5774 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5775 return CAMERA_ERROR_INVALID_PARAMETER;
5778 CAM_LOG_INFO("Enter");
5780 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5781 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5783 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5785 CAM_LOG_INFO("ret : 0x%x", ret);
5791 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5793 int ret = CAMERA_ERROR_NONE;
5794 camera_cli_s *pc = (camera_cli_s *)camera;
5795 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5797 if (!pc || !pc->cb_info || !foreach_cb) {
5798 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5799 return CAMERA_ERROR_INVALID_PARAMETER;
5802 CAM_LOG_INFO("Enter");
5804 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5805 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5807 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5809 CAM_LOG_INFO("ret : 0x%x", ret);
5815 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5817 int ret = CAMERA_ERROR_NONE;
5818 camera_cli_s *pc = (camera_cli_s *)camera;
5819 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5820 camera_msg_param param;
5821 int set_rotation = (int)rotation;
5823 if (!pc || !pc->cb_info) {
5824 CAM_LOG_ERROR("NULL handle");
5825 return CAMERA_ERROR_INVALID_PARAMETER;
5828 CAM_LOG_INFO("Enter");
5830 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5832 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5834 CAM_LOG_INFO("ret : 0x%x", ret);
5840 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5842 int ret = CAMERA_ERROR_NONE;
5843 camera_cli_s *pc = (camera_cli_s *)camera;
5844 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5846 if (!pc || !pc->cb_info || !rotation) {
5847 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5848 return CAMERA_ERROR_INVALID_PARAMETER;
5851 CAM_LOG_INFO("Enter");
5853 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5855 if (ret == CAMERA_ERROR_NONE)
5856 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5858 CAM_LOG_INFO("ret : 0x%x", ret);
5864 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5866 int ret = CAMERA_ERROR_NONE;
5867 camera_cli_s *pc = (camera_cli_s *)camera;
5868 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5869 camera_msg_param param;
5870 int set_flip = (int)flip;
5872 if (!pc || !pc->cb_info) {
5873 CAM_LOG_ERROR("NULL handle");
5874 return CAMERA_ERROR_INVALID_PARAMETER;
5877 CAM_LOG_INFO("Enter");
5879 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5881 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5883 CAM_LOG_INFO("ret : 0x%x", ret);
5889 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5891 int ret = CAMERA_ERROR_NONE;
5892 camera_cli_s *pc = (camera_cli_s *)camera;
5893 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5895 if (!pc || !pc->cb_info || !flip) {
5896 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5897 return CAMERA_ERROR_INVALID_PARAMETER;
5900 CAM_LOG_INFO("Enter");
5902 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5904 if (ret == CAMERA_ERROR_NONE)
5905 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5907 CAM_LOG_INFO("ret : 0x%x", ret);
5912 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5914 int ret = CAMERA_ERROR_NONE;
5915 camera_cli_s *pc = (camera_cli_s *)camera;
5916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5917 camera_msg_param param;
5918 int set_mode = (int)mode;
5920 if (!pc || !pc->cb_info) {
5921 CAM_LOG_ERROR("NULL handle");
5922 return CAMERA_ERROR_INVALID_PARAMETER;
5925 CAM_LOG_INFO("Enter");
5927 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5929 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5931 CAM_LOG_INFO("ret : 0x%x", ret);
5937 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5939 int ret = CAMERA_ERROR_NONE;
5940 camera_cli_s *pc = (camera_cli_s *)camera;
5941 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5943 if (!pc || !pc->cb_info || !mode) {
5944 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5945 return CAMERA_ERROR_INVALID_PARAMETER;
5948 CAM_LOG_INFO("Enter");
5950 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5952 if (ret == CAMERA_ERROR_NONE)
5953 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5955 CAM_LOG_INFO("ret : 0x%x", ret);
5961 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5963 int ret = CAMERA_ERROR_NONE;
5964 camera_cli_s *pc = (camera_cli_s *)camera;
5965 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5967 if (!pc || !pc->cb_info) {
5968 CAM_LOG_ERROR("NULL handle");
5969 return CAMERA_ERROR_INVALID_PARAMETER;
5972 CAM_LOG_INFO("Enter");
5974 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5977 CAM_LOG_ERROR("error is occurred 0x%x", ret);
5981 CAM_LOG_INFO("ret : %d", ret);
5987 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5989 int ret = CAMERA_ERROR_NONE;
5990 camera_cli_s *pc = (camera_cli_s *)camera;
5991 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5993 if (!pc || !pc->cb_info) {
5994 CAM_LOG_ERROR("NULL handle");
5995 return CAMERA_ERROR_INVALID_PARAMETER;
5998 CAM_LOG_INFO("Enter");
6000 if (!camera_attr_is_supported_hdr_capture(camera)) {
6001 CAM_LOG_ERROR("HDR not supported");
6002 return CAMERA_ERROR_NOT_SUPPORTED;
6006 CAM_LOG_ERROR("NULL callback");
6007 return CAMERA_ERROR_INVALID_PARAMETER;
6010 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6012 if (ret == CAMERA_ERROR_NONE) {
6013 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6015 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6016 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6018 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6021 CAM_LOG_INFO("ret : 0x%x", ret);
6027 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6029 int ret = CAMERA_ERROR_NONE;
6030 camera_cli_s *pc = (camera_cli_s *)camera;
6031 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6033 if (!pc || !pc->cb_info) {
6034 CAM_LOG_ERROR("NULL handle");
6035 return CAMERA_ERROR_INVALID_PARAMETER;
6038 CAM_LOG_INFO("Enter");
6040 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6042 if (ret == CAMERA_ERROR_NONE) {
6043 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6045 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6046 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6048 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6051 CAM_LOG_INFO("ret : 0x%x", ret);
6057 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6059 int ret = CAMERA_ERROR_NONE;
6060 camera_cli_s *pc = (camera_cli_s *)camera;
6061 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6062 camera_msg_param param;
6063 int set_enable = (int)enable;
6065 if (!pc || !pc->cb_info) {
6066 CAM_LOG_ERROR("NULL handle");
6067 return CAMERA_ERROR_INVALID_PARAMETER;
6070 CAM_LOG_INFO("Enter");
6072 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6074 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6076 CAM_LOG_INFO("ret : 0x%x", ret);
6082 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6084 int ret = CAMERA_ERROR_NONE;
6085 camera_cli_s *pc = (camera_cli_s *)camera;
6086 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6088 if (!pc || !pc->cb_info || !enabled) {
6089 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6090 return CAMERA_ERROR_INVALID_PARAMETER;
6093 CAM_LOG_INFO("Enter");
6095 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6097 if (ret == CAMERA_ERROR_NONE)
6098 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6100 CAM_LOG_INFO("ret : 0x%x", ret);
6106 bool camera_attr_is_supported_anti_shake(camera_h camera)
6108 int ret = CAMERA_ERROR_NONE;
6109 camera_cli_s *pc = (camera_cli_s *)camera;
6110 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6112 if (!pc || !pc->cb_info) {
6113 CAM_LOG_ERROR("NULL handle");
6114 return CAMERA_ERROR_INVALID_PARAMETER;
6117 CAM_LOG_INFO("Enter");
6119 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6122 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6126 CAM_LOG_INFO("ret : %d", ret);
6132 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6134 int ret = CAMERA_ERROR_NONE;
6135 camera_cli_s *pc = (camera_cli_s *)camera;
6136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6137 camera_msg_param param;
6138 int set_enable = (int)enable;
6140 if (!pc || !pc->cb_info) {
6141 CAM_LOG_ERROR("NULL handle");
6142 return CAMERA_ERROR_INVALID_PARAMETER;
6145 CAM_LOG_INFO("Enter");
6147 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6149 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6151 CAM_LOG_INFO("ret : 0x%x", ret);
6157 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6159 int ret = CAMERA_ERROR_NONE;
6160 camera_cli_s *pc = (camera_cli_s *)camera;
6161 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6163 if (!pc || !pc->cb_info || !enabled) {
6164 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6165 return CAMERA_ERROR_INVALID_PARAMETER;
6168 CAM_LOG_INFO("Enter");
6170 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6172 if (ret == CAMERA_ERROR_NONE)
6173 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6175 CAM_LOG_INFO("ret : 0x%x", ret);
6181 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6183 int ret = CAMERA_ERROR_NONE;
6184 camera_cli_s *pc = (camera_cli_s *)camera;
6185 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6187 if (!pc || !pc->cb_info) {
6188 CAM_LOG_ERROR("NULL handle");
6189 return CAMERA_ERROR_INVALID_PARAMETER;
6192 CAM_LOG_INFO("Enter");
6194 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6197 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6201 CAM_LOG_INFO("ret : %d", ret);
6207 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6209 int ret = CAMERA_ERROR_NONE;
6210 camera_cli_s *pc = (camera_cli_s *)camera;
6211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6212 camera_msg_param param;
6213 int set_enable = (int)enable;
6215 if (!pc || !pc->cb_info) {
6216 CAM_LOG_ERROR("NULL handle");
6217 return CAMERA_ERROR_INVALID_PARAMETER;
6220 CAM_LOG_INFO("Enter");
6222 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6224 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6226 CAM_LOG_INFO("ret : 0x%x", ret);
6232 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6234 int ret = CAMERA_ERROR_NONE;
6235 camera_cli_s *pc = (camera_cli_s *)camera;
6236 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6238 if (!pc || !pc->cb_info || !enabled) {
6239 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6240 return CAMERA_ERROR_INVALID_PARAMETER;
6243 CAM_LOG_INFO("Enter");
6245 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6247 if (ret == CAMERA_ERROR_NONE)
6248 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6250 CAM_LOG_INFO("ret : 0x%x", ret);
6256 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6258 int ret = CAMERA_ERROR_NONE;
6259 camera_cli_s *pc = (camera_cli_s *)camera;
6260 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6262 if (!pc || !pc->cb_info) {
6263 CAM_LOG_ERROR("NULL handle");
6264 return CAMERA_ERROR_INVALID_PARAMETER;
6267 CAM_LOG_INFO("Enter");
6269 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6272 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6276 CAM_LOG_INFO("ret : %d", ret);
6282 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6284 int ret = CAMERA_ERROR_NONE;
6285 camera_cli_s *pc = (camera_cli_s *)camera;
6286 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6287 camera_msg_param param;
6288 int set_disable = (int)disable;
6290 if (!pc || !pc->cb_info) {
6291 CAM_LOG_ERROR("NULL handle");
6292 return CAMERA_ERROR_INVALID_PARAMETER;
6295 CAM_LOG_INFO("Enter");
6297 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6299 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6301 CAM_LOG_INFO("ret : 0x%x", ret);
6307 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6309 int ret = CAMERA_ERROR_NONE;
6310 camera_cli_s *pc = (camera_cli_s *)camera;
6311 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6312 camera_msg_param param0;
6313 camera_msg_param param1;
6315 if (!pc || !pc->cb_info) {
6316 CAM_LOG_ERROR("NULL handle");
6317 return CAMERA_ERROR_INVALID_PARAMETER;
6320 CAM_LOG_INFO("Enter");
6322 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6323 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6325 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6326 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6328 CAM_LOG_INFO("ret : 0x%x", ret);
6334 int camera_attr_get_pan(camera_h camera, int *pan_step)
6336 int ret = CAMERA_ERROR_NONE;
6337 camera_cli_s *pc = (camera_cli_s *)camera;
6338 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6340 if (!pc || !pc->cb_info || !pan_step) {
6341 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6342 return CAMERA_ERROR_INVALID_PARAMETER;
6345 CAM_LOG_INFO("Enter");
6347 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6349 if (ret == CAMERA_ERROR_NONE)
6350 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6352 CAM_LOG_INFO("ret : 0x%x", ret);
6358 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6360 int ret = CAMERA_ERROR_NONE;
6361 camera_cli_s *pc = (camera_cli_s *)camera;
6362 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6364 if (!pc || !pc->cb_info || !min || !max) {
6365 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6366 return CAMERA_ERROR_INVALID_PARAMETER;
6369 CAM_LOG_INFO("Enter");
6371 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6373 if (ret == CAMERA_ERROR_NONE) {
6374 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6375 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6378 CAM_LOG_INFO("ret : 0x%x", ret);
6384 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6386 int ret = CAMERA_ERROR_NONE;
6387 camera_cli_s *pc = (camera_cli_s *)camera;
6388 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6389 camera_msg_param param0;
6390 camera_msg_param param1;
6392 if (!pc || !pc->cb_info) {
6393 CAM_LOG_ERROR("NULL handle");
6394 return CAMERA_ERROR_INVALID_PARAMETER;
6397 CAM_LOG_INFO("Enter");
6399 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6400 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6402 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6403 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6405 CAM_LOG_INFO("ret : 0x%x", ret);
6411 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6413 int ret = CAMERA_ERROR_NONE;
6414 camera_cli_s *pc = (camera_cli_s *)camera;
6415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6417 if (!pc || !pc->cb_info || !tilt_step) {
6418 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6419 return CAMERA_ERROR_INVALID_PARAMETER;
6422 CAM_LOG_INFO("Enter");
6424 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6426 if (ret == CAMERA_ERROR_NONE)
6427 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6429 CAM_LOG_INFO("ret : 0x%x", ret);
6435 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6437 int ret = CAMERA_ERROR_NONE;
6438 camera_cli_s *pc = (camera_cli_s *)camera;
6439 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6441 if (!pc || !pc->cb_info || !min || !max) {
6442 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6443 return CAMERA_ERROR_INVALID_PARAMETER;
6446 CAM_LOG_INFO("Enter");
6448 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6450 if (ret == CAMERA_ERROR_NONE) {
6451 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6452 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6455 CAM_LOG_INFO("ret : 0x%x", ret);
6461 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6463 int ret = CAMERA_ERROR_NONE;
6464 camera_cli_s *pc = (camera_cli_s *)camera;
6465 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6466 camera_msg_param param;
6467 int set_ptz_type = (int)ptz_type;
6469 if (!pc || !pc->cb_info) {
6470 CAM_LOG_ERROR("NULL handle");
6471 return CAMERA_ERROR_INVALID_PARAMETER;
6474 CAM_LOG_INFO("Enter");
6476 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6478 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6480 CAM_LOG_INFO("ret : 0x%x", ret);
6486 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6488 int ret = CAMERA_ERROR_NONE;
6489 camera_cli_s *pc = (camera_cli_s *)camera;
6490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6492 if (!pc || !pc->cb_info || !foreach_cb) {
6493 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6494 return CAMERA_ERROR_INVALID_PARAMETER;
6497 CAM_LOG_INFO("Enter");
6499 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6500 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6502 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6504 CAM_LOG_INFO("ret : 0x%x", ret);
6510 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6512 int ret = CAMERA_ERROR_NONE;
6513 camera_cli_s *pc = (camera_cli_s *)camera;
6514 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6515 int set_display_roi_area[4] = {x, y, width, height};
6520 if (!pc || !pc->cb_info) {
6521 CAM_LOG_ERROR("NULL handle");
6522 return CAMERA_ERROR_INVALID_PARAMETER;
6525 CAM_LOG_INFO("Enter");
6527 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6528 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6529 if (ret != MM_ERROR_NONE) {
6530 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6531 return CAMERA_ERROR_INVALID_OPERATION;
6535 length = sizeof(set_display_roi_area) / sizeof(int) + \
6536 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6538 msg = muse_core_msg_new(api,
6539 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6542 CAM_LOG_ERROR("msg creation failed: api %d", api);
6543 return CAMERA_ERROR_OUT_OF_MEMORY;
6546 if (pc->cb_info->is_server_connected) {
6547 __camera_update_api_waiting(pc->cb_info, api, 1);
6549 g_mutex_lock(&pc->cb_info->fd_lock);
6550 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6551 g_mutex_unlock(&pc->cb_info->fd_lock);
6555 CAM_LOG_ERROR("message send failed");
6556 ret = CAMERA_ERROR_INVALID_OPERATION;
6558 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6561 __camera_update_api_waiting(pc->cb_info, api, -1);
6563 muse_core_msg_free(msg);
6565 CAM_LOG_INFO("ret : 0x%x", ret);
6571 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6573 camera_cli_s *pc = (camera_cli_s *)camera;
6574 int ret = CAMERA_ERROR_NONE;
6575 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6577 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6578 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6579 return CAMERA_ERROR_INVALID_PARAMETER;
6582 CAM_LOG_INFO("Enter");
6584 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6586 if (ret == CAMERA_ERROR_NONE) {
6587 *x = pc->cb_info->get_display_roi_area[0];
6588 *y = pc->cb_info->get_display_roi_area[1];
6589 *width = pc->cb_info->get_display_roi_area[2];
6590 *height = pc->cb_info->get_display_roi_area[3];
6593 CAM_LOG_INFO("ret : 0x%x", ret);
6599 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6601 int ret = CAMERA_ERROR_NONE;
6602 int get_device_state = 0;
6605 CAM_LOG_ERROR("NULL pointer");
6606 return CAMERA_ERROR_INVALID_PARAMETER;
6609 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6610 (int)device, "get_device_state", &get_device_state);
6612 if (ret == CAMERA_ERROR_NONE) {
6613 *state = (camera_device_state_e)get_device_state;
6614 CAM_LOG_INFO("device state %d", *state);
6616 CAM_LOG_ERROR("failed 0x%x", ret);
6623 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6625 int ret = CAMERA_ERROR_NONE;
6626 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6627 camera_cb_info *info = NULL;
6629 if (!callback || !cb_id) {
6630 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6631 return CAMERA_ERROR_INVALID_PARAMETER;
6634 /* check camera support */
6635 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6636 if (ret != CAMERA_ERROR_NONE) {
6637 CAM_LOG_ERROR("get device state failed");
6641 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6643 info = g_new0(camera_cb_info, 1);
6645 CAM_LOG_ERROR("info failed");
6646 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6650 info->id = ++g_cam_dev_state_changed_cb_id;
6651 info->callback = (void *)callback;
6652 info->user_data = user_data;
6656 /* subscribe dbus signal for camera state change */
6657 if (!g_cam_dev_state_changed_cb_conn) {
6658 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6659 if (!g_cam_dev_state_changed_cb_conn) {
6660 CAM_LOG_ERROR("failed to get gdbus connection");
6661 ret = CAMERA_ERROR_INVALID_OPERATION;
6665 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6666 MM_CAMCORDER_DBUS_OBJECT,
6667 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6668 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6670 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6671 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6672 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6673 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6674 CAM_LOG_ERROR("failed to get gdbus connection");
6675 ret = CAMERA_ERROR_INVALID_OPERATION;
6679 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6682 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6684 CAM_LOG_INFO("callback id %d", info->id);
6687 if (ret != CAMERA_ERROR_NONE) {
6693 if (g_cam_dev_state_changed_cb_conn) {
6694 g_object_unref(g_cam_dev_state_changed_cb_conn);
6695 g_cam_dev_state_changed_cb_conn = NULL;
6699 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6705 int camera_remove_device_state_changed_cb(int cb_id)
6707 int ret = CAMERA_ERROR_NONE;
6708 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6709 GList *tmp_list = NULL;
6710 camera_cb_info *info = NULL;
6712 /* check camera support */
6713 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6714 if (ret != CAMERA_ERROR_NONE) {
6715 CAM_LOG_ERROR("get device state failed");
6719 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6721 if (!g_cam_dev_state_changed_cb_list) {
6722 CAM_LOG_ERROR("there is no callback info");
6723 ret = CAMERA_ERROR_INVALID_OPERATION;
6727 tmp_list = g_cam_dev_state_changed_cb_list;
6730 info = tmp_list->data;
6731 tmp_list = tmp_list->next;
6734 CAM_LOG_WARNING("NULL info");
6738 if (info->id == cb_id) {
6739 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6744 if (!g_cam_dev_state_changed_cb_list) {
6745 /* no remained callback */
6746 if (g_cam_dev_state_changed_cb_conn) {
6747 /* unsubscribe signal */
6748 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6749 g_cam_dev_state_changed_cb_subscribe_id = 0;
6751 /* unref connection */
6752 g_object_unref(g_cam_dev_state_changed_cb_conn);
6753 g_cam_dev_state_changed_cb_conn = NULL;
6757 CAM_LOG_INFO("id %d callback removed", cb_id);
6758 ret = CAMERA_ERROR_NONE;
6764 CAM_LOG_ERROR("id %d callback not found", cb_id);
6765 ret = CAMERA_ERROR_INVALID_PARAMETER;
6768 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);